tags:

views:

300

answers:

6

how to call url of any other website in php.

+6  A: 

use curl php library: http://php.net/manual/en/book.curl.php

direct example: CURL_EXEC

Lex
when i use curl it gives fatal errorAs:Fatal error: Call to undefined function curl_init() in C:\xampp\htdocs\sample.php on line 3
Beginner
What version of PHP are you using? Is it compiled with curl? try phpinfo();
Lex
i am using XAMPP 1.7.3 i thing it contents PHP version 5.3.1
Beginner
what does phpinfo() says?
Lex
uncomment (remove ;) the line ;extension=php_curl.dll in php.ini
Andy
i dowmload curl library then also i am getting same problem.Is it necessary that we hv to store this library in specific folder
Beginner
@Andy i am not getting this line in php.iniextension=php_curl.dll
Beginner
thanks, to all of you. its working now, when i make changes in php.ini file
Beginner
A: 

Depending on what you mean, either redirect or use curl.

David Dorward
A: 

Check out the PHP cURL functions. They should do what you want.

Or if you just want a simple URL GET then:

$lines = file('http://www.example.com/');
Aiden Bell
A: 

As other's have mentioned, PHP's cURL functions will allow you to perform advanced HTTP requests. You can also use file_get_contents to access REST APIs:

$payload = file_get_contents('http://api.someservice.com/SomeMethod?param=value');

Starting with PHP 5 you can also create a stream context which will allow you to change headers or post data to the service.

Andy E
+1  A: 

The simplest way would be to use FOpen or one of FOpen's Wrappers.

$page = file_get_contents("http://www.domain.com/filename");

This does require FOpen which some web hosts disable and some web hosts will allow FOpen, but not allow access to external files. You may want to check where you are going to run the script to see if you have access to External FOpen.

Jamza
A: 

If you meant .. to REDIRECT from that page to another, the function is really simple

header("Location:www.google.com");
Skun