Jump to content

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

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.