Font size
WorksheetsPHP FUNDAMENTALS
Total questions: 40
Worksheet time: 40mins
What is PHP?
PHP is an open-source programming language
PHP is used to develop dynamic and interactive websites
PHP is a server-side scripting language
All of the mentioned
What does PHP stand for?
PHP stands for Preprocessor Home Page
PHP stands for Pretext Hypertext Processor
PHP stands for Hypertext Preprocessor
PHP stands for Personal Hyper Processor
Which of the following is the correct way to add a comment in PHP code?
#
//
/* */
All of the mentioned
Which of the following is the default file extension of PHP files?
.php
.ph
.xml
.html
How to define a function in PHP?
functionName(parameters) {function body}
function {function body}
function functionName(parameters) {function body}
data type functionName(parameters) {function body}
$GREETING
no output
PHP is a scripting language
GREETING
What will be the value of the variable $input in the following PHP program?
<?php
$input = "PHP<td>stands for</td>Hypertext<i>Preprocessor</i>!";
$input = strip_tags($input,"<i></i>");
echo $input;
?>
PHP stands for Hypertext <i>Preprocessor</i>!
PHP stands for Hypertext Preprocessor!
PHP <td>stands for</td> Hypertext <i>Preprocessor</i>!
PHP <td>stands for</td> Hypertext Preprocessor!
What will be the output of the following PHP program?
<?php
$a = 100;
if ($a > 10)
printf("PHP Quiz");
else if ($a > 20)
printf("PHP MCQ");
else if($a > 30)
printf("PHP Program");
?>
(a)
Which of the looping statements is/are supported by PHP?
i) for loop
ii) while loop
iii) do-while loop
iv) foreach loop
Only iv
i) and ii)
i), ii) and iii)
i), ii), iii) and iv)
Which PHP statement will give output as $x on the screen?
echo “\$x”;
echo “$$x”;
echo “/$x”;
echo “$x;”;
What will be the output of the following PHP code?
<?php
$x = 4;
$y = 3
$z = 1;
$z = $z + $x + $y;
echo "$z";
?>
(a)
What will be the output of the following PHP program?
<?php
$mcq = (a) ;
switch(print $mcq)
{
case 2:
print "HTML";
break;
case 1:
print "CSS";
break;
default:
print "JavaScript";
}
?>
Which variable is used to collect form data sent with both the GET and POST methods?
$_BOTH
$REQUEST
$_REQUEST
$BOTH
Variable name in PHP starts with -
! (Exclamation)
$ (Dollar)
&(Ampersand)
#(Hash)
Which of the following is used to display the output in PHP?
echo
write
Both (a) and (c)
1. Which of the following is the use of strlen() function in PHP?
The strlen() function returns the type of string
The strlen() function returns the length of string
The strlen() function returns the value of string
The strlen() function returns both value and type of string
Which of the following is used for concatenation in PHP?
+ (plus)
* (Asterisk)
. (dot)
append()
Which of the following is the use of strpos() function in PHP?
The strpos() function is used to search for the spaces in a string
The strpos() function is used to search for a number in a string
The strpos() function is used to search for a character/text in a string
The strpos() function is used to search for a capitalize character in a string
Which of the following is the correct way to create a function in PHP?
Create myFunction()
New_function myFunction()
function myFunction()
None of the above
Syntax for declaring a variable is (a)
Which of the following is/are the code editors in PHP?
Notepad++
Notepad
Adobe Dreamweaver
All of the above
Which of the following is used to end a statement in PHP?
(a)
String values in PHP must be enclosed within -
Double Quotes
Single Quotes
Both (a) and (b)
None of the above
Which of the following variable name is invalid?
$newVar
$new_Var
$new-var
All of the above
Which of the following is the correct way to print "Hello World" in PHP?
"Hello World";
write("Hello World");
echo "Hello World";
None of the above
Which of the following function converts a string to all uppercase?
upper()
uppercase()
struppercase()
strtoupper()
What will be the output of the following program?
<?php
echo "Welcome" . "to" . "the" . "javaTpoint.com";
?>
What will be the output of the following program?
<?php
echo "Welcome" , "to" , "the" , "javaTpoint.com";
?>
What will be the output of the following program?
<?php
$var1 = "Hello";
$var2 = "World";
echo $var1, $var2;
?>
(a)
What will be the output of the following program?
<?php
$var1 = "Hello";
$var2 = "World";
echo "$var1$var2";
?>
HelloWorld
"$var1$var2"
Hello World
None of the above
What will be the output of the following program?
<?php
$a;
if ($a)
{
echo "hi";
}
else
{
echo "How are you";
}
?>
(a)
What will be the output of the following program?
<?php
$a = 0;
while ($a++)
{
echo "$a";
}
echo $a;
?>
0
1
01
none of the above
What will be the output of the following program?
<?php
echo (a) ;
?>
What will be the output of the following program?
<?php
$a = _____;
function show()
{
$a = _____;
echo "$a";
}
show();
echo "$a";
?>
(a)
What will be the output of the following program?
<?php
$var1="Hello World";
echo strrev("$var1");
?>
(a)
Which of the following is correct about PHP?
PHP is a recursive acronym for "PHP: Hypertext Preprocessor".
PHP is a server side scripting language that is embedded in HTML.
It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.
All the above
Which of the following is correct about constants vs variables in PHP?
Constants may be defined and accessed anywhere without regard to variable scoping rules.
Once the Constants have been set, may not be redefined or undefined.
Both of the above.
None of the above.
Which of the following function is used to get length of a string?
(a)
PHP is an example of ---------------scripting language
(a)
Which of the following is not true?
PHP can be used to develop web applications.
PHP makes a website dynamic
PHP applications can not be compile
PHP can not be embedded into html
