Topic: if and else

hi

how would i make an if statement so if first variable is the same as second variable it displays the word "same" and if they are different it displays the word "different"

thanks

Thumbs up

Re: if and else

you would do something like this:

<?php
$word = "google";
$word_1 = "google";
$word2 = "yahoo";


if($word, $word_1) == $word_1) { // First $word is the word that it is being checked if it matches $word_1 
   echo "<font color='green'>Same: Word = google </font>";
} else {

  echo "<font color='red'>Different</font>";
}


if($word2, $word) == $word) { 
   echo "<font color='green'>Same: Word = $word </font>";
} else {

  echo "<font color='red'>Different: word = $word you typed $word2</font>";
}


?>

Thumbs up

Re: if and else

Here is some basic PHP code,

<?php
    if ($firstVariable == $secondVariable)
    {
        echo "same";
    }
    else
    {
        echo "different";
    }
?>

Thumbs up

Re: if and else

thanks  big_smile

Thumbs up

Re: if and else

if you have any other questions please feel free to post 'em here or in a new thread.

-John

Thumbs up