Home › PHP Tutorial › PHP strings
PHP strings
Measure, search and change text.
PHP has hundreds of string functions. Common ones are strlen, strtoupper, str_replace and strpos. Positions start counting at 0.
Example code
<?php
$s = "Hello, World";
echo strlen($s) . PHP_EOL;
echo strtoupper($s) . PHP_EOL;
echo str_replace("World", "PHP", $s) . PHP_EOL;
echo strpos($s, "World") . PHP_EOL;
?>