Jump to content

Archived

This topic is now archived and is closed to further replies.

leeming

page inside include not calling varible

Recommended Posts

im totaly sure ive always been able to do this...
[code]
$var = 1;

include("file.php");

echo $var;
[/code]
where file.php...
[code]
echo 'var is: '.$var.' :inside include<BR>';
[/code]

where it should output

[quote]var is: 1 :inside include
1[/quote]


but the following code i did doesnt let me, (is there a setting in sum file that turns this on/off? because i've had trouble where the server admin has changed things on all sites instead of just one...)
[code]
include($site_link."/inc/functions.inc.php");

//...code between.. nothing to do with $page....

if(in_array("$page", $public_pages))
{
  include($site_link."/pub-".$page.".php");
    die("goo::$page::gooo");
}[/code]
functions.inc.php contains (i even commented every thing out apart form this line)
[code]
  print"goo::$page::gooo";[/code]

all i get from them is
[quote]
goo::::gooo
goo::main::gooo[/quote]

Share this post


Link to post
Share on other sites
Are you sure that the statement

[code]print"goo::$page::gooo";[/code]

in the included file is NOT within a function? Because then $page would be a different variable (private to the function) from the one you set.

ROnald  ;D

Share this post


Link to post
Share on other sites
[quote author=ronverdonk link=topic=102616.msg407518#msg407518 date=1154462971]
Are you sure that the statement

[code]print"goo::$page::gooo";[/code]

in the included file is NOT within a function? Because then $page would be a different variable (private to the function) from the one you set.

ROnald  ;D

[/quote]

no no its not in a function.. i just put it one of the 1st include files on my page 2 test it my theory (which took a while y my code wasnt working)

its just a plain variable that works in the main page.. but as soon as its inside an include/require it stops existance....


heres another try.. (to check there is no mixing with values)
[code]
//main page
$leeming = "woot";

include($site_link."/inc/functions.inc.php");

die($leeming);




//include file

if($leeming)
{
  print"'leeming' is here<BR>";
}
elseif(isset($leeming))
{
  print"'leeming' is set<BR>";
}
else
{
  print"no to all the above<BR>";
}
[/code]

outputs,
[quote]
no to all the above
woot
[/quote]

Share this post


Link to post
Share on other sites
humm i figgured it out with this code

[code]
$leeming = "woot";

include($site_link."/inc/functions.inc.php");
include("inc/functions.inc.php");
include "inc/functions.inc.php" ;

die($site_link);
[/code]

$site_link, is the full address... so it wasnt passing the variable

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.