Novell Previous Years Solved Sample Placement Papers
-
Which of the following variable name is invalid?
A. $newVar
B. $new_Var
C. $new-var Answer: Option C
D. All of the above
- Solution: In PHP, a variable is declared using a $ sign followed by the variable name. A variable name must start with a letter or underscore (_) character. A PHP variable name cannot contain spaces.
-
Which of the following is the correct way to create an array in PHP?
A. $season = array["summer" , "winter" , "spring" , "autumn"];
B. $season = array("summer" , "winter" , "spring" , "autumn"); Answer: Option B
C. $season = "summer" , "winter" , "spring" , "autumn";
D. All of the above
- Solution: None.
-
Which of the following is a built-in function in PHP that adds a value to the end of an array?
A. array_push() Answer: Option A
B. inend_array()
C. into_array()
D. None of the above
- Solution: The array_push() is a built-in function in PHP. This function helps users add elements at the end of an array. It allows inserting any number of elements into an array, including strings and numeric values.
-
Which of the following function in PHP returns a text in title case from a variable?
A. toUpper($var)
B. ucwords($var) Answer: Option B
C. ucword($var)
D. All of the above
- Solution: The ucwords() is an in-built function in PHP, which converts the first character of each word in a string to uppercase. The other characters of the string remain unchanged.
-
Which of the following is the correct way to print "Hello World" in PHP?
A. "Hello World";
B. write("Hello World");
C. echo "Hello World"; Answer: Option C
D. None of the above
-
Solution: PHP echo is a language construct, not a function. Therefore, you don't need to use parentheses with it. The correct way to print "Hello World" in PHP is:
echo "Hello World";
-
Which of the following function is used to compress a string in PHP?
A. compress()
B. zip_compress()
C. gzcompress() Answer: Option C
D. zip()
- Solution: The gzcompress() function in PHP compresses the given string using the ZLIB format.
-
What does SPL stand for in PHP?
A. Standard PHP Library Answer: Option A
B. Simple PHP Library
C. Simple PHP List
D. None of the above
- Solution: In PHP, SPL stands for "Standard PHP Library."
-
Which of the following function converts a string to all uppercase?
A. upper()
B. uppercase()
C. struppercase()
D. strtoupper() Answer: Option D
- Solution: The strtoupper() function in PHP converts all lowercase English characters in a string to uppercase.
-
The function in PHP that can be used to concatenate array elements to form a single delimited string is -
A. implode() Answer: Option A
B. concat()
C. explode()
D. concatenate()
- Solution: PHP implode() is a string function that joins the elements of an array into a single string. It works similarly to the join() function.