#34367 [Opn->Bgs]: strange parsing of auto_prepend_file from CmdPrompt
| From: | derick@php.net | Date: | Mon, 05 Sep 2005 07:54:27 +0000 |
| Subject: | #34367 [Opn->Bgs]: strange parsing of auto_prepend_file from CmdPrompt | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-84543@lists.php.net to get a copy of this message | ||
ID: 34367
Updated by: derick@php.net
Reported By: csaba at alum dot mit dot edu
-Status: Open
+Status: Bogus
Bug Type: CGI related
Operating System: Win XP Pro
PHP Version: 5CVS-2005-09-04 (CVS)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is expected behavior. Unlike PHP's normal mode where the whole
script is parsed first, and then executed - in interactive mode it is
done line by line. This means that if you call popup() in line 2, the
actual function is not yet defined (as you do that later in line 3).
Previous Comments:
------------------------------------------------------------------------
[2005-09-05 09:46:41] csaba at alum dot mit dot edu
For testing with php.exe, replace pop.php with:
<?php
popup ("inside pop.php");
function popup($text, $title="PHP popup") {
print ("$title: $text");
}
?>
Fails/Works in the same way except, of course, where one expected a
popup in the earlier cases, there would now be the text
PHP popup: inside pop.php
In particular, with test 2 you wind up with:
Interactive mode enabled
Fatal error: Call to undefined function popup() in C:\Enyem\pop.php on
line 2
whereas you should get:
Interactive mode enabled
PHP popup: inside pop.php
Also, note that if you replace the -a with -q, the test does not fail
(as with test 1).
Also, these non COM tests are pretty meaningless with php-win.exe since
it doesn't send print to the command window (you want a non COM test for
php-win.exe? Output to a file). Only test 3 behaves the same in both
situations (an error message). In the COM cases, we had only the
presence or lack of a popup window to go on.
Csaba
------------------------------------------------------------------------
[2005-09-05 09:05:47] sniper@php.net
Provide a test that doesn't need COM.
------------------------------------------------------------------------
[2005-09-04 19:07:41] csaba at alum dot mit dot edu
Description:
------------
In a main script file, or included file, or auto_prepend_file it does
not matter whether doSomething() is before or after function
doSomething() {... does something...}
However, this seems broken when the file is an auto_prepend_file and
PHP is called from the command line in interactive mode.
Specifically, two of the four scenarios below seem incorrect. Scenario
2 is the bug described here, whereas scenario 4 is a separate bug report
(Bug 33430).
Csaba Gabor from Vienna
Reproduce code:
---------------
Create a file pop.php (test will only work on a windows system because
of the COM component):
<?php
popup ("inside pop.php");
function popup($text, $title="PHP popup") {
$oWSH = new COM("WScript.Shell");
if (is_null($text)) $text = "NULL";
$oWSH->Popup($text, 4, $title, 131120);
}
?>
Now from the Cmd Prompt do the following 4 tests:
1. php.exe -d auto_prepend_file=pop.php
2. php.exe -d auto_prepend_file=pop.php -a
3. php.exe -d auto_prepend_file=pop.php pop.php
4. php.exe -d auto_prepend_file=pop.php -r print('Hi');
Expected result:
----------------
1,2: I expect to get a single popup and then have PHP wait for input
3: I expect to get a single popup and then PHP should complain about
popup being redifined
4: I should get a single popup and the output should show: Hi
Actual result:
--------------
1, 3: As expected
2: The reason for this bug report: PHP dies and complains that it
doesn't know what the definition of popup is. Note that if the
invocation of popup is moved below the definition, the popup appears as
expected.
4. The only thing that happens is that Hi is printed. The
auto_prepend_file is not loaded so there is no popup. This is a
separate bug report, Bug 33430, at http://bugs.php.net/33430
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34367&edit=1