Q:
PHP find output programs (switch Statement) | 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 used switch-case statements. Here, we created a variable $var initialized with "1". Switch block contains multiple cases, the $var will match with "case 1" because 1 and "1" can be matched in switch case block in PHP. Then finally "One" will print on the webpage.
Answer 2:
Output:
Explanation:
In the above program, we used switch-case statements. Here, we created a variable $var, which is initialized with the value returned by the print() function. The print() function returns 1 on successful printing data specified in it. So the print() function will print "OK " and return 1. Then the value of $var will be 1.
The switch block contains multiple cases, the $var will match with "case 1" and print "One" on the webpage.
Answer 3:
Output:
Explanation:
In the above program, we used switch-case statements. Here, we created a variable $var, which is initialized with the value returned by the printf() function. The printf() function return the total number of characters printed by the printf(), here "OK " are 3 characters, then it will return 3. So printf() function will print "OK " and return 3. Then the value of $var will be 3.
The switch block contains multiple cases, the $var will match with "case 3" and print "Three" on the webpage.
Answer 4:
Output:
Explanation:
In the above program, we used switch-case statements. Here, we created a variable $var and initialized with true, "true" is a predefined constant that's value is 1. So, $var is actually initialized with 1. Then $var will match with "case 1" and print "One" on the webpage.
Answer 5:
Output:
Explanation:
In the above program, we used switch-case statements. Here, we created a variable $var and initialized with (true+true), "true" is a predefined constant that's value is 1. So, $var is actually initialized with 2. Then $var will match with "case 2" and print "Two", but here we missed break statement after "case 2" then it will also execute "case 3" and also print "Three" on the webpage.
Then the final output "TwoThree" will be printed on the webpage.
need an explanation for this answer? contact us directly to get an explanation for this answer