3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml_retorno = simplexml_load_string('<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?><transaction><date>2020-12-09T09:20:51.000-03:00</date><code>EACDE7D2-EBD5-4F69-B760-640A5EFDC6A6</code><type>1</type><status>3</status><lastEventDate>2020-12-09T09:23:01.000-03:00</lastEventDate><paymentMethod><type>1</type><code>102</code></paymentMethod><grossAmount>46.50</grossAmount><discountAmount>0.00</discountAmount><feeAmount>2.72</feeAmount><netAmount>43.78</netAmount><extraAmount>0.00</extraAmount><escrowEndDate>2020-12-23T01:00:00.000-03:00</escrowEndDate><installmentCount>1</installmentCount><itemCount>1</itemCount><items><item><id>Prestação de serviço digital</id><description>XCHCU7</description><quantity>1</quantity><amount>46.50</amount></item></items><sender><name>GGGG</name><email>corporativo@vvvv.agr.br</email><phone><areaCode>16</areaCode><number>981746872</number></phone></sender><shipping><address><street>Rua Mariana Amaral</street><number>138</number><complement></complement><district>Lagoinha</district><city>SAO XXXDO XXX</city><state>MG</state><country>BRA</country><postalCode>445333</postalCode></address><type>3</type><cost>0.00</cost></shipping></transaction>'); var_dump($xml_retorno -> items -> item[0] -> amount); var_dump(round($xml_retorno -> items -> item[0] -> amount,2));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
object(SimpleXMLElement)#4 (1) { [0]=> string(5) "46.50" } Fatal error: Uncaught TypeError: round(): Argument #1 ($num) must be of type int|float, SimpleXMLElement given in /in/c4DSH:7 Stack trace: #0 /in/c4DSH(7): round(Object(SimpleXMLElement), 2) #1 {main} thrown in /in/c4DSH on line 7
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 object(SimpleXMLElement)#4 (1) { [0]=> string(5) "46.50" } Fatal error: Uncaught TypeError: round(): Argument #1 ($num) must be of type int|float, SimpleXMLElement given in /in/c4DSH:7 Stack trace: #0 /in/c4DSH(7): round(Object(SimpleXMLElement), 2) #1 {main} thrown in /in/c4DSH on line 7
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
object(SimpleXMLElement)#4 (1) { [0]=> string(5) "46.50" } float(46.5)

preferences:
119.13 ms | 402 KiB | 151 Q