Mcloide's resources library

All about PHP, Javascript, concepts and development

Posts Tagged ‘exam’

PHP5 Zend Exam – QA I

Posted by mcloide on November 14, 2008

I have been getting lot’s of questions from people all around the world asking me how to pass on the Zend Exam, what to study, etc.

Today I got an email, from Marvin, with some pretty good questions about the Exam and here is the first version of the PHP5 Zend Exam QA (thanks Marvin).

- Are all those functions from the manual included? I mean even the .NET stuff?

-> Dont worry about the .NET stuff, the goal of the exam is for you to demonstrate that you know PHP very very well

- What topic does the exam is focused more ? e.g streams ?

-> Follow the categories that is shown at the book (including patterns). You will have a lot of questions regarding arrays, strings, streams, xml and SOAP, but, again, they will ask you about everything.

- What are other stuffs that I should study as a beginner, that are not in the manual you encountered in the exam?

-> Have you done any mock exams? If not, do so, so you can get an idea of what are your weak points and focus on those. On the mock exams, do not accept anything besides excellent.

- How many months have you reviewed regardless of your work experience ?

-> I took the exam 2 times before passing. If I have to put it up how much time I have studied from the first exam to the last, I would say at least 3 months, studying every day (including weekends). Do the following, and this will help a lot, get a mock exam and for each question, copy the question and the choice with your selected answer to a word document. Answer it and go forward. Repeat this process through all the exam. After is done, read every single question again and before answering it, go to Google, Yahoo, etc, and try to see if you can find an answer for it. It will actually help a lot.

- Do those mock exams from Zend has online timers?  (if there is, it would be hard for me to copy the questions and review them again)

-> Yes they do, but they do not restrict the time even knowing that you should finish in time.

For everyone that is out there studying, keep the good work and good luck.

Posted in PHP, Zend | Tagged: , , , , , | Leave a Comment »

How to pass PHP5 Zend Certification Exam

Posted by mcloide on October 2, 2008

I have finally passed the PHP5 Zend Exam. It was very hard work. Long time studying and understanding every core PHP function.
Anyway, here are my tips for you to pass as well:

- Study hard. Don’t think you know. Be certain that you know.
- Take the mock exams and only accept Excellent in all categories of the test, nothing less.

- Go outside the books, read forums, blogs (including this one) and off course, the PHP.net site.
- Learn the difference of echo and print and how each one work.

- Learn strings, string functions, patterns, patterns functions, streams and streams functions.

- Learn PHP.INI, not everything, mostly the new settings and session
- Learn session management and it’s security risks
- Don’t be afraid of creating scripts to better learn a new extension of PHP.
- Check the ZendCon 08 Slides. There a few there with some great info.
- Remember you must know very well all the subjects that the certification book informs
- and most important, have fun.

Cristiano Diniz da Silva
PHP5 Zend Certified Engenieer
http://mcloide.wordpress.com

Posted in PHP, Zend, development | Tagged: , , , , | 18 Comments »

ZendCon 2008 Slides

Posted by mcloide on September 29, 2008

Zend Developer Zone has just released the slides from the 200 end Conference. A lot of good stuff incluinding the one with PHP PDO that can be very ususefull for the PHP5 Zend Exam.

Check it out: ZendCon 08 Slides

Posted in PHP, Zend, resources | Tagged: , , , , , , , | Leave a Comment »

Zend Exam Tips: Strings

Posted by mcloide on September 23, 2008

When you are taking an exam Strings and Patterns are by far one of the hardest part of the exam. I will take a small overview of the strings section in this category of the exam.

When I first took the exam, the strings section was the section that I got my worst score. It took me days to figure out what went wrong. I don’t think that there’s any PHP developer that doesn’t work with strings at least once a day and I do work with strings and patterns pretty much the whole day long. After you get to know strings manipulation a bit more you will see that it is as powerfull as Arrays.

For a start do you know what’s the difference between echo and print? Basically is only the fact that print returns a interger (1 or 1 – true or true always) and prints the string in the document, but you should know how both work, because that is what is going to be asked from you in the exam.

Take a look in the print.

  • Is a language constructor so you don’t need the parenthesis
  • it will work as a function because it will return a value
  • it does not always work in the same way as echo

If you do <?php print 9.9 ?> it will print on the document 9.9, but, if you <?php echo 9.9 ?> it will print on the document 99. This is the first big catch with print and echo.

