PHP MCQ
PHP MCQ
4. A PHP script should start with ___ and end with ___:
A.
B.
C.
<??>
D.
Ans.D
11. Which of the following php statement/statements will store 111 in variable
num?
i) int $num = 111;
ii) int mum = 111;
iii) $num = 111;
iv) 111 = $num;
A. Both (i) and (ii)
B. All of the mentioned.
C. Only (iii)
D. Only (i)
Ans.C
< ?php
$num = 1;
$num1 = 2;
?>
A. 3
B. 1+2
C. 1.+.2
D. Error
Ans.B
< ?php
$num = "1";
$num1 = "2";
print $num+$num1 ;
?>
A. 3
B. 1+2
C. Error
D. 12
Ans.A
$foo = 'Bob';
$bar = &$foo;
echo $bar;
echo $foo;
?>
A. Error
B. My name is BobBob
C. My name is BobMy name is Bob
D. My name is Bob Bob
C
Ans.C
Ans.C
< ?php
$fruits = array_flip($fruits);
echo ($fruits[0]);
?>
A. mango
B. Error
C. peach
D. 0
Ans.B
< ?php
echo $states["karnataka"]["population"];
?>
A. karnataka 11,35,000
B. 11,35,000
C. population 11,35,000
D. karnataka population
Ans.B
21. Which function can be used to move the pointer to the previous array
position?
A. last()
B. before()
C. prev()
D. previous()
Ans.C
Ans. A
Ans. B
C.$request D.$post
Ans. B
C.ord( ); D.val( );
Ans. C
25) Which of the following method sends input to a script via a
URL?
A.Get B.Post
C.Both D.None
Answer : Option A
C.toupper($var) D.ucword($var)
Answer : Option A
C.strcount($variable) D.strlen($variable)
Answer : Option D
32) which of the following are the valid PHP data types?
a. resource
b. null
c. boolean
d). All of the above
Ans: d
Ans: d
47) Which of the following is correct with regard to echo and print?
a. echo is a construct and print is a function
b. echo is a function and print is a construct
c. Both are functions
d. Both are constructs
Ans: d
50) In multidimensional arrays rather than a single key they values are stored in
Ans.A
A. Vector arrays
B. Perl arrays
C. Hashes
D. All of them
Ans.C
A. Same size
B. Same type
C. Different size
D. Different type
Ans.B
A. Faster
B. Slower
C. Stable
D. None of them
Ans.A
Ans.C
55) The updated MySQL extension released with PHP 5 is typically referred to
as..
a) MySQL
b) mysql
c) mysqli
d) mysqly
Ans. C
Ans. A
56)Which one of the following statements can be used to select the database?
a) $mysqli=select_db(‘databasename’);
b) mysqli=select_db(‘databasename’);
c) mysqli->select_db(‘databasename’);
d) $mysqli->select_db(‘databasename’);
Ans.D
57) Which of the methods are used to manage result sets using both associative
and indexed arrays?
a) get_array() and get_row()
b) get_array() and get_column()
c) fetch_array() and fetch_row()
d) fetch_array() and fetch_column()
Ans. C
58)Which two predefined variables are used to retrieve information from forms?
a) $GET & $SET
b) $_GET & $_SET
c) $__GET & $__SET
d) GET & SET
Ans. B
59) When you use the $_GET variable to collect data, the data is visible to..
a) none
b) only you
c) everyone
d) selected few
Ans.C
60)When you use the $_POST variable to collect data, the data is visible to..
a) none
b) only you
c) everyone
d) selected fewAns
Ans. B
A.on_array()
B.is_array()
C.the_array()
D.None
Ans. B
A.push()
B.pop()
C.stack()
D.None
Ans. A
A.push()
B.pop()
C.stack()
D.None
Ans. B