[PHP]Error handler werkt niet goed

Gestart doorRik9 reacties33 weergaven

10 berichten · pagina 1 van 1

Rik

Lid · Topicstarter

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Ziet iemand wat ik hier fout doe?

Er wordt namelijk geen mail verstuurd, en PHP gebruikt zijn eigen errors gewoon:

[COLOR= #0000BB]<?[/COLOR]    [COLOR= #FF8000]// ERROR HANDLER \[/COLOR]
    [COLOR= #007700]function[/COLOR] handle_on_error[COLOR= #007700]([/COLOR][COLOR= #0000BB]$e_number[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_message[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_file[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_line[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_vars[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"<strong>Errno:</strong>"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$e_number[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"
<br />"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Bestand:</strong> "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$e_file[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"
<br />"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Regel(s):</strong> "[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$e_line[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]" 
<br />"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Bericht:</strong> "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$e_message[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"
<br />"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Datum en Tijd:</strong>"[/COLOR][COLOR= #007700].[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]j-n-Y H:i:s[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]"
<BR />"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Errvars</strong><br />FORUMCODE0"[/COLOR][COLOR= #007700];[/COLOR] 
        [COLOR= #0000BB]$headers[/COLOR]  [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]From: =geheim=@mywerewolf.nl[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"
"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]Reply-To: =geheim=@mywerewolf.nl[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"
"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]X-Mailer: PHP/[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/phpversion"]phpversion[/URL][COLOR= #007700]();[/COLOR]
        [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]MIME-Version: 1.0[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"
"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]Content-type: text/html; charset=iso-8859-1[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"
"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/error_log"]error_log[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$error_message[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]=geheim=@mywerewolf.nl[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$headers[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<strong>Excuses:</strong>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er is iets mis gegaan, de webmaster(s) zijn op de hoogte gesteld. Exuses voor het ongemak <br />"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
    }[/COLOR]
    [COLOR= #FF8000]// END ERROR HANDLER \[/COLOR]
    [URL="http://www.php.net/set_error_handler"]set_error_handler[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]handle_on_error[/COLOR][COLOR= #007700],[/COLOR] E_ALL [COLOR= #007700]&[/COLOR] ~E_NOTICE[COLOR= #007700]);[/COLOR] ?>
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
dat er geen mail word vesrtuurd komt misschien omda tje de mail() tag bent vergetenxd
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
error_log verzend de mail
0
Rik

Lid · Topicstarter

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Eleky schreef:
dat er geen mail word vesrtuurd komt misschien omda tje de mail() tag bent vergetenxd
Error log heeft een ingebouwde mail-functie.
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Als je die 2e parameter weghaalt, doettie het dan wel?
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dus van

set_error_handler(handle_on_error, E_ALL & ~E_NOTICE);


dit maken:

set_error_handler(handle_on_error);


?
Nee, dan werkt het ook niet
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Sure?

Dit:
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] handle_on_error[COLOR= #007700]([/COLOR][COLOR= #0000BB]$e_number[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_message[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_file[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_line[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_vars[/COLOR][COLOR= #007700])
{[/COLOR]

    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"<strong>Errno:</strong>"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$e_number[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"n<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Bestand:</strong> "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$e_file[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"n<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Regel(s):</strong> "[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$e_line[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]" n<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Bericht:</strong> "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$e_message[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"n<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Datum en Tijd:</strong>"[/COLOR][COLOR= #007700].[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]j-n-Y H:i:s[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]"n<BR />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Errvars</strong><br />FORUMCODE0"[/COLOR][COLOR= #007700];[/COLOR] 
    
    [COLOR= #0000BB]$headers[/COLOR]  [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]From: =geheim=@mywerewolf.nl[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"rn"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]Reply-To: =geheim=@mywerewolf.nl[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"rn"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]X-Mailer: PHP/[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/phpversion"]phpversion[/URL][COLOR= #007700]();[/COLOR]
    [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]MIME-Version: 1.0[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"rn"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]Content-type: text/html; charset=iso-8859-1[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"rn"[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/error_log"]error_log[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$error_message[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]=geheim=@mywerewolf.nl[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$headers[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<strong>Excuses:</strong>"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er is iets mis gegaan, de webmaster(s) zijn op de hoogte gesteld. Exuses voor het ongemak <br />"[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/set_error_handler"]set_error_handler[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]handle_on_error[/COLOR][COLOR= #007700],[/COLOR] E_ALL [COLOR= #007700]&[/COLOR] ~E_NOTICE[COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$efweefwe[/COLOR][COLOR= #007700];[/COLOR]
?>


geeft dit:
Notice: Undefined variable: efweefwe in D:localhostwwwtest.php on line 29


wat je dus niet wilt, omdat die fout niet wordt opgevangen;

maar dit:
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] handle_on_error[COLOR= #007700]([/COLOR][COLOR= #0000BB]$e_number[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_message[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_file[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_line[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$e_vars[/COLOR][COLOR= #007700])
{[/COLOR]

    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"<strong>Errno:</strong>"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$e_number[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"n<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Bestand:</strong> "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$e_file[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"n<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Regel(s):</strong> "[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$e_line[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]" n<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Bericht:</strong> "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$e_message[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"n<br />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Datum en Tijd:</strong>"[/COLOR][COLOR= #007700].[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]j-n-Y H:i:s[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]"n<BR />"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$error_message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<strong>Errvars</strong><br />FORUMCODE1"[/COLOR][COLOR= #007700];[/COLOR] 
    
    [COLOR= #0000BB]$headers[/COLOR]  [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]From: =geheim=@mywerewolf.nl[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"rn"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]Reply-To: =geheim=@mywerewolf.nl[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"rn"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]X-Mailer: PHP/[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/phpversion"]phpversion[/URL][COLOR= #007700]();[/COLOR]
    [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]MIME-Version: 1.0[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"rn"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]Content-type: text/html; charset=iso-8859-1[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"rn"[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/error_log"]error_log[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$error_message[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]=geheim=@mywerewolf.nl[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$headers[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<strong>Excuses:</strong>"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er is iets mis gegaan, de webmaster(s) zijn op de hoogte gesteld. Exuses voor het ongemak <br />"[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/set_error_handler"]set_error_handler[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]handle_on_error[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$efweefwe[/COLOR][COLOR= #007700];[/COLOR]
?>


geeft wel dit:
Warning: error_log() [function.error-log]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:localhostwwwtest.php on line 18
Excuses:Er is iets mis gegaan, de webmaster(s) zijn op de hoogte gesteld. Exuses voor het ongemak


precies wat je wilt dus..

Let wel op dat PHP niet alle errors vervangt door jouw meldingen (fatale fouten sowieso niet, maar hoe het verder precies zit weet ik ook niet).
0
Rik

Lid · Topicstarter

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Maar dan krijgen we voor elke notice een mailtje, en dat zijn er nogal wat (paar dingen die we niet vooraf gedefineerd hebben).
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Fix die dan. emo
Hoe je het anders krijgt weet ik niet, misschien error_reporting() anders instellen?

Maar t is serieus een slechte gewoonte om die errors gewoon maar niet weer te geven; los ze gewoon op en bouw je systeem zo dat je alle errors opslaat. Doen we hier ook en dat bevalt prima.
Hij stuurt hier trouwens 1x per sessie een mailtje; dus als er 100 fouten op 1 pagina voorkomen krijg je niet 100 mailtjes. Misschien handig om dat ook bij jullie in te bouwen, anders ga je dr spijt van krijgen dat je dat niet hebt. ^^
0
Rik

Lid · Topicstarter

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Naja, inmiddels ben ik er achter wat de fout was, hij neemt parse fouten enzo namelijk niet mee. En ik teste het script uit met een parse fout :")
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren