Explore common PHP string functions like strlen(), str_word_count(), strrev(), strpos(), and str_replace(). Learn how to use these functions with examples to manipulate strings effectively.
strlen()
: Get the length of a string.str_word_count()
: Count the number of words in a string.strrev()
: Reverse a string.strpos()
: Find the position of a substring.str_replace()
: Replace a substring with another.<?php
echo strlen("Hello World!"); // Output: 12
echo str_word_count("Hello World!"); // Output: 2
echo strrev("Hello World!"); // Output: !dlroW olleH
echo strpos("Hello World!", "World"); // Output: 6
echo str_replace("World", "PHP", "Hello World!"); // Output: Hello PHP!
?>