As we mentioned in the PHP Basics chapter, strings wear many hats in PHP—far from being relegated to mere collections of textual characters, they can be used to store binary data of any kind, as well as text encoded in a way that PHP does not understand natively, but that one of its extensions can manipulate directly.
String manipulation is a very important skill for every PHP developer—a fact that is reflected in the number of exam questions that either revolve directly around strings or that require a firm grasp on the way they work. Therefore, you should ensure that you are very familiar with them before taking the exam.
Keep in mind, however, that strings are a vast topic; once again, we focus on the PHP features that are most likely to be relevant to the Zend exam.
Strings can be defined using one of several methods. Most commonly, you will encapsulate them in single quotes or double quotes. In PHP, unlike some other languages, these two methods behave quite differently: single quotes represent simple strings, in which almost all characters are used literally. Double quotes, on the other hand, encapsulate complex strings that allow for special escape sequences (for example, to insert special characters) and for variable substitution, which makes it possible to embed the value of a variable directly in a string, without the need for any special operator.
Escape sequences are sometimes called control characters and take the form of a backslash () followed by one or more characters. Perhaps the most common escape sequence is the newline character
. In the following example, we use hex and octal notation to display an asterisk:
echo "x2a";
echo "