php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54042 Include within If Statement inputs blank string
Submitted: 2011-02-18 06:43 UTC Modified: 2011-02-20 16:46 UTC
From: jballard at natoga dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.3.5 OS: Ubuntu 10.04 LTS
Private report: No CVE-ID: None
 [2011-02-18 06:43 UTC] jballard at natoga dot com
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-18 13:22 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2011-02-18 13:22 UTC] cataphract@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

include_once is not a function; read the manual.
 [2011-02-18 20:38 UTC] jballard at natoga dot com
Regardless of whether or not this is a function, this is still --unexpected behavior--, indicating a bug. I am not asking for support; I have found a workaround and this bug does not affect me, therefore support would be unnecessary.

I realise include_once and include are not functions in the strict sense, but this is STILL unexpected behaviour not found anywhere in the documentation.

THIS IS A BUG, NOT A SUPPORT REQUEST.

Please read the original post again; I know perfectly well the difference between a support system and the bug system...
 [2011-02-18 20:41 UTC] jballard at natoga dot com
Further, the "package" chosen, while include() is indeed not a "Filesystem function", was the most appropriate in my mind for the bug. If need be, it can be suggested to be changed to a more appropriate package.
 [2011-02-20 08:43 UTC] anon at anon dot anon
Sorry dude, but PHP's bug reviewers are usually about as helpful as call center staff. That is to say, not very.
 [2011-02-20 16:46 UTC] rasmus@php.net
You are treating include_once as if it was a function and you are expecting it to 
behave like a function. It is not, and it does not. This may be unexpected 
behaviour for you, but it is expected behaviour for a PHP statement, so there is 
no bug here. This cannot be changed without some serious low-level changes to PHP 
which would degrade performance significantly.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 04:01:30 2024 UTC