Re: SimpleXML and the Single String (SOLVED)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 22.02.12 16:04, schrieb Jay Blanchard:
> On 2/22/2012 8:32 AM, marco@xxxxxxxxxx wrote:
>>   There is another nice way.
>> You can pass a second value to the simple xml constructor which is a
>> class
>> name to be used instead of SimpleXMLElement.
>> You can write your own class that extends SimpleXMLElement and
>> override the
>> magic methods to skip the casting
>>
> I don't really see a need to add an extra layer or class extension
> when casting works fine. Am I wrong? Why add several lines of code in
> an extension class?
>
To keep the code readable?

$value = $xml->node;

vs.

$value = (String)$xml->node;

I like the first one. Plus you handle it to dynamically to the right type

function __get($value)
{
    if is float return float casted value
    if is boolean ...
    and so on
}

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: marco@xxxxxxxxxx

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz


Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux