Jump to content


Photo

Query Strings & Include()


  • Please log in to reply
2 replies to this topic

#1 vnought

vnought
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts
  • LocationCanada

Posted 16 June 2006 - 09:42 PM

Hey,

Just a thought-I thought it might be useful if true: Can include (and its require counterpart) pass $_GET variables through to the page it's including, say:

include('header.php?page=12');

Thanks.

#2 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 16 June 2006 - 10:29 PM

no, include does not load the page it just inserts the code for processing on the same page, but if the $_GET was set in the page holding the include(); function it would affect the included file in the same manner
z..z..z..z..z..z..z..z..

#3 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 17 June 2006 - 12:16 AM

Giving you an example; if you have a file called "header.php":

<?php

echo 'Page: ' . $_GET['page'];

?>

Now if you access header.php?page=12 it will print out:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Page: 12[/quote]

But if you have another file, called another.php:

<?php

include 'header.php';
echo 'Included!';

?>

And access another.php?page=15, it will print:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Page: 15
Included[/quote]
~ D Kuang




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users