written 8.3 years ago by | • modified 8.3 years ago |
Mumbai University > Information Technology > Sem 4 > Web Programming
Marks: 5M
Year: Dec 2014, May 2014
written 8.3 years ago by | • modified 8.3 years ago |
Mumbai University > Information Technology > Sem 4 > Web Programming
Marks: 5M
Year: Dec 2014, May 2014
written 8.3 years ago by |
PHP String Functions are:
strlen(string 1) : It finds total number of characters in the string
Example:
<?php
$s=”Friend”;
echo $s
?>
Output: 6
strcmp(string 1, string 2) : It compares the two strings. In this, function returns 0 when both the strings are equal, function returns value >0 when string 1 is greater than string 2 and function returns <0 when string 1 is less than string 2.
Example:
<?php
echo
strcmp(“PHP”,”PHP”);
?>
Output: 0
strtolower(string 1) : This function converts the characters in string 1 to lower case.
Example:
<?php
Echo strtolower(“PHP”);
?>
Output: php
strtoupper(string1): This function converts the characters in string 1 to upper case. Example: Output: PHP ● trim(string1): This function eliminates the white space from both the ends of strings.
Example :
<?php
$str=”PHP”;
Echo “\lth3\gt:$str</h3>”;
Echo “<h3>:”.trim($str);
Echo “</h3>”
?>
Output- : PHP
: PHP