Now let’s take a look in the echo:

  • is a language constructor so you don’t need to use the parenthesis (that you knew) but if you want you can use the parenthesis just like print
  • it does not return a result after printing the string in the document
  • you can pass more than one string to print with echo using commas (know this by heart)
  • dot’s are used to concatenate strings in an echo
  • double quotes and single quotes does not work in the same way

Using the same example as before would not make much sense, but I have one that will help you understand what kind of question you will see in the exam when working with strings.

What is the final result that is going to be printed?

<?php
echo ‘55′ . print(‘0.4′) + 3;
?>

To answer correctly this question you must know how both constructors work, so let’s “debug” this question.

print(‘0.4′) will print 0.4, but echo print(‘0.4′) will print 0.41. Seems odd, but you got to remember that print will first print it’s result and then echo will print the return of the print constructor, so 0.41.

echo ‘55′ . print(‘0.4′) will print then 0.4551. Now things get confusing, but it’s not hard. The print constructor will work a bit faster than echo because it only have a single string to print and echo will have 2 arguments to take care of, so print will print first 0.4 then echo will print it’s first argument, 55 and finally it will print it’s last argument, 1 that is the result of print. In the end we will have 0.4551 as result.

Now comes the third part of the question, adding the value 3 to the string. You must noted by now that the whole string is numeric, so PHP converting the string to float and then adding 3 would not be a problem, but how do you think it would work if we added the string ‘ab’ with the ‘55′ string and an ‘c’ inside the print? In this case it would try to convert the result of the print first to a float number, so ‘c’ would be excluded, and then add the value 3 and then concatenate the string.

This is all and actually all of this are all my notes about strings when studying for the exam. Here are some links that you should take a look at to learn more about strings:

Posted in PHP, Zend, development | Tagged: , , , , , , , , , | 3 Comments »

Zend Exam Tips – Scoring system

Posted by mcloide on September 18, 2008

If you have failed the test and have looked to the score sheet that they give you after you finish the exam and still do not understand why you have failed, here is why: Zend does not accept any score lower than Intermediate (medium) in an exam and if you got that, you have failed.

You have for the exam 12 categories, arrays, web features, xml, design, differences between PHP4 and 5, etc. All categories are marked with low, medium and high scores, or better, knowledge level. To pass the exam all you need to do is have a knowledge level of medium / high in all categories to pass.

I got this information after talking with the Zend customer support (and off course, I have asked about the confidentiality policy to know if I could disclose that) and hey, I got some good news, if you have taken the exam before, you are eligible for getting an discount to retake the exam. All you got do is sending an email to certification@zend.com.

Good luck on your next exam.

Posted in PHP, Zend, development, resources | Tagged: , , , , , , | 8 Comments »

Zend Exam Tips – double check the question before answering

Posted by mcloide on September 10, 2008

http://knowfree.net/

If you are a professional and you are working full time (sometimes even more), like yours trully, then here comes a good tip.

Not only once, but more often than I would like, I have answered wrongly a question just because I have read it fast.

Take a look at this question:

What is the output of the following?

<?php
function 1dotEach($n)
{
if ($n > 0)
{
1dotEach(–$n);
echo “.”;
}else
{
return $n;
}
}
1dotEach(4);
?>

Answer…
A) …0
B) Parse Error: Syntax Error
C) …..
D) ….
E) …

At first you would consider A or E as the answer for this question, but, take a second look at the line where the function is defined. The function starts with 1, a number and in PHP you cant have functions names,  variables names, class names, object names, etc,  starting with numbers which make B the correct answer for this.

Posted in PHP | Tagged: , , , , | 4 Comments »

Zend Tips – destroy session

Posted by mcloide on September 4, 2008

I have been using sessions for a long time and always, when I don’t need them any more I simply use session_destroy to completly wipe out the session information in the server. The issue with this is that sessions, by default, uses cookies to propagate the session ID and when you use session_destroy it will not unset the cookie. In order to completly destroy a session you must use the session_destroy function and unset the cookies.

Check the http://www.php.net/function.session-destroy to get better information of how sessions work.

Posted in PHP, Zend | Tagged: , , , , | Leave a Comment »

Zend Exam Tips – Streamming

Posted by mcloide on September 2, 2008

I will not only talk about the streamming question that I got on this latest Mock Exam, but as well something that I have noticed. The first time that I did this exam I went well, so the next exam wasn’t so hard and I went very well. This time that I took the exam, it was way harder than before and very close to what I got in the real Zend Certification Exam that I took last year, so as a tip, you should consider scoring Excellent in all topics of the Mock Exam so you can always get the most of the questions in the Mock Exam.

