Lab 2 Self-Assessment Quiz
Which of the following statements is FALSE about HTTP GET? (There are more than 1 answers)
Question 1 options: It can be used to send confidential data
It is possible to bookmark the HTML page with the HTTP GET method
There is no limit to the amount of data you can send from a form with the GET method
All variable names and values sent from a form with the GET method are displayed in the URL
Answer (1) It can be used to send confidential data
(2) There is no limit to the amount of data you can send from a form with the GET method
Which statements below is TRUE regarding PHP?
Question 2 options: PHP scripts cannot be embedded within HTML pages
PHP codes are executed on the server-side
PHP codes must be compiled before it can be used
PHP source code will be displayed under 'View Source' in browsers
Answer : PHP codes are executed on the server-side
Which one of the following PHP scripts will print out "Temasek Polytechnic" with the enclosed double quotation marks?
Question 3 options: <?php
$heading="Temasek Polytechnic";
Print $heading;
?>
<?php
$heading=""Temasek Polytechnic"";
Print $heading;
?>
<?php
$heading="/"Temasek Polytechnic/"";
Print $heading;
?>
<?php
$heading="\"Temasek Polytechnic\"";
Print $heading;
?>
Answer : <?php
$heading="\"Temasek Polytechnic\"";
Print $heading;
?>
Which of the following is NOT an advantage of using PHP pages?
Question 4 options: Ease of connectivity to data storage
User-friendly graphical interface
Answer :User-friendly graphical interface
Question 5 options: Complete each blank with the correct answer (answers are case-sensitive ):
<?php
class calGst {
function afterGst ($a)
{
$a = $a * 1.07;
return $a;
}
}
$foo = __________________;
$msg ="After GST , total is ";
echo $msg;
//it should display the GST amount for $100
echo ____________ (100);
?>
Answer : Fill in the blanks
<?php
class calGst {
function afterGst ($a)
{
$a = $a * 1.07;
return $a;
}
}
$foo = __________________;
________ ( new calGst, new calGst() )
$msg ="After GST , total is ";
echo $msg;
//it should display the GST amount for $100
echo ____________ (100);
?>
________ ( $foo->afterGst )
Given the following HTML codes, what should the PHP codes be to retrieve the value of "username" from the form submission?
<form action = "form.php" method = "post" >
<input type = "text" name = "username" >
<input type = "submit" name = "submit" >
<input type = "submit" name = "cancel" >
</form>
Question 6 options:
Answer : $_POST["username"]
What will be printed out from this PHP code:
<?php
$string1= "Hello";
$string2="Dear Friend";
$string3="How do you do?";
$string4=$string1 . " " . $string2. " " .' $string3';
Print $string4;
?>
Question 7 options: Hello Dear Friend How do you do?
Hello. .Dear Friend. .$string3?
$string1 $string2 $string3
Hello Dear Friend $string3
Answer : Hello Dear Friend $string3
Given the following php codes, which of the following are the correct ways of calling the function foo in PHP? (There are more than 1 answer)
<?php
function foo ($arg_1, $arg_2)
{
$arg_2 = $arg_1 * $arg_2;
return $arg_2;
}
?>
Question 8 options: $result = echo foo (10, 3);
$result = foo (10, 3);
echo $result;
echo function foo (10, 3);
Answer : echo foo (10, 3);
Which one of the following statements is TRUE about PHP variables?
Question 9 options: $_FORM is a reserved variable name
You can declare a PHP variable with "foo = 20;"
PHP variable names are case-sensitive
Answer : PHP variable names are case-sensitive
When the following PHP code is run, there is an error. What is causing the error?
<?php
class Calculate {
private $total=0;
public function getSum (int $a, int $b) {
$this->total = $a+$b;
}
}
$app = new Calculate;
$app->getSum (93,8); //Output 101
echo $app->total;
?>
Question 10 options: Did not specify the return type of function getSum
Did not specify whether the class Calculate is public or private
Did not specify the data type of the variable $total
Did not specify the scope of the variable $total correctly
Answer : Did not specify the scope of the variable $total correctly
Comments
Post a Comment