note 71210 added to function.include
| From: | Janci at osu1 dot php dot net | Date: | Thu, 16 Nov 2006 15:59:58 +0000 |
| Subject: | note 71210 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119805@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:
<?
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.
----
Server IP: 62.65.181.66
Probable Submitter: 195.168.49.58
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- https://master.php.net/note/edit/71210
Del: integrated -- https://master.php.net/note/delete/71210/integrated
Del: useless -- https://master.php.net/note/delete/71210/useless
Del: bad code -- https://master.php.net/note/delete/71210/bad+code
Del: spam -- https://master.php.net/note/delete/71210/spam
Del: non-english -- https://master.php.net/note/delete/71210/non-english
Del: in docs -- https://master.php.net/note/delete/71210/in+docs
Del: other reasons-- https://master.php.net/note/delete/71210
Reject -- https://master.php.net/note/reject/71210
Search -- https://master.php.net/manage/user-notes.php