Тестирование — oDesk PHP5 Test

\u041f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439 \u043d\u0430\u0437\u0430\u0434 \u0431\u044b\u043b\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c — «\u043a\u0430\u043a\u043e\u0439 \u0441 \u043c\u0435\u043d\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442». \u041d\u0430 \u0441\u0430\u0439\u0442\u0435 oDesk.com, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d, \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0439\u0442\u0438 \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0437\u043d\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0443. \u042f \u0432\u044b\u0431\u0440\u0430\u043b PHP5 Test. \u0421\u043f\u0443\u0441\u0442\u044f \u043f\u043e\u043b\u0447\u0430\u0441\u0430 \u0443\u043c\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u044f \u0431\u044b\u043b \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d — \u043f\u043e\u043b\u0443\u0447\u0438\u043b 4.20 \u0438\u0437 5.00 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445, \u0438 \u043f\u043e\u043f\u0430\u043b \u0432 Top 20%. \u041c\u0435\u043b\u043e\u0447\u044c, \u0430 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \ud83d\ude42\n

\n

\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435 \u043f\u043e\u0441\u043e\u0431\u0438\u0435 \u043f\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u043a \u0442\u0435\u0441\u0442\u0443. \u041d\u0438\u0436\u0435 \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u0438 \u043c\u043e\u0439 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u044f \u043e\u0442\u0432\u0435\u0442\u0438\u043b \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u0435 \u0432\u043d\u0435\u0441\u0442\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043d\u0430 \u0432\u0430\u0448\u0443 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443.\n

\u0418 \u0435\u0449\u0435: \u0435\u0441\u043b\u0438 \u043c\u043e\u0439 \u043f\u043e\u0441\u0442 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u0412\u0430\u0441 — \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0439 \u0431\u0430\u043d\u043d\u0435\u0440, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0434 \u044d\u0442\u0438\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c. \u0412\u0430\u043c \u044d\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442, \u0430 \u043c\u043d\u0435 — \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435! \ud83d\ude42\n\n

\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0442\u0432\u0435\u0442\u044b, \u044f \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u0446\u0432\u0435\u0442\u043e\u043c:\n

Question (many answers): What is true regarding $a + $b where both of them are arrays?\n

a. Duplicated keys are NOT overwritten
\nb. $b is appended to $a
\nc. The + operator is overloaded
\nd. This produces a syntax error\n

Question: You have two strings, which you want to concatenate.\n

$str1 = \u2018Have a \u2018;
\n$str2 = \u2018Nice Day\u2019;
\nThe fastest way would be:
\na. $str1.Concat($str2);
\nb. $str1.$str2;
\nc. \u201c$str1$str2\u201d;
\nd. None of the above\n

Question: Which of the following pair have non-associative equal precedence?\n

a. +,-
\nb. ==,!=
\nC. \u00ab,\u00bb
\nd. &=,|=\n

Question:Which of the following variables is not related to file uploads?\n

a. max_file_size
\nb. max_execution_time
\nc. post_max_size
\nd. max_input_time\n

Question: You have a 2D array in PHP:\n

$array = array(array(141,151,161), 2,3, array(101, 202, 303));
\nYou want to display all the values in the array The correct way is:\n

a.\n

function DisplayArray($array) {\r\n   foreach ($array as $value) {\r\n      if (array_valid($value)) {\r\n         DisplayArray($value);\r\n      } else {\r\n         echo $value. \u201c<br>\u201d;\r\n      }\r\n   }\r\n}\r\n\r\nDisplayArray($array);\n

b.\n

function DisplayArray($array) {\r\n   for ($array as $value) {\r\n      if (valid_array($value)) {\r\n         DisplayArray($value);\r\n      } else {\r\n         echo $value. \u201c<br>\u201d;\r\n      }\r\n   }\r\n}\r\n\r\nDisplayArray($array);\n

c.\n

function DisplayArray($array) {\r\n   for ($array as $value) {\r\n      if (is_array($value)) {\r\n         DisplayArray($value);\r\n      } else {\r\n         echo $value. \u201c&ltbr>\u201d;\r\n      }\r\n   }\r\n} \r\n\r\nDisplayArray($array);\n

d.\n

