Skip to content
AgileLogics
4 min read

Strings

Prerequisites: Operators

Strings can use single quotes ('...', no interpolation) or double quotes ("...", which interpolate variables directly).

$name = "Ada";
echo "Hello, $name";   // Hello, Ada — interpolated
echo 'Hello, $name';    // Hello, $name — literal, not interpolated

echo strlen($name);           // 4
echo strtoupper($name);        // ADA
echo str_contains($name, "Ad"); // 1 (true)

Common mistakes

  • Using single quotes and expecting $name to interpolate — it only works inside double quotes (or heredo/nowdoc, next lesson).