PHP Q.
PHP Q.
o Answer
Identify the PHP function used to print the content
2
Identify the PHP function used to get the username value submitted by a user o Answer
without adding any values submitted through form? * 3
o Answer
Identify the PHP function used to randamize values
2
Identify the PHP function used to get values submitted through a form without o Answer
using any database? * 3
Usha wants to create a mail database with a users table. Identify the SQL code used o Answer
to complete the task? * 2
o Answer
Vishal wants to delete email database and add ajay to the mail database
3
o Answer
HTML Code
3
6. Identify the code used to generate a diagonal matrix, which has 0s and 1s.
Select one:
a) <?php
for($a=1;$a<=3;$a++) {
for($b=1;$b<=3;$b++) {
if($c==$b)
{ echo $c; }
else { echo "0"; } }
$c; echo "<br>";
}
?>
b) <?php
for($c=1,$a=1;$a<=3;$a++) {
for($b=1;$b<=3;$b++) {
if($c==$b)
{ echo $c; }
else { echo "0"; }
} $c++; echo "<br>";
}
?>
c) <?php
for($c=1,$a=1;$a<=3;$a++) {
for($b=1;$b<=3;$b++) {
if($c!=$b)
{ echo $c; }
else { echo "0"; }
} $c--;
echo "<br>";
}
?>
d) <?php
for($c=3,$a=1;
$a<=3;$a++) {
for($b=1;$b<=3;$b++) {
if($c==$b)
{ echo $c; }
else { echo "0"; }
} $c;
echo "<br>"; }
?>
2
ONLINE PHP
7. Usha has installed XAMPP on Linux OS, where would she put all PHP script files to execute them.
Please provide her with setup location details.
Select one:
a) /var/html/php
b) /var/www/htdocs/php
c) /var/www/php
d) /var/bin/php
8. Kiran has installed XAMPP on Linux OS and he seem to get a " 404- page not found error".
What should he do to resolve this error?
Select one:
a) He should check if all PHP files are placed in /var/www/html/php location
b) should check if all PHP files are placed in /var/www/php location
c) He should check if all PHP files are placed in /var/www/bin/php location
d) He should check if all PHP files are placed in /var/www/htdocs/php location
9. Vinod wants to print the current date and time on the page. What function should he use to
generate that? *
Select one:
a) cho $date." ".$time
b) echo $date(DATE_RFC822).
c) echo $day." ".$hours
d) echo $now." ".$time
10. Identify the comment clause to include along with in php code
Select one:
a) //#include 'http://www.example.com/file.htm';
b) <!-- include 'file.php' -->
c) <? include location='file.txt' ?>
d) /* #include 'file.php' */
11. Identify the POST function to get variables posted using a form.
Select one:
a) $_GET()
b) $POST['name']
c) $_POST('name');
d) $_POST();
$x=3;
$y=4;
$power=1;
for($i=1;$i<=$y;$i++)
$power=$power*$x;
echo $x.' raised to the power '.$y.' = '.$power;
?>
Select one:
a) 3 raised to the power 3 = 27
b) 3 raised to the power 4 = 81
c) 2 raised to the power 3 = 8
d) 4 raised to the power 3 = 64
15. Predict the Missing code expression from below program which gives " 3, 4" as output
<?php
$x=3; $y=4;
for($i=1;$i<=$y;$i++)
{ $x*=$i;
<missing code>
{
echo $x," ", $y;}
}
?>
Select one:
a) for($j=0;$j!=$i; $j--)
b) for($j=0;$j<=$i; $j--)
c) for($j=1;$j>=$i; $j--)
d) for($j=1;$j>=$i; $j++)
16. How to include javascript code within PHP script file, to execute javascript code?
Select one:
a) <code></code>
b) <script type=javascript>.....</script>
4
ONLINE PHP
c) <include>
d) <javascript>...</javascript>
*paliendrome means a word whose spelling remains the same even after reversing it
Select one:
a) None of these
b) $word = "malayal";
$j = strlen ($word)-1;
$pal = true;
// skip spaces
while ($word[$i] === " ") {$j++;}
while ($word[$j] === " ") {$i--;}
$j = strlen ($word)-1;
$pal = true;
// skip spaces
while ($word[$i] === " ") {$i++;}
while ($word[$j] === " ") {$j--;}
$j = strlen ($word)-1;
5
ONLINE PHP
$pal = true;
// skip spaces
while ($word[$i] === " ") {$i++;}
while ($word[$j] === " ") {$j--;}
18. Karan want to transfer value from i to j without using a third variable. Select the correct option to
complete this task.
<?php
var $i, $j;
$i=10;
echo "The value of i: $i";
echo "Value of i, j is:", $i," ",$j;
?>
Select one:
a) <?php
$i=5; $j=8;
echo "Value of i, j is:", $i," ",$j."
$i+=$j;
$j=$i-$j;
$i--;
echo "Value of i, j is:", $i," ",$j;
?>
b) <?php
$i=5; $j=8;
echo "Value of i, j is:", $i," ",$j;
$i+=$j;
$j=$i-$j;
$i+=$j;
echo "Value of i, j is:", $i," ",$j;
?>
c) <?php
$i=5; $j=8;
echo "Value of i, j is:", $i," ",$j;
$i+=$j;
$j=$i-$j;
$j*=$j;
6
ONLINE PHP
echo "Value of i, j is:", $i," ",$j;
?>
d) <?php
$i=5;
$j=8;
echo "Value of i, j is:", $i," ",$j;
$i+=$j;
$j=$i-$j;
$i++;
echo "Value of i, j is:", $i," ",$j;
?>
19. Ajay plans to check the values input through a form on submit to a new page directed as URL
link.. What method should he use in the <form> tag?
Select one:
a) GET
b) REDIRECT
c) POST
d) None of these
20. Vinod wants to generate a two dimensional array of city names. How would he implement it?
* [Hyd, Kolkatta, Agra, Jaipur, Surat, Mumbai]
Select one:
a) <?php
$s=array('Hyd','Kol','Agra','GU','Surat', 'Mumbai');
for($i=0;$i<6;$i++)
{ echo "<br>";
for($j=0;$j<3;$j++) {
echo $s[$i][$j]." ";
}}
?>
b) <?php
$s=array('Hyd','Kol','Agra','Guj','Surat', 'Mumbai');
for($i=0;$i<6;$i++) { echo "<br>";
for($j=1;$j<6;$j++) { echo $s[$i][$j]." "; } }
?>
c) <?php
$s=array('Hyd','Kol','Agra','Guj','Surat', 'Mumbai');
for($i=0;$i<6;$i++) {
echo "<br>";
for($j=3;$j<3;$j++) { echo $s[$i][$j]." ";
}}
?>
d) <?php
$s=array('Hyd','Kol','Agra','Guj','Surat', 'Mumbai');
for($i=6;$i>1;$i++) { echo "<br>";
for($j=0;$j>3;$j++) { echo $s[$i][$j]." "; } }
?>
7
ONLINE PHP
21. Predict the output for following code:
<?php
echo "Welcome to News Today";
$a=0
while($a<3){ print "Call for all readers";}
$a++;
?>
Select one:
a) Welcome to News Today
b) Call for all readers
Welcome to News Today
c) Welcome to News Today
Call for all readers
Call for all readers
Call for all readers
d) Welcome to News Today, Call for all readers
e) Call for all reader
23. We can use editors such as notepad, gedit, etc to edit PHP script files.
Select one:
a) True
b) False
24. PHP scripts cannot be integrated into webpages to generate dynamic content. Because, it is very
complex to implement.
Select one:
a) True
b) False