I wrote the program code like this.
| The code is as follows: |
Copy code |
|
?? Php
// Initialize a cURL object
$ Curl = curl_init ();
// Set the URL you want to capture
Curl_setopt ($ curl, CURLOPT_URL, 'http: // www.111cn.net ');
// Set the header
Curl_setopt ($ curl, CURLOPT_HEADER, 1 );
// Set the cURL parameter to save the result to the string or output to the screen.
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
// Run cURL to request the webpage
$ Data = curl_exec ($ curl );
// Close the URL request
Curl_close ($ curl );
// Display the obtained data
Var_dump ($ data ); |
The result shows: Call to undefined function curl_init (). Later, Baidu provided some solutions for your reference.
Modify the configuration under windows + apache:
1. Modify php. ini and remove the semicolon before extension = php_curl.dll.
2. Copy the libeay32.dll and ssleay32.dll (C: AppServphp5) files to the system32 directory.
3. Restart Apache (services. msc).
Linux + apache solution:
Install the curl package. If you use ubuntu, open the new software package manager to search for curl and install curl.