-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.php
31 lines (25 loc) · 1.01 KB
/
string.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<p>This code shows how to work with strings in php</p>
<?php
echo "we have to use echo to print in the page </br>";
echo "Concat ". " strings". " Use . to concat strings</br>";
echo "";
?>
<strong>Strign functions</strong></br></br></br>
<?php
$first = "This is the first string";
$second = "This is the second string";
$third = $first;
$third .= $second;
echo $third;
?>
</br>
Lower case: <?php echo strtolower($third); ?></br>
Upper case: <?php echo strtoupper($second); ?></br>
upper case first:<?php echo ucfirst($first); ?></br>
upper case word :<?php echo ucwords($third); ?></br>
String lenght : <?php echo "String lenth of {$third} is:"; echo strlen($third);?></br>
Trim(Trim will remove the white space</br>
from the end and the begining of the string that we are passing to it):
<?php echo "A". trim(' B C D ').'E';?></br>
Find(This will return the string and everything after it): <?php echo strstr($third, 'second');?></br>
Replace :<?php echo str_replace('first', 'repfirst', $first);?>