Datatypes supported by PHP
- String
- Integer
- Floating point
- Boolean
- Array
- Object
- NULL
- Resource
String Functions
Strlen() : Returns the length of a string (number of characters).
<?php
echo strlen("Hello world!"); // outputs 12
?>
Strrev() : reverses a string:
<?php
echo strrev("Hello world!"); // outputs !dlrow olleH
?>
Strpos() : searches for a specific text within a string.
If a match is found, the function returns the character position of the first match. If no match is found, it will return FALSE.
<?php
echo strpos("Hello world!", "world"); // outputs 6
?>
str_replace() : Replaces some characters with some other characters in a string.
<?php
echo str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly!
?>
0 Comment(s)