<?php
echo strlen("Hello<")."<br/>";//count the string length
echo str_word_count("Hello to you");//count the word
echo "<br/>".strrev("Happy");//reverse the string
echo "<br/>".strpos("Hello Jack", "Jack");//find the first character position of the word that match
echo "<br/>".str_replace("world","Dolly", "Hello worlds!");//replace some characters with some other in a string
//create constant
define("GREETING","Welcome to Me",true);// true mean case-insensitive, default is fasle mean case-sensitive
echo "<br/>".greeting;
//Constants are Global
define("HELLO", "Welcome to constant",true);
function myTest(){
echo "<br/>".hello."<br/>";
}
myTest();
$t = date("H");
if($t <"20"){
echo "Have a good day!"."<br/>";
}else
echo "Null"."<br/>";
$favcolor = "red";
switch ($favcolor) {
case 'red':
echo "Your favorite color is red!";
break;
case "blue":
echo "Your favorite color is blue!";
break;
default:
echo "Your favorite color is neither red, nor blue";
break;
}
echo "<br/>";
$x = 1;
while ($x <= 10) {
echo "The number is : $x<br>";
$x++;
}
do{
echo "number is : $x <br>";
$x++;
}while ($x <=10);
$colors = array("red","green","blue","yellow");
foreach ($colors as $key => $value) {
echo $key." ".$value."<br>";
}
?>