Jump to content

[SOLVED] Echo inside include?


mnybud

Recommended Posts

Newbie questions time :)

 

I am trying to accomplish the following:

 

I have a url formated like this:

http://www.domain.com/?word_I_want=thisword

 

I can echo "thisword" fine on my page with

 <?PHP  echo $_REQUEST['word_I_want']; ?>

 

But I also need to include it within this after ?query=

<?PHP include("parser.php?query=word_I_want") ?>

 

I know this should be simple but I have tried several variations of what I thought might work and keep getting syntax errors. Can anyone help me out please?

Link to comment
Share on other sites

All you need to do is retrieve the variable THEN include the file and due to the scope of the variable it should be accessible in the included file.

 

$variable = $_GET['word_I_want'];

include("page.php");

 

page.php:

echo $variable;

 

Also, use $_GET for retrieving variables from the URL, not $_REQUEST because that also stores the $_POST variables. You're better off specifying the one you want.

Link to comment
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.