0% found this document useful (0 votes)
63 views

PHP Final

The document contains a form asking for name and email address, with the note that submitting the form will allow the owner to see this information. It then presents 22 multiple choice questions testing knowledge of PHP concepts like variables, arrays, functions, and database usage. Correct answers are provided for self-checking understanding of PHP fundamentals.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

PHP Final

The document contains a form asking for name and email address, with the note that submitting the form will allow the owner to see this information. It then presents 22 multiple choice questions testing knowledge of PHP concepts like variables, arrays, functions, and database usage. Correct answers are provided for self-checking understanding of PHP fundamentals.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Hi ‫وسيم‬, when you submit this form, the owner will be able to see your name and email

address.

Required
1
What does PHP stand for?
(1 Point)
Hypertext Pre-processor
Personal Hypertext Processor
Private Home Page
Personal Home Pages
2
the result after excecution program is . <?php $x = 1; if ($x == 2) print
"hi" ; else if($x = 2) print $x; else print "how are u";} ?>
(1 Point)
error
2
hi
how are u
3
What is the correct way to include the file “config.inc” ?
(1 Point)
<!— include file = “config.inc” -->
<% include file =”config.inc” ;%>
<?php require(”config.inc”); ?>
<?phpinclude_file( “config.inc”); ?>
4
If you want to pass the argument of the function by reference, the
correct path would be:
(1 Point)
function ModifyReport(&$Rptfile){}
function ModifyReport($Rptfile){}
function ModifyReport(ByRef $Rptfile){}
function ModifyReport(&Rptfile){}
5
the result after excecution program is: <?php $a = 100; if ($a > 10)
printf("M.S. Dhoni"); else if ($a > 20) printf("M.E.K Hussey"); else if($a >
30) printf("A.B. de villiers"); ?>
(1 Point)
M.E.K.Hussey
M.S.Dhoni
M.S.Dhoni,M.E.K.Hussey,A.B.de villiers
No output
6
Associative array are returned to the browser as PHP file
(1 Point)
True
False
7
The program will continue When using INCLUDE_OCE, REQUIRE for not
found files
(1 Point)
True
False
8
When setting an action form in PHP, the action must be set in the close
form tag ()?
(1 Point)
True
False
9
When setting method for form in PHP, the method must be get?
(1 Point)
True
False
10
VAR_DUMP in PHP using for shuffle arrays
(1 Point)
True
False
11
How do you get information from a form that is submitted using the
"get" method?
(1 Point)
“_GET[]”.
_GET[];
POST[];
none of above
12
PHP code is executed on the _______, and the plain HTML result is sent
on to the ______.
(1 Point)
Server
Browser
Client
None of these
13
If x+=y shape then what will be the similar statement
(1 Point)
y = y + x;
x = x + y;
x = y;
None of these;
14
the result after excecution program is: <?php for($i=0; $i<4; ++$i)
{ echo $i++.' '; if(++$i) continue; } ?>
(1 Point)
03
151
023
0123
15
In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for
strings:
(1 Point)
True
False
16
Default statement is must in switch case.
(1 Point)
True
False
17
Write function to convert marks from number to grade using switch
case then call function by value 88 from 90 - 100 to A 80 - 90 to B 60 -
70 to C 50 - 60 to D less than 50 Fail Note : $grade = (int)($grade/10);
(5 Points)

18
1. find prime numbers from 1-20 by Call function prima() output should
be like. 2 is Prime 3 is Prime 5 is Prime 7 is Prime 11 is Prime 13 is Prime
17 is Prime 19 is Prime
(5 Points)

19
According to the picture Print material with it’s mark.
(3 Points)

20
According to the picture Print students with his materials and marks
(3 Points)

21
Delete the last element of array marks
(2 Points)

22
To Retrieve data from employee table under test database with pdo

connection by using foreach loop


(2 Points)
echo '<table border="1">';
echo
'<tr><th>Rows</th><th>ID</th><th>NAME</th><th>LOCATION</th></r>';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error()); }
mysql_select_db('test');
$name = $_POST['emp_name'];
$sql="select * from emp ";
$retval = mysql_query( $sql );
foreach($retval as $rows => $row )
{
echo "<tr><td>" . $rows . "</td>";
foreach( $row as $col => $cell ) {
echo '<td>'.$cell.'</td>'; }
echo '</tr>';
}
echo '</table>';
Option 2

You might also like