Upwork Test Answer PHP 5 Skill Test
Question: 01
Which composite data types are supported by php?
Answer: Array
Question: 02
The default value of register_globals in PHP is:
Answer: Off
Question: 03
Which of the following is not a valid PHP connection status?
Answer: open
Question: 04
Choose the correct statement:
Answer: include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before
Question: 05
If the session_cache_expire() is not set, then by default the session cache will expire after:
Answer: 3 hrs
Question: 06
What will be the output of the following script?
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
Answer: It will print 1
Question: 07
What is true regarding this code?
Answer: setcookie will return true
Question: 08
Which of the following is not a correct way of printing text in php5?
Answer: echo "Plain text";
Question: 09
Which of the following is not the correct way of starting a session?
Answer: session_initiate()
Question: 10
Which of the following functions do you need to implement HTTP Basic Authentication?
Answer: None of the above
Question: 11
Which of the following Command Line Interface constant is not defined in the CLI SAPI?
Answer: STDPRT
Question: 12
Which of the following statements is correct with regard to final and abstract?
Answer: a. An abstract class cannot have final methods
Question: 13
State whether True or False
Paamayim Nekudotayim operator allows access only to the static members of a class?
Answer: True
Question: 14
Which of the following statements is true with regard to comparisons in PHP5?
Answer: With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.
Question: 15
Which of the following built-in function assist in checking if actually the function exists or not?
Answer: function_exists
Question: 16
What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a ="="">
Answer: 1
Question: 17
What will be the output of the following code?
$i=4;
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . " " . $j . " " . $k . " ";
Answer: 5 31 7.5
Question: 18
Which of the following is a not a correct way of commenting in php?
Answer: /#PHP Comment
Question: 19
Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + --$z;
echo $z;
what will be the output?
Answer: 18
Question: 20
Which of the following is the correct way of specifying default value?
Answer: function GetDiscount($Type = "Special") { . . . }
Question: 21
With reference to the following php script:
print 'Text Line1'
print 'Text Line2'
?>
What will be the output on running the script?
Answer: Error message will be printed
Question: 22
What will be the ouput of the following code?
for ($i = 0; $i < i ="="">
0134
Question: 23
Late PHP versions support remote file accessing for the functions:
Answer: include_once()
require_once()
both of them
Question: 24
You have designed a user login form as follows:
Which composite data types are supported by php?
Answer: Array
Question: 02
The default value of register_globals in PHP is:
Answer: Off
Question: 03
Which of the following is not a valid PHP connection status?
Answer: open
Question: 04
Choose the correct statement:
Answer: include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before
Question: 05
If the session_cache_expire() is not set, then by default the session cache will expire after:
Answer: 3 hrs
Question: 06
What will be the output of the following script?
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
Answer: It will print 1
Question: 07
What is true regarding this code?
Answer: setcookie will return true
Question: 08
Which of the following is not a correct way of printing text in php5?
Answer: echo "Plain text";
Question: 09
Which of the following is not the correct way of starting a session?
Answer: session_initiate()
Question: 10
Which of the following functions do you need to implement HTTP Basic Authentication?
Answer: None of the above
Question: 11
Which of the following Command Line Interface constant is not defined in the CLI SAPI?
Answer: STDPRT
Question: 12
Which of the following statements is correct with regard to final and abstract?
Answer: a. An abstract class cannot have final methods
Question: 13
State whether True or False
Paamayim Nekudotayim operator allows access only to the static members of a class?
Answer: True
Question: 14
Which of the following statements is true with regard to comparisons in PHP5?
Answer: With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.
Question: 15
Which of the following built-in function assist in checking if actually the function exists or not?
Answer: function_exists
Question: 16
What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a ="="">
Answer: 1
Question: 17
What will be the output of the following code?
$i=4;
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . " " . $j . " " . $k . " ";
Answer: 5 31 7.5
Question: 18
Which of the following is a not a correct way of commenting in php?
Answer: /#PHP Comment
Question: 19
Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + --$z;
echo $z;
what will be the output?
Answer: 18
Question: 20
Which of the following is the correct way of specifying default value?
Answer: function GetDiscount($Type = "Special") { . . . }
Question: 21
With reference to the following php script:
print 'Text Line1'
print 'Text Line2'
?>
What will be the output on running the script?
Answer: Error message will be printed
Question: 22
What will be the ouput of the following code?
for ($i = 0; $i < i ="="">
0134
Question: 23
Late PHP versions support remote file accessing for the functions:
Answer: include_once()
require_once()
both of them
Question: 24
You have designed a user login form as follows:
User Name:
Password:
How can you access the username entered by the user in the 'Validate.php' webpage?
a. $var= $_POST['username'];
b. $var= $_REQUEST['username'];
c. import_request_variables('p', 'p_');
d. $var= $p_username;
Answer: Both of them
Question: 25
Which of the following does not represent logical AND operator in PHP?
Answer: &
Question: 26
Which of the following is not true for a persistent connection?
Answer: These can't be converted to non-persistent connections
Question: 27
Which of the following are invalid data types in PHP?
Answer: char
Question: 28
The Manager and Office classes are as follows:
class Manager{
function printName() {
echo "Manager";
}
}
class Office{
function getManager() {
return new Manager();
}
}
$ofc = new Office();
???
?>
Which of the following should replace '???' to obtain the value of printName() function?
Answer: $ofc->getManager()->printName();
Question: 29
The classes are defined as follows:abstract class BaseCls{
protected abstract function getName();
}
class ChildCls extends BaseCls{
}
Which of the following implementations of getName() is invalid in ChildCls?
Answer: public function getName(){}
Question: 30
Which of the following variable declarations within a class is invalid in PHP5?
Answer: var $term =3;
Question: 31
What will be the output of following code?
$arr = "a";
$arr[0]="b";
echo $arr;
echo $arr[0];
Answer: bb
Question: 32
For the following code: the output will be:
Answer: 171
Question: 33
What is the result of the following expression?
Answer: 5+2 * 4+6
Question: 34
What will be the output of following code?
$var = 1 + "-1.3e3";
echo $var;
Answer: -1299
Question: 35
What will be the output of following code?
$var1="a";
$$var1="b";
echo "$var1 $a";
Answer: a b
Question: 36
What is the output of the following code?
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
Answer: 0
Question: 37
What will be the ouput of the following code?
if (-1)
print "true";
else
print "false";
?>
Answer: true
Question: 38
What will be the output of the following code?
echo 126;
Answer: 126
Question: 39
Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
Answer: 1
How can you access the username entered by the user in the 'Validate.php' webpage?
a. $var= $_POST['username'];
b. $var= $_REQUEST['username'];
c. import_request_variables('p', 'p_');
d. $var= $p_username;
Answer: Both of them
Question: 25
Which of the following does not represent logical AND operator in PHP?
Answer: &
Question: 26
Which of the following is not true for a persistent connection?
Answer: These can't be converted to non-persistent connections
Question: 27
Which of the following are invalid data types in PHP?
Answer: char
Question: 28
The Manager and Office classes are as follows:
class Manager{
function printName() {
echo "Manager";
}
}
class Office{
function getManager() {
return new Manager();
}
}
$ofc = new Office();
???
?>
Which of the following should replace '???' to obtain the value of printName() function?
Answer: $ofc->getManager()->printName();
Question: 29
The classes are defined as follows:abstract class BaseCls{
protected abstract function getName();
}
class ChildCls extends BaseCls{
}
Which of the following implementations of getName() is invalid in ChildCls?
Answer: public function getName(){}
Question: 30
Which of the following variable declarations within a class is invalid in PHP5?
Answer: var $term =3;
Question: 31
What will be the output of following code?
$arr = "a";
$arr[0]="b";
echo $arr;
echo $arr[0];
Answer: bb
Question: 32
For the following code: the output will be:
Answer: 171
Question: 33
What is the result of the following expression?
Answer: 5+2 * 4+6
Question: 34
What will be the output of following code?
$var = 1 + "-1.3e3";
echo $var;
Answer: -1299
Question: 35
What will be the output of following code?
$var1="a";
$$var1="b";
echo "$var1 $a";
Answer: a b
Question: 36
What is the output of the following code?
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
Answer: 0
Question: 37
What will be the ouput of the following code?
if (-1)
print "true";
else
print "false";
?>
Answer: true
Question: 38
What will be the output of the following code?
echo 126;
Answer: 126
Question: 39
Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
Answer: 1
Don't Miss A Single Updates
✓Remember to check your email account to confirm your subscription.