CHAPTER 4

image

String

A string is a series of characters that can be stored in a variable. In PHP, strings are typically delimited by single quotes.

$a = 'Hello';

String concatenation

PHP has two string operators. The dot symbol is known as the concatenation operator (.) and combines two strings into one. It also has an accompanying assignment operator (.=), which appends the right-hand string to the left-hand string variable.

$b = $a . ' World'; // Hello World$a .= ' World';     // Hello World

Delimiting strings

PHP strings can be delimited in four different ways. There are two single-line notations: double-quote (" ") and single-quote (' '). The ...

Get PHP Quick Scripting Reference 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.