ID:          35811
 Updated by:  [EMAIL PROTECTED]
 Reported By: csaba at alum dot mit dot edu
 Status:      Open
-Bug Type:    Scripting Engine problem
+Bug Type:    Documentation problem
 PHP Version: 5.1.1
 New Comment:

I don't understand a word of this report so I assume it's documentation
issue. The ini option behaves just like it's meant to.


Previous Comments:
------------------------------------------------------------------------

[2005-12-27 01:42:33] csaba at alum dot mit dot edu

Description:
------------
auto_prepend_file in the php.ini file neither acts as if it prepends
the designated file nor as if it were included (as stated at
http://hu.php.net/manual/en/ini.core.php#ini.auto-prepend-file).

Specifically, if this were the case, then functions defined in the main
script would take precedence over functions defined in the
auto_prepend_file, but they do not.

Use case: It seems reasonable to define a standard library of all
functions available to all scripts under a php installation (through
the auto_prepend_file php.ini setting).  It also makes sense for select
scripts to be able to override these functions.  In a single .php file
(with no auto_prepend_file present), this would be accomplished as
follows with Script1:

<?php
if (!function_exists('showLine')) {
function showLine($letter) { print "First $letter.\n"; } }
showLine("B");
function showLine($letter) { print "Second $letter.\n"; }
?>

This produces no error, and an output of: Second B.  If the last line
is commented out, you would instead get: First B.



Moving the first two lines to includeMe.php:
<?php
if (!function_exists('showLine')) {
function showLine($letter) { print "First $letter.\n"; } }
?>

and invoking the following script2 leads to the same result:
<?php
include('includeMe.php');
showLine("B");
function showLine($letter) { print "Second $letter.\n"; }
?>


However, if php.ini's auto_prepend_file now points to includeMe.php and
the include statement is removed from script2 to yield script3, script3
will error with a duplicate function definition, which is what I am
reporting as improper behaviour.  Script3:
<?php
showLine("B");
function showLine($letter) { print "Second $letter.\n"; }
?>


Thanks,
Csaba Gabor from Vienna

Expected result:
----------------
My expectation for what the auto_prepend_file does is that it either
prepends the designated file to the main script, or treats it as having
been named by an include/require function as the 1st line of the script
(the difference is effectively whether the function definitions in the
auto_prepend_file are seen before the main script's function
definitions or not).

To be specific:  Remove, the first statement from the doc and have only
(with code to match): Specifies the name of the file to be parsed as if
it were called via an include construct at the very beginning of the
main script (so include_path is used).

Actual result:
--------------
The documentation at the page above claims two contradictory things: 
It says that auto_prepend_file is parsed before the main file, and it
says that the file is included as if it were called with the include()
function.

The current situation is that the auto_prepend_file is parsed
separately (before) the main script file (as opposed to prepended or
included), but the file name is placed onto the include file list (so
that it can no longer be include_once'd - see also:
http://bugs.php.net/bug.php?id=32924)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35811&edit=1

Reply via email to