PHP Variables, Echo/Print and Syntax Questions and Answers

PHP Programming : Php Variables and Syntax

This is PHP Programming Sections with Various Multiple choice Questions on PHP Echo/Print, Php Variables and Syntax. Generally these questions are very helpful for Web Developer Interviews.
1. Which symbol is used to declare variable in php?
[A] $
[B] %
[C] #
[D] @
Loading...
2. How to declare a string variable in php?
[A] string str = “abc”;
[B] var string = “abc”;
[C] $str = “abc”;
[D] None of the above
Loading...
3. Which are invalid variable ?
[A] $name1
[B] $_name
[C] $1name
[D] All of the above
Loading...
4. $name = ’foo’; 
$$name = ’bar’; 
Result of echo $foo;
[A] foo
[B] $name
[C] $$name
[D] bar
Loading...
5. $name = ’123’;
$$name = ’456’;
Result of echo ${’123’};
[A] 456
[B] 123
[C] 456{123}
[D] None of above
Loading...
6. How to define constant in php ?
[A] $
[B] define
[C] #define
[D] All of the above
Loading...
7. Select invalid constant.
[A] Define(‘email’,’test@test.com’);
[B] Define(‘1test’,’test@test.com’);
[C] Define(‘a’,’my first alphabet’);
[D] All of the above
Loading...
8. $a = 10;
$b = $a;
$b = 20;
Result of echo $a;
[A] 10
[B] 20
[C] 30
[D] None of the above
Loading...
9. $a = 10;
$b = &$a; // by reference
$b = 20;
Result of echo $a;
[A] 10
[B] 20
[C] 30
[D] None of the above
Loading...
10. Which are the global array in php ?
[A] $_POST
[B] $_GET
[C] $_REQUEST
[D] All of the above
Loading...

Are these questions helpful for you?



Comments: (Your feedback is valuable to us)