Jump to content

make error invisible


MDanz

Recommended Posts

this works, it echoes "worked".

<?php

$url = "http://www.realgm.com";

$tags = (get_meta_tags($url)) ? get_meta_tags($url) : false;

if($tags){
echo "worked";
}else{
echo "failed";
}
?>

 

i've deliberately done this so it doesn't work.  It fails to open stream.  How do i make the error message invisible?... it should just say "failed".

<?php

$url = "gssgdd";

$tags = (get_meta_tags($url)) ? get_meta_tags($url) : false;

if($tags){
echo "worked";
}else{
echo "failed";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/195856-make-error-invisible/
Share on other sites

If You just want to make the error invisible put error_reporting(0) after php tag. i.e.,

<?php

error_reporting(0);

 

....Your code here....

?>

 

Do this only if you ensure your code is correct  otherwise it might hide the errors that u must know to correct the code.

Thanks,

Strangesoul.

You can do a little bit more with this:

<?php
$url = 'http://www.realgm.com';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);


curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if($status == 0){
echo 'Site doesn\'t exist!';
}elseif($status == 200){
echo 'Site is live and working!';
}elseif($status == 404){
echo 'Site is live but document not found!';
}elseif($status == 500){
echo 'Site is live and returned an internal server error!';
}

echo '<p>'.$status.'</p>';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.