Forum Moderators: coopster

Message Too Old, No Replies

how to catch an error message

         

zozzen

12:04 pm on Sep 19, 2010 (gmt 0)

10+ Year Member



Hi,

I'm using a CMS and a bunch of plug-in, but an error message sometimes mysteriously displays, possibly due to the crash with other plug-ins.

Although I don't really know what happens, the website still works fine.

To make it simple, I'm wondering if it's possible to "un-display" the error message like this?

Notice: Undefined variable: RecentLink in D:\xampp\htdocs\wiki\extensions\example.php

Any advice is appreciated!

SevenCubed

2:08 pm on Sep 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



According to your example it isn't a full-fledged error but a notice which is confirmed by you saying the pages still display as intended so you could add this simple snippet of code at the very top of a page above the html...

<? php error_reporting (E_ALL ^ E_NOTICE); ?>

That will not suppress actual error messages which I don't think you would want to do but it will suppress NOTICE messages such as the one you used in your example.

brotherhood of LAN

2:18 pm on Sep 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Or if you wanted to suppress purely that warning, put an @ sign before the variable on the particular line that's reporting the warning

$var to @$var

penders

2:30 pm on Sep 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



TBH, that doesn't look like a "crash with other plug-ins". It looks like either the developer has not anticipated this situation or has developed the code with E_NOTICE's turned off (which is what SevenCubed's post does).

The code still 'works' because PHP will default the value of $RecentLink if it is not defined.

zozzen

3:19 pm on Sep 25, 2010 (gmt 0)

10+ Year Member



thanks so much! the problem is solved with SevenCubed's way now.

thanks!