2

i am new to php and i want to get a webpage html through the use of php curl...i am not getting the output,am just getting a white page. Can anyone please help?

<?php 
$url=$_POST['txturl'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$output = curl_exec($ch);
echo $output;
curl_close($ch); 
?>
0

1 Answer 1

6

You don't need to send URL twice

<?php 
$url=$_POST['txturl'];
$ch = curl_init();//I have removed it from here
curl_setopt($ch, CURLOPT_URL,$url);// This will do
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$output = curl_exec($ch);
echo $output;
curl_close($ch); 
?>

Check if you really have cURL Installed

<?php
echo function_exists('curl_version')?'Yes':'No';
?>
Sign up to request clarification or add additional context in comments.

3 Comments

Try this code <?php phpinfo(); ?> , ctrl+F and type 'curl' and see if it is enabled.
Also add this on top of your PHP code, maybe your error reporting is off. <?php error_reporting(E_ALL); ini_set('display_errors', 1);
<?php echo function_exists('curl_version')?'Yes':'No'; ?> i have tried this but neither yes nor No has been displayed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.