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?


Who is Participating?
maxkirConnect With a Mentor Commented:
$fp = fopen("", "r");
while (!feof($fp))
    print fgets($fp, 4096);
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 ?
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 :)
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,

All Courses

From novice to tech pro — start learning today.