Jump to content

page inside include not calling varible


leeming

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]
Link to comment
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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.