passing variables to an include file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 17
Joined: Wed Jul 03, 2002 3:10 am

passing variables to an include file

Postby sametch » Mon May 05, 2003 4:22 am

I have a page, which receives a variable $pageid from another page using the get method. The receiving page needs to use the value of $pageid in an include file which it calls.

I dont seam to be able to get it to work. I can display the value of $pageid at the top of the actual page no problem. But if I use the variable $pageid in the code of the included file it ends up with no value.

Am I doing something wrong.


main page code:

echo "pageid = ".$pageid"; //this displays the value fine
include include.php;

include file code:

echo "pageid = ".$pageid"; //this doesn't display on the page calling the include it comes up "pageid ="


User avatar
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby Redcircle » Tue May 20, 2003 1:08 am

$_GET['pageid'] is the correct method. You have register_globals on so you must user the superglobal instead. (which is the correct way to do it)

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests