A String is a sequence of characters. String is one of the data types supported by PHP. Ex- ”Phpuncle PHP Tutorial ”
Functions of PHP String:
PHP are some existing string functions which can be used directly in our programs making an appropriate call to them. No installation is required to use these functions.
The string length function is used to count the number of character in a string. Spaces in between characters are also counted.
<?php echo strlen("Phpuncle PHP Tutorial!"); // outputs 22 ?>
The PHP str_replace() function is used to Replace Text Within a String. This function takes three strings as arguments.The third argument is the original string and the first argument is replaced by the second one.
<?php echo str_replace("Phpuncle", "Phpuncle PHP", "Phpuncle Tutorial!"); // outputs Phpuncle PHP Tutorial! ?>