function DisplayArray($array) {\r\n   foreach ($array as $value) {\r\n      if (is_array($value)) {\r\n         DisplayArray($value);\r\n      } else {\r\n         echo $value \u201c&ltbr>\u201d;\r\n      }\r\n   }\r\n}\r\n\r\nDisplayArray($array);\n

Right answer: d.\n

Question: Multiple select\/load is possible with:\n

a. Checkbox
\nb. Select
\nc. File
\nd. All of the above\n

Question: The following php variables are declared:\n

$company = \u2018ABS Ltd\u2019;
\n$$company =\u2018, Sydney\u2019;
\nWhich of the following is not a correct way of printing \u2018ABS Ltd. Sydney\u2019?\n

a. echo \u201c$company $$company\u201d;
\nb. echo \u201c$company ${$company}\u201d;
\nc. echo \u201c$company ${\u2018ABS Ltd\u2018}\u201c;
\nd. echo \u201c$company {$$company}\u201d;\n

Question (many answers)\n

We have two variable definitions:
\n1. 023
\n2. x23\n

Choose the correct options:
\na. 1 is octal
\nb. 2 is hexadecimal
\nc. 2 is octal
\nd. 1 is hexadecimal\n

Question: Which of the following is a predefined constant?\n

a. TRUE
\nb. FALSE
\nc. NULL
\nd. _FILE_
\ne. CONSTANT\n

Question (many answers): Which of the following variable names are invalid?\n

a. $var_1
\nb. $var1
\nc. $var-1
\nd. $var\/1
\ne. $vl\n

Question (many answers): Which of the following are not considered as boolean False?\n

a. FALSE
\nb. 0
\n c. \u201c0\u201d
\nd. \u201cFALSE\u201d
\n e. 1
\nf. NULL\n

Question: Which of the following regular expressions can be used to check the validity of an e-mail addresss?\n

a. ^[^@ ]+@[^@ ]+\\.[\u201c@ ]+$
\nb. ^[^@ ]+@[^@ ]+[^@ ]+$
\nc. $[^@ ]+@[^@ ]+\\[^@ ]+^
\nd. $[^@ ]+@[^@ ]+[^@ ]+^\n

Question: Which of the following type cast is not correct?\n

$fig=23;
\n$varbl= (real) $fig;
\n$varb2 = (double) $flg;
\n$varb3 = (decimal) $flg;
\n$varb4 = (bool) $fig;\n

a. real
\nb. double
\nc. decimal
\nd. boolean\n

Question: Which of the following statements is not true with regard to abstract classes in php5?\n

a. Abstract classes are introduced in PHP5
\nb. A class with a single abstract method must be declared abstract
\nc. Abstract class can contain non abstract methods
\nd. Abstract method must have method definition and can have optional empty braces following it\n

Question: What do you infer from the following code?\n

$str = \u2018Dear Customer,\\nThanks for your query. We will reply very soon\\n Regards,\\n Customer Service Agent\u2019;\r\nprint $str;\n

a. Only first \\n character will be recognised and new line will be inserted
\nb. Last \\n will not be recognised and only first two parts will come in new lines
\nc. All the \\n will work and text will be printed on respective new lines.
\nd. All will be printed on one line irrespective of the \\n.\n

Question: Which of the following characters are taken care of by htmlspecialchars?\n

a. <
\nb. >
\nc. single quote
\nd. double quote
\ne. &
\nf. All of the above
\n\n

Question: What will be the output of the following code?\n

$a = 10;
\nif($a > 5 OR < 15)
\necho \u201ctrue\u201d;
\nelse
\necho \u201cfalse\u201d\n

a. true
\nb. false
\nc. No output
\nd. Parse Error\n

Question: If expire parameter of setCookie function is not specified then:\n

a. Cookie will never expire
\nb. Cookie will expire with closure of the browser
\nc. Cookie will expire with within 30 minutes
\nd. Cookie will expire in 24 hours\n

Question: You need to check the size of a file in PHP function.\n

$size=X(filename);\n

Which function will suitably replace \u2018X’ ?
\na. filesize
\nb. size
\nc. sizeofFile
\nd. getSize\n

Question: Which of the following text manipulation functions is supported by PHP?\n

a. strtoupper()
\nb. ucfirst()
\nc. strtolower()
\nd. str_split()
\ne. All of the above\n

