PHP Practice Test: Trivia Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Mukeshrajput
M
Mukeshrajput
Community Contributor
Quizzes Created: 3 | Total Attempts: 1,174
| Attempts: 282 | Questions: 21
Please wait...
Question 1 / 21
0 %
0/100
Score 0/100
1. Which of the following function returns the number of characters in a string variable?

Explanation

The function strlen($variable) is used to return the number of characters in a string variable. It calculates and returns the length of the string, which represents the number of characters in the string. This function is commonly used in programming to determine the length of a string and perform operations based on that length.

Submit
Please wait...
About This Quiz
PHP Practice Test: Trivia Quiz - Quiz


PHP practice test: a trivia quiz. This server scripting language is commonly used to design interactive WebPages. If you have just started learning about it, this quiz is... see moreexactly what you need to refresh your memory. Do you know how to work with the remote file in PHP? This quiz tests you on how to align strings in your algorithm but identifiers as well. Give it a try and see how helpful it will be for you. see less

2. Which of the following are valid float values?

Explanation

All of the given values are valid float values. 4.5678 and 4.0 are decimal numbers, which can be represented as floats. 7e4 is a scientific notation for 7 multiplied by 10 to the power of 4, which is also a valid float value. Therefore, all of the given values are valid float values.

Submit
3. Given a variable $email containing the string [email protected] which of the following will extract the string example.com?

Explanation

