Friday, October 25, 2013

PHP - if Statement

This is a conditional statement on PHP.

Some tells you like this "If you work hard you can become 1st"

What will done if you work hard? You can become 1st.

PHP If statement is most suitable to it.

PHP "if" Syntax is below

if (condition)
  {
  code to be executed if condition is true;
  }

The example below will output "Hi, Good Morning!" if the current time (HOUR) is less than 12

We can get current time in hour using  date() function.

<?php

$time_in_hour=date("H");

if ($time_in_hour<"12")

  {

  echo "Hi, Good Moring!";

  }

?> 

0 comments:

Post a Comment