Monday, February 3, 2014

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();

Example:
 <?php echo bcpow('4.2''3'2); // 74.08 ?>

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

Example
<?php

$x = 9;
$y = 4;

echo $x%$y;  // output is: 1

echo $x %= $y; // output is: 1

?>

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
rRead only. Starts at the beginning of the file
r+Read/Write. Starts at the beginning of the file
wWrite 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
aAppend. 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
xWrite 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");

Example
<?php

function inverse($x) {
    if (!$x) {
        throw new Exception('Division by zero.');
    }
    return 1/$x;
}
?>


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


10 comments:

  1. Our team provide help for freelancer exams

    100% result satisfaction

    Website : http://freelancerexams.com

    exams Sample ID :https://www.freelancer.com/u/IIBRAHIM1.html

    ReplyDelete
    Replies
    1. New answers updated weekly for Freelancer orientation exam

      http://freelancer-odesk-exams-answers.blogspot.de/

      Delete
  2. Hi…I was a bit low as I lost my day job. But your blog made me smile after a month of moping around in the dark. I am now sure that whatever has happened to me is for the good. I don’t feel lost anymore. After reading your article, I visited some marketplace websites like Freelance Work From Home, buy graphics design, and posted some samples of my music compositions. I am an instrumentalist, you see…and I have received a few offers. Let’s see how it works out.

    ReplyDelete
  3. Pass any freelancer exams with 100 percent results. Get certified with prime position at freelancer. Check now for freelancer exam answers

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

    a+ - Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it. In this mode, fseek() only affects the reading position, writes are always appended.
    http://php.net/manual/en/function.fopen.php

    15. The file handle argument in fread() allows you to specify

    handle - A file system pointer resource that is typically created using fopen().
    http://php.net/manual/en/function.fread.php

    ReplyDelete
  5. Your post is really good providing good information.. I liked it and enjoyed reading it. Keep sharing such important posts.
    hire seo consultant

    ReplyDelete
  6. I am looking for and I love to post a comment that "The content of your post is awesome" Great work! Africa freelancer

    ReplyDelete
  7. This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this.. loungu account

    ReplyDelete
  8. Today, I was just browsing along and came upon your blog. Just wanted to say good blog and this article helped me a lot, due to which I have found exactly I was looking. microsoft MCSA 70 740 dumps

    ReplyDelete
  9. I can provide you a permanent dofollow backlink with high DA-99, PA-97 guest post on Reddit community to promote your website, blogs, youtube videos and 100% index guaranty. If you want, you can contact me

    ReplyDelete