Hi.
Is it possible to check if an object really is an object without generate notice. I have an simplexml_load_file (I use PHP 5.1.x) import that gets an xml feed. I do a check on each value with the is_object becouse I thought that would make sure I didnt generate a notice. But the is_object function generate an notice it self! It doesnt really matter since this is only in development, but it really anoys me!!
is_object without generating notice?
hmm... I didnt think that would be the behaviour. Are you sure it is from is_object() rather than for an incorrect use of the variable? In any case, it should be safe to suppress such a warning with the @ operator, e.g. @is_object($variable)
What does the notice say? "Undefined variable"? If that's the case you should be checking to see that the variable is even set before trying to determine the type that it's set to.
Weedpacket wrote:What does the notice say? "Undefined variable"? If that's the case you should be checking to see that the variable is even set before trying to determine the type that it's set to.
If I remember correctly the the notice was "Undefined variable". And that is the problem. It doesnt allways exist. This is an object generated by the XML import. So I dont really have control if it exist exist or not. That is what I'm trying to check :bemused:
About using the @. I would probably do it in production, but I prefere getting rid of the "problem" instead of supressing it Its not really correct to call it a problem, its just anoying hehe.
So instead of
is_object($something_that_might_not_exist)
try
isset($something_that_might_not_exist)
and the notice should go away.