Tell me how to get 5% of the number 223.66 on php I am writing

$number = 223,66; $result = $number * 5 /100; 

But in the end it’s not how to fix it? Thank you, figured out!

  • 3
    ? $number = 223.66; $result = $number * 0.05; . - user207618

2 answers 2

Forget about commas in real numbers.

 $number = 223.66; $result = $number * 5 /100; 

    Floating-point numbers (also known as "float", "double", or "real") can be defined with the following syntax:

     <?php $a = 1.234; $b = 1.2e3; $c = 7E-10; ?> 

    php.net> source

    If you are not sure about the type, use the settype () function .

     settype($your_value,"double");