「PHP入門」PHPの条件分岐If…Else

1. if…else

説明:

if (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;

サンプルコード:

<?php
$d=date("D");
if ($d=="Fri")
  {
  echo "Hello!
"; 
  echo "Have a nice weekend!";
  echo "See you on Monday!";
  }
?>
2.ElseIf 
説明:
if (condition)
 code to be executed if condition is true;
elseif (condition)
 code to be executed if condition is true;
else
 code to be executed if condition is false; 
サンプルコード:
<?php
$d=date("D");
if ($d=="Fri")
 echo "Have a nice weekend!"; 
elseif ($d=="Sun")
 echo "Have a nice Sunday!"; 
else
 echo "Have a nice day!"; 
?>

PHP

Posted by arkgame