FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP Page Source





DanielXP
Is it posiable to set a varible such as

$url = "http://google.co.uk";

and then get the variable

$urlsource = ...........

As that pages source?


If this is posible to get the source and set it as a variable please could you tell me it.

Thanks,
Daniel
qscomputing
I assume you mean HTML source.

Yes, it can be done: the file that you pull off the Internet IS the source code, so all you need to do is grab that file over the Internet and read its contents. This can be done using cURL, but I'm no PHP expert so I can't really help you further.
MrBlueSky
Code:

<?php
$c = curl_init('http://www.google.com');
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$pagesource = curl_exec($c);
curl_close($c);
?>

DanielXP
Thanks m8
rohan2kool
I guess you can do it even with file_get_contents($url);
MrBlueSky
rohan2kool wrote:
I guess you can do it even with file_get_contents($url);


Yes, if allow_url_fopen is enabled in "php.ini". But Curl has some very usefull options.

(I thought allow_url_fopen was disabled at frihost, but it isn't Smile )
duckling
allow_url_fopen comes enabled in default Smile
Related topics
Tutorial: PHP Installed Modules Dynamic Reference Tool
IIS, PHP and Tomcat not cooperating!
xmlhttprequest
Running a "Hello World" php script
Never Mind Problem Resolved
PHP VS ASP
PHP Page
help - download pop up on php page
how do i make a window/iframe in a table within php page..??
php page flickering, maybe caused by flash item
Using PHP toreciever information from external source.
How to make a php page act differently
Drupal: Best PHP Open Source CMS 2008
PHP error page, die()
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.