Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

include() with value

Ok, this is from the php manuel:

Please note that both include() and require() actually pull the contents of the target file into the calling script file itself; they do not call the target via HTTP or anything like that. So any variable set in the scope in which the inclusion happens will be available within the included file
automatically, since it has effectively become a part of the calling file.

include( "" ); /* Won't work. */

$varone = 1;
$vartwo = 2;
include( "" );  /* $varone and $vartwo will be available in */

and I understand that.... but... I need to have an unnamed variable attached the the file, so it would be like:

because I already have a script that uses the variable like that (unnamed).  How would I do this?


  • 4
  • 4
1 Solution
I don't understand what your problem is...???
I think maxkir will have the solution. He always has :)
It isn't the case ... What is your real problem ?
If forget about include stuff, what task you're attempting to solve ?
ChrisAndrewsAuthor Commented:

My goal is to use php to mirror a page.  The page I want to mirror has a variable.

The page:

will be:

<? require( "" );?>

but the ?abc causes an error, as indicated in the manuel.  The manuel gives examples of how to put the variable in as a 'var1=abc'   but how do I put it in as just 'abc'?

<? $=awc;
require( "" );?>

doesn't work.

In a related question, when I mirror this page, I would like to parse out everything between the body tags and just use that, so that I can enter my own title and metatags.  Is that difficult to do?  I can increase pts to 200 if you can tell me how to do that also.



ps - mirroring this page is something I have permission to do :)
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

$fp = fopen("", "r");
while (!feof($fp))
    print fgets($fp, 4096);
ChrisAndrewsAuthor Commented:

H Maxkir,

That seems to look in my home directory for the web page I want to mirror, when it needs to go to an entirely different site to get it, is that fixable?

Thank you for trying :)

place in place of any site you want. And the script will output the page.
ChrisAndrewsAuthor Commented:


Got it :)

For some reason I had to make it  (with a slant after for it to work for me.  But that works out great, thank you.

Now for the body part... is there a way to parse it and just use what's in the body tags or does that get really difficult?

Thanks again,

Is it quite another question ... The answer is - yes, you can do some parsing using regular expressions.
ChrisAndrewsAuthor Commented:

Thanks,  I will play around with this and see what I can do on my own first :)  Don't know how far I will get, learning by doing ya know,

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now