PHP 8.4.24 Released!

Voting

: four plus five?
(Example: nine)

The Note You're Voting On

mahmutta at gmail dot com
16 years ago
while using simple xml and get double or float int value from xml object for using math operations (+ * - / ) some errors happens on the operation, this is because of simple xml returns everythings to objects. 
exmple;

<?php

$name = "somestring";
$size = 11.45;
$xml = '
<xml>
 <name>somestring</name>
 <size>11.45</size>
</xml>';

 
$xmlget = simplexml_load_string($xml)

echo $xml->size*2;    // 20  its false
// ($xml->size is an object (int)11 and  (45) )

// this is true
echo $size*2;            // 22.90 
echo (float)$size*2;   // 22.90 
?>

<< Back to user notes page

To Top