21. Variable name in PHP starts with
- $ (Dollar)
- ! (Exclamation)
- # (Hash)
- & (Ampersand)
Answer : A Explanation: In Hypertext Preprocessor (PHP), a variable is declared using a Dollar ($) sign followed by the variable name. As we know that PHP is a loosely typed language, so we don’t need to declare the data types of the variables. It automatically analyzes the values and makes conversions to its correct datatype. Variables in PHP (Hypertext Preprocessor) are case-sensitive, so for example, $xyz and $XYZ both are treated as different variables.
22. Among echo and print, which is faster?
- Can’t say
- Both have same speed
Answer : B Explanation: echo is faster than print.
23. Is php variable case sensitive
Answer : B Explanation: Yes, PHP variables are case sensitive.
24. In PHP, class names as well as function/method names are not case sensitive
Answer : A Explanation: In PHP, class names as well as function/method names are not case sensitive, though it is usually good form to call functions as they appear in their declaration.
25. In PHP, Which keyword precedes a method name?
Answer : C Explanation: In PHP, a method declaration resembles a function declaration. The function keyword precedes a method name, followed by an optional list of argument variables in parentheses. So, option C is correct.
26. Which of the following PHP functions accepts any number of parameters?
Answer : D Explanation: In PHP, func_get_args() functions accepts any number of parameters. func_get_args() returns an array of arguments provided. One can use func_get_args() inside the function to parse any number of passed parameters. So, option D is correct.
27. Which of the following method can be used to create a MySql database using PHP?
- None of the mentioned
Answer : C Explanation: mysql_query() method can be used to create a MySql database using PHP.
28. Which one of the following is not a valid class name?
Answer : B Explanation: In PHP, one can declare a class with the class keyword and an arbitrary class name. Class names can be written with any combination of numbers and letters, although they must not begin with a number. So, option B is correct.
29. Which of the following is used to display the output in PHP?
- Both (A) and (B)
- Both (A) and (C)
Answer : D Explanation: In Hypertext Preprocessor (PHP), both “echo” and “print” are language constructs. Both “echo” and “print” 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, option D is correct.
30. A function in PHP that starts with _ _ (double underscore) is known as
- Magic Function
- Inbuilt Function
- User Defined Function
- Default Function
- None of the mentioned
Answer : A Explanation: In Hypertext Preprocessor (PHP), functions that start with a double underscore ( _ _ ) are called magic functions. They are functions that are always defined inside classes, and are not stand-alone functions. So, option A is correct.