Sunday, February 12, 2017

PHP Level 1 freelancer exam answers 2017

PHP Level 1  freelancer exam answers 2017

PHP Level 1  Freelancer.com


PHP Level 1 Exam

1. What is the correct way to add 1 to the $counter variable?
Answer: $counter++;

2. What function raises the first argument to the power of the second argument, with decimal places to be specified by the scale factor?
Answer: bcpow();

 

3. Which operator performs the same function as x=x%y?
Answer: %=

4. Which file mode will read and write to the end of an existing file or create a new file?
Answer: w+

Basic file modes 
r
Read only. Starts at the beginning of the file
r+
Read/Write. Starts at the beginning of the file
w
Write only. Opens and clears the contents of file; or creates a new file if it doesn't exist
w+
Read/Write. Opens and clears the contents of file; or creates a new file if it doesn't exist
a
Append. Opens and writes to the end of the file or creates a new file if it doesn't exist
a+
Read/Append. Preserves file content by writing to the end of the file
x
Write only. Creates a new file. Returns FALSE and an error if file already exists
x+
Read/Write. Creates a new file. Returns FALSE and an error if file already exists


5. Which of the following is correct for adding a comment in a PHP script?
Answer: /* comment */

Type of comments in PHP
 //   or  #   single line comment
/* */            multi line  comment


6. Which function returns (and caches) the owner ID number?
Answer: fileowner()

7. Which of the following is the correct way to implement a do-while loop?
Answer:
$j = 0;
do { print "$j"; }
while ($j > 0);
 


8. Which statement will skip the rest of the current loop iteration and continue execution at the beginning of next iteration.
Answer: continue

9. Which of the following is correct to show a message for an exception?
Answer: throw new Exception ("Invalid data"); 


10. What term refers to the ability to shorten Extra_Long_Names improving readability of source code? 
Answer: Aliasing 

11. What PHP function returns the arctangent in radians of a numerical argument?
Answer: atan()

12.Which function is used to start tracking a user?
Answer: session_start()

13. What statement will delete session files?
Answer: session_destroy()

14. How are sessions tracked on PHP
Answer: with code rewriting using the PHP Session reference variable 


15. The file handle argument in fread() allows you to specify ___________.
Answer: the number of bytes you wish to read

No comments:

Post a Comment