0% found this document useful (0 votes)
15 views8 pages

PHP Q.

The document consists of a series of PHP and MySQL questions designed to test knowledge of functions, commands, and coding practices. It includes matching functions, predicting outputs, and identifying correct code snippets for various tasks. The questions cover topics such as form handling, database operations, and basic programming logic.

Uploaded by

ANIRUDDHA SAHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views8 pages

PHP Q.

The document consists of a series of PHP and MySQL questions designed to test knowledge of functions, commands, and coding practices. It includes matching functions, predicting outputs, and identifying correct code snippets for various tasks. The questions cover topics such as form handling, database operations, and basic programming logic.

Uploaded by

ANIRUDDHA SAHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

ONLINE PHP

1. Match the correct PHP functions? *


Identify the PHP function used to get the username value submitted by a user and o Answer
also add values submitted to query 1

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

2. Match the correct PHP functions? *


o Answer
Identify the PHP tag used to mark the begining and ending of the script
1

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

3. Match the correct MySQL commands


o Answer
Arun wants to create a mail database and add a new user arun to the database
1

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

4. Select the correct pairs


o Answer
PHP code
1

Identify the insert command to o Answer


add a new user details 2

o Answer
HTML Code
3

5. 1. Identify the output of the code *


<?php
$year=2036;
if($year%400==0 || ($year%100!=0 && $year%4==0))
1
ONLINE PHP
echo $year.' is Leap Year';
else echo $year.' is Not a Leap Year';
?>
Select one:
a) None of the above
b) Leap year
c) 2036 is a Leap year
d) Not a leap year

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();

12. Predict the html code used to generate a form *


Select one:
a) <html><body></body></html>
b) <html><body><form method=post ><input type=text></form></body></html>
c) <html><body><forms><input type=text></body></html>
d) None of these

13. Predict the output of the code given below.


<?php
$a=1, $b=2;
3
ONLINE PHP
$b--;
if($a==$b){echo "I am feeling lucky";}
else{echo "I am feeling confused";}
?>
Select one:
a) I am feeling lucky
b) I am feeling confused
c) I am feeling
d) None of these

14. Predict the output of the following program code?


<?php

$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>

17. Sudha wants to check where given word is paliendrome or not.


Identify the PHP script to implement the check

*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;

for ($i = 0; $i < strlen($word)/2; ++$i, --$j) {

// skip spaces
while ($word[$i] === " ") {$j++;}
while ($word[$j] === " ") {$i--;}

echo "$word[$i]== $word[$j]\n";


if ($word[$i] = $word[$j]) {
$pal = false;
break;
}
}

if ($pal) print "no"; else print "yes";


c) $word = "malayalam";

$j = strlen ($word)-1;
$pal = true;

for ($i = 0; $i < strlen($word)/2; ++$i, --$j) {

// skip spaces
while ($word[$i] === " ") {$i++;}
while ($word[$j] === " ") {$j--;}

echo "$word[$i]== $word[$j]\n";


if ($word[$i] !== $word[$j]) {
$pal = false;
break;
}
}

if ($pal) print "yes"; else print "no";


d) $word = "malayal";

$j = strlen ($word)-1;
5
ONLINE PHP
$pal = true;

for ($i = 0; $i < strlen($word)/2; ++$i, --$j) {

// skip spaces
while ($word[$i] === " ") {$i++;}
while ($word[$j] === " ") {$j--;}

echo "$word[$i]== $word[$j]\n";


if ($word[$i] == $word[$j]) {
$pal = true;
break;
}
}

if ($pal) print "yes"; else print "no";

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

22. Check whether the following PHP code is correct? *


<?php
$i=1; $j=2;
$s= $i+$j;
echo $s;
?>
Select one:
a) True
b) False

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

You might also like