leeming Posted August 1, 2006 Share Posted August 1, 2006 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 include1[/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::::gooogoo::main::gooo[/quote] Link to comment https://forums.phpfreaks.com/topic/16242-page-inside-include-not-calling-varible/ Share on other sites More sharing options...
ronverdonk Posted August 1, 2006 Share Posted August 1, 2006 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 Link to comment https://forums.phpfreaks.com/topic/16242-page-inside-include-not-calling-varible/#findComment-67299 Share on other sites More sharing options...
leeming Posted August 1, 2006 Author Share Posted August 1, 2006 [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 fileif($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 abovewoot[/quote] Link to comment https://forums.phpfreaks.com/topic/16242-page-inside-include-not-calling-varible/#findComment-67314 Share on other sites More sharing options...
leeming Posted August 1, 2006 Author Share Posted August 1, 2006 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 Link to comment https://forums.phpfreaks.com/topic/16242-page-inside-include-not-calling-varible/#findComment-67320 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.