You need to store a price, which includes cents, in a variable in your PHP script. What type of number would you use and why?

  • float
  • integer
  • string
  • boolean
In this case, you would use the float data type to store a price that includes cents in a variable in your PHP script. The float data type allows for the representation of real numbers with a decimal point, which is suitable for storing prices that may have fractional values, such as cents. Integer data type is not suitable as it does not allow for decimal points. String data type could be used, but it is more appropriate to use float to perform arithmetic calculations if needed. Learn more: https://www.php.net/manual/en/language.types.float.php
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *