Internet Programming II Model Exam
Internet Programming II Model Exam
1. Based on the html code given below identify the correct statement.
12. Which one of the following PHP functions is used to redirect a user to a specific page?
A. Send_redirect() B. header_location() C. header() D. redirect()
13. which one of the following statements is wrong about a session?
A. It is used to make data accessible across all pages of a website
B. echo $_SESSION[“email”]; is used to display the value of a session variable called email.
C. session_start() function is used to start a session and must be there at the beginning of an
index.php page of the website
D. session_unset() function destroys all session variables
14. which one of the following syntaxes is the correct way of defining a function in PHP?
A. functionName(parameters) {function body}
B. function {function body}
C. function functionName(parameters) {function body}
D. data type functionName(parameters) {function body}
<?php
15. what will be the output of the following program?
$x=27;
A. 9 $x/=3;
B. 81 $y=pow($x,0.5);
C. 27 echo $y;
D. 3 ?>
16. Which one of the following PHP functions is used to execute SQL queries?
A. mysqli_select_db() C. mysqli_execute_query()
B. mysqli_fetch_assoc() D. mysqli_query()
17. Based on the code snippet given below, which one of the following statements allow you to
assign an email submitted from the form to a variable called email?
A. $email= $_GET[“email”]; <form action="" method="get">
B. $email= $_POST[“email”]; UserEmail<input type="text" name="email">
C. echo $_REQUEST[“email”]; <input type="submit" name="submit" alue="Submit"></form>
D. $email= $_REQUEST[“UserEmail”];
18. Which one of the following statements is the right way of creating a cookie called product that
can only stay for 2?
A. createcookie(“product”,”smart phone”,time()+(60*60*14),”/”,”localhost”,0);
B. setcookie(“product”,”smart phone”,time()+(60*60*2*24),”/”,”localhost”,0);
C. setcookie(“product”,”smart phone”,time()+(60*60*24*14),”/”,”localhost”,0);
D. setcookie(“product”,”smart phone”,time()+(60*60*24),”/”,”localhost”,0);
19. What is the use of isset() function in PHP?
A. The isset() function is used to check whether a variable is set or not
B. The isset() function is used to check whether a variable is free or not
C. The isset() function is used to check whether a variable is a string or not
D. The isset() function is used to set a new value to a variable
20. Identify the correct statement based on the code snippet given below.
A. xyz.txt file is opened for reading only $fop=fopen(“xyz.txt”,”a+”);
B. the text hello will be appended to the existing content in xyz.txt file fwrite($fop,”hello”);
C. the text hello won’t be written to xyz.txt file, if the file does not exist fclose($fop);
D. xyz.txt file is opened for write-only access
21. Assume we have a text file called “myfile.txt”. The content in the file is “How is the
exam?”. Based on this information, which one of the following will be the output of the
program given below? <?php
A. 15 bytes $fn="myfile.txt";
$fo=fopen($fn,'r');
B. 16 bytes
$fs=filesize($fn)
C. 128 bits echo "$fs bytes";
D. 16 bits ?>
22. Which one of the following statements is the right way of copying the content of a file
called navigation.php into another PHP file?
A. <?php include(“navigation.php”); ?> C. <?php copy(“index.php”); ?>
B. <?php includeOnce(“index.php”); ?> D. <?php requireOnce(“navigation.php”); ?>
23. which one of the following PHP functions removes the last element of an array?
A. array_pop() B. array_unshift() C. array_push() D. array_shift()
24. Which PHP function is capable to read contents of a file character by character?
A. filegets() B. fget() C. fgets() D. fgetc()
25. In the following statement, what does the "+" symbol mean?
preg_match('/^[0-9]+$/', $data)
A. Any character
B. one character between 0 and 9
C. One or more characters between 0 and 9
D. Any character between 0 and 9 followed by a $
26. The updated MySQL extension released with PHP 5 is typically referred to
as__________.
A. MySQL B. mysql C. mysqli D. mysqly
27. Which one of the following statements is true about mysqli_fetch_assoc() function in
PHP?
A. Used to count the number of records a table has
B. Used to retrieve all the records of an existing table at once
C. Used to retrieve only one record from an existing table
D. Retrieves all records of a table at a time in the form of associative array
28. Which one of the following is not included in $_FILES array?
A. temp_name B. name C. size D. type
29. What will be the output of the following PHP code?
<?php
A. 10 C. infinite loop for(;;) { echo "5"; }
B. no output D. error ?>
30. What will be the output of the following PHP code?
A. 100 <?php
B. Error $x = 75;
C. 75 $y = 25;
function addition(){
D. 25
$GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
}
addition();
echo $z;
?>