Question: Which of the following is a correct declaration?\n

a. static $varb = array(1 ,\u2018var, 3);
\nb. static $varb = 1+(2*9O);
\nc. static $varb = sqrt(81);
\nd. static $varb = new Object;\n

Question: You wrote following script to check for the right category:\n

1<?php
\n2 $cate=5
\n3 …
\n4 …
\n5
\n6 if ($cate==5)
\n7 {
\n8 ?>
\n9 Correct category!
\n10 <?php
\n11 } else {
\n12 ?>
\n13 Incorrect category!
\n14 <?php
\n15 }
\n16 ?>\n

What will be the output of the program if value of\u2019cate\u2019 remains 5?
\na. Correct category!
\nb. Incorrect category!
\nc. Error due to use of invalid operator in line 6:\u201dif ($cate=5)»
\nd. Error due to incorrect syntax at line 8, 10, 12 and 14\n

Question: If visibility is not defined for a method\/member then it is treated as public static.\n

a. True
\nb. False\n

Question (many answers): Which of the following statements is incorrect with regard to interfaces?\n

a. A class can implement multiple interfaces
\nb. An abstract class cannot implement multiple interlaces
\nc. An interlace can extend multiple interfaces
\nd. Methods with same name, arguments, and sequence can exist in the different interlaces implemented by a class\n

Question: Which of the following is a Ternary Operator?\n

a. &
\nb. =
\nc. : ?
\nd. ? :
\ne. +=
\nf. &&\n

Question: Which of the following are the valid PHP data types?\n

a. resource
\nb. null
\nc. boolean
\nd. string
\ne. Both a and c
\nf. Both c and d
\ng. All of the above (\u041e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435)\n

Question: You are using sessions and session_register() to register objects. These objects are serialized automatically at the end of each PHP page and are de-serialized automatically on each of the following pages Is this true or false?\n

a. True
\nb. False\n

Question: What will be the output of the following code?\n

$Rent = 250;\r\nfunction Expenses($Other) {\r\n   $Rent = 250 + $Other;\r\n   return $Rent;\r\n}\r\n\r\nExpenses(50),\r\necho $Rent;\n

a. 300
\nb. 250
\nc. 200
\nd. Program will not compile\n

Question: What will be the result of the following expression:\n

6+4 * 9-3\n

a. 60
\nb. 87
\nc. 39
\nd. 30\n

Question: Does php 5 support exceptions?\n

a. Yes
\nb. No\n

Question (many answers): Which of the following printing construct\/function accepts multiple parameters?\n

a. echo
\nb. print
\nc. printf
\nd. Allof the above\n

Question: What will be the output of the following code?\n

$var = 10;\r\nfunction fn() {\r\n   $var=20;\r\n   return $var;\r\n}\r\n\r\nFn();\r\necho $var;\n

a. 10
\nb. 20
\nc. Undefined Variable
\nd. Syntax Error\n

Question: Which of the following is not true regarding XForms?\n

a. PHP provides support for XForm
\nb. It can be used on PDF documents
\nc. The data is sent in XML format
\nd. The action and method parameters are defined in the body\n

Question: How would you start a session?\n

a. session(start);
\nb. session();
\nc. session_start();
\nd. begin_sesion();\n

Question: How would you store order number (34) in an OrderCookie\u2019?\n

a. setcookie(«OrderCookie\u201d, 34);
\nb. makeCookie(\u201dOrderCookie\u201d, 34);
\nc. Cookie(«OrderCookie\u201d, 34);
\nd. OrderCookie(34);\n

Question: What will be the output of the following code?\n

function fn(&$var) {\r\n   $var = $var - ($var\/l0*5);\r\n   return $var;\r\n)\r\necho fn(100);\n

a.100
\nb. 50
\nc. 98
\nd. Error message
\ne. None of the above\n

Question: What will be the result of following operation?\n

print 4 << 5;
\na. 3
\nb. 128
\nc. 120
\nd. 6\n

Question: Which of the following is not supported in PHP5?\n

a. Type Hinting
\nb. Reflection
\nc. Magic Methods
\nd. Muftiple Inheritance
\ne. Object Cloning\n

Question: Which of the following is not a valid PHP parser tag?\n

