Q:
PHP find output programs (Number Functions) | set 1
belongs to collection: PHP Find Output Programs
PHP Find Output Programs
- PHP find output programs (basics) | set 1
- PHP find output programs (basics) | set 2
- PHP find output programs (basics) | set 3
- PHP find output programs (Superglobals) | set 1
- PHP find output programs (conditional statements) | set 1
- PHP find output programs (conditional statements) | set 2
- PHP find output programs (conditional statements) | set 3
- PHP find output programs (switch Statement) | set 1
- PHP find output programs (switch Statement) | set 2
- PHP find output programs (switch Statement) | set 3
- PHP find output programs (Operators) | set 1
- PHP find output programs (Operators) | set 2
- PHP find output programs (Operators) | set 3
- PHP find output programs (Loops) | set 1
- PHP find output programs (Loops) | set 2
- PHP find output programs (Loops) | set 3
- PHP find output programs (Loops) | set 4
- PHP find output programs (Arrays) | set 1
- PHP find output programs (Arrays) | set 2
- PHP find output programs (Arrays) | set 3
- PHP find output programs (User-defined functions) | set 1
- PHP find output programs (User-defined functions) | set 2
- PHP find output programs (User-defined functions) | set 3
- PHP find output programs (String Functions) | set 1
- PHP find output programs (String Functions) | set 2
- PHP find output programs (Number Functions) | set 1
- PHP find output programs (Math Functions) | set 1
- PHP find output programs (Math Functions) | set 2
- PHP find output programs (Date and Time) | set 1
- PHP find output programs (define Constant) | set 1
- PHP find output programs (static variables, classes, methods) | set 1
- PHP find output programs (static variables, classes, methods) | set 2
- PHP find output programs (Regular Expressions) | set 1
- PHP find output programs (Exceptions) | set 1
- PHP find output programs (Exceptions) | set 2
- PHP find output programs (Filters) | set 1
- PHP find output programs (Filters) | set 2
- PHP find output programs (JSON) | set 1
- PHP find output programs (const Keyword) | set 1
- PHP find output programs (Class & Objects) | set 1
- PHP find output programs (Class & Objects) | set 2
- PHP find output programs (Class & Objects) | set 3
- PHP find output programs (Constructors and Destructors) | set 1
- PHP find output programs (Constructors and Destructors) | set 2
- PHP find output programs (Constructors and Destructors) | set 3
- PHP find output programs (Inheritance) | set 1
- PHP find output programs (Inheritance) | set 2
- PHP find output programs (Inheritance) | set 3
Answer 1:
Output:
Explanation:
In the above program, we created two variables $num1 and $num2 initialized with "123" and 123 respectively. Here, we used the is_int() function, which is used to check the specified variable contains an integer number or not.
In the above program, $num1 is a string, while $num2 contains an integer number. Then firs if-else block will print "num1 is not an integer number". And the second if-else block will print "num2 is an integer number" on the web page.
Answer 2:
Output:
Explanation:
In the above program, we declared a variable $num initialized with 12.24. Here, we used two built-in functions is_float() and is_double(). is_double and is_float() have functionality. is_double() is the alias of is_float(). Then both functions will return true, and then it will print "num is a float number" and after the newline, "num is a double number" will be printed on the webpage.
Answer 3:
Output:
Explanation:
In the above program, we created three variables $num1, $num2, and $num3 initialized with "12.24", "1224" and "A123" respectively. Here, we used the is_numeric() function, which is used to check the specified variable contains a numeric value or not.
In the above program, $num1 is a floating-point string, while $num2 contains an integer string, and $num3 contains an alphanumeric string. Then firs if-else block will print "num1 is numeric". And the second if-else block will print "num2 is numeric" and third if-else block will print "num3 is not numeric" on the web page.
Answer 4:
Output:
Explanation:
The above program will generate the compile-time error, int() is not a built-in function in PHP. While the below statement is used to typecast the number $num1 from floating-point number to integer number,
$num2 = (int)$num1;
Answer 5:
Output:
Explanation:
In the above program, we created a variable $num1, which is initialized with 12.24. The below statement is used to typecast the number $num1 from floating-point number to integer number.
$num2 = (int)$num1;
After that, we used int_val(), which is used to return an integer value, and then we used '\n' instead of '<br>' tag for a new line.
So finally, "12\n12\n" will be printed on the webpage.
Answer 6:
Output:
Explanation:
The above program will print 1240 on the webpage because the intval() function returns the number corresponding to the specified numeric string.
$num2 = intval($num1)+6;
In the above statement intval($num1) returns integer number 1234 and then we added 6 to it, then 1240 assigned to $num2.
Then the final value of $num2 is 1240, will be printed on the webpage.
Answer 7:
Output:
Explanation:
In the program, we created a variable $num1, which is initialized with a floating-point string.
$num2 = (integer)$num1+6;
In the above statement, we typecast $num1 into integer and added 6 to it, then 18 assigned to $num2.
Then the final value of $num2 is 18, will be printed on the webpage.
need an explanation for this answer? contact us directly to get an explanation for this answer