Now available: Study Guide for ZCE PHP exam. The Zend PHP Certification Study Guide provides an excellent resource to pre-test your skills and guide. the Zend PHP Training program, which provides the necessary study guide and classes to help PHP developers become Zend PHP portal7.info part of the. x The Zend. PHP Certification. Practice Test Book. Practice Questions for the. Zend Certified Engineer Exam. John Coggeshall and Marco Tabini er d.
|Language:||English, Spanish, German|
|ePub File Size:||23.33 MB|
|PDF File Size:||12.39 MB|
|Distribution:||Free* [*Sign up for free]|
The first € price and the £ and $ price are net prices, subject to local VAT. Prices indicated with * include VAT for books; the €(D) includes 7% for. Germany, the. PHP 7 Zend. Certification Study. Guide. Ace the ZCE PHP Exam Any source code or other supplementary material referenced by the author in this. The Zend PHP Certification Study Guide provides an excellent resource to pre- test your skills and guide you to your ultimate goal of becoming a Zend Certified.
I decided to get a one up and try for my Zend PHP5 certification. I found one post on the Zend forms by a user named Nick A Williams that looks as if it were lost after Zend preformed an upgrade to their bulletin board software. The following is taken from the search engine cache of the forum 1. I must say I am very disappointed with the certification program so far. I have found the practice exams and study guide to be very misleading while preparing for the exam.
Zend: Adjust the descriptions for both the practice exams and study guide in your store to avoid confusion. Inform customers that the study guide is no substitute for the PHP manual. Remove your current practice exam description, and suggest how to properly use the practice exams for studying. More certified PHP developers will add far more value to your business objectives than a few pointless sales 1.
After all, certification exams should be somewhat difficult, be challenging and show an aptitude for the technology or language being tested over.
Still, I do agree with Mr. The exam tested on things like order of parameters and lots of stuff that can be found in the PHP manual. Real skill comes from experience and being a good PHP developer means writing maintainable, secure and scalable code. Not being able to know the manual inside-out. I have been coding PHP for 6 years. Yet I failed the Zend certification test. The test feedback was non-existent.
I feel I am a better coder because I have studied. True False Q4: You cannot use empty as a callback for the usort function. What will this code output? Hello World! This produces an error Q9: How would you refer to the parameter with the value cat in the following function?
A B C This produces an error. There is no particular limit on how long a string may be on a bit PHP system. The difference is that complex strings will be evaluated with respect to control characters and variables.
When using simple strings that are not evaluated. This helps to make strings binary safe. On bit systems a string can be as large as 2 GB. Simple strings are declared in 'single quote marks' while complex strings are declared in "double quote marks".
Embedding Variables One of the chief advantages of complex strings is the fact that PHP will parse them and automatically evaluate variable names contained in them. PHP stores the length of the string along with its contents and does not rely on a terminating character to denote the end of the string.
To include variables in simple strings you need to concatenate them. The following example illustrates the difference between concatenating variables to strings and embedding them in complex strings. In an earlier example. It is possible to include array and object syntax with double quotes too: The third echo statement shows an example of the variable name being evaluated in a complex string.
This is necessary. Because the braces explicitly denote the end of the variable in the string. It is rather output as literal characters. When the parser encounters one in a string. Using a backslash followed by anything other than a control character will result in the backslash being displayed.
The control characters are marked by a backslash followed by the code. Nowdoc was introduced in PHP 5. Instead of having to add multiple newline characters. Common uses for heredoc include creating SQL queries. Heredoc and Nowdoc A heredoc is a convenient way to declare a string that spans multiple lines.
Heredoc strings are evaluated for control characters and variables. You specify that a string is a nowdoc and not a heredoc by wrapping the label in single quotes. You can also use them to initialize variables.
Heredocs use the syntax like this: If your character set uses more than one byte per character. PHP does not store information about how the string is encoded. You should use the multibyte equivalents of those functions. The native string functions in PHP assume strings are an array of single bytes. A variable-width encoding scheme uses codes of differing lengths to encode a character set.
Writing to a position that is out of range will result in the string being padded with spaces to accommodate the missing section. PHP and Multibyte Strings PHP implements strings as an array of bytes with an integer indicating the length of the buffer not null terminated. Multibyte encodings use varying number of bytes to encode characters. Multibyte encoding allows a larger number of characters to be encoded and so represented on a computer.
In its current version. PHP will issue a range warning if you attempt to write to a negative position of a string. If you use one of these encodings and encounter a Unicode character that cannot be represented. Encoding is the way in which a Unicode character is represented. You can get away with doing it this way. UTF-8 stores all the codepoints from in a single byte. Putting the content type in the HTML as a meta tag is slightly less satisfactory because unless the client knows the encoding type.
There are hundreds of encoding schemes that can store some of the Unicode codepoints. There is no limit on the characters that Unicode can store. This lets the client know how your output is encoded and therefore how to display it correctly.
This covers the entire range of the English alphabet. There was some confusion originally about Unicode being two bytes. Unicode defines codepoints that are abstract concepts of a character. Only people who wrote characters with accents would ever end up with a file that was encoded differently from ASCII. A Unicode codepoint represents a character and is written like this: Changing Between Encoding Schemes The mbstring extension provides a number of functions that can be used to help detect and convert between encoding schemes.
Unless a client knows how a string is encoded. Codepoints above are stored in multiple bytes up to 6 bytes.
You can specify encodings in order for PHP to try or rely on the default encoding. It does so by comparing the string to a list of encoding schemes and selecting the first scheme under which the string is validly encoded. The PHP function strlen returns how many bytes are in the string. It declares an array with three different ways to say "hello" and then runs some string commands on each of them to illustrate some points. In chapter 1. In addition to using operators.
The operator can be used on any variable types. PHP also provides a number of string comparison functions. Instead of using alphabetical sorting. Strings that sound the same will have the same soundex key. It is more accurate than soundex. PHP has two functions that let you work with the way a string sounds.
The Levenshtein distance is defined as the minimal number of characters you have to replace. The soundex function calculates a key based on how the string sounds. This can be a very computationally expensive procedure for long sections of text. To compare substrings. Also be aware that the order that you pass the arguments in is significant.
There are two other ways to compare strings. The metaphone function similarly creates the same key for similar sounding strings. Another function. Extracting Strings An individual position in a string can be referenced with the same syntax as an array element.
Of course. This example shows the difference: This section introduces the functions that are used to search strings. If length is given as a negative number. The PHP Manual for substr shows the syntax for the command like this: If the start value is greater than the length of the string. The Zend exam is very much geared to reward experience rather than an encyclopedic knowledge of the manual. If the start value is positive or 0. The same happens when the start parameter is bigger or equal to the string.
The PHP Manual3 gives some more examples: If length is given as a positive number. Both the start and the length parameters can be positive or negative. It is strongly recommended that you experiment with the functions and read up on their manual pages.
Although Boolean false evaluates to 0. The following table lists the PHP Manual definitions for the string search functions. If you pass the optional fourth variable it is a reference argument. It returns false if no occurrence is found. As a general rule. Note that using strpos is preferable because it is faster.
It otherwise takes three parameters. This lets you replace multiple values in one call. The following parameters are values that must be typecast and inserted into those placeholders. The general usage is to specify a formatting string and the values that need to be placed into it. If only two parameters are supplied.
In the example. Formatting Strings The printf function is used to output a formatted string. PHP formats are locale-aware. Available since PHP 4. In earlier versions. This is shown in an example on the PHP Manual: No argument is required. The precision specifier stands for the number of digits after the decimal point since PHP 5. You can pass one. This happens due to other scripts running in different threads of the same process at the same time.
On Windows machines. It is locale-aware and uses the information set by the host system. Here is an example: The function takes parameters for the number to be formatted. To format currency. They are listed in the following table. There are several to choose from and they make it a lot quicker to play with expressions and see how they match strings. The rules are written as a string using a format that describes the pattern you are searching for. Usually the forward slash is used.
They need to be escaped if you intend to have them as a literal part of the expression. There are several flavors of regex. Regular Expressions Regular expressions are a set of rules against which you match strings.
Any character can be used. When learning regular expressions. Meta-Characters Meta-characters are interpreted to have a meaning in the search pattern. You will need to be familiar with them before sitting for your exam. The following table lists the character types that are available in PCRE. Generic Character Types Regex offers a way for you to specify that a character in your search string may be any of a particular type. You specify them using the backslash Escape meta-character and then providing the letter for the type.
The actual characters that are included in this are locale-aware. You saw in the meta-characters table that you create a character class by putting it inside square brackets. If you refer back to the table on meta-characters. You can find this table in the original specification document at http: An example of a character class is [A-Z]. By specifying a small sequence of characters in your pattern.
You can also use all of the generic types in character classes. Character Classes Character classes are very flexible ways to define what set of characters in your search string can be matched. You can use braces to limit the number of matches.
The syntax is best displayed in a table, where you match the expression against the string "abcABCabc":. Capturing Groups Capturing groups are delineated by brackets and allow you to apply a quantifier to the group. They also produce numbered groups that store the value that was matched, and they can be referenced elsewhere in your expression. This outputs string 22 "I can haz Cheeseburger". You can use non-capturing groups to optimize your query.
It may seem confusing that the? Just remember that a quantifier cannot occur at the start of a group because there is nothing to quantify. Imagine that you want to match HTML tags, so you try the following:. By contrast, a lazy search returns the shortest possible match. You can modify a quantifier to make it lazy by adding a question mark?
There are a lot more options to modify quantifiers, but they are outside of the scope of this book. Getting All Matches So far your expressions are returning just the first occurrence of the matching portion of a search string. Naming Groups You can name capturing groups by adding? For example:. The previous example outputs this:. Pattern Modifiers You can add a modifier after the closing delimiter of an expression.
The following table lists the modifiers. Modifier Function i The expression is case-insensitive. Strings can span multiple lines and newline characters are ignored. It is deprecated as of PHP 5. U This makes the quantifiers lazy by default and using the? This means that characters instead of bytes are matched.
You cannot compare a string variable to an integer variable using the greater than or less than operators. You can only compare string and integer values with the equivalence operator. Which of these regex expressions will identify both e-mail addresses and only the e-mail addresses in the following text. Pick as many as apply. In this chapter, we're going to be looking at PHP arrays. PHP arrays are implemented as an ordered map that associates values to keys.
There are three types of array in PHP: PHP has a lot of array functions that cover a great many common uses for functions. Before you write a function to operate on an array, you should first check if there is already one. They are implemented in C and so are going to be a lot faster than any function you could write in PHP to achieve the same result.
The array manual page1 lists them in one place, and you should make sure that you study this page and each function's manual page. This book would be too long to exhaustively list every function. Rather than duplicating this information, this chapter focuses on grouping and explaining some of these functions. Declaring and Referencing Arrays We will not dwell on what arrays are and will rather move straight onto the syntax used to declare arrays in PHP.
Arrays are created as a set of value-pairs that are separated by commas. If you do not specify a key then PHP will assign an auto-incrementing numeric key. In the example, the first two assignments are identical because PHP automatically assigns the key. A key may be numeric or a string. An array may contain a mixture of numeric and string keys. Arrays keyed on numbers are called enumerative. The first two examples are enumerative.
Arrays that have strings for keys are called associative arrays. The last two examples are associative arrays. There are two syntax forms to declare an array; choosing one is a question of coding style. Arrays may be nested.
In other words, an array value can itself be an array. These are called multi-dimensional arrays.
An individual array element may be referenced using the  operator like this:. If you do not specify a key in the brackets, PHP assumes that you are trying to reference a new element. You can use this to add an element to the end of an array:. Functions That Create an Array There are lots of PHP functions that return an array, but I'm going to introduce a few that are directly related to arrays.
The function explode is used to split up a string into an array. It's easiest to explain by example:. The function takes three parameters. The first is a string to be used as a delimiter. Typically, this is just a single character like a comma when working with CSV , but it could be of any length. The second parameter is a string containing a list of elements that are separated by the delimiter. The third parameter limits the number of items that PHP will return.
A zero limit is treated the same as 1. This example specifies -2 as the limit so PHP returns all the elements except the last two. The output of this example is:. The implode function2 operates in the reverse manner. It joins the elements of an array together into a string delimited by a string you supply.
It is similar to explode , but it uses a regular expression to delimit the field instead of using a literal string. It is documented in the PHP Manual.
It takes two parameters: Array Operators PHP arrays can be tested for equivalence and identity. They are identical if they have the same key and value pairs. If a key exists in both arrays. If the chunk size is greater than the length of the string.
We saw in the section on comparison operators that arrays are equivalent if they have the same key and value pairs. PHP appends the array on the right of the operator to the left. Other variable types are cast into one of these types before being stored.
Strings containing decimal valid integers will be cast to the integer type. PHP array keys are case sensitive: Keys may only be a string or an integer. Arrays are considered equal if they have the same key-value pairs. They are not equivalent.
Booleans can also be cast to integers. The PHP Manual has many useful examples. PHP rounds floats toward zero when it casts floats to integers. The hexadecimal and binary formats are both converted to decimal. Composite variables objects and arrays and resources cannot be used as key.
If you try to do so. You specify the beginning. The Boolean value true evaluates to integer 1 and false becomes integer 0. So the null key will be stored under the key ''.
Null is treated as an empty string. Another way of putting this is to say that the fractional portion of the number is truncated. The string "04" is not converted to an integer because it contains an octal representation and not a decimal.
This will output the following: Keys are unique. PHP will issue a warning "illegal offset type". Filling Up Arrays You can use the range function to add values to an array based on a range of values you specify. This script outputs: It takes parameters for the starting index. This function will fill up an array with a specific value and lets you specify what keys to use. The identity operator will only return true if the arrays have the same keys and values.
In the output. When applied to arrays. The commands that remove an element from the array return it to you and shift all the elements down. These four commands are used to add or remove elements from arrays. Numeric keys are reduced until they start counting from 0 and literal keys are left untouched.
It will return an array containing the values from the first array that were not present in any of the other arrays. To see the difference. This lets you validate that a form has been completely filled in. It takes a list of array parameters followed by a callable as the last parameter. If you apply it to the arrays in the example. The return value is empty because.
It calculates which values from the first array are also present in all the other arrays. More realistic use-cases could involve more complicated operations. We're using a custom function to do the comparison. There are PHP functions to allow you to specify your own callable to compare keys. Look at the manual page13 and make sure you have studied all its related functions. They have the same naming convention and parameters.
It takes two or more arrays as parameters and processes them from left to right. There are similar functions to perform the intersection. It follows these rules to determine the final result: Combining Arrays PHP offers some useful functions to help combine arrays. Consider this example: The function works from left to right. Both evaluate to 1 and so will replace the value in that position.
There are two things that you should pay attention to in the code output: We'll look at some in detail in the book. The following table lists them. As promised. Of these functions. We replace the slice that we extract with the replacement array. To add further complication.
This script looks for a slice of the input array that starts at position 1 and is of length 1. We know that arrays are zero based. The output of the script is therefore: Not only does it return a value the slice that was extracted.
That will make more sense if you see an example: Here is a basic example of its usage: A better and more robust approach is to use the foreach construct. It lets you quickly look at two possible syntaxes that foreach uses and then move on. You should already be familiar with its usage if you're considering sitting for your exam. Since PHP 5. This is particularly useful when dealing with database results.
The second foreach loop traverses it and passes the key and value. If you change the value in the code block it will not have an effect outside of the code block.
PHP the value passed into the code block of a foreach loop is passed by value. After the loop finishes. Relying on this feature makes your code harder to read. You can.
Here are the basic cursor functions: Functions Performs reset Moves the cursor to the beginning of the array17 end Moves the cursor to the end of the array next Advances the cursor18 prev Advances the cursor current Returns the value of the element the cursor points at key Returns the key of the element the cursor points at Objects can be iterated over using the same syntax.
A number of PHP functions use the cursor to determine which element to operate on. A less commonly seen use of a cursor is one such as this: The first is the value of the element from the array and the second is its index.
All sort functions take a reference to the array as their parameter and return a Boolean value indicating success or failure. As an exercise try to work out why this is so. The each function returns the current key and value pair from an array and advances the array cursor. The callable function will be passed two parameters.
If we had used strtoupper as a callback. PHP would generate warnings. Some internal functions. Note that I pass the value by reference into my lambda function. They follow a naming convention whereby the base sort function is prefixed with r for reverse and a for associative.
Here is an example that will convert all the elements of an array to uppercase: Sorting Arrays PHP offers several sort functions. Look at one of their manual pages19 for an example. Natural Order Sorting Natural ordering is a sort order that makes sense to human beings. It is an alphabetic sort order. As an example. These flags are predefined constants: All of the functions except usort accept an optional parameter to indicate the sort flag.
This lets you work with arrays as objects. Note that I've used the explode function to break up a string into an array.
These objects can use the methods of the ArrayObject class. This example will output: Are PHP keys case-sensitive? What will the output of this script be?
You can also optionally specify flags: Flag Effect ArrayObject:: This produces an error 2 3 5 Q6: This produces an error 3 2 1 This produces an error int 1 string 6 "lemons" None of the above Q5: This produces an error 2 3 4 Q8: Undefined offset: This produces an error 1 3 5 This book is not going to try to teach object-oriented programming but will rather focus on the PHP implementation.
PHP has supported object-oriented programming since version 3. Declaring Classes and Instantiating Objects Classes are declared using the class keyword. To instantiate an object from a class. Your coding standards will determine the case convention you use. Spotlight Learn more about this. Zend Framework Fundamentals.
Zend Framework Advanced. Zend Framework Master. Skip to the end of the images gallery. Skip to the beginning of the images gallery. Now available: