ayofoto.info Biography ZEND CERTIFICATION STUDY GUIDE PDF

Zend certification study guide pdf

Thursday, April 11, 2019 admin Comments(0)

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 ayofoto.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.


Author: JANESSA FONDER
Language: English, Spanish, Dutch
Country: Oman
Genre: Business & Career
Pages: 141
Published (Last): 18.11.2015
ISBN: 831-9-63323-325-7
ePub File Size: 30.51 MB
PDF File Size: 8.61 MB
Distribution: Free* [*Regsitration Required]
Downloads: 29601
Uploaded by: KATLYN

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.

Return by Reference It is possible to declare a function so that it returns a reference to a variable. This book focuses on PHP 7. This argument helps to mitigate an attack where an opponent can change the value of the parameter that is passed to unserialize. Zend contributed their optimization engine to PHP. If it finds a matching function. The switch statement looks like this: You can use static scalar values to define a constant.

There are some rules that need to be remembered regarding how variables are cast in PHP. By default. Converting a string to a number results in 0 unless the string begins with valid numeric data see the PHP Manual4 for more detail. You can also call the settype function on a variable that takes the desired data type as a second argument.

You should read the manual page on type juggling3 carefully. Instead of exhaustively listing the rules. Casting from float to integer does not round the value up or down. Also make sure that you read the pages linked to from the type juggling page.

PHP integers are always signed. The reason behind this is that some numbers are rational in base 10 but are irrational in base 2. When PHP converts a floating point number to integer it rounds toward zero. Although 0. The PHP Manual5 has a very good example of how internal implementation details of numeric types can have counter- intuitive results: Because there are a limited number of bits available to store the number.

The range of values that an integer can take will depend on the system PHP is running on. There are similar constants for other numeric types. You should avoid testing floats directly for equality and rather test if they are the same up to a given degree of precision.

This script will output Those values are different because the difference is greater than the degree of error that we defined. They are listed in the PHP Manual page on reserved constants. Older versions had a complicated set of rules to determine how it would evaluate this sort of syntax. Here is a more complicated example that illustrates how PHP evaluates from left to right: Variables become unset when they become out of scope and you can use the command unset to manually clear a variable.

They could impact on your code security and can also make your code a little murky to read. The command empty will return true if a variable is not set and will not generate a warning. Checking If a Variable Has Been Set The command isset will return true if a variable has been set and false otherwise. This is best illustrated by example: This is not a bulletproof way to test if a variable is set.

They can be defined using the define8 function as shown: They have the same naming rules as variables. Constants can only contain arrays or scalar values and not resources or objects. You can also use the const keyword to define constants.

The constant function9 is used to retrieve the value of a constant. You can alter the values of superglobals. You can use static scalar values to define a constant. Superglobals are available in every scope. You need to know what each of the superglobals stores. There are quite a lot of reserved constants12 and you will need to know the error constants. Knowledge of this level of detail is required for the certification exam.

The unary operators following take only one argument and their placement before or after the variable changes how they work. There are two unary operators in PHP. They are named for whether the operator appears before or after the variable that it affects. If condition is true. The symbol form operators are C-based..

The general format is as follows: In this example. Null Coalescing Operator The null coalescing operator is just a special case of the ternary operator. Using them on a different variable type will cause PHP to cast the variable to integer before operating on it.

Bitwise Bitwise operators work on the bits of integers represented in binary form. The result of a bitwise operator will be the value that has its bits set according to these rules.

There are three standard logical bitwise operators: It returns The following table shows shifting bits. To understand how these operators work. In this case. The effect of these operators is to shift the bit pattern of the value either left or right while inserting bits set to 0 in the newly created empty spaces.

Bit Shifting PHP also has operators to shift bits left and right. PHP gives us the integer value and you can quickly confirm that the binary representation you evaluated matches it.

When we shift left. If you understand the effect it has on the bits. This is best understood by example: The first line will echo 0 as shifting left 32 bits will fill the bit integer with 0 bits.

