1.
chr():
Returns a character from the given ASCII
value.
Syntax:chr(ascii_value);
Example:
echo chr(65);
// A
[Link]():
Returns the ASCII value of a character.
Syntax:ord(character);
Example:
echo ord("A");
// 65
[Link]():
Converts a string into lowercase letters.
Syntax:strtolower(string);
Example:
echo strtolower("HELLO");
// hello
4. strtoupper():
Converts a string into uppercase letters.
Syntax:strtoupper(string);
Example:
echo strtoupper("hello");
// HELLO
5. strlen()
Explanation: Returns the length of a string.
Syntax:
strlen(string);
Example:
echo strlen("Hello"); // 5
6. ltrim()
Explanation: Removes whitespace from
the left side of a string.
Syntax:
ltrim(string);
Example:
echo ltrim(" Hello"); // Hello
7. rtrim()
Explanation: Removes whitespace from
the right side of a string.
Syntax:
rtrim(string);
Example:
echo rtrim("Hello "); // Hello
8. trim()
Explanation: Removes whitespace from
both sides of a string.
Syntax:
trim(string);
Example:
echo trim(" Hello "); // Hello
9. substr()
Explanation: Returns a portion of a string.
Syntax:
substr(string, start, length);
Example:
echo substr("Hello World", 0, 5); // Hello
10. strcmp()
Explanation: Compares two strings (case-
sensitive).
Syntax:
strcmp(string1, string2);
Example:
echo strcmp("Hello", "Hello"); // 0
11. strcasecmp()
Explanation: Compares two strings (case-
insensitive).
Syntax:
strcasecmp(string1, string2);
Example:
echo strcasecmp("Hello", "hello"); // 0
12. chop()
Explanation: Removes whitespace from
the end of a string.
Syntax:
chop(string);
Example:
echo chop("Hello "); // Hello
13. strpos()
Explanation: Finds the position of the first
occurrence of a substring.
Syntax:
strpos(string, substring);
Example:
echo strpos("Hello World", "World"); // 6
14. stristr()
Explanation: Finds the first occurrence of a
string (case-insensitive).
Syntax:
stristr(string, search);
Example:
echo stristr("Hello World", "world"); //
World
15. str_replace()
Explanation: Replaces a specified
substring with another string.
Syntax:
str_replace(search, replace, string);
Example:
echo str_replace("World", "PHP", "Hello
World"); // Hello PHP
16. strrev()
Explanation: Reverses a string.
Syntax:
strrev(string);
Example:
echo strrev("Hello"); // olleH