Font size
WorksheetsPHP First Internal Practical Viva
Total questions: 20
Worksheet time: 31mins
Type your full name
Type your full Reg No
Type your campus ID
Choose your Course (MCA/MSc)
MCA
MSc
Which of the following php statement/statements will store 111 in variable num?
int $num = 111;
int mum = 111;
$num = 111;
111 = $num;
What will be the output of the following php code
< ?php
$num = 1;
$num1 = 2;
print $num . "+". $num1 ;
?>
3
1+2
1.+.2
Error
What will be the output of the following PHP code?
< ?php
$fruits = array ("mango", "apple", "pear", "peach");
$fruits = array_flip($fruits);
echo ($fruits[0]);
?>
mango
Error
peach
0
What will be the output of the following code?
$Rent = 250;
function Expenses($Other) {
$Rent = 250 + $Other;
return $Rent; }
Expenses(50);
echo $Rent;
300
250
200
Program will not compile
In multidimensional arrays rather than a single key they values are stored in
Sequence of key values
2 keys
linear style
None of them
In PHP, which character is used at the end of each statement?
(a)
Which of the following is a correct way to define a constant in PHP?
define('CONST_NAME', 'Value');
const CONST_NAME = 'Value';
Both a and b
None of the above
In PHP, variable names must start with which of the following.
No numbers
Letters
Underscore
All of the above
Identify the function which converts a string to uppercase.
uppercase()
str_uppercase()
strtoupper()
struppercase()
Which of the following function is used to sort array in descending order?
(a)
Spot the error in the following PHP code:
for ($i = 0; $i <= 10; $i++) {
echo $i; } echo $i;
?>
Undefined variable outside loop
Missing semicolon
No error in the code
Syntax error in loop
Which superglobal array in PHP contains information about headers, paths, and script locations?
$_GET
$_POST
$_SERVER
$_FILES
What is the correct way to check if a form has been submitted in PHP?
Checking if $_POST is set
Checking if $_SERVER['REQUEST_METHOD'] is POST
Checking if $_GET is set
Checking if $_REQUEST is set
Spot the error in the following PHP form handling code:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo $_POST[name];
}
?>
Missing quotes around array key name
No error in the code
Syntax error in if statement
Missing semicolon in echo statement
What will be the output of the following PHP code?
$i = 0;
while($i < 3) {
echo $i;
$i++;
}
?>
(a)
What two key words best describe your experience and learning from this lab viva?
