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 Characters. Quotation marks in PHP do not point in a direction. ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.