Jump to content

include()


Recommended Posts

[!--quoteo(post=325053:date=Dec 6 2005, 08:44 AM:name=ChrisDarl)--][div class=\'quotetop\']QUOTE(ChrisDarl @ Dec 6 2005, 08:44 AM) 325053[/snapback][/div][div class=\'quotemain\'][!--quotec--]

Does anyone know of a way to use URL variables in the function include(); or another similar function.

 

i.e.

 

include("./includes/leftMenu.php?item=21");

 

so that the item=21 will change something on the leftMenu.php page.

Many thanks, Chris

 

you don't need to pass variables that way. think of it this way: when you include() or require() a file, the contents of that file become part of the current page. with that in mind, all the variables are shared, too. so, all you'd have to do is something like this:

<?php
$item = 21;
include("./includes/leftMenu.php");
?>

 

then, $item on leftMenu.php will already be set.

 

hope this helps your understanding a bit

Link to comment
https://forums.phpfreaks.com/topic/2993-include/#findComment-10041
Share on other sites

Thanks, yeah, i understand that. I really was after this sort of thing...

 

====page a.php=====

 

include("b.php?page=4");

 

 

====page b.php=====

 

if($_GET['page'] == "4")
{
     //include page four code in a.php;
}
else
{
    //include other pages in a.php
}

 

hope this helps you to understand what im trying to do more clearly.

 

Thanks for your reply obsidian

Link to comment
https://forums.phpfreaks.com/topic/2993-include/#findComment-10043
Share on other sites

Archived

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

×
×
  • 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.