find anything here

find anything here

Upwork Test Answers | PHP Upwork Test Answers 2017


Upwork Test Answers | PHP Upwork Test Answers 2017

Hello Every one,

Today I am available  for you with Upwork Test Answers | PHP Upwork Test Answers 2017. It is very Important to pass Upwork Tests with good score to get job on Upwork. Its little bit difficult to pass any   programming language test on Upwork for beginners.

 This article will help you to pass Upwork PHP test easily. I have tried to make all possible php questions and answers available for you. It may be possible that some questions will out of this list but I am sure you can pass this exam by studying this article carefully. If you interested to pass upwork wordpress test it is also available for you, you can find here detail description about how to use this question and answers during test.

Upwork Test Answers | PHP Upwork Test Answers 2017

  1. which MIME type needs to be used to send an attachment in mail ?
  •    multipart/mixed
  1. What is the output of  the following code ?

class Foo {private $foo;

protected $bar;

public $test;

public function  __construct()


$this->foo = 1;

$this->bar = 2;

$this ->test = 3;



print_r(   (array) new Foo );

  •   Array([Foofoo]=>1 [*bar]=>2[test]=>3)
  1. By default, every database connection opened by a script is either explicitly closed by the user during run time of released__________ at the end of the script.
  •  Server-side
  1. Which magic method is used to implement overloading in PHP ?
  •  __call
  1. What will be the output of following code ?

<?php   $i = 016;echo $i /2;


