note 71210 modified in function.include by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 May 2009 01:02:21 +0000 |
| Subject: | note 71210 modified in function.include by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155473@lists.php.net to get a copy of this message | ||
Please note that althought you can call a function that is DEFINED later in the code, you cannot
call a function that is defined in a file which is INCLUDED later. Consider following two examples:
Example 1:
<?php
test();
function test()
{
echo 'In test.';
}
?>
Example 2:
file1.php:
<?php
test();
include 'file2.php';
?>
file2.php:
<?php
function test()
{
echo 'In test.';
}
?>
Please be aware that while the first example will work as expected, the second one will generate a
fatal error "Call to undefined function: test() ...". The same is true for the require.
--was--
Please note that althought you can call a function that is DEFINED later in the code, you cannot
call a function that is defined in a file which is INCLUDED later. Consider following two examples:
Example 1:
<?php
test();
function test()
{
echo 'In test.';
}
?>
Example 2:
file1.php:
<?
test();
include 'file2.php';
?>
file2.php:
<?
function test()
{
echo 'In test.';
}
?>
Please be aware that while the first example will work as expected, the second one will generate a
fatal error "Call to undefined function: test() ...". The same is true for the require.
http://php.net/manual/en/function.include.php