Lesson 28 of 3093%
(Progress persistence is disabled until Phase 9)
PHP
Beginner
String Functions
Learn about String Functions in PHP.
PHP is a powerful server-side language. In this lesson, we will cover String Functions.
Real code examples
<?php
echo strlen("Hello world!"); // 12
echo "\n";
echo str_word_count("Hello world!"); // 2
echo "\n";
echo strrev("Hello world!"); // !dlrow olleH
echo "\n";
echo strpos("Hello world!", "world"); // 6
echo "\n";
echo str_replace("world", "Dolly", "Hello world!"); // Hello Dolly!
?>
Common mistakes
Make sure you include the <?php tag when writing PHP!
Try It Yourself
You can experiment with this in the Playground.