PHP Quiz | Set-2

Question 1
Which below method is used to compute the difference between two arrays in PHP?
Tick
array_diff
Cross
diff_array
Cross
arrays_diff
Cross
diff_arrays


Question 1-Explanation: 
The array_diff is used to compare the difference between given arrays and return the value as a difference. It is used to compare the difference between two or more than two arrays. So for computing, the difference between the two arrays in PHP the method is used is array_diff.
Question 2
What is the output of the following code snippets: <?php $output = array(3, 3, 3); echo array_product($a); ?>
Cross
8
Tick
27
Cross
10
Cross
6


Question 2-Explanation: 
The array_product methods in PHP are used to calculate the product of arrays, So the given values are 3,3,3, and the product of the given value is 27.
Question 3

Which of the following method in PHP is used to get the current day and location?

Tick

date_sunrise()

Cross

sunrise()

Cross

date-sunrise()

Cross

None of the above



Question 3-Explanation: 

The date_sunrise() is an inbuilt function in PHP which is used to find the sunrise time for a specified day and location.

Question 4

What is the output of the below code snippets?

<?php    
 	$value="GeeksForGeeks";    
 	echo strrev("$value");      
?>
Tick

skeeGroFskeeG

Cross

skeeGroFskeeO

Cross

skeeGorFskeeG

Cross

skeeForFskeeG



Question 4-Explanation: 

strrev is used to reverse the string in PHP so after reversing the string in PHP the value is skeeGroFskeeG. 

Question 5
What is the output of the below code snippets?
<?php  
	while()  
	{  
	echo "GeeksForGeeks";  
	}  
?> 
Cross
Hello World
Cross
Infinite loop
Cross
no output
Tick
Error


Question 5-Explanation: 
After running the code the error is throwing so the code is not executable.
Question 6

Which of the following is used to calculate a number of character values in PHP?

Cross

count($variable)

Cross

len($variable)

Cross

strcount($variable)

Tick

strlen($variable)



Question 6-Explanation: 

strlen($variable) is used to calculate the number of character values in PHP. The function returns the length of the $string including all the whitespaces and special characters.

Question 7

Which of the following is not considered predefined values?

Cross

$get

Tick

$ask

Cross

$request

Cross

$post



Question 7-Explanation: 

$ask is not considered as predefined value so from the above option only option $ask is correct.

Question 8

Which of the following is true if you want to send input through the script in PHP?

Cross

Post

Tick

Get

Cross

All of the above

Cross

None of the above



Question 8-Explanation: 

Get method is used if we want to send the input through the script in PHP.

Question 9

The correct syntax for enclosing the PHP script are?

Cross

<PHPgt; </phpgt;

Tick

<?PHP ?gt;

Cross

?PHP ?PHP

Cross

<p?gt; </?pgt;



Question 9-Explanation: 

The correct syntax for enclosing is the php script are <?php  ?> where , <?php is starting position and end with  ?> 

Question 10

How many types of filtering is present in PHP?

Tick

2

Cross

3

Cross

4

Cross

None



Question 10-Explanation: 

In PHP there are two main types of filtering: validation and sanitization.

There are 15 questions to complete.


  • Last Updated : 27 Sep, 2023

Share your thoughts in the comments
Similar Reads