a. script
\nb. ?p
\nc. %
\nd. ?php\n

Question: What will be the output of following code?\n

$a=10;
\necho \u201cValue of a =$a\u201d;\n

a. Value of a=10
\nb. Value of a=$a
\nc. Undefined
\nd. Syntax Error\n

Question: You need to keep an eye on the existing number of objects of a given class without introducing a non-class member variable.Which of the following makes this happen?\n

a. Add a member variable that gets incremented in the default constructor and decremented in the destructor
\nb. Add a local variable that gets incremented in each constructor and decremented in the destructor
\nc. Add a static member variable that gets incremented in each constructor and decremented in the destructor
\nd. This cannot be accomplished since the creation of objects is being done dynamically via \u201cnew\u201d\n

Question: Which of the following multithreaded servers allow PHP as a plug-in?\n

a. Netscape FastTrack
\nb. Microsoft\u2019s Internet Information Server
\nc. O\u2019Reilly\u2019s WebSite Pro
\nd. Allof the above\n

Question: Which of the following is used to maintain the value of a variable over different pages?\n

a. static
\nb. global
\nc. session_register()
\nd. Noneoftheabove\n

Question: Which of the following variable declarations within a class is invalid in PHP5?\n

a. private $type = \u2018moderate\u2019;
\nb. internal $term = 3;
\nc. public $amnt = \u2018500\u2019;
\nd. protected $name = \u2018Quantas Private Limited\u2019;\n

Question: Consider the following two statements:\n

1 while (expr) statement
\n2 while (expr): statement endwhile;\n

Which of the following are true in context of the given statements?
\na. 1 is correct and 2 is wrong
\nb. 1 is wrong and 2 is correct
\nc. Both 1 & 2 are wrong
\nd. Both 1 & 2 are correct\n

Question: You have defined three variables $to, $subject, and $body to send an email. Which of the following methods would you use for sending an email?\n

a. mail($to,$subject,$body)
\nb. sendmail($to,$subject,$body)
\nc. mail(to,subject,body)
\nd. sendmail(to,subject,body)\n

Question: What is the output of the following code?\n

function vec_add (&Sa, Sb) {\r\n   $a[X] += $b[\u2019x\u2019];\r\n   $a[y] += $b[\u2019y\u2019];\r\n   $a[Z] += $b['Z'];\r\n}\r\n$a = array (x => 3, y => 2, z => 5);\r\n$b = array (x => 9, y => 3, z => -7);\r\n\r\nvec_add (&$a, $b);\r\nprint_r ($a);\n

