Jump to content

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>';
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.