Jump to content

read a php file content


munim

Recommended Posts

Hello group!

i want to load a php file inside a php file.

for instance, we can get the content of any file using [b]include "file.ext"[/b] or using [b]fopen[/b].

[u]but the problem is:[/u]

i want to get the content of a php file which seems like this:

[b]./somefile.php?id=1&gid=12[/b]

I want to get the content of this [b]file with arguments[/b] in some string like:

$str = readFile ( './somefile.php?id=1&gid=12' );

TIA
munim

Link to comment
https://forums.phpfreaks.com/topic/32181-read-a-php-file-content/
Share on other sites

[quote author=Orio link=topic=120276.msg493182#msg493182 date=1167409750]
You can include it with URL wrappers:
include("http://youdomain.com/somefile.php?id=3");
The content will be displayed.
If you want to save the result into a variable, you should be looking into cURL.

Orio.
[/quote]

URL wrapper doesnt work. it says

Warning: main(./somefile.php?gid=1): failed to open stream: Invalid argument in c:\inetpub\wwwroot\testprc\process.php on line 21
You can also do file('http://path/to/script.php?a=b');
then parse out the results...
I do it all the time...

[code]$lines = file('http://xxxxxxxx/pbcool.php?guid=true');
foreach ($lines as $line_num => $line) {
  if($line_num > 1){
        $data=explode(" ",$line);
        $aa=$data[0]." ".$data[1];
        $bb=$data[2];
        $cc=$data[3];
        $dd=$data[5];
        $ee=trim($data[6]);
        $sql=mysql_query("insert into tablename values ('$aa','$bb','$cc','$dd','$ee')");
        }
}

[/code]

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.