Solved

include() with value

Posted on 2000-04-12
9
221 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now