Not showing an error


#1

I have a script that checks if a URL is valid or not using fopen. So it’s basically ok for the script to have an error, that is what the script is for… to see if something is erroneous. So I want to know how to make it so it doesn’t show the error, because im writing my own error. How do i do this?


#2

You should check out trigger_error()

Reference:
http://www.php.net/manual/en/function.trigger-error.php


#3

I don’t like what that does. I can edit what the error says but then the error will still say

Notice: hello in /home/exfugaco/public_html/edit_account.php on line 4

thats not what i wanted. I want the error message to go away completely, because that error isnt user-friendly.


#4

@ is the error repressor for a single line/function. Put it in front of what ever is throwing the error. It however does not work with everything and it does not stop the error from happening.


#5

You can try something like this using @ to supress errors:
[php]<?PHP
$errorMsg = NULL;
// way one
if(!@$fp = fopen(“file.txt”, “r”)) $errorMsg = TRUE;
// way two
@$fp = fopen(“file.txt”, “r”) or $errorMsg = TRUE;
if($errorMsg) echo “Can’t open the file.”;
?>[/php]