Re: Scope of include

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/17/07, jekillen <jekillen@xxxxxxxxxxx> wrote:
Hello php list:
If I include a php script inside a php function definition and then
call the
function in another script. What is the scope of variables in the
included
script? Are they local to the function that calls include with the file
name?
Thanks in advance;
I'm not sure where to look for this answer;
JK

Does your included PHP script contain any functions?  Or is it more like:

file1.php contents:

function my_function () {
 if (i_feel_like_it) {
   include("inc.php");
 }
}

and inc.php contains variables at the global level such as:

inc.php:
$var1 = 2;
$var2 = 3;

Am I close?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux