munim Posted December 29, 2006 Share Posted December 29, 2006 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' );TIAmunim Link to comment https://forums.phpfreaks.com/topic/32181-read-a-php-file-content/ Share on other sites More sharing options...
Orio Posted December 29, 2006 Share Posted December 29, 2006 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. Link to comment https://forums.phpfreaks.com/topic/32181-read-a-php-file-content/#findComment-149357 Share on other sites More sharing options...
munim Posted December 29, 2006 Author Share Posted December 29, 2006 [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 Link to comment https://forums.phpfreaks.com/topic/32181-read-a-php-file-content/#findComment-149363 Share on other sites More sharing options...
Orio Posted December 29, 2006 Share Posted December 29, 2006 What did you exactly write?Orio. Link to comment https://forums.phpfreaks.com/topic/32181-read-a-php-file-content/#findComment-149392 Share on other sites More sharing options...
AV1611 Posted December 29, 2006 Share Posted December 29, 2006 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] Link to comment https://forums.phpfreaks.com/topic/32181-read-a-php-file-content/#findComment-149396 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.