php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41114 String concat operator and function param
Submitted: 2007-04-17 10:43 UTC Modified: 2007-04-18 06:07 UTC
From: danishzahoor at gmail dot com Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.4.6 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: danishzahoor at gmail dot com
New email:
PHP Version: OS:

 

 [2007-04-17 10:43 UTC] danishzahoor at gmail dot com
Description:
------------
Anything string that comes after concat operator will be concaticated in string param of include_once function.

Reproduce code:
---------------
<?php

	print "Including file from lib first<BR>";
	echo "result = " . include_once("lib/file.php") . "<BR>";
	test1();

	function test1()
	{
		print "Including file from lib inside function.<BR>";
		print "result = " . include_once("lib/file.php") . "<BR>";
	}
	
?>

Actual result:
--------------
PHP 4
=====
Including file from lib first

Warning: main(lib/file.php
): failed to open stream: No such file or directory in /var/www/www.mobiletest.com/htdocs/html/php.samnan/php5_tests/test_include_once.php on line 4

Warning: main(): Failed opening 'lib/file.php<BR>' for inclusion (include_path='.:/usr/local/php/lib/php') in /var/www/www.mobiletest.com/htdocs/html/php.samnan/php5_tests/test_include_once.php on line 4
result = Including file from lib inside function.

Warning: test1(lib/file.php
): failed to open stream: No such file or directory in /var/www/www.mobiletest.com/htdocs/html/php.samnan/php5_tests/test_include_once.php on line 10

Warning: test1(): Failed opening 'lib/file.php<BR>' for inclusion (include_path='.:/usr/local/php/lib/php') in /var/www/www.mobiletest.com/htdocs/html/php.samnan/php5_tests/test_include_once.php on line 10
result = 

PHP 5
=====
Including file from lib first

Warning: include_once(lib/file.php<BR>) [function.include-once]: failed to open stream: No such file or directory in /var/webuser/php.samnan/temp/test_include_once.php on line 4

Warning: include_once() [function.include]: Failed opening 'lib/file.php<BR>' for inclusion (include_path='./:/usr/local/php/lib/php') in /var/webuser/php.samnan/temp/test_include_once.php on line 4
result = Including file from lib inside function.

Warning: include_once(lib/file.php<BR>) [function.include-once]: failed to open stream: No such file or directory in /var/webuser/php.samnan/temp/test_include_once.php on line 10

Warning: include_once() [function.include]: Failed opening 'lib/file.php<BR>' for inclusion (include_path='./:/usr/local/php/lib/php') in /var/webuser/php.samnan/temp/test_include_once.php on line 10
result = 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-17 20:03 UTC] moron at industrial dot org
include_once is *not* a function so you cannot use it in the way you are attempting to.  The brackets are optional so you are really just telling PHP:

include_once "lib/file.php" . "<BR>";

i.e. concatenate the stuff at the right then include the contents of the named file.

That said, the parser should probably raise an error since technically your code is malformed due to the bracket in the middle.

So if there is any bug, it is the parser not complaining about the syntax error.

Cheers
 [2007-04-18 06:07 UTC] derick@php.net
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

(And there is no parse error as the < is part of a string)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 13:01:30 2024 UTC