note 95714 rejected from function.include by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 Jan 2010 00:24:19 +0000 |
| Subject: | note 95714 rejected from function.include by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165060@lists.php.net to get a copy of this message | ||
Note Submitter: sisgri at iol dot it
----
This happens with PHP 5.2.8 - very strange behaviour:
<?php
include_once $_SERVER['DOCUMENT_ROOT'].'/incl_file.php';
?>
works as needed.
On the contrary:
<?php
function doIt() {
include $_SERVER['DOCUMENT_ROOT'].'/incl_file.php';
}
doIt();
?>
does not find the file.
Everything works using the function syntax instead of the construct syntax:
<?php
function doIt() {
include($_SERVER['DOCUMENT_ROOT'].'/incl_file.php');
}
doIt();
?>