Reply to Re: [PHP] simplexml_load_string always FALSE

Your name:

Reply:


Posted by "Richard Lynch" on 11/10/05 23:08

On Thu, November 10, 2005 12:26 pm, Scott Klarenbach wrote:
> I have a call
> $oXML = simplexml_load_string($xmlString);
>
> I then check it, with
>
> if(!$oXML) throw new XMLException();
>
> For some reason, it's always evaluating to FALSE. Even though there
> are no errors and the rest of the xml parsing works fine.
>
> If I change it to
>
> if($oXML === FALSE) throw new XMLException();
> then it works fine.
>
> Is it evaluating a valid xml object as 0?

Probably.

The type-casting rules for PHP Objects to integer (and later boolean,
when those were introduced) have changed in minor ways with every
major release.

The exact details of the OO->int conversion always seemed muddy to me,
personally.

> I wonder if anyone can
> enlighten me.

I think your code is way more better with the strict test you already
discovered as a "work-around".

You are explicitly checking for FALSE, which is an unusual value for
an Object to take on.

You may also want to look at xmlerror or whatever it is, which is
where there is PROBABLY and error message just waiting for you to ask.

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация