1. What is the largest integer value supported in 64-bit PHP?
Answer:
Explanation:
In a 64-bit version of PHP, the largest integer is 2^63 – 1.
2. How is a hexadecimal number specified in PHP?
Answer:
Explanation:
Hexadecimal numbers are specified with a leading 0x in PHP.
3. What function checks if a variable is a number or a numeric string in PHP?
Answer:
Explanation:
The is_numeric() function checks if a variable is a number or a numeric string.
4. How do you convert a string to an integer in PHP?
Answer:
Explanation:
intval() and casting with (int) are both used to convert a string to an integer.
5. What is the result of the expression 0.1 + 0.2 in PHP?
Answer:
Explanation:
Due to floating-point precision, the sum of 0.1 and 0.2 may not exactly equal 0.3.
6. Which function can be used to format a number with grouped thousands in PHP?
Answer:
Explanation:
The number_format() function is used to format numbers with grouped thousands.
7. What is the output of the following PHP code? echo (int)(8.9);
Answer:
Explanation:
Casting a float to an int in PHP truncates the decimal part.
8. How do you define a float number in scientific notation in PHP?
Answer:
Explanation:
Scientific notation in PHP can be written using either uppercase E or lowercase e.
9. What is the purpose of the PHP function round()?
Answer:
Explanation:
round() can round a number to its nearest integer or to a specified number of decimal points.
10. How does PHP handle arithmetic operations on an integer that exceed its maximum value?
Answer:
Explanation:
PHP automatically converts integers to floats when they exceed their maximum value.
11. What is the output of the PHP expression var_dump(0123)?
Answer:
Explanation:
Numbers starting with 0 are interpreted as octal numbers. 0123 in octal is equivalent to 83 in decimal.
12. Which function checks whether a variable is a float in PHP?
Answer:
Explanation:
is_float(), is_double(), and is_real() are all equivalent and check if a variable is of type float.
13. What is the maximum number of decimal digits guaranteed to be preserved in float operations in PHP?
Answer:
Explanation:
PHP guarantees that at least 14 decimal digits can be preserved in float operations.
14. What is the result of the following PHP code? echo gettype(10.0);
Answer:
Explanation:
In PHP, floating-point numbers are of the type double.
15. Which PHP function will return a string representation of a number in binary format?
Answer:
Explanation:
The decbin() function converts a decimal number to a binary string.