MCQ Sybbaca Ca-304 PHP
MCQ Sybbaca Ca-304 PHP
Answer: c
Answer: c
i) Notepad
ii) Notepad++
iv) PDT
a) Only iv)
b) i), ii), iii) and iv)
c) i), ii) and iii)
d) Only iii)
Answer: b
5. Which of the following must be installed on your computer so as to run PHP script?
i) Adobe Dreamweaver
ii) XAMPP
iv) IIS
Answer: d
Answer: d
i) /?
ii) //
iii) #
iv) /* */
a) Only ii)
b) i), iii) and iv)
c) ii), iii) and iv)
d) Both ii) and iv)
Answer: c
8. Which of the following PHP statement/statements will store 111 in variable num?
Answer: c
1. <?php
2. $num = 1;
3. $num1 = 2;
4. print $num . "+". $num1;
5. ?>
a) 3
b) 1+2
c) 1.+.2
d) Error
Answer: b
1. <?php
2. $num = "1";
3. $num1 = "2";
4. print $num+$num1;
5. ?>
a) 3
b) 1+2
c) Error
d) 12
Answer: a
i) $3hello
ii) $_hello
iii) $this
iv) $This
a) Only ii)
b) Only iii)
c) ii), iii) and iv)
d) ii) and iv)
Answer: d
1. <?php
2. $foo = 'Bob';
3. $bar = &$foo;
4. $bar = "My name is $bar";
5. echo $bar;
6. echo $foo;
7. ?>
a) Error
b) My name is BobBob
c) My name is BobMy name is Bob
d) My name is Bob Bob
Answer: c
13. Which of the following PHP statements will output Hello World on the screen?
a) i) and ii)
b) i), ii) and iii)
c) i), ii), iii) and iv)
d) i), ii) and iv)
Answer: b
1. <?php
2. $color = "maroon";
3. $var = $color[2];
4. echo "$var";
5. ?>
a) a
b) Error
c) $var
d) r
Answer: d
1. <?php
2. $score = 1234;
3. $scoreboard = (array) $score;
4. echo $scoreboard[0];
5. ?>
a) 1
b) Error
c) 1234
d) 2
Answer: c
1. <?php
2. $total = "25 students";
3. $more = 10;
4. $total = $total + $more;
5. echo "$total";
6. ?>
a) Error
b) 35 students
c) 35
d) 25 students
Answer: c
Answer: b
Answer: a
1. <?php
2. function track() {
3. static $count = 0;
4. $count++;
5. echo $count;
6. }
7. track();
8. track();
9. track();
10. ?>
a) 123
b) 111
c) 000
d) 011
Answer: a
1. <?php
2. $a = "clue";
3. $a .= "get";
4. echo "$a";
5. ?>
a) get
b) true
c) false
d) clueget
Answer: d
1. <?php
2. $a = 5;
3. $b = 5;
4. echo ($a === $b);
5. ?>
a) 5 === 5
b) Error
c) 1
d) False
Answer: c
Answer: b
1. <?php
2. $num = 10;
3. echo 'What is her age? \n She is $num years old';
4. ?>
a) What is her age? \n She is $num years old
b) What is her age?She is $num years old
i) if statements
a) Only i)
b) i), ii) and iv)
c) ii), iii) and iv)
d) i), ii), iii) and iv)
Answer: d
1. <?php
2. $team = "arsenal";
3. switch ($team) {
4. case "manu":
5. echo "I love man u";
6. case "arsenal":
7. echo "I love arsenal";
8. case "manc":
9. echo "I love manc"; }
10. ?>
a) I love arsenal
b) Error
c) I love arsenalI love manc
d) I love arsenalI love mancI love manu
Answer: c
i) for loop
Answer: c
1. <?php
2. $user = array("Ashley", "Bale", "Shrek", "Blank");
3. for ($x=0; $x < count($user); $x++) {
4. if ($user[$x] == "Shrek") continue;
5. printf ($user[$x]);
6. }
7. ?>
a) AshleyBale
b) AshleyBaleBlank
c) ShrekBlank
d) Shrek
Answer: b
Answer: d
29. What will be the value of $a and $b after the function call in the following PHP code?
1. <?php
2. function doSomething( &$arg ) {
3. $return = $arg;
4. $arg += 1;
5. return $return;
6. }
7. $a = 3;
8. $b = doSomething( $a );
9. ?>
a) a is 3 and b is 4
b) a is 4 and b is 3
c) Both are 3
d) Both are 4
Answer: b
Answer: a
31.This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on
“Functions”.
Answer: d
32. Which type of function call is used in line 8 in the following PHP code?
1. <?php
2. function calc($price, $tax)
3. {
4. $total = $price + $tax;
5. }
6. $pricetag = 15;
7. $taxtag = 3;
8. calc($pricetag, $taxtag);
9. ?>
a) Call By Value
b) Call By Reference
c) Default Argument Value
d) Type Hinting
Answer: a
1. <?php
2. function calc($price, $tax="")
3. {
4. $total = $price + ($price * $tax);
5. echo "$total";
6. }
7. calc(42);
8. ?>
a) Error
b) 0
c) 42
d) 84
Answer: c
i) function()
ii) €()
iii) .function()
iv) $function()
a) Only i)
b) Only ii)
c) i) and ii)
d) iii) and iv)
Answer: b
1. <?php
2. function a()
3. {
4. function b()
5. {
6. echo 'I am b';
7. }
8. echo 'I am a';
9. }
10. a();
11. a();
12. ?>
a) I am a
b) I am bI am a
c) Error
d) I am a Error
Answer: a
1. <?php
2. function a()
3. {
4. function b()
5. {
6. echo 'I am b';
7. }
8. echo 'I am a';
9. }
10. b();
11. a();
12. ?>
a) I am b
b) I am bI am a
c) Error
d) I am a Error
Answer: c
1. <?php
2. $op2 = "blabla";
3. function foo($op1)
4. {
5. echo $op1;
6. echo $op2;
7. }
8. foo("hello");
9. ?>
a) helloblabla
b) Error
c) hello
d) helloblablablabla
Answer: c
38. A function in PHP which starts with __ (double underscore) is known as __________
a) Magic Function
b) Inbuilt Function
c) Default Function
d) User Defined Function
Answer: a
1. <?php
2. function foo($msg)
3. {
4. echo "$msg";
5. }
6. $var1 = "foo";
7. $var1("will this work");
8. ?>
a) Error
b) $msg
c) 0
d) Will this work
Answer: d
40. This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “In-Built
Functions in PHP”.
Answer: b
41. Which one of the following PHP functions can be used to find files?
a) glob()
b) file()
c) fold()
d) get_file()
Answer: a
42. Which of the following PHP functions can be used to get the current memory usage?
a) get_usage()
b) get_peak_usage()
c) memory_get_usage()
d) memory_get_peak_usage()
Answer: c
43. Which of the following PHP functions can be used for generating unique ids?
a) uniqueid()
b) id()
c) md5()
d) mdid()
Answer: a
44. Which one of the following functions can be used to compress a string?
a) zip_compress()
b) zip()
c) compress()
d) gzcompress()
Answer: d
1. <?php
2. echo chr(52);
3. ?>
a) 1
b) 2
c) 3
d) 4
Answer: d
1. <?php
2. echo ord ("hi");
3. ?>
a) 106
b) 103
c) 104
d) 209
Answer: c
1. <?php
2. $str = "Hello World";
3. echo wordwrap($str,5,"<br>\n");
4. ?>
a) Hello World
b) Hello World
c) Hellow worlds
d) none of these
1. <?php
2. echo ucwords("i love my country");
3. ?>
a) I love my country
b) i love my Country
c) I love my Country
d) I Love My Country
Answer: d
1. <?php
2. echo lcfirst("welcome to India");
3. ?>
a) welcome to India
b) welcome to india
c) Welcome to India
d) Welcome to india
Answer: a
Answer: b
------------------------------------------------------------------
1)PHP is a server scripting language, and a powerful tool for making _____and
________Web pages.
c) static , interactive
d) object , SPA
Answer: a
Answer: c
a) .object
b) .php
c) .ph
d) .js
Answer: b
4) _______ used to show the out put …or give message..same as printf in c
language…
a) Echo
b) printf
c) print
d) 4)cout
Answer: a
b) Hypertext Microprocessor
c) Hypertext Pre-processor
Answer: c
a) null
b) 2)Boolean
c) Array
d) ampersand(&)
Answer: d
a) Logical operators
b) String operators
c) Array operators
d) Boolean
Answer: d
a) +
b) &&
c) &
d) .
Answer: d
a) +
b) =
c) --
d) ;
Answer: b
a) <>
b) &&
c) &
d) ?
Answer: b
11) A ______ data types is used for logical data it represents two possible states:
TRUE or FALSE.
a) integer
b) Null
c) Array
d) Boolean
Answer: d
12) The _______keyword is used to access a global variable from within a function.
a) Global
b) Local
c) General
d) expand
Answer: a
13) In php define () key word is used to declare the a constant .The constant value
cannot be changed during the script.
a) constant
b) const
c) static
d) define
Answer: d
14)PHP is compatible with almost all servers used today (Apache, IIS, etc.)
a) True
b) False
d) non of these
Answer: a
a) True
b) False
d) non of these
Answer: a
a) True
b) False
d) non of these
Answer: b
17) in PHP ,A variable starts with the $ sign, followed by the name of the
variable
a) True
b) False
d) non of these
Answer: a
18) == Is quality it is used to assign the value of right hand side to left hand side.
a) True
b) False
d) non of these
Answer: b
19) in PHP , Variable names are case-sensitive ($age and $AGE are two
different
a) True
b) False
d) non of these
Answer: a
20) An array is a special variable, which can hold more than one value at a time
with different data types.
a) True
b) False
d) non of these
Answer: b
21) __________ is Web development software . Create, code and manage dynamic
websites easily with a smart, simplified coding engine
a) HTTP
b) Bandwidth
c) webpage
d) Dream viewer
Answer: d
22) ________ is a server scripting language, and a powerful tool for making dynamic
and interactive Web pages.
a) PHP
b) java script
c) Angular js
d) none of these
Answer: a
Answer: a
Answer: a
Answer: a
26) __________ is used to show the out put …or give message..same as printf in c
language…
a) Echo
b) java script
c) Angular js
d) none of these
Answer: a
27) A PHP script starts with <?php and ends with ?>:
<?php
// PHP code goes here
?>
a) true
b) false
c) both a and b
d) none of these
Answer: a
28) PHP code is executed on the server, and the result is returned to the browser as
plain html
a) true
b) false
c) both a and b
d) none of these
Answer: a
29) PHP files can contain text, HTML, CSS, JavaScript, and PHP code
a) true
b) false
c) both a and b
d) none of these
Answer: a
30) PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
31) PHP is compatible with almost all servers used today (Apache, IIS, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
a)String
b) Integer
Answer: d
a)Increment/Decrement operators
b)Logical operators
c)String operators
Answer: d
34) The basic assignment operator in PHP is __________ It means that the left operand
gets set to the value of the assignment expression on the right.
a) =
b) ++
c) ==
d) ?
Answer: a
35) the _________ statement is used to perform different actions based on different
conditions
a) switch
b) if condition
c) foreach
d) while
Answer: b
a) while loop
b) for loop
c) foreach
Answer: d
37) the _________ statement is used to check the action on each step and perform
different actions based on different conditions
a) if else condition
b) if condition
c) else if ladder
d) while
Answer: c
38) In PHP, ______in this loop we check show true statement first then check the
condition :
a) while loop
b) for loop
c) do while
Answer: c
a) if else condition
b) if condition
c) switch
d) while
Answer: c
40)_____ are used to execute the same block of code again and again, as `long
as a certain condition is true.
a) if else condition
b) if condition
c) loop
d) while
Answer: c
a) if else condition
b) if condition
c) loop
d) while
Answer: d
42) _____ loops through a block of code once, and then repeats the loop as
long as the specified condition is true
a) if else condition
b) if condition
c) loop
d) do while
Answer: d
a) if else condition
b) if condition
c) loop
d) for
Answer: d
array
a) if else condition
b) if condition
c) loop
d) for each
Answer: d
45)The _____ will always execute the block of code once, it will then check
the condition, and repeat the loop while the specified condition is true.
a) if else condition
b) if condition
c) do while loop
d) for each
Answer: c
46)The works only on arrays, and is used to loop through each key/value
pair in an array.
a) if else condition
b) if condition
c) foreach loop
d) for each
Answer: c
47) PHP files can contain text, HTML, CSS, JavaScript, and PHP code
a) true
b) false
c) both a and b
d) none of these
Answer: a
48) PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
49) PHP is compatible with almost all servers used today (Apache, IIS, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
a)String
b) Integer
Answer: d
========================================================
1) _________means the way to move from one page to another page in website.
To move from one page to another pages hyperlinks are used.
a) HTTP
b) Bandwidth
c) Navigation
d) Dream viewer
Answer: c
a) HTTP
b) Bandwidth
c) webpage
d) Dream viewer
Answer: d
3) ________ is a server scripting language, and a powerful tool for making dynamic
and interactive Web pages.
a) PHP
b) java script
c) Angular js
d) none of these
Answer: a
Answer: a
7) __________ is used to show the out put …or give message..same as printf in c
language…
a) Echo
b) java script
c) Angular js
d) none of these
Answer: a
Answer: a
9) PHP code is executed on the server, and the result is returned to the browser as
plain html
a) true
b) false
c) both a and b
d) none of these
Answer: a
10) PHP files can contain text, HTML, CSS, JavaScript, and PHP code
a) true
b) false
c) both a and b
d) none of these
Answer: a
11) PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
12) PHP is compatible with almost all servers used today (Apache, IIS, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
a)String
b) Integer
Answer: d
a) explicitly
b) implicitly
c) both a and b
d) None of these
Answer: d
a)Increment/Decrement operators
b)Logical operators
c)String operators
Answer: d
17) The basic assignment operator in PHP is __________ It means that the left operand
gets set to the value of the assignment expression on the right.
a) =
b) ++
c) ==
d) ?
Answer: a
18) the _________ statement is used to perform different actions based on different
conditions
a) switch
b) if condition
c) foreach
d) while
Answer: d
a) while loop
b) for loop
c) foreach
Answer: a
20) the _________ statement is used to check the action on each step and perform
different actions based on different conditions
a) if else condition
b) if condition
c) else if ladder
d) while
Answer: c
21) In PHP, ______in this loop we check show true statement first then check the
condition :
a) while loop
b) for loop
c) do while
Answer: c
22) PHP code is executed on the server, and the result is returned to the browser as
plain html
a) true
b) false
c) both a and b
d) none of these
Answer: a
23) PHP files can contain text, HTML, CSS, JavaScript, and PHP code
a) true
b) false
c) both a and b
d) none of these
Answer: a
24) PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
25) PHP is compatible with almost all servers used today (Apache, IIS, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
a)String
b) Integer
Answer: d
a) explicitly
b) implicitly
c) both a and b
d) None of these
Answer: d
a)Increment/Decrement operators
b)Logical operators
c)String operators
Answer: d
30) The basic assignment operator in PHP is __________ It means that the left operand
gets set to the value of the assignment expression on the right.
a) =
b) ++
c) ==
d) ?
Answer: a
31) the _________ statement is used to perform different actions based on different
conditions
a) switch
b) if condition
c) foreach
d) while
Answer: d
a) while loop
b) for loop
c) foreach
Answer: a
33) the _________ statement is used to check the action on each step and perform
different actions based on different conditions
a) if else condition
b) if condition
c) else if ladder
d) while
Answer: c
34) The basic assignment operator in PHP is __________ It means that the left operand
gets set to the value of the assignment expression on the right.
a) =
b) ++
c) ==
d) ?
Answer: a
35) the _________ statement is used to perform different actions based on different
conditions
a) switch
b) if condition
c) foreach
d) while
Answer: b
a) while loop
b) for loop
c) foreach
Answer: d
37) the _________ statement is used to check the action on each step and perform
different actions based on different conditions
a) if else condition
b) if condition
c) else if ladder
d) while
Answer: c
38) In PHP, ______in this loop we check show true statement first then check the
condition :
a) while loop
b) for loop
c) do while
Answer: c
a) if else condition
b) if condition
c) switch
d) while
Answer: c
40)_____ are used to execute the same block of code again and again, as `long
as a certain condition is true.
a) if else condition
b) if condition
c) loop
d) while
Answer: c
a) if else condition
b) if condition
c) loop
d) while
Answer: d
42) _____ loops through a block of code once, and then repeats the loop as
long as the specified condition is true
a) if else condition
b) if condition
c) loop
d) do while
Answer: d
a) if else condition
b) if condition
c) loop
d) for
Answer: d
array
a) if else condition
b) if condition
c) loop
d) for each
Answer: d
45)The _____ will always execute the block of code once, it will then check
the condition, and repeat the loop while the specified condition is true.
a) if else condition
b) if condition
c) do while loop
d) for each
Answer: c
46)The works only on arrays, and is used to loop through each key/value
pair in an array.
a) if else condition
b) if condition
c) foreach loop
d) for each
Answer: c
47) PHP files can contain text, HTML, CSS, JavaScript, and PHP code
a) true
b) false
c) both a and b
d) none of these
Answer: a
48) PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
49) PHP is compatible with almost all servers used today (Apache, IIS, etc.)
a) true
b) false
c) both a and b
d) none of these
Answer: a
a)String
b) Integer
Answer: d
------------------------------------------------------------------------------------------------