Just for enrichment purposes. The second line will use the maths library and output the correct value of 2 raised to the power of The result of any assignment expression is the value of the variable following the assignment. The assignment operator can be combined with just about all the binary and arithmetic operators. It uses the fact that PHP will not let you change the value of a constant. If you always place the constant on the left of an equality comparison.

Whether the cost of code readability is worth it is a matter of personal style. This syntax serves as a shortcut that is best shown by providing an example of equivalent statements: Comparison Operators PHP uses the following comparison operators: PHP assigns all scalar variables by value. PHP will generate a parse error.

This is the default for Nginx and Apache. In the following example. The last operator we will discuss is the backtick operator. It is better to use PHP settings to suppress errors in your production environment and to allow your development environment to display errors. This will work only if the library that the function is based on uses PHP standard error reporting.

Having code that fails silently without producing an error makes debugging much more difficult than it needs to be.

Control Structures Control structures allow you to analyze variables and then choose a direction for your program to flow in. In this section. When compared to a scalar variable. When using comparison operators on arrays. They are identical if they have the same key and value pairs.. In a web environment this will probably be www-data. To illustrate. If you omit the break command. If structures look like this: The switch statement looks like this: This can be useful in some circumstances.

If statements may be nested. The loop will continue to run until the condition evaluates as false. The for loop syntax shows the C roots of PHP and looks like this: The second condition is evaluated at the beginning of each loop.

This means that if the expression is false. It has two forms. Using continue has the effect of stopping the current iteration and allowing the loop to process the next evaluation condition. This allows you to let any further iterations to occur. Using break has the effect of stopping the entire loop and no further iterations will occur. The break statement takes an optional integer value that can be used to break out of multiple levels of a nested loop.

If no value is specified, it defaults to 1. Namespaces Namespaces help you avoid naming collisions between libraries or other shared code. They can be used to avoid overly descriptive names for classes, to sub-divide a library into sections, or to limit the applicability of constants to one section of code.

Zend PHP Certification Study Guide

Classes encapsulate code into instantiable units. Namespaces group functions, classes, and constants into spaces where their name is unique. Namespaces affect constants, but you must declare them with the const keyword and not with define. It is possible to have two namespaces in a file, but most coding standards will strongly discourage this. To accomplish this, you wrap the code for the namespace in braces, as in this example:. Fully Qualified Namespace Names If you are working in a namespace, then the interpreter will assume that names are relative to the current namespace.

Consider this class as a basis for the following examples:. If we want to use this class from another namespace, we need to provide a fully qualified namespace, as in this example:. You may precede a name with a backslash to indicate that you intend to use the global namespace, as in this example:. In this example, if we had not indicated the global scope with the backslash, the interpreter would look for a class called Exception within the MyApp namespace.

Configuration I can highly recommend that you do some practical work to configure PHP. You can set up a virtual machine on your computer16 and install Linux17 on it, which will give you hands-on experience. There are several Windows and Mac packages that offer an all-in-one configuration for PHP, but you should make sure that you find the config files and go through them. Duplicating it here will only result in stale information.

Refer to the following links: Windows machines use the registry to store the location of the php. The actual key name varies between versions of PHP, but will follow a pattern similar to this: If a Windows machine is unable to find it in the location specified by the Registry, it will fall back to looking for the file in a number of default locations, including the Windows system directory. In addition to the php. This means that if you make a change to the PHP configuration, you will need to reload your Apache2 server or restart the fpm service.

PHP will first check for these files in the directory that the script is running in and work backward up to the document root. These INI files will override the settings in php.

Refer to the previous link for a list of settings and where they may be changed. The main configuration file has two directives that pertain to user INI files.

They are searched for in the same method as the fastcgi files are. You must set the AllowOverride setting in your vhost config to true in any directories that you want the.

Study zend guide pdf certification

