0

I want to test whether everything is okay or not with the curl in my PHP installation,

I tried the below code, but it I got internal server error! Would anybody help me with this.

   <?php
// Create a cURL handle
$ch = curl_init('http://xx.xx.xx.xxx/Dinga/');

// Execute
curl_exec($ch);

// Check if any error occurred
if (!curl_errno($ch)) {
  $info = curl_getinfo($ch);
  echo 'Took ', $info['total_time'], ' seconds to send a request to ', $info['url'], "\n";
}

// Close handle
curl_close($ch);
?>
3
  • Code is working fine,please check the URL you are passing. try to hit same URL via browser and check the response Commented May 10, 2016 at 9:14
  • Get all status by print_r( $info); Commented May 10, 2016 at 9:17
  • Check this answer here. Commented Jan 26, 2021 at 16:34

3 Answers 3

2

try this use this into before curl close

if(curl_error($ch))
{
echo 'curl error is -' . curl_error($ch);
}
Sign up to request clarification or add additional context in comments.

Comments

1

Add the following code in the start and try again.

ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);    
error_reporting(E_ALL);

And if there is any parsing issue, then you will have to edit php.ini file and set this param

display_errors = on

Comments

0

Locally I did this

$fp = fopen('/tmp/errorlog.txt', 'w');
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.