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
Loading...
Related Quiz
- OOP in PHP stands for Object-Oriented ______.
- You are writing a PHP script and you need to access the user's IP address. How would you do this using the $_SERVER superglobal?
- Regular Expressions in PHP are case-sensitive.
- Which of the following is a comparison operator in PHP?
- A common practice in PHP forms is to validate user inputs such as email and URL to prevent ______.