Performance A great deal of PHP performance issues relate to the deployment environment, which is beyond the scope of this reference. One potential deployment issue with performance worth mentioning in the context of the Zend examination is using the xdebug extension in production. As the name suggests, this extension is for debugging and should not be installed in production. Another deployment concern is in keeping your PHP version up to date.

PHP 7. When considering performance for the Zend examination, we focus on memory management and the opcode cache. PHP uses a container called a zval to store variables. The zval container contains four pieces of information:. Piece Description Value The value the variable is set to. Type The data type of the variable. Remember that variables can be assigned by reference. This Boolean value helps PHP decide if a particular variable is a normal variable or if it is a reference to another variable.

Refcount This is a counter that tracks how many variable names point to this particular zval container. This refcount is incremented when we declare a new variable to reference this one. Variable names are referred to as symbols and are stored in a symbol table that is unique to the scope in which the variables occur.

PHP accomplishes this by only copying the value to a new zval when it changes, and initially pointing the new symbol to the same zval container. Arrays and Objects Arrays and objects use their own symbol table, separate from the scalar variables. They also use zval containers, but creating an array or object will result in several containers being created.

Consider this example:. This means that the member in the variable that is a reference to itself is not unset. Garbage collection is likely to be of benefit in long-running scripts or those where a memory leak is repeatedly created. There is no symbol pointing to this zval container and so the user cannot free the memory herself.

Just as for scalar variables. The Opcode Cache PHP is compiled into a sequence of intermediate instructions that are executed in order by the runtime engine. In this event. PHP will clear up these references at the end of the request. Remember that PHP is not intended to be a long-running language and is designed to be a text processor built for serving specific requests within the context of a web application.

The garbage collector will only cause a slowdown when it actually needs to do something. PHP does not iterate through the composite object because this would result in recursion as it follows links to itself. The PHP Manual has a series of diagrams explaining this on the refcounting basics page. These instructions are called opcodes or bytecodes and this process occurs every time the script is run.

This is more likely to occur in use-cases with objects because PHP always assigns objects by reference. Memory Leaks in Arrays and Objects Memory leaks can occur when a composite object includes a reference to itself as a member. Garbage Collection The garbage collector clears circular references.

Other extensions need to be downloaded and installed manually. Windows machines need to compile and install extensions manually. In addition to the cache built into PHP. These extensions include core functionality such as reflection. Extensions PHP extensions extend on the functionality offered by the core language. A number of them are enabled by default into standard repository distributions of PHP. An opcode cache stores the converted instructions for a script. Zend contributed their optimization engine to PHP.

In This determines the interval in seconds that PHP will scan for changes in the source file before recompiling it.

Known as opcache. It provides an easy way to download and install extensions on Linux. PHP will not scan the file more than once per request. Installing an Extension Extensions are enabled through the php. You can set it to 0 to tell PHP to always scan for changes.

PHP is both precompiled and interpreted. Take note of the setting opcache. Subsequent calls to the script do not require the script to be interpreted prior to being run. You should be able to rely on them being installed. Variable names Class names Namespaces Function names Here is an example from the PHP Manual: PECL extensions can be installed using the pecl command-line utility.

Choose all that apply. What will this script output? Call to undefined function C Error caught in global scope: Call to undefined function b None of the above Call to undefined function C 1 Error caught in global scope: Call to undefined function b None of the above Q6: What is the output of this script? ChildException Caught MyException: MyException Nothing An error message related to an uncaught exception Q7: This will generate an error because constants can only hold scalar values.

This will generate an error because you cannot use expressions or functions when declaring a constant. This will generate an error because you cannot use define to declare an array constant. Arguments Arguments to a function. In PHP. Any valid code can be used inside a function. If your function is called and the variable passed is the incorrect type. Functions are distinct from language constructs. This is useful because PHP is a loosely typed language and if you specify exactly what sort of variable you expect.

Functions can be built- in. To specify the type of argument that you are expecting. Another advantage is that giving type hints helps your IDE to give you more meaningful hints. Arguments are passed as a comma-separated list and are evaluated left to right. Argument Type Declarations You can specify what type of variable may be passed as an argument.

