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
Which of the following is the correct way to create a function in PHP?
function myFunction()
New_function myFunction()
Create myFunction()
None of the above
Answer with explanation
Answer: Option AExplanation
We can declare and call user-defined functions easily. The syntax to declare user-defined functions is given below –
function functionname(){ //code to be executed }
Workspace
Which of the following is the use of strlen() function in PHP?
The strlen() function returns the length of string
The strlen() function returns both value and type of string
The strlen() function returns the value of string
The strlen() function returns the type of string
Answer with explanation
Answer: Option AExplanation
The strlen() function is predefined function of PHP. It is used to find the length of string or returns the length of a string including all the whitespaces and special characters.
Workspace
Which of the following is not a variable scope in PHP?
Global
Static
Local
Extern
Answer with explanation
Answer: Option DExplanation
The scope of a variable is defined as its range in the program under which it can be accessed. PHP has three types of variable scopes:
Workspace
Variable name in PHP starts with –
$ (Dollar)
! (Exclamation)
# (Hash)
& (Ampersand)
Answer with explanation
Answer: Option AExplanation
In PHP, a variable is declared using a $ (Dollar) sign followed by the variable name.
As PHP is a loosely typed language, so we do not need to declare the data types of the variables. It automatically analyzes the values and makes conversions to its correct datatype. Variables in PHP are case-sensitive, as an instance, the variables $name and $NAME both are treated as different variables.
Workspace
PHP stands for –
Personal Home Processor
Pretext Hypertext Preprocessor
Hypertext Preprocessor
None of the above
Answer with explanation
Answer: Option CExplanation
PHP stands for Hypertext Preprocessor. PHP is an open-source, interpreted, and object-oriented scripting language that can be executed on the server-side. It is well suited for web development.
Workspace
Which of the following type of variables are special variables that hold references to resources external to PHP (such as database connections)?
Resources
Objects
Arrays
Strings
Answer with explanation
Answer: Option AExplanation
The correct answer is Resources
Resources: are special variables that hold references to resources external to PHP (such as database connections).
Workspace
Which of the following is correct about the preg_match() function?
The preg_match() function searches string for a pattern, returning true if a pattern exists, and false otherwise
The preg_match() function searches throughout a string specified by the pattern for a string specified by string. The search is not case sensitive
The preg_match() function searches a string specified by string for a string specified by pattern, returning true if the pattern is found, and false otherwise
None of the above
Answer with explanation
Answer: Option AExplanation
The correct answer is the preg_match() function searches string for a pattern, returning true if a pattern exists, and false otherwise
Workspace
Which of the following is correct about ereg() function?
The ereg() function searches a string for a pattern, returning true if a pattern exists, and false otherwise.
The ereg() function searches throughout a string specified by the pattern for a string specified by string. The search is not case-sensitive.
The ereg() function searches a string specified by string for a string specified by the pattern, returning true if the pattern is found, and false otherwise
None of the above
Answer with explanation
Answer: Option CExplanation
The correct answer is The ereg() function searches a string specified by string for a string specified by the pattern, returning true if the pattern is found, and false otherwise.
Workspace
Which of the following method can be used to close a MySql database using PHP?
mysql_close()
mysql_query()
mysql_connect()
None of the above
Answer with explanation
Answer: Option AExplanation
To close the connection in MySQL database we use PHP function mysql_close() which disconnect from database.
Workspace
In distributed SQL statements, which of the following retrieves information from two or more nodes?
Distributed update
Distributed query
Both A & B
None of the above
Answer with explanation
Answer: Option BExplanation
The correct answer is a distributed query retrieves information from two or more nodes.
Workspace