Skip to content

PHP Strings

Syntax

Strings in PHP are sequences of characters enclosed in single (') or double (") quotes.

// Declaring strings
$singleQuoteString = 'Hello World';
$doubleQuoteString = "Hello World";

Example

$empty = '';
$character = 'H';
$word = 'Hello';
$phrase = 'Hello World';
$sentence = 'Hello, World!';
// These are still strings because of the quotes
// even though they look like other data types
$numberString = '42';
$booleanString = 'true';