String Basics and Concatenation
Build and join strings in PHP with . and interpolation.
Strings in PHP
A string is a sequence of characters. PHP strings are binary-safe and can contain any byte. They are immutable — string operations return new strings, they don't modify originals.
Single vs Double Quotes
Single-quoted strings are literal; double-quoted strings parse variables and escape sequences:
<?php
$name = 'Alice';
echo 'Hello $name\n'; // Hello $name\n — literal
echo "Hello $name\n"; // Hello Alice — parsed
// Prefer single quotes for performance when no interpolation neededAll lessons in this course
- String Basics and Concatenation
- Searching and Replacing in Strings
- Substring and Padding Functions
- Splitting and Joining Strings