My slightly bad PHP skills...
Posted: Wed Apr 30, 2008 9:15 am
I'm doing an "if statement" but idk what i'm doing wrong here...
I'm tring to make $answer = 17 without declaring $answer as 17 using math but it's not working all that well... it's either my bad php skills or my bad math skills lol I can't really tell
can anyone see what I'm doing wrong? The problem I'm tring to solve is
2x + 7 and the answer should come out 17....
My else statement was triggered so I'm guessing somewhere in my PHP I messed up....
I'm tring to make $answer = 17 without declaring $answer as 17 using math but it's not working all that well... it's either my bad php skills or my bad math skills lol I can't really tell
can anyone see what I'm doing wrong? The problem I'm tring to solve is
2x + 7 and the answer should come out 17....
Code: Select all
<?php
// Practice so I don't forget how to do PHP
// Declare variables
$number = "2";
$number1 = "7";
$letter = "x";
$letter * $number = "5";
$two_x = $number * $letter;
$two_x + $number1 = $answer;
// If statement (hopefully this will work >.<)
if ( $answer = $two_x + $number1 )
{
echo ( $answer );
}
else
{
echo ( "Wrong... the right answer is: " . $answer );
}
?>