Jump to content

[SOLVED] Feed included URL into a variable.


Humpty

Recommended Posts

G'day Guys.

 

I need to access a page (CGI) on a different server.  I can do this fine with an include and that will display all the info I need on the screen.

 

The problem I face is that I actually need to parse through that info.  When i try assigning it to a variable...

$dogggg = include ("$SpecialString");

...the variable is always "1".   

 

$specialString is the URL

 

Clearly what I am doing is wrong but if someone can please point me in the right direction for what I need to do in order to get that output into a variable so that I can parse it, do what I need to with that info and then display it.

 

Thaks heaps

-Humpty

 

Link to comment
https://forums.phpfreaks.com/topic/41701-solved-feed-included-url-into-a-variable/
Share on other sites

cURL: artacus; It seems to be a very full featured thing. I was after something far simpler though.

 

ob_start(): thorpe; That is exactly what I was after.  Thankyou very much for that.

 

I would like to thank you both for this and really appreciate it, you have both given me two new things to look into for other future uses.

 

Thanks.      ...did I say thanks yet?

 

-Humpty

That will only work if he wants to display that page. Its not going to work if he wants to return it as a variable and parse thru it.

 

$dogggg = include ("$SpecialString");

returns 1 meaning it succeeded. It's NOT the text from the page. If it's a page that you have control over (I doubt it), you can make it's contents read something like

<?php
$doggg = "...whatever...";

 

Otherwise use curl.

 

No, No this is good:

 

ob_start();
include ("$SpecialString");
$var222 = ob_get_clean();
$var333 = strstr($var222, 'INVALID');

It gives me that ability to do what I need to do.

 

When I say Parse I mean more than anything search through a string in most cases for a specific item or keyword.

Its not going to work if he wants to return it as a variable and parse thru it.

 

Read my post. The output of the include is now stored in $var.

 

Of course... an even easier option (which slipped my mind for some wierd reason) would be to simply use  file_get_contents.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.