Studio Lounge
Studio Lounge Wed Design and Photography Edmonton
PHP if Statement

A lot can be done with a basic if statement, this is why it is so important to programmers. its boils down to basic logic. “if something is true then do it., if not do something else.”

here is a quick example:

Code (php)

$name = "Adam";
if ( $name == "Adam" ) {
echo "Hello Adam!"; }
echo "Welcome to my homepage!";

This is what would display:

Hello Adam!
Welcome to my homepage!

If we had a statement that was equal to false then we would see this:

Code (php)

$name = "Bob";
if ( $name == "Adam" ) {
echo "Hello Adam!"; }
echo "Welcome to my homepage!";
 

The output from this would be:

Welcome to my homepage!

Here are some comparison operators

  • == is equal to
  • != is not equal to
  • > is greater than
  • < is lesser than
  • >= is greater than or equal to
  • < = is lesser than or equal to

check out PHP operators

No Responses to “ PHP if Statement ” Jump

Leave a Reply