Now about the streamming, take a look at this question. It’s an essay type of question and it’s really not so hard, but it will get you confused.

 

Consider the following PHP script:

 

<?php

function get_socket($host, $port) {

  $fr = fsockopen($host, $port);

  stream_set_blocking($fr, false);

  return $fr;

}

 

// Assume $host1, $host2, etc are defined properly

$write_map[] = array(‘fr’ => get_socket($host1, $port1),

                     ‘data’ => str_pad(“”, 500000, “A”));

$write_map[] = array(‘fr’ => get_socket($host2, $port2),

                     ‘data’ => str_pad(“”, 500000, “B”));

$write_map[] = array(‘fr’ => get_socket($host3, $port3),

                     ‘data’ => str_pad(“”, 500000, “C”));

 

do {

  $write_sockets = array();

 

  foreach($write_map as $data) {

    $write_sockets[] = $data['fr'];

  }

 

  $num_returned = stream_select($r = null, $write_sockets, $e = null, 30);

 

  if($num_returned) {

    foreach($write_sockets as $fr) {

      foreach($write_map as $index => $data) {

        if($data['fr'] === $fr) {

          $len = fwrite($fr, $data['buf']);

 

          if($len) {

            $data['buf'] = substr($data['buf'], $len);

 

            if(empty($data['buf'])) {

              fclose($data['fr']);

              /* ????????? */

            }

          }

        }

      }

    }

  }

} while(count($write_map));

?>

What should go in the ??????? above for this script to function properly?

The answer for this question is simple: 

unset($write_map[$index]);

The answer by itself shows the logic that is behind the script and if you stop and read again the question you will see that this is really the only logic you can use. After the buffer has been written on the server, to avoid it continuing in an insane loop, you should unset the array in that index. Take a look at the while condition and you will understand.

Posted in PHP, Zend | Tagged: , , , , , | Leave a Comment »

Zend Exam Tips – be careful with serialize

Posted by mcloide on September 1, 2008

In the last mock exam that I did I made the same mistake twice: the “serialize” mistake. If you have read my post Zend Exam Tips III you will see that I believed that unserialize would take care of a string that seemed to be serialized. This time my mistake was over the serialize function. The question was simple:

The _______ function is used to convert an array into a string, maintaining your ability to return the string into an array.

Believe it or not, that’s not the concept of serialize function, that’s the concept of the implode function. Even knowing that I have used the implode function to perform exactly what have been described, I haven’t remembered that during the exam because “serialize” seems so obvious for being the correct question.

If you are preparing yourself to do the Zend Exam, be more than careful with the “serialize” concept.

Just to help you out, in accordance with PHP.Net, the serialize function is:

Description

string serialize ( mixed $value )

Generates a storable representation of a value

This is useful for storing or passing PHP values around without losing their type and structure.

To make the serialized string into a PHP value again, use unserialize().

Posted in PHP, Zend, resources | Tagged: , , , , , | 1 Comment »

Zend Exam Tips III

Posted by mcloide on August 26, 2008

I finally found a very smart question on this mock exams. Check this out:

What is the best approach for converting this string:

$string = "a=10&b[]=20&c=30&d=40+50";

Into this array?

array(4) {
  ["a"]=>
  string(2) "10"
  ["b"]=>
  array(1) {
    [0]=>
    string(2) "20"
  }
  ["c"]=>
  string(2) "30"
  ["d"]=>
  string(5) "40 50"
}

Answer…

A

Write a parser completely by hand, it’s the only way to make sure it’s 100% accurate

B

Use the parse_str() function to translate it to an array()

C

Pass the variable to another PHP script via an HTTP GET request and return the array as a serialized variable

D

Just call unserialize() to translate it to an array()

E

Write a string parser using strtok() and unserialize() to convert it to an array

My first thought  was to use unserialize and there you go, everything should be right, but as you know, not always I’m right. D was my answer at the exam and after I runned some tests I have found out that C is the correct answer.

Take a look again at the string a=10&b[]=20&c=30&d=40+50.

If you put a index.php? before the string you will get a full correct $_GET request: index.php?a=10&b[]=20&c=30&d=40+50.

Why the heck din’t I think on that!??????

Posted in PHP, Zend | Tagged: , , , | 8 Comments »