11. Which of the following is the correct way to add a comment in PHP code?
- //
- /**/
- #
- All of the above
Answer : D Explanation: In PHP (Hypertext Preprocessor), /**/ can also be used to comment just a single line although it is used for paragraphs. # and // are used only for single-line comments. So, all of the above option is correct.
12. Which of the following is used to display the output in PHP?
- echo
- write
- Both (A) and (B)
Answer : D Explanation: In PHP, both print and echo are language constructs. Both print and echo statements can be used with or without parentheses. We can use these statements to output variables or strings. The echo is a statement, which is used to display the output. The print is a statement used as an alternative to echo at many times to display the output. So, both (A) and (B) option is correct.
13. Which of the following function is used to unset a variable in PHP?
- unset()
- delete()
- unlink()
- delete()
Answer : A Explanation: unset() function is used to unset a variable in PHP.
14. Which of the following is not a built-in string function in PHP?
- strlen()
- strreverse()
- str_replace()
- strpos()
Answer : B Explanation: strreverse() function is not a Built-in String functions in PHP.
15. Which of the following is the correct way to create a function in php?
- new_function myFunction()
- create myFunction()
- function myFunction()
- None of the mentioned
Answer : C Explanation: The declaration of a user-defined function in PHP (Hypertext Preprocessor) starts with the word function, followed by the name of the function you want to create followed by parentheses i.e. () and finally place the function’s code between curly brackets {}.PHP functions are also similar to functions of any other programming languages. A function is a piece of code that takes one or more input in the form of a parameter and does some processing and returns a value. There are built-in functions but PHP gives you the option to create your own functions as well.
Data Science MCQ Questions and Answers
16. Which of the following is the correct way to create an array in PHP?
- $season = array(“mango” , “orange” , “banana” , “apple”);
- $season = array[“mango” , “orange” , “banana” , “apple”];
- $season = “mango” , “orange” , “banana” , “apple”;
- All of the mentioned
Answer : A Explanation: $season = array(“mango” , “orange” , “banana” , “apple”); is the correct way to create an array in PHP.
17. Which of the following function displays the information about PHP and its configuration?
- phpinfo()
- php_info()
- info()
- None of the mentioned
Answer : A Explanation: The phpinfo() function displays the information about the PHP configuration and installation in our system. The phpinfo() function is generally used to check and display the configuration settings.
18. Which of the following function in PHP returns a text in title case from a variable?
- toUpper($var)
- ucword($var)
- ucwords($var)
- All of the mentioned
Answer : C Explanation: The ucwords() is an in-built function of PHP, which is used to convert the first character of each word to uppercase in a string. It takes a string as an input and converts the first character of each word of the string to uppercase. The other characters of the string remain the same. So, option C is correct.
19. Which of the following function returns the number of characters in a string variable in PHP?
- count($variable)
- strlen($variable)
- len($variable)
- strcount($variable)
Answer : B Explanation: strlen($variable) function returns the number of characters in a string variable in PHP.
20. Which of the following variable is not a predefined variable in PHP?
- $get
- $ask
- $post
- $request
Answer : B Explanation: $ask is not a predefined variable in PHP.
Pingback: Project Management MCQ Questions And Answers | Software Project Management MCQ - cozmocard