3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<?xml version="1.0"?> <xdm:Device xmlns:xdm="http://www.hp.com/schemas/imaging/con/xdm/1.1/" xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/" xmlns:bsi="http://www.hp.com/schemas/imaging/con/bsi/2003/08/21" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:count="http://www.hp.com/schemas/imaging/con/counter/2006/01/13" xmlns:media="http://www.hp.com/schemas/imaging/con/media/2006/01/13/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tt="http://www.hp.com/schemas/imaging/con/capabilities/1.1/" xmlns:pwg="http://www.hp.com/schemas/imaging/con/pwg/sm/1.0/"> <xdm:Information> <xdm:Component id="system" componentType="system"> <dd:MakeAndModel>Samsung LaserJet ML220</dd:MakeAndModel> <dd:Description>Blackand while printer</dd:Description> <dd:ProductNumber>XB3zzz</dd:ProductNumber> <dd:Manufacturer> <dd:Name>Samsung</dd:Name> </dd:Manufacturer> </xdm:Component> </xdm:Information> </xdm:Device>'; // Defining my own ways of referring to the namespaces, regardless of prefix used define('XMLNS_HP_XDM_1_1', 'http://www.hp.com/schemas/imaging/con/xdm/1.1/'); define('XMLNS_HP_DICT_1_0', 'http://www.hp.com/schemas/imaging/con/dictionaries/1.0/'); // Load the XML in the normal way $sx = simplexml_load_string($xml); // Switch to the first namespace, and look at the first Component $component = $sx->children(XMLNS_HP_XDM_1_1)->Information->Component; $component_id = (string)$component->attributes(null)->id; // Switch to the second namespace to find the MakeAndModel $make_and_model = (string)$component->children(XMLNS_HP_DICT_1_0)->MakeAndModel; echo "$component_id : $make_and_model";
Output for 5.1.2 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
system : Samsung LaserJet ML220
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
: Samsung LaserJet ML220
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/vXXv8 on line 33
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/vXXv8 on line 33
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/vXXv8 on line 33
Process exited with code 255.

preferences:
196.75 ms | 412 KiB | 5 Q