25.09.2014 Views

ZEND PHP 5 Certification STUDY GUIDE

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4<br />

Strings And Patterns<br />

As we mentioned in the <strong>PHP</strong> Basics chapter, strings wear many hats in <strong>PHP</strong>—far<br />

from being relegated to mere collections of textual characters, they can be used to<br />

store binary data of any kind—as well as text encoded in a way that <strong>PHP</strong> does not<br />

understand natively, but that one of its extensions can manipulate directly.<br />

String manipulation is a very important skill for every <strong>PHP</strong> developer—a fact that is<br />

reflected in the number of exam questions that either revolve directly around strings<br />

or that require a firm grasp on the way they work. Therefore, you should ensure that<br />

you are very familiar with them before taking the exam.<br />

Keep in mind, however, that strings are a vast topic; once again, we focus on the<br />

<strong>PHP</strong> features that are most likely to be relevant to the Zend exam.<br />

String Basics<br />

Strings can be defined using one of several methods. Most commonly, you will encapsulate<br />

them in single quotes or double quotes. Unlike some other languages,<br />

these two methods behave quite differently: single quotes represent “simple strings,”<br />

where almost all characters are used literally. Double quotes, on the other hand, encapsulate<br />

“complex strings” that allow for special escape sequences (for example, to<br />

insert special characters) and for variable substitution, which makes it possible to<br />

embed the value of a variable directly in a string, without the need for any special<br />

operator.<br />

Licensed to 482634 - Amber Barrow (itsadmin@deakin.edu.au)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!