Solved

include() with value

Posted on 2000-04-12
9
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting PHP triple des decrypt to c# 9 152
CURL sending XML without spaces PHP 5 67
PHP Curl Problem 10 68
Best hashing method? 1 13
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 dynamically set the form action using jQuery.

736 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