The correct answer is substr($email, strops(($email,"@")+1). This is because the function strops($email,"@") will return the position of the "@" symbol in the string $email. Adding 1 to this position will give us the starting position of the substring we want to extract. Then, the substr() function will extract the substring starting from that position until the end of the string, giving us "example.com".

Submit
4. The output of following script would be $somerar=15; function ad it () { GLOBAL $somevar; $somerar++ ; echo "somerar is $somerar"; } addit ();

Explanation

The output of the script would be "somerar is 16". This is because the script defines a global variable $somerar with a value of 15. Then, a function called addit() is defined, which increments the value of $somerar by 1 and echoes the result. Finally, the addit() function is called, resulting in the value of $somerar being incremented to 16 and echoed.

Submit
5. PHP is a widely used ……………. scripting language that is especially suited for web development and can be embedded into HTML.

Explanation

PHP is a widely used scripting language that is especially suited for web development and can be embedded into HTML. It is open source, meaning that it is freely available for anyone to use and modify. It is also a general-purpose language, which means that it can be used for a wide range of applications, not just web development.

Submit
6. The left associative dot operator (.) is used in PHP for

Explanation

The left associative dot operator (.) is used in PHP for concatenation. It is used to combine two strings together to create a new string. This operator allows you to join multiple strings or string variables into a single string. For example, if you have two variables $str1 = "Hello" and $str2 = "World", using the dot operator like $str1 . $str2 will result in the string "HelloWorld".

Submit
7. Which of the following variables is not a predefined variable?

Explanation

The variable "$ask" is not a predefined variable. In PHP, predefined variables are variables that are already defined and can be used without any additional declaration. Variables like "$get", "$request", and "$post" are examples of predefined variables in PHP, which are used to retrieve data from the URL, server, and HTTP POST requests respectively. However, "$ask" is not a predefined variable in PHP.

Submit
8. Which of the following method sends input to a script via a URL?

Explanation

The correct answer is "Get". The Get method is used to send input to a script via a URL. It appends the input data to the URL as query parameters, allowing the data to be visible in the URL itself. This method is commonly used for retrieving data from a server or fetching web pages.

Submit
9. Which of the following will not combine strings $s1 and $s2 into a single string?

Explanation

The correct answer is $s1+$s2. This is because the "+" operator in PHP is used for numerical addition, not for string concatenation. In order to combine two strings in PHP, the "." operator should be used. The other options, "{$s1}{$s2}" and implode(' ', array($s1,$s2)), are valid ways to combine strings in PHP.

Submit
10. Which of the following variable assignments is 'by value' assignment in PHP.

Explanation

The correct answer is $value1= $value. In PHP, a 'by value' assignment means that the value of the variable is copied to another variable. In this case, the value of $value is being assigned to $value1, creating a new variable with the same value. The other options involve passing the variable by reference, indicated by the use of the ampersand (&) symbol, which means that both variables will refer to the same memory location.

Submit
11. When defining identifier in PHP you should remember that

Explanation

When defining an identifier in PHP, it is important to remember that identifiers are case sensitive. This means that $result is considered different than $ result. Additionally, identifiers can be of any length. Therefore, the correct answer is that both of these statements are true.

Submit
12. A variable $word is set to "HELLO WORLD", which of the following script returns in title case?

Explanation

The function ucwords() capitalizes the first letter of each word in a string. In this case, the string "HELLO WORLD" is first converted to lowercase using strtolower(), and then ucwords() is applied to capitalize the first letter of each word, resulting in "Hello World". The other options either capitalize only the first letter of the entire string (ucfirst($word)), or do not convert the string to title case at all.

Submit
13. Which of the following method is suitable when you need to send larger form submissions?

Explanation

The Post method is suitable when you need to send larger form submissions. Unlike the Get method, which appends form data to the URL, the Post method sends the data in the body of the HTTP request. This allows for larger amounts of data to be sent securely and efficiently. Therefore, the Post method is the recommended choice for sending larger form submissions.

Submit
14. To work with remote files in PHP you need to enable.

Explanation

To work with remote files in PHP, you need to enable the "allow_url_fopen" option. This option allows PHP to open and read files from remote locations using URLs. By enabling this option, you can use functions like file_get_contents() or fopen() to access and manipulate remote files. The "allow_remote_files" option is not a valid option in PHP, so the correct answer is "allow_url_fopen".

Submit
15. Which of the following functions require the allow-url-fopen must be enabled?

Explanation

The functions include() and require() both require the allow-url-fopen to be enabled. These functions are used to include files in PHP scripts. When allow-url-fopen is enabled, these functions can include files from remote URLs as well. If allow-url-fopen is disabled, including files from remote URLs will not be possible. Therefore, both of these functions require the allow-url-fopen to be enabled.

Submit
16. The ____ function can be used to compare two strings using a case-insensitive binary algorithm.

Explanation

The strcasecmp() function can be used to compare two strings using a case-insensitive binary algorithm. This means that the function will compare the strings without considering the difference between uppercase and lowercase letters. This is useful when you want to compare strings without being sensitive to the case of the letters.

Submit
17. The difference between include() and require()

Explanation

The correct answer is that include() and require() are different in how they handle failure. Include() produces a Fatal Error, which means that if the included file is not found or there is an error in the file, the script will stop executing. On the other hand, require() results in a Warning, which means that if the required file is not found or there is an error, the script will continue executing but with a warning message.

Submit
18. Trace the odd data type.

Explanation

The odd data type in this list is "integer" because it is the only data type that represents whole numbers without any decimal places. The other data types, such as "floats," "doubles," and "real number," all allow for decimal places in their values.

Submit
19. The function setcookie( ) is used to

Explanation

The function setcookie() is used to store data in a cookie variable. It allows the programmer to set a cookie with a specified name, value, expiration time, path, and domain. This function enables the server to send a cookie to the client's browser, which can then be stored and later sent back to the server with subsequent requests. This allows the server to remember information about the user, such as their preferences or login status. Therefore, the correct answer is "Store data in cookie variable".

Submit
20. In PHP string data are

Explanation

In PHP, string data can be delimited by single quotes (''), double quotes ("") or even by using the heredoc syntax. Therefore, the correct answer is "delimited by all of the above".

Submit
21. Casting operator introduced in PHP 6 is

Explanation

The casting operator (int64) is used in PHP 6 to convert a value to a 64-bit integer. This operator is used when you want to specifically convert a value to a 64-bit integer data type.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 22, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jul 04, 2013
    Quiz Created by
    Mukeshrajput
Cancel
  • All
    All (21)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following function returns the number of characters in a...
Which of the following are valid float values?
Given a variable $email containing the string [email protected] which...
The output of following script would be...
PHP is a widely used ……………....
The left associative dot operator (.) is used in PHP for
Which of the following variables is not a predefined variable?
Which of the following method sends input to a script via a URL?
Which of the following will not combine strings $s1 and $s2 into a...
Which of the following variable assignments is 'by value'...
When defining identifier in PHP you should remember that
A variable $word is set to "HELLO WORLD", which of the following...
Which of the following method is suitable when you need to send larger...
To work with remote files in PHP you need to enable.
Which of the following functions require the allow-url-fopen must be...
The ____ function can be used to compare two strings using a...
The difference between include() and require()
Trace the odd data type.
The function setcookie( ) is used to
In PHP string data are
Casting operator introduced in PHP 6 is
Alert!

Advertisement