Solved

include() with value

Posted on 2000-04-12
9
227 Views
Last Modified: 2013-11-18

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( "file.inc?varone=1&vartwo=2" ); /* Won't work. */

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

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

file.inc?example

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

Chris

0
Comment
Question by:ChrisAndrews
  • 4
  • 4
9 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2710852
I don't understand what your problem is...???
I think maxkir will have the solution. He always has :)
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2711179
It isn't the case ... What is your real problem ?
If forget about include stuff, what task you're attempting to solve ?
0
 

Author Comment

by:ChrisAndrews
ID: 2712126


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

The page:

http://www.example.com

will be:

<? require( "http://ex.com?abc" );?>

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( "http://ex.com?abc" );?>

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.

Thanks

Chris

ps - mirroring this page is something I have permission to do :)
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 2

Accepted Solution

by:
maxkir earned 100 total points
ID: 2712194
<?php
$fp = fopen("http://ex.com?abc", "r");
while (!feof($fp))
{
    print fgets($fp, 4096);
}
flose($fp);
?>
0
 

Author Comment

by:ChrisAndrews
ID: 2712333

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

Chris
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2712369
place in place of ex.com any site you want. And the script will output the page.
0
 

Author Comment

by:ChrisAndrews
ID: 2712465

Hi,

Got it :)

For some reason I had to make it http://www.ex.com/?abc  (with a slant after ex.com) 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,

Chris
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2712477
Is it quite another question ... The answer is - yes, you can do some parsing using regular expressions.
0
 

Author Comment

by:ChrisAndrews
ID: 2712525

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,

Chris
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question