Upwork PHP 5 test answers

Q:  Which composite data types are supported by php?
Ans:     Array

Q:     The default value of register_globals in PHP is:
Ans:     Off

Q:     Which of the following is not a valid PHP connection status?
Ans:     open

Q:     Choose the correct statement:
Ans:      include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before

Q:     If the session_cache_expire() is not set, then by default the session cache will expire after:
Ans:     3 hrs

Q:     What will be the output of the following script?
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
Ans:     It will print 1


Q:     What is true regarding this code?
Ans:     setcookie will return true

Q:     Which of the following is not a correct way of printing text in php5?
Ans:     echo "Plain text";
Q:     Which of the following is not the correct way of starting a session?
Ans:     session_initiate()
                                                                                                                   
Q:     Which of the following functions do you need to implement HTTP Basic Authentication?
Ans:     None of the above

Q:     Which of the following Command Line Interface constant is not defined in the CLI SAPI?
Ans:     STDPRT

Q:     Which of the following statements is correct with regard to final and abstract?
Ans:     a. An abstract class cannot have final methods

Q:     State whether True or False

Paamayim Nekudotayim operator allows access only to the static members of a class?
Ans:     True

Q:     Which of the following statements is true with regard to comparisons in PHP5?
Ans:     With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.

Q:     Which of the following built-in function assist in checking if actually the function exists or not?
Ans:     function_exists

Q:     What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a ="="">
Ans:     1
Ques:     What will be the output of the following code?
$i=4;
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . " " . $j . " " . $k . " ";

Ans:     5 31 7.5

Q:     Which of the following is a not a correct way of commenting in php?
Ans:     /#PHP Comment

Q:     Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + --$z;
echo $z;
what will be the output?

Ans:     18

Q:     Which of the following is the correct way of specifying default value?
Ans:     function GetDiscount($Type = "Special") { . . . }

What will be the output on running the script?
Ans:     Error message will be printed

Q:     Late PHP versions support remote file accessing for the functions:

Ans:     include_once()
          require_once()
both of them

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_');
$var= $p_username;

Ans:      Both of them

Q:     Which of the following does not represent logical AND operator in PHP?
Ans:     &amp

Q:     Which of the following is not true for a persistent connection?
Ans:     These can't be converted to non-persistent connections

Q:     Which of the following are invalid data types in PHP?
Ans:     char

Q:    Which of the following should replace '???' to obtain the value of printName() function?
Ans:     $ofc->getManager()->printName();

Q:     The classes are defined as follows:abstract class BaseCls{
protected abstract function getName();
}
class ChildCls extends BaseCls{
}
Q: Which of the following implementations of getName() is invalid in ChildCls?
Ans:     public function getName(){}

Q:     Which of the following variable declarations within a class is invalid in PHP5?
Ans:     var $term =3;

Q:     What will be the output of following code?
$arr = "a";
$arr[0]="b";
echo $arr;
echo $arr[0];
Ans:     bb

Q:     For the following code:
the output will be:
Ans:     171

Q:     What is the result of the following expression?
Ans:     5+2 * 4+6

Q:     What will be the output of following code?
$var = 1 + "-1.3e3";
echo $var;
Ans:     -1299

Q:     What will be the output of following code?
$var1="a";
$$var1="b";
echo "$var1 $a";
Ans:     a b

Q:    What is the output of the following code?
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
Ans:     0

Q:What will be the ouput of the following code?
if (-1)
print "true";
else
print "false";
?>
Ans:     true

Q:     What will be the output of the following code?
echo 126;
Ans:     126

Q:     Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
Ans:     1 

No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...