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:
The above program will generate an error because $GLOBALS array is used to access global variables, but we used $GLOBAL, that's why error will be generated.
Answer 2:
Output:
Explanation:
The above program will print 1900 on the webpage. In the above program, we created two variables $A and B initialized with 100 and 200 respectively. Then we defined function fun(), here we accessed global variables using super-global array $GLOBALS.
Let's evaluate the expression:
$GLOBALS['C'] = $GLOBALS['A']*(int)fmod(pi()*3,2)+$GLOBALS['B']*printf("RESULT : "); $GLOBALS['C'] = 100*(int)fmod(pi()*3,2)+200*9; $GLOBALS['C'] = 100*1+200*9; $GLOBALS['C'] = 100+1800; $GLOBALS['C'] = 1900;
In the above expression, printf() function will print "RESULT : " and return 9, and fmod() function is used to find the remainder of floating-point number and then we typecast the result into an integer. And finally, we print the value of 'C' that will print 1900 on the webpage.
Answer 3:
Output:
Explanation:
In the above program, we created two variables $A and $B initialized with 100 and "300" respectively. Then we defined function fun(), here we defined a local variable $A with initial value 200.
Let's evaluate the expression:
$C = $A+count($GLOBALS['A'])+count($GLOBALS['B']); $C = 200+1+1; $C = 202;
The count() function is used to count the values of the array, here global $A and $B both contain single values, then it count() function will return 1 for both. Then the final value 202 will be printed on the webpage.
Answer 4:
Output:
Explanation:
In the above program, we defined a function fun(), here we declared a local variable $A, and we used count() function to count default super-global variables stored in $GLOBAL, then it will return 8. If we defined global variables explicitly then the count will increase.
Let's evaluate the expression:
$C = $A+count($GLOBALS); $C = 200+8; $C = 208;
Then 208 will be printed on the webpage.
Answer 5:
Output:
Explanation:
The above program will generate PHP Notice. Because $C is a local variable of function fun(), and we are accessing it outside the function, then it will generate PHP notice.
need an explanation for this answer? contact us directly to get an explanation for this answer