  •   7
  1. Which of the following file modes is used to write into a file at the end of the existing content, and create the file if the file does not exist ?
  •  a
  1. Which of the following statements is incorrect with respect to inheritance in PHP?
  •  A Class can extend more than one class.
  1. You can extend the exception class, but you cannot override any of the preceding methods they are declared as :
  • final
  1. What is the correct syntax of mail() function in php ?
  •  mail($to,$subject,$message,$headers)
  1. What is the fastest way to insert an item $item into the specified position $position of the array $array ?
  •  array_merge() and array_slice()
  1. Which of the following MySQL fetch constants imply: if the columns are returned into the array having both a numerical index and the field name as the array index ?
  1. Which function is used to get  the number of arguments passed to the function ?
  •  func_num_args()
  1. What is the output of the following code ?

<?phpfunction abc(){



function xyz()


return abc();


echo xyz();


  •  abc
  1.  Which Function can be used to determine if a file exist? (choose all that apply)
  •    is_readable(),



  1. What will be the output of following code

<?phpclass A {

public static function foo() {



public static function who(){

echo __CLASS__.”\n”;



class B extends A {

public static function test(){





public static function who() {

echo __CLASS__. “\n”;



Class C extends B {

public static function who(){

echo __CLASS__.”\n”;





  •  ACC
  1. Which of the following will print out the PHP call stack ?
  •   $e=new Exception;


  1. What is the correct way to send an SMTP(Simple Mail Transfer Protocol) email using PHP?
  •  sendmail($EmailAddress,”Subject”,”$MessageBody);
  1. The PDO_MYSQL Data Source Name(DSN) is composed of the following elements ?
  • dbname



  1. Which is true about the curl_setopt() API ?
  •  It sets one option for cURL transfer
  1. What will be the output of the following PHP code ?


$int options  = array(“options”=>array(“min_range”=>0,”max_range”=>256));

if(!filter_var($var,FILTER_VALIDATE_INT, $int_options))

echo(“Integer is not valid”);


echo(“Integer is valid”);


  • Integer is not valid
  1. Which function is used to read a file removing the HTML and PHP tags in it ?
  • fgetss()
  1. What will the output of following code :-

<?phpclass BaseClass {

public function test() {

echo “BaseClass::test() called\n”;


final public function moreTesting() {

echo “BaseClass::moreTesting() called \n”;



class ChildClass extends BaseClass {

public function moretesting(){

echo “ChildClass::moreTesting() called\n”;



$obj = new ChildClass;



  • Results in Fatal error : Cannot override final method


  1. What will happen if a fatal error was thrown in your PHP program ?
  • The PHP program will stop executing at the point where the error


  1. Which of the following code can be used to send email to multiple recipients ?
  • $recipients = array(‘’,’;


  1. Which of the following functions belong to Exception class ? (Choose all that apply)
  •    getLine()


  1. Which of the following are valid MySQLi Configuration options ? (Choose all that apply ?
  •    mysqli.allow_persistent



  1. Which is the best approach to parse HTML and extract structured information from it ?
  •  Use an XML parser (as simpleXML) and XPath queries if available.
  1. What is the output of the following code ?

<?phpfunction y($v) {

echo $v;


$w = “y”;

$w (“z”);

$w = “x”;


  •  z
  1. Xdebug is a PHP____________, the information which Xdebug provides is about stack and functions with full parameter for user defined functions, memory allocation and support for infinite recursions.
  •  Extension
  1. See the example class code below

class ExampleClass{

public $val = 5 ;

function &getValNum()


return $this->val;


which of the following one can be used for Return by reference ?

  •   $obj = new ExampleClass();

$myVal = $obj->getValNum();

  1. What is the output of following code ?

function myFun($a) {if(!$a){

throw new Exception(‘Value init.’);


return 3/$a;


try {

echo myfun(3) .”\n”;

}catch (Exception $e){

echo ‘Caught exception: ‘, $e->getMessage(), “\n”;

} finally {

echo “first\n”;



echo myFun(1).”\n”;

} catch (Exception $e) {

echo ‘Caught exeption:’, $e->getMessage(),”\n”;

}  finally {

echo “second\n”;


echo “Hello PHP Example\n”;

  •  1 first 3 second Hello PHP Example
  1. What is true about ini_set(‘memory_limit’,’-1’) ?
  • parse error
  1. what is the correct way to read-in multiple values from an array ?
  •  list($x,$y,$z) = array(7,8,9);
  1. What is the best practice for running MySQL queries in PHP? Consider the risk of SQL injection ?
  •  Use PDO prepared statements and parameterized queries
  1. Which of the following is the right MIME to use as a Contant Type for JSON data ?
  • application/json
  1. Which of the following is the correct way to convert a variable from a string to an integer ?
  •  $number_variable = (int)$string_variable;
  1. There are a number of mysqlnd plugins already available. These include
  •  PECL/mysqlnd_pscache – Prepared Statement Handle Cache plugin

PECL/mysqlnd_sip – SQL Injection Protection Plugin

PECL /mysqlnd_uh – User Handler Plugin

PECL/mysqlnd_qc – Query Cache Plugin

  1. What will be the  output of executing the following code ?
  •  Fata error : Call to private method Foo:: printName() from context
  1. When designing classes with UML, a class at its core has the following components ? (choose all that apply)
  •  Methods, Attributes
  1. Which of the following would show an error in php ?
  •  @echo 1
  1. What would be the output of the following code ?

$str = “0011110000bsts11100”;echo trim($str,’010s’);

  •  bst
  1. What would be the output of the I and II sample codes:

I)$a  = array();

$b = $a;

$b[‘foo’] = 42;

echo $a[‘foo’];


$a = new StdClass();

$b = $a;

$b->foo = 42;

echo $a->foo;

  •  Null 42
  1. Which of the following is not a Super Global variable in PHP ?
  •  None of the above
  1. Which of the following would produce an error :
$currentDT = new DateTime();
  •  $currentDT->getTimezone(new DateTimeZone(‘UTC’));
  1. Which statement is incorrect ?
  •  unset() forces the PHP garbage collector to immediately.
  1. which of the following is not related to garbage collection in PHP ?
  • gc_cycles()
  1. which statement is not correct ?
  2. $x = null;

  • empty($x) return TRUE
  1. What would be the output of the following code ?
  2. $parts = parse_url(“”);


    echo count($query);

  • 4
  1. Which of the following is not the correct way to create an empty object in PHP ?
  • $obj = new stdClass();
  1. Which function is used to destroy a variable or object ?
  • unset()
  1. What will be the output of the following code ?
  2. $arr = array(“THEY”,”WE”,array(“I”,”YOU”),”YOUR”);


  • 6
  1. Which statement is not correct ?
  • PHP_EOL – The correct ‘End of Line’ symbol for this platform.
  1. Which method is used to tweak an oject’s cloning behavior ?
  • clone()
  1. How do you access result set meta data ?



$mysqli = new mysqli(“”, “user”, “password”, “database”);

if ($mysqli->connect_errno) {

echo “Failed to connect to MySQL: (” . $mysqli->connect_errno . “) ” . $mysqli->connect_error;



$res = $mysqli->query(“SELECT 1 AS _one, ‘Hello’ AS _two FROM DUAL”);



  1. Which of the following will decode a JSON variable $json to an object ?
  2. $json = ‘{“abc”:1,”def”:2,”ghi”:3,”jkl”:4,”mno”:5}’;

  • both of above ($object = json_decode($json); and $object = json_decode($json,true);)
  1. Choose the correct option to force redirect from http to https :
  • RewriteCond %{HTTPS} off

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

  1. What will be the output of executing the following code ?
  2. <?php

    class Foo {

    private function printName($name) {




    $a = new Foo();



  • Fatal error: Call to private method Foo::printName() from context…
  1. What will be the output of the below code ?
  2. $tmp = “Dragon%%Ball%%z%”;

    $arr = explode(‘%’,trim($tmp));

    echo count($arr);

  • 6
  1. Which of the following options will fall to remove the element “y” when placed in the blank space in the below sample code
  2. $row = array(0=>”x”,1=>”y”,2=>”z”,3=>”w”)


  • array_diff($row,[“y”]);


  1. Which of the following is the correct option to get a numerically indexed array containing all defined timezone identifiers in PHP


  • DateTimeZone::listIdentifiers(DateTimeZone::UTC);


  1. What will be the output of the following code ?
  2. echo(1234==’1234 test’ ? ‘Equal’ : ‘Not equal’);

  • Equal
  1. After the following query is executed using PHP, which function can be used to count the number of rows returned ?(choose all that apply)
  2. SELECT * from students

  • mysqli_affected_rows()


Hope this article will help you to clear upwork php test easily.Please feel free to comment below your feed back and if you pass the test share screenshot of your test result with us, It will motivate others.

Hello Top 10 thing's lovers ! My name is Mahommad Jamaluddin Saiyed. I'm a Entrepreneur and Content Creator at A Learning blogger, story-teller, and a movie freak. Don't hesitate to connect with me on social media.

7 Comments to Upwork Test Answers | PHP Upwork Test Answers 2017

  1. saiyed9974 says:

    Coming Soon….Upwork Excel Test Answers !

  2. Virendra says:

    Very helpful article, i passed php test with top 30 Rank.
    view result here

  3. Md Sohel says:

    thnx for your informative article

  4. I’m not that much of a internet reader to be honest but
    your sites really nice, keep it up! I’ll go ahead and bookmark your site to come back later on. Many

  5. neeraj kumar says:

    hi very good article thanks for sharing keep up the good work

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2018: All Top 10 |All Rights Reserved by :