rayge99;10988942 wrote:right now with the code AS IS i get a Wanring printed to the screen but no exception captured..
Well then that means that there is no exception to capture.
rayge99;10988942 wrote:right now with the code AS IS i get a Wanring printed to the screen but no exception captured..
Well then that means that there is no exception to capture.
OK well the how can i handle this warning in such a way so that it doesn't dump a warning to the screen but i can capture it and print it out how I would like?
Especially if i cant capture it in this method?
What's the warning you're getting?
I didnt think that mattered.
Im testing this code on xml that was malformed and instead of capturing the error with other code I had and posting it to the screen for another developer to view it
just continued saying everything was OK yet showing a warning on the screen.
Here are the errors:
Warning: XMLReader::read() [xmlreader.read]: file: {FILEPATH}.xml:525: parser error : StartTag: invalid element name in {FILEPATH}.php on line 10
Warning: XMLReader::read() [xmlreader.read]: , Alarm_Img, Alarm_Snd FROM device_personal_reminders WHERE (reminder_end_date < in {FILEPATH}.php on line 10
Warning: XMLReader::read() [xmlreader.read]: ^ in {FILEPATH}.php on line 10
Warning: XMLReader::read() [xmlreader.read]: An Error Occured while reading in {FILEPATH}.php on line 10
What i need to do is handle any native php warnings such as this in a way so i can control the output of them how i see fit.
OK so since its not an exception its an error then it LOOKS LIKE i can use
set_error_handler()
I'm not sure what to say... it's frustrating, but there are times when I run into situations in PHP where there's no accessor-type function that I can use to check if the next action will cause an error, and yet there is no way to (gracefully/quietly) 'catch' any errors that due actually occur when you actually perform that action. Unless I'm missing something, it looks like you might be facing a similar dilemma here. One possible solution might be to: store current error logging/outputting settings somewhere, [man]ini_set/man them such that no PHP warnings are logged/displayed anywhere, perform whatever operation(s) you need, and then restore those previous settings after you're done.
Or, alternatively, see below.
rayge99;10988947 wrote:What i need to do is handle any native php warnings such as this in a way so i can control the output of them how i see fit.
Have you considered writing your own error handler? (See the manual page for [man]set_error_handler/man for more info on that.)
LOL Good timing on that message
It half ass works for me.. NOW the question is how to output the data from the custom error handler function to a string variable that I can use.
rayge99;10988954 wrote:NOW the question is how to output the data from the custom error handler function to a string variable that I can use.
Take a look at the manual page for the $php_errormsg variable here: [man]reserved.variables.phperrormsg[/man]. Note that even if that directive isn't enabled, you could still replicate its functionality manually by doing something like:
$GLOBALS['php_errormsg'] = 'some error message';
inside your error handler.
DUH Great idea on using GLOBALS! that will do the trick!
bradgrafelman;10988952 wrote:no accessor-type function that I can use to check if the next action will cause an error, and yet there is no way to (gracefully/quietly) 'catch' any errors that due actually occur when you actually perform that action
But XMLReader is based on libXML, so doesn't [man]libxml_use_internal_errors[/man] and [man]libxml_get_last_error[/man] work?
johanafm;10989052 wrote:But XMLReader is based on libXML, so doesn't [man]libxml_use_internal_errors[/man] and [man]libxml_get_last_error[/man] work?
Good call - never realized those libxml functions were available.