Chapter 6. Working with Strings

In this lesson you will learn about some of the powerful string functions that are included in the PHP language.

Anatomy of a String

A string is a collection of characters that is treated as a single entity. In PHP, strings are enclosed in quotation marks, and you can declare a string type variable by assigning it a string that is contained in either single or double quotes.

The following examples are identical; both create a variable called $phrase that contains the phrase shown:

$phrase = "The sky is falling";
$phrase = 'The sky is falling';

Note

Anatomy of a String

Quote CharactersQuotation marks in PHP do not point in a direction. ...

Get Sams Teach Yourself PHP in 10 Minutes now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.