PHP is a Hypertext-preprocessor. A string can be used directly in a function or it can be stored in a variable. Here in this articles we will use the XAMPP sever to run the php scripting.
Strings in PHP
With a string variable we can store and manipulate text. String variable are
used to contain the characters.
Let us see the various kind of functionality available with strings
in PHP.
- String variable
- String Length
- String Position
- String Replace
- String Toupper
- String ucfirst
- String Trim
Program
This is the php scripting to understand the functionality.
<html>
<head></head>
<body
bgcolor="#ffffCC">
<h3>
PHP STRINGS
</h3>
<hr/>
<?php
echo
" String
variable myString : ";
$myString =
"Text of a
String variable !";
echo
$myString;
?>
<br><br><hr>
<?php
echo
"String
Length(): length of DEEPAK DWIJ is -->";
echo
strlen("DEEPAK
DWIJ");
?>
<br><br><hr>
<?php
echo
"String
Position() : Position of dwij in Deepak dwij is -->";
echo
strpos("Deepak
dwij","dwij");
?>
<br><br><hr>
<?php
echo
"Replace()
: Deep is replaced by Deepak dwij -->";
$myString =
"My name
is Deep";
echo
str_replace("Deep",
"Deepak dwij",
$myString);
?>
<br><br><hr>
<?php
echo
"String
Toupper() : deepak is change to DEEPAK --> ";
$myString =
"deepak";
echo
strtoupper($myString);
?><br><br><hr>
<?php
echo
"UCfirst()
: deepak is change to Deepak --> ";
$myString =
"deepak";
echo
ucfirst($myString);
?>
<br><br><hr>
<?php
echo"StringTrim()
: ";
$myString =
" Deepak!
";
echo
trim($myString);
?>
</body>
</html>
Saved it by
string.php.
Result of string.php scripting
The above script
look like as under when it runs on browser:

reza parmarPosted Feb 21, 2014, 7:03 AM
Please check the example for CRYPT_MD5 Thank you