Lesson content
Read, practise, then check your understanding
PHP strings are byte sequences. Single quotes perform minimal escaping; double quotes and heredoc interpolate. Use mbstring or Intl when characters, locale, or Unicode semantics matter.
Practical example
<?php
$name = trim($input);
$message = sprintf('Hello, %s', $name);
$contains = str_contains($message, 'Hello');
$length = mb_strlen($message, 'UTF-8');
strlen counts bytes. Search, replacement, splitting, joining, and formatting do not escape output. HTML, URLs, headers, SQL, shells, and JSON each require their own contextual APIs. Normalize external encoding at boundaries.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.