We discuss exactly what callables are a little later in this chapter. The following table summarizes what types can be declared. I've shown that we can tell PHP to expect scalar variables. Type Description Class name or Interface The parameter must be an instance of. There are two ways that you can enforce scalar type hinting: You configure the mode per file by placing a declare directive at the top of the file.

PHP will expect an instance of a class called boolean. Uncaught TypeError: Argument 1 passed to A must be an instance of boolean. Argument 1 passed to sayHello must be of the type string. This will affect the way that PHP enforces the function arguments as well as the function return type.

PHP will automatically try to cast variables of the wrong type to the expected type. In coercive mode. You can prefix the type hint with a question mark to indicate that the variable may either be null or of the specified type.

Too few arguments myFunc. Optional Arguments You can specify a default value for a parameter that has the effect of making it optional.

Study zend pdf certification guide

Here's an example: You can only omit passing parameters that are optional. PHP does let you call a function with different arguments and offers you some functions to be able to access the arguments that a function was called with.

This shows that in PHP 7 if you change the value of an argument in a function. PHP will not let you redeclare the same function name. Here are three of these functions: PHP passes arguments to functions by value. References By default. This outputs: By using the..

The variadic parameters are made available in your function as an array. If you are mixing normal fixed parameters with a variadic syntax. You can do this by declaring the argument as a pass by reference. The PHP manual2 has a very clear example that shows the interaction between compulsory.

You can call any callable as a variable function. It then looks for a function that has a name matching this evaluation. If a function argument is not defined as being a reference. This code will generate a fatal error: Variable Functions Variable functions are similar in concept to variable variable names.

If it finds a matching function. Changes to this parameter in the function will change the variable passed to it. You cannot use them as variable functions. We discuss this in the next section. These are similar enough to returns to mention in passing here. At the end of the yielded list of values. Generators let you write a function that will generate successive members of an array that you can iterate over without needing to hold the entire data set in memory.

If you specify strict mode. To do so. Return Type Declarations We previously looked at how you can declare what variable type your function arguments will be.

In PHP 7. You can also specify what variable type the function will return. If we declared strict mode. If you return from the root scope. The same types are available for return types as can be specified for the arguments. The PHP Manual notes that you should not do this as a performance optimization.

To declare a function as return by reference. After this call. If you try to return. Two use cases for this are the Factory pattern and for obtaining a resource like a file handle or database connection. Return by Reference It is possible to declare a function so that it returns a reference to a variable.

The function itself must return a variable. Every time a function is called. You can include global scope variables into your function in one of two ways: Lambda variables and closures can both be used in functions that accept a callable. That looks nearly identical to a lambda.

Early and Late Binding There are two ways in which a variable can be bound: This is usually done in some static declarative manner. A closure in PHP is an anonymous function that encapsulates variables so they can be used once their original references are out of scope. PHP will coerce the variable to a specific type and value when it needs to operate on it.

By contrast. In practical syntax in PHP. In early binding. PHP will use early binding by default. If you want to use late binding. The value of the variable that is used inside the parameter will be the value that it was when the closure was defined. In this lambda example. When it binds a variable to a closure. Binding Closures to Scopes When you create a closure.

You can use this sort of structure to avoid polluting your global scope. Callables Callables were introduced as a type hint for functions in PHP 5. In the previous example. A callable for a function such as usort can be one of the following: Is this true? There are examples of all of these in the PHP manual page on callables. What is the output of the following code? Int Float Fatal error: Uncaught TypeError Q2: Some PHP functions. All PHP functions require you to use brackets when calling them.

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.

Guide study zend pdf certification

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.

Zend PHP Certification Study Guide

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.

Study guide certification pdf zend

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.

PHP 7 Zend Certification Study Guide Ace the ZCE 2017-PHP Exam

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. Toggle Nav. 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: The Guide provides complete coverage on every topic that is part of the exam, including: Add to Cart. All rights reserved.