Website design tutorial with php
PHP string
A string is a sequence of characters, like “Hello world!”.
PHP String Functions
The PHP strlen()
function returns the length of a string.
Example
Return the length of the string “Hello world!”:
<?php
echo strlen("Hello world!"); // outputs 12
?>
str_word_count() – Count Words in a String
The PHP str_word_count()
function counts the number of words in a string.
Example
Count the number of word in the string “Hello world!”:
<?php
echo str_word_count("Hello world!"); // outputs 2
?>
strrev() – Reverse a String
The PHP strrev()
function reverses a string.
Example
Reverse the string “Hello world!”:
<?php
echo strrev("Hello world!"); // outputs !dlrow olleH
?>
When you develop your site with php, these functions may help you. You edit or write php in with code editor from file manager in techvila hosting control panel.