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
You are not logged in. Please login or register.
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
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>";
}
?>Here is some basic PHP code,
<?php
if ($firstVariable == $secondVariable)
{
echo "same";
}
else
{
echo "different";
}
?>if you have any other questions please feel free to post 'em here or in a new thread.
-John
Powered by PunBB, supported by Informer Technologies, Inc.