Solved

include() with value

Posted on 2000-04-12
9
230 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
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.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to count occurrences of each item in an array.

828 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