MDanz Posted March 19, 2010 Share Posted March 19, 2010 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 More sharing options...
Psycho Posted March 19, 2010 Share Posted March 19, 2010 if($tags = @get_meta_tags($url)) { echo "worked"; } else { echo "failed"; } Link to comment https://forums.phpfreaks.com/topic/195856-make-error-invisible/#findComment-1028777 Share on other sites More sharing options...
strangesoul Posted March 20, 2010 Share Posted March 20, 2010 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. Link to comment https://forums.phpfreaks.com/topic/195856-make-error-invisible/#findComment-1029215 Share on other sites More sharing options...
The Little Guy Posted March 20, 2010 Share Posted March 20, 2010 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>'; ?> Link to comment https://forums.phpfreaks.com/topic/195856-make-error-invisible/#findComment-1029224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.