Showing posts with label php basic example. Show all posts
Showing posts with label php basic example. Show all posts

switch statement - how to use switch, case, break, default in php

switch statement - how to use switch, case, break, default in php


switchstatement.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>switch statement - how to use switch, case, break, default in php</title>
</head>

<body>
    <h2 style="color:DodgerBlue; font-style:italic">php example: using switch statement</h2>
    <hr width="400" align="left" color="CornFlowerBlue" />
    <br />

<?php 
 $Color="SaddleBrown";
 switch($Color)
 {
  case Tan:
  $Message="Color is: Tan";
  break;
  
  case SaddleBrown:
  $Message="Color is: SaddleBrown";
  break;
  
  default:
  $Message="no color match in our list";
  }
  echo "<div style='Padding-left:35px;padding-top:35px;padding-bottom:35px;padding-right:35px;Background-color:HotPink;Color:Snow;width:450px;'>";
   echo $Message;
  echo "</div>";
?>

</body>
</html>




php stringconcatenation - how to concatenate string in php

php stringconcatenation - how to concatenate string in php


stringconcatenation.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>php stringconcatenation - how to concatenate string in php</title>
</head>

<body>
    <h2 style="color:DodgerBlue; font-style:italic">php example: using stringconcatenation</h2>
    <hr width="400" align="left" color="CornFlowerBlue" />
    <br />

<?php 
 $HiString ="Hi Jones";
 $WellcomeString="wellcome in our php example blog";
 echo "<div style='Color:Orange;Background-color:MistyRose;height:100px; width:375px;padding-left:25px;font-size:large;'>";
  echo "<br />";
  echo "$HiString"."! "."$WellcomeString"; 
 echo "</div>";
?>

</body>
</html>




if statement - how to use if statement (if condition) in php

if statement - how to use if statement (if condition) in php


ifstatement.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>if statement - how to use if statement (if condition) in php</title>
</head>

<body>
    <h2 style="color:OrangeRed; font-style:italic">php example: using if statement (if condition)</h2>
    <hr width="450" align="left" color="Green" />
    <br />

<?php 
 $Color="Green";
 
 if($Color == "Crimson")
 {
 echo "<div style='Color:Snow;Background-color:$Color;height:125px; width:375px;padding-left:25px;font-size:large;'>";
  echo "<br />";
  echo "selected color is: crimson";
 echo "</div>";
  }
 if($Color == "Green")
 {
 echo "<div style='Color:Snow;Background-color:$Color;height:125px; width:375px;padding-left:25px;font-size:large;'>";
  echo "<br />";
  echo "selected color is: Green";
 echo "</div>";
  }
?>

</body>
</html>




if else statement - how to use if else statement (condition) in php

if else statement - how to use if else statement (condition) in php


ifelsestatement.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>if else statement - how to use if else statement (condition) in php</title>
</head>

<body>
    <h2 style="color:Seagreen; font-style:italic">php example: using if else statement (if else condition)</h2>
    <hr width="525" align="left" color="Green" />
    <br />

<?php 
 $ColorName="MistyRose";
 
 if($ColorName == "Crimson")
 {
 echo "<div style='Color:Snow;Background-color:Crimson;height:125px; width:375px;padding-left:35px;font-size:x-large;'>";
  echo "<br />";
  echo "selected color is: crimson";
 echo "</div>";
  }
 else
 {
 echo "<div style='Color:Snow;Background-color:LightPink;height:125px; width:375px;padding-left:35px;font-size:x-large;'>";
  echo "<br />";
  echo "There is no selected color.";
 echo "</div>";
  }
?>

</body>
</html>