This is a discussion on Windows ENV['_'] equivalent within the PHP General forums, part of the PHP Programming Forums category; On Mon, October 16, 2006 9:04 am, Jochem Maas wrote: > 2. try making use of the $_ENV['PHP_PEAR_PHP_BIN'] ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Mon, October 16, 2006 9:04 am, Jochem Maas wrote:
> 2. try making use of the $_ENV['PHP_PEAR_PHP_BIN'] value which should > be > configured if pear is installed properly. (it's there in my local > setup C:\Documents and Settings\rlynch>C:\php5.1.1\php.exe -a Interactive mode enabled <?php echo $_ENV['PHP_PEAR_PHP_BIN'], "\n\n";?> Notice: Undefined index: PHP_PEAR_PHP_BIN in C:\Documents and Settings\rlynch\- on line 1 C:\Documents and Settings\rlynch> rlynch@LTRLYNCH /cygdrive/k/pizzahut/tests $ /cygdrive/c//php5.1.1/php.exe -a Interactive mode enabled <?php echo $_ENV['PHP_PEAR_PHP_BIN'], "\n\n";?> Notice: Undefined index: PHP_PEAR_PHP_BIN in k:\pizzahut\tests\- on line 1 ^D rlynch@LTRLYNCH /cygdrive/k/pizzahut/tests Apparently, PEAR is not correctly installed when I snag php5.1.1 and dump it into c:\php5.1.1 and run CLI. Since I seldom use PEAR, I've never noticed this before. I'm fairly confident that var_dump($_ENV) did not output any key/value that had anything useful to my needs -- I scoured that pretty carefully, as it's where I expected my answer to be. Ditto for $_SERVER. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? |
|
|||
|
On Sat, October 14, 2006 4:09 am, Stut wrote:
> Richard: AFAIK there is no way to know this under windows without > writing an extension to tell you. Sounds like you actually know how to do this... :-) Would such an extension be cross-platform to all PHP installs, or Windows-only? And is this some trivial thing that the PHP Devs just havent' had time to do, or some monumental task of goofy OSes that nobody wants to touch? I'm happy to take a shot at it if it's easy, but if it's something the PHP Devs don't want to touch, I know I ain't got a shot at it! :-) -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? |
|
|||
|
On Mon, October 16, 2006 4:41 pm, Roman Neuhauser wrote:
> Just a thought: var_dump(ini_get('register_argc_argv')) ? I should have been more clear If/when there are any $args, then $argc/$argv are set: $ /cygdrive/c/php5.1.1/php.exe -q argv.php array(1) { [0]=> string(8) "argv.php" } C:\Documents and Settings\rlynch>c:\php5.1.1\php.exe -q K:\pizzahut\argv.php array(1) { [0]=> string(20) "K:\pizzahut\argv.php" } But $argv does not contain the path of the binary PHP running -- it has everything AFTER that in the command line. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? |
|
|||
|
Richard Lynch wrote:
> On Sat, October 14, 2006 4:09 am, Stut wrote: >> Richard: AFAIK there is no way to know this under windows without >> writing an extension to tell you. > > Sounds like you actually know how to do this... :-) > > Would such an extension be cross-platform to all PHP installs, or > Windows-only? > > And is this some trivial thing that the PHP Devs just havent' had time > to do, or some monumental task of goofy OSes that nobody wants to > touch? > > I'm happy to take a shot at it if it's easy, but if it's something the > PHP Devs don't want to touch, I know I ain't got a shot at it! :-) I've not looked at the CLI SAPI at all yet, so I don't know if it gets put anywhere, but the SAPI main() function will get what you want passed to it. I guess now's as good a time as any... Hey, whaddya know, it does. Check out [1]. Not sure how you'd get to that in an extension, but it's there. Since it's not linked that's a pretty good sign that that particular member of the struct is not used anywhere. In fact, looking at the usage of that var [2] it may not be available outside the SAPI code. However, looking a bit further [3] it's defined as a static var in php_cli.c, so you may be able to get at it with an extern declaration. You should get the full path to the binary from the CLI module, looks like it's NULL for any SAPI that doesn't set it. However, it was never going to be that simple. It looks like that struct has a different name in each SAPI, so you may need to do something to mod the code if it's not building the CLI SAPI. Should be able to knock something up armed with that. And yes, it should be the same code for all platforms. I'd love to have a go at this myself (just for fun), but unfortunately I don't have a great deal of spare time at the moment. Let me know how you get on. [1] http://lxr.php.net/source/php-src/sa.../php_cli.c#691 [2] http://lxr.php.net/ident?i=cli_sapi_module [3] http://lxr.php.net/source/php-src/sa.../php_cli.c#368 -Stut |
|
|||
|
# ceo@l-i-e.com / 2006-10-16 14:28:41 -0500:
> On Fri, October 13, 2006 7:44 pm, Roman Neuhauser wrote: > > # ceo@l-i-e.com / 2006-10-13 13:53:56 -0500: > >> So, I have this automated testing script I wrote, and I want to make > >> it work on more than just my computer. > >> > >> In cygwin, and in Linux, EVN['_'] has the nice path to the binary > >> CLI > >> which is running -- which I call again in a backticks for each test > >> script in turn, to provide a consistent starting point. > >> > >> In windows... There ain't nothing in phpinfo() that matches the > >> php.exe which I'm running... > >> > >> How do you handle this? > >> > >> Note that I'm not attempting to test specific versions of PHP -- > >> just > >> the PHP scripts, so I really just want to run whatever PHP they are > >> already running in their test environment, whatever that might be. > >> > >> It's not in $argv, it's not in ENV. > > > > What does $argv look like in windows? > > $argv looks the same in both cases. > > array (0) { > } Just a thought: var_dump(ini_get('register_argc_argv')) ? -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 |