From:
Operating system: Ubuntu 10.04 LTS
PHP version: 5.3.5
Package: Filesystem function related
Bug Type: Bug
Bug description:Include within If Statement inputs blank string
Description:
------------
PHP Version: 5.3.2-1ubuntu4.7
When using an include() statement within an if statement, PHP always fails
with a seemingly blank input.
However, when used normally (obviously) it works fine, and when assigning
the return value to a variable and then testing the value of the variable,
include() works as intended.
Something that may or may not be a factor in this bug is that I have
appended to the default include path; however, logically in all test cases
(both in the actual project and the test script to create this bug report)
this seems irrelevant to the bug.
Test script:
---------------
<?php
/*
$v = include_once("blank.php");
if(!$v)
echo "FAILED";
else
echo "SUCCESS";
*/
if( include_once("blank.php") != true)
echo "FAILED";
else
echo "SUCCESS";
?>
Expected result:
----------------
As is, the script should run just like a normal function; why it behaves in
this matter only within in an if-then statement is the bug.
The script above -should- output FAILED if there is not a script entitled
"blank.php", and SUCCESS if there is.
Actual result:
--------------
The script above, as-is, believes there is a blank string being inputted
into the include() call, when in reality there is a perfectly valid
filename. If you comment out the second half of the script and uncomment
the first part, it works perfectly fine.
Error message:
Warning: include_once(/natoga/website/www/dev) [function.include-once]:
failed to open stream: Not a directory in
/natoga/website/www/dev/includeoncebug.php on line 10
Warning: include_once() [function.include]: Failed opening '' for inclusion
(include_path='.:/usr/share/php:/usr/share/pear:/natoga/website/www/res')
in /natoga/website/www/dev/includeoncebug.php on line 10
--
Edit bug report at http://bugs.php.net/bug.php?id=54042&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54042&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54042&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54042&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54042&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54042&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54042&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54042&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54042&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54042&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54042&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54042&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54042&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54042&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54042&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54042&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54042&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54042&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54042&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54042&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54042&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54042&r=mysqlcfg