Thuta Learning
BasicProgrammingbeginner

Strings

Relax. We'll talk through this in plain words — no textbook voice.

A string is just text data. You'll handle things like names, emails, titles, messages, addresses, and product descriptions as strings. PHP has a huge set of string functions for checking length, trimming, transforming text, and more.

php
<?php
$message = "Learn PHP step by step";

echo strlen($message);
echo "<br>";
echo str_word_count($message);
echo "<br>";
echo strtoupper($message);
?>
You should see
22 5 LEARN PHP STEP BY STEP

Easy traps

  • Measuring Burmese/Unicode strings with strlen() gives you a byte count, which may not match the number of characters a human would count.