a. Array
\n(
\n[X] => 9
\n[y] => 3
\n[Z] => -7\n

b. Array
\n[x] => 3
\n[y] => 2
\n[z] => 5\n

c. Array
\n[xJ =>12
\n[yJ => 5
\n[z] => -2\n

d. Error
\ne. None of the above\n

Question: In your PHP application you need to open a file. You want the application to issue a warning and continue execution, in case the file is not found The ideal function to be used is:\n

a. include()
\nb. require()
\nc. nowarn()
\nd. getFile(false)\n

Question (many answers); Which of the the following are PHP file upload related functions?\n

a. upload_file()
\nb. is_uploaded_file()
\nc. move_uploaded_file()
\nd. Noneoftheabove\n

Question: Which of the following attribute is needed for file upload via form?\n

a. enctype=\u201dmultipart\/formdata\u201d
\nb. enctype=\u201dsinglepart\/data\u2019
\nc. enctype=»file\u201d
\nd. enctype=»form-data\/file\u201d\n

Question: Variable\/functions in PHP don\u2019t work directly with:\n

a. echo()
\nb. isset()
\nc. print()
\nd. All of the above
\n\n

Question: Which of the following is a PHP resource?\n

a. Domxml document
\nb. Odbc link
\nc. File
\nd. All of the above (\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435)\n

Question: The inbuilt function to get the number of parameters passed is:\n

a. arg_num()
\nb. func_args_count()
\nc. func_num_args()
\nd. None of the above\n

Question: For the following code:\n

function Expenses() {\r\n   function Salary() {\r\n      function Loan() {\r\n         function Balance() {\r\n         }\r\n      }\r\n   }\r\n}\n

Which of the following sequence will run successfully?
\na. Expenses();Salary();Loan; Balance();
\nb. Salary();Expenses();Loan(); Balance();
\nc. Expenses();Salary();Balance();Loan();
\nd. Balance();Loan();Salary(); Expenses();\n

Question: What will be the output of the following code?\n

echo 30 * 5.7\n

a. 150.7
\nb. 1507
\nc. 171
\nd. you can\u2019t concatenate integers
\ne. error will occur\n

Question: Which of the following is correct with regard to echo and print?\n

a. echo is a construct and print is a function
\nb. echo is a function and print is a construct
\nc. Both are functions
\nd. Both are constructs\n

Question: Which of the following is not a file related function in PHP?\n

a. fclose
\nb. fopen
\nc. fwrite
\nd. fgets
\ne. fappend\n

Question: Which of the following variables are supported by \u2018str_replace\u2019 function?\n

a. Integer
\nb. String
\nc. Boolean
\nd. Array\n

Question: Which of the following are useful for method overloading?\n

a. _call,_get,_set
\nb. _get,_set,_load
\nc. _get,_set,_isset
\nd. _overload\n

Question: What will be the output of the following code?\n

var_dump (3*4);\n

a. int(3*4)
\nb. int(12)
\nc. 3*4
\nd. 12
\ne. None of the above\n

Question: You need to count the number of parameters given in the URL by a POST operation. The correct way is:\n

a. count($POST_VARS);
\nb. count($POST_VARS_PARAM);
\nc. count($_POST);
\nd. count($HTTP_POST_PARAM);\n

Question: Consider the following class:\n

1 class Insurance
\n2 {
\n3 function clsName()
\n4 {
\n5 echo get_class($this);
\n6 }
\n7 }
\n8 $cl = new Insurance();
\n9 Scl->clsName();
\n10 lnsurance::clsName();\n

Which of the following Lines should be commented to print the class name without errors?
\na. Line 8 and 9
\nb. Line 10
\nc. Line 9 and 10
\nd. All the three lines 8,9, and 10 should be left as it is.\n

Question: Which of the following statement is not correct for PHP?\n

a. it is a server side scripting language
\nb. A php file may contain text, html tags or scripts
\nc. it can run on windows and Linux systems only
\nd. it is compatible with most of the common servers used today\n

Question: Which of the following functions output text?\n

a. echo()
\nb. print()
\nc. println()
\nd. display()\n

Question: Which of the following crypto \u00a1n PHP returns longest hash value?\n

a. md5()
\nb. sha1()
\nc. crc32()
\nd. All return same length hash\n

Question: The value of a local variable of a function has to be retained over multiple calls to that function. How should that variable be declared?\n

a. local
\nb. global
\nc. static
\nd. None of the above\n

Question: Does PHP provide the goto keyword in latest version?\n

a. Yes
\nb. No\n

P.S. \u041f\u043e\u043a\u0430 \u043f\u0438\u0441\u0430\u043b \u0437\u0430\u043c\u0435\u0442\u043a\u0443 \u043d\u0430 \u0441\u0430\u0439\u0442, \u043d\u0430\u0448\u0435\u043b \u0443 \u0441\u0435\u0431\u044f \u043f\u0430\u0440\u0443 \u043e\u0448\u0438\u0431\u043e\u043a. \u041d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u0434\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442, \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \ud83d\ude09\n

The On Demand Global Workforce - oDesk\n"Movie Get Out (2017)

42 thoughts on “Тестирование — oDesk PHP5 Test

  1. Hi!

    Спасибо за ответы! С несколькими я не согласна.
    Вот здесь мои ответы

    Question: Which of the following is a correct declaration?

    a. static $varb = array(1 ,‘var’, 3); — correct
    b. static $varb = 1+(2*9O);
    c. static $varb = sqrt(81);
    d. static $varb = new Object;

    Question: What will be the output of the following code?

    echo 30 * 5.7

    a. 150.7
    b. 1507
    c. 171 — correct (можно 3 * 57)
    d. you can’t concatenate integers
    e. error will occur

    Question: Which of the following is correct with regard to echo and print?

    a. echo is a construct and print is a function
    b. echo is a function and print is a construct
    c. Both are functions
    d. Both are constructs — correct

    Question: What is the output of the following code?

    function vec_add (&Sa, Sb) {
    $a[X] += $b[’x’];
    $a[y] += $b[’y’];
    $a[Z] += $b[‘Z’];
    }
    $a = array (x => 3, y => 2, z => 5);
    $b = array (x => 9, y => 3, z => -7);

    vec_add (&$a, $b);
    print_r ($a);

    a. Array
    (
    [X] => 9
    [y] => 3
    [Z] => -7

    b. Array
    [x] => 3
    [y] => 2
    [z] => 5

    c. Array — correct
    [xJ =>12
    [yJ => 5
    [z] => -2

    d. Error
    e. None of the above

    Question: What will be the output of the following code?

    function fn(&$var) {
    $var = $var — ($var/l0*5);
    return $var;
    )
    echo fn(100);

    a.100
    b. 50
    c. 98
    d. Error message — correct
    e. None of the above

    Question: What will be the output of the following code?

    $Rent = 250;
    function Expenses($Other) {
    $Rent = 250 + $Other;
    return $Rent;
    }

    Expenses(50),
    echo $Rent;

    a. 300
    b. 250 correct
    c. 200
    d. Program will not compile

    Question: You have a 2D array in PHP:

    $array = array(array(141,151,161), 2,3, array(101, 202, 303));
    You want to display all the values in the array The correct way is:

    a.

    function DisplayArray($array) {
    foreach ($array as $value) {
    if (array_valid($value)) {
    DisplayArray($value);
    } else {
    echo $value. “”;
    }
    }
    }

    DisplayArray($array);

    b.

    function DisplayArray($array) {
    for ($array as $value) {
    if (valid_array($value)) {
    DisplayArray($value);
    } else {
    echo $value. “”;
    }
    }
    }

    DisplayArray($array);

    c.

    function DisplayArray($array) {
    for ($array as $value) {
    if (is_array($value)) {
    DisplayArray($value);
    } else {
    echo $value. “&ltbr>”;
    }
    }
    }

    DisplayArray($array);

    d.

    function DisplayArray($array) {
    foreach ($array as $value) {
    if (is_array($value)) {
    DisplayArray($value);
    } else {
    echo $value “&ltbr>”;
    }
    }
    }

    DisplayArray($array);

    Right answer: d.

    1. Просмотрел Ваши варианты. Не согласен. Например, с последним. Объясните, почему вариант d а не c?

        1. как минимум в 2 ответах заметил ошибки в самом переводе, автор при ответе на вопросы не замечает «отрицание»
          ну и в других ответах есть ошибки
          в частности goto есть как минимум в 5.3

          1. Давайте конкретнее, совместными усилиями исправим.

  2. А разве в оригинале на сайте oDesk в скобках ($var/l0*5) именно такой текст? Если да — тогда естественно будет ошибка. Иначе мой вариант правильный.

    function fn(&$var) {
    $var = $var – ($var/l0*5);
    return $var;
    )
    echo fn(100);

  3. Какая разница что в скобках? Разве так сложно было проверить, набрав код в PHP?
    Получается ошибка «Only variables can be passed by reference».
    Ну нельзя передавать число и принимать его по ссылке.

    1. Согласен, «слона» я не заметил. Передавать значение (например, «echo fn(100);») , а не переменную — нельзя. А я зациклился на этом — ($var/l0*5), что «l0» — это не 10.
      Нереально во время ответов на вопросы проверить правильность в PHP. Спасибо за подсказку, исправил.

  4. Не знаю насколько это актуально, но выскажу свои соображения.

    Question: We have two variable definitions:
    1. 023
    2. x23

    Choose the correct options:
    a. 1 is octal
    b. 2 is hexadecimal
    c. 2 is octal
    d. 1 is hexadecimal

    По-моему, правильный вариант один: «a. 1 is octal».
    Потому что hexademical задаётся 0x23.
    А значит во 2-м мы имеем строку.
    Вариант d. не может быть правильным, потому что это octal, а число не может быть одновременно и hexademical и octal (а 0XXX — это именно octal формат).

    Question: Which of the following is a predefined constant?

    a. TRUE
    b. FALSE
    c. NULL
    d. _FILE_
    e. CONSTANT

    _FILE_ — это predefined constant, достаточно написать скрипт в одну строку: echo _FILE_
    А вот вариант «e» не задан.

    Question: Which of the following type cast is not correct?

    $fig=23;
    $varbl= (real) $fig;
    $varb2 = (double) $flg;
    $varb3 = (decimal) $flg;
    $varb4 = (bool) $fig;

    a. real
    b. double
    c. decimal
    d. boolean

    Здесь с вариантов «a» всё нормально, правильный ответ вариант «c» (достаточно ввести предлагаемый код в пхп файл и посмотреть).

    Question: Which of the following statements is not true with regard to abstract classes in php5?

    a. Abstract classes are introduced in PHP5
    b. A class with a single abstract method must be declared abstract
    c. Abstract class can contain non abstract methods
    d. Abstract method must have method definition and can have optional empty braces following it

    Здесь правильный ответ «c» (http://php.su/learnphp/phpoo/?php5_2 8 абзац)

    Question: Which of the following is a correct declaration?

    a. static $varb = array(1 ,‘var, 3);
    b. static $varb = 1+(2*9O);
    c. static $varb = sqrt(81);
    d. static $varb = new Object;

    Ответ «c» неправильный, потому что в объявлении переменных в классе не может использоваться выражение в качестве начального значения переменной.
    Правильный ответ «a».

    Question: Which of the following are the valid PHP data types?

    a. resource
    b. null
    c. boolean
    d. string
    e. Both a and c
    f. Both c and d
    g. All of the above

    Здесь правильный ответ «g» (http://php.su/learnphp/datatypes/).

    Question: You are using sessions and session_register() to register objects. These objects are serialized automatically at the end of each PHP page and are de-serialized automatically on each of the following pages Is this true or false?

    a. True
    b. False

    Здесь правильный ответ «a» (http://php.net/manual/ru/function.session-register.php читайте в самом конце страницы).

    Question: Which of the following is not a valid PHP parser tag?

    a. script
    b. ?p
    c. %
    d. ?php

    Здесь правильный ответ «b» (http://www.php.net/manual/en/language.basic-syntax.phptags.php).

    Question: Consider the following two statements:

    1 while (expr) statement
    2 while (expr): statement endwhile;

    Which of the following are true in context of the given statements?
    a. 1 is correct and 2 is wrong
    b. 1 is wrong and 2 is correct
    c. Both 1 & 2 are wrong
    d. Both 1 & 2 are correct

    Тут правильный «d» (http://php.net/manual/en/control-structures.while.php).

    1. Question: Which of the following statements is not true with regard to abstract classes in php5?

      Правильный ответ: d) Abstract method must have method definition and can have optional empty braces following it

  5. Спасибо большое за помощь! Я прошёл тест! Балл 3,5. Проходной 2,6.
    Если придерживаться только ответов из главного поста, а не обращать на комментарии, Вы пройдете тест! Не волнуйтесь!

    Мои результаты http://s41.radikal.ru/i092/1211/5b/85b8d544230a.png

    1. Пожалуйста! Но разобраться и понять ответы в любом случае нужно, как минимум для будущего профессионального роста 🙂

  6. ya bi poprosil tex kto otvechaet na voprosi nespesha otvechat,oto vashi otveti vvodyat lyudey v zablujdenie.Vot naprimer na vopros «Which of the following statements is not true with regard to abstract classes in php5?» otvet d na moy vsglyad potomuchto abstractniy class mojet imet ne obstracniy method.primer abstract class A{
    function goo(){}
    }

    1. В моем начальном посте ответ правильный, d).
      Вот ссылка из документации «PHP 5 introduces abstract classes and methods. Classes defined as abstract may not be instantiated, and any class that contains at least one abstract method must also be abstract. Methods defined as abstract simply declare the method’s signature — they cannot define the implementation.»

      А товарищ выше, который утверждает, что правильный ответ c) приводит правильную ссылку, а вот правильный ответ выбрать не может — абстрактный класс может! содержать обычные, не абстрактные методы.

  7. Menya bolshe vsego volnuet otvet na vopros Which of the following statements regarding PHP forms, are correct?

    a. In PHP, the predefined $_POST variable is used to collect values in a form with method=»post»
    b. In PHP, the predefined $_GET variable is used to collect values in a form with method=»get»
    c. In PHP, the predefined $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE
    d. Information sent from a form with the POST method is invisible to others and has an 8MB limit on the amount of information to send, which cannot be changed. Tut ya somnivayus v variante d. potomuchto napisano method post nevidim dlya drugix.Kto eti drugie?dlya lyudey -da,a dlya skripta net

    1. Все пункты для данного вопроса верны. Если с первыми тремя (a..c) и так понятно, то по последнему d) тоже все верно, и вот почему:
      That depends on the value of the PHP configuration directive POST_MAX_SIZE which is usually set to 8 MB (~8 million characters).

      Также, невидимость параметров здесь в сравнении с GET-методом.

      1. izveni no na schot a i b otvetov ya nesoglasen,potomuchto $_POST i $_GET eto massivi v kotorix xranyatsya dannie ot sootvetstvuyushix methodov,oni nesobirayut dannie,a methodi sobirayut dannie i zapisivayut vnix.Tut otvet ili c ili c,d.Voobshe mutno s otvetom d

        1. Спорить не буду. Свое мнение я высказал. Возможно, кто-то еще прокомментирует.

  8. Which of the following printing construct/function accepts multiple parameters?

    a. echo
    b. print
    c. printf
    d. All of the above
    Tut vo pervix nado razobratsya kak stavitsya vopros,ya tak i ne ponyal esli sprashivaetsya kakaya function prinemaet mnogo param,to otvet c.printf,a esli i construkciy to i echo toje,voobshe neponyatno

    1. mixed (т.е. несколько) параметров принимают только echo и printf, соответственно, в основном списке ответов всё правильно.

      1. Не верно. Mixed это «любой тип данных», а не неизвестное количество параметров.
        Правильный ответ — a и c
        void echo ( string $arg1 [, string $… ] )
        int printf ( string $format [, mixed $args [, mixed $… ]] )
        int print ( string $arg )

        Выражение
        print $a, $b;
        Вызовет ошибку: PHP Parse error: syntax error, unexpected ‘,’ in php shell code on line 1

  9. Na vopros «The value of a local variable of a function has to be retained over multiple calls to that function. How should that variable be declared?»
    Ya bi otvetil static,
    function foo(){
    static $a=0;
    echo $a++;
    }
    foo();
    foo();
    foo();
    Ya ponyal tak,xotyat soxranit localnuyu peremennuyu,pomoemu on nedoljna bit svyazanna s globalnoy ,ili vopros netak ponyal?

    1. В оригинальном посте ответ правильный, вариант b) global.
      Если объявить переменную, как глобальную, внутри функции, значение этой переменной будет доступно в глобальном скопе, т.е. будет передаваться между вызовами процедур.

  10. Menya skorey volnuet voprosi
    Which of the following environment variables is used to fetch the IP address of the user in your PHP application?

    a. $IP_ADDR
    b. $REMOTE_ADDR_USER
    c. $REMOTE_ADDR
    d. $IP_ADDR_USER
    Podozrevayu c. $REMOTE_ADDR

    1. В моем списке такого вопроса нет, но правильный ответ c) $REMOTE_ADDR.
      Переменная будет существовать при условии, что включена переменная в php.ini — register_globals=On,
      т.к. c. $REMOTE_ADDR, это переменная из массива $_SERVER ($_SERVER[‘REMOTE_ADDR’]).

  11. Which of the following is an iterator classes included in Standard PHP Library (SPL) in PHP5?

    a. OuterIterator
    b. InifiniteIterator
    c. RecursiveIterator
    d. SeekableIterator
    Tut daje v php.net e nesmog razobratsya kotoriy vopros pravilniy krome b?

    1. Каждый из ответов правильный, все перечисленные итераторы существуют в стандартной PHP-библиотеке, начиная с 5.1.0.

    1. Правильный ответ — a. b. c. d, т.е. все перечисленные варианты поддерживаются.
      Исправил в основном списке.

      Небольшой пример:
      $search = true;
      $replace = ‘True’;
      $subject = ‘What is the right answer for bool variable? Answer: 1’;
      echo str_replace($search, $replace, $subject);

      На экране будет:
      What is the right answer for bool variable? Answer: True

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *

*

code