Windows 10 Pulling hair out calling php file from batch file

Bear

Well-Known Member
Joined
Sep 29, 2016
I'm having a hell of a time getting php to return a string.
I don't know where they are going to install my batch file so I set the file location via %~dp0.
there are 2 functions in my .php file, one to process color another to process Joomla's Version. The joomla one worked fine until I made it a function but my main concern is I can't return a simple string!!
I've tried everything I can think of.
I want parameter #2 to be the function choice and param 1 to be the variable passed to the function.
Code:
:: SET git_repo & branch to use by deafult
SET scriptDir=%~dp0
SET git_repo=https://github.com/joomla/joomla-cms.git
SET git_branch=4.0-dev
SET Message=Select branch to be used:  press enter FOR branch: [%GIT_BRANCH%]
SET new=false
SET update=false
SET uninstall=false
SET verbose=false
SET dirname=joomla-cms
SET _params=%*

SETLOCAL enabledelayedexpansion
:: SET local dirname
FOR %%* in (.) do SET localDir=%%~n*
echo on
FOR /f %%a in ('CALL php %~dp0jver.php "%CD%" ') do SET JVersion=%%a
echo %JVersion%




ENDLOCAL
goto:eof


php file:
/* $argv[1] is first parmater AFTER call */
$one = $argv[1];
$two = $argv[2];


$bear="Are you sure you want to do this?  Type 'yes' to continue: ,";
return $bear ;


function hi($bear){
$temp = "HI BEAR!, here's your var:" . $bear . " right?";
return $temp . PHP_EOL;
}

function jver($version){
require_once $argv[1] . '/libraries/src/Version.php';
$version = Version::MAJOR_VERSION . '.' . Version::MINOR_VERSION;
return $version . PHP_EOL;
}
 
PHP isn't really meant to be used as a client side language I'd also use Powershell over a batch file you have a lot more flexibility with your code and in the long run much easier to use.
 
I get that, but it would be really helpful if you could explain the proper way to get a return string. This used to be a common way to do things.
 
Back
Top Bottom