A Learning Portal from Recruitment India
Which PHP function determines the last access time of a file?
fileatime()
filectime()
filetime()
None of the above
Answer with explanation
Answer: Option AExplanation
The fileatime() function in PHP is used to return the last access time of a file as a UNIX timestamp. On failure, the fileatime() returns false.
Workspace
Which of the following is the correct way to print “Hello World” in PHP?
echo “Hello World”;
write(“Hello World”);
“Hello World”;
None of the above
Answer with explanation
Answer: Option AExplanation
PHP echo is a language construct, not a function. Therefore, you don’t need to use parenthesis with it. The correct way to print “Hello World” in PHP is:
echo "Hello World";
Workspace
Which of the following function in PHP can be used to test the type of any variable?
settype()
gettype()
showtype()
None of the above
Answer with explanation
Answer: Option BExplanation
The gettype() function is an inbuilt function in PHP, and as its name implies, it returns the type of a variable. The gettype() function in PHP is used to check the type of existing variable.
Workspace
Which of the following function is used to get the ASCII value of a character in PHP?
chr()
ascii()
asc()
val()
Answer with explanation
Answer: Option AExplanation
The PHP Chr() function is used to generate a single byte string from a number. In other words, we can say that it returns a character from a specified ASCII value.
Workspace
Which of the following is the correct way of defining a variable in PHP?
$variable name as value;
$variable_name = value
$variable_name = value;
$variable name = value;
Answer with explanation
Answer: Option CExplanation
In PHP, a variable is declared using a $ sign followed by the variable name. A PHP variable name cannot contain spaces.
Syntax of declaring a variable in PHP is given below:
$variable_name=value;
Workspace