error77
asked on
Variables and PHP includes problem
Hi all,
I have an issue with php includes..
On page A I have:
$id = 1;
include ('pageB.php');
then in page B I've got:
echo $id;
But it's returning nothing ...I though includes where like having a page inside a page right?
Thanks
I have an issue with php includes..
On page A I have:
$id = 1;
include ('pageB.php');
then in page B I've got:
echo $id;
But it's returning nothing ...I though includes where like having a page inside a page right?
Thanks
Your thinking is correct, but your example does not include all the code to recreate the failure. It is an issue of variable scope. Look for functions or classes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And add
include('pageA');
in pageB
include('pageA');
in pageB
Please, keep only my last comment: global is for other things...
Conceptually what you say is correct, so there must be some minor discrepancy. Show the full code.
Also doublecheck that you are getting to the right page, by changing Page B to
echo "Debug 1 $id";
Also doublecheck that you are getting to the right page, by changing Page B to
echo "Debug 1 $id";
I wrote only stupid things: maybe I have to sleep ;-)
If you create two simple scripts doing what you say, they works, so the problem must reside in other code you have in your actual files: post your full code to get help.
Cheers
If you create two simple scripts doing what you say, they works, so the problem must reside in other code you have in your actual files: post your full code to get help.
Cheers
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.