Sorry for the delay, but let me explain it.
PHP thanks to the $ before the variable name doesn't have that much of a complication with variable names, but other languages (php is not excluded!) have reserved words for the programming itself, like int, bool, new, etc.
PHP has some but I think that if you name correctly your variables you won't have a problem.
Some good practice is to do something like:
Code: Select all
$var = 1;
$playerHealth = 100; //notice the capitalization
$player = new Player();
$enemy = new Enemy();
$enemyHealth = 200;
$enemy_health = 200; //is also a good practice to either use capitalization to separate words or "_" underscore.
About the if statements all you need to know (i think) is:
Code: Select all
if(true)
{
echo "it's true";
}
else
{
echo "it's false";
}
or
Code: Select all
if(playerHealth > 0)
{
echo "Player is alive";
}
else if($playerHealth < 20)
{
echo "Player is bleeding";
}
else // $playerHealth >= 20
{
echo "Player is fine";
}
That's basically what you need to know, also one more thing
Code: Select all
if(something)
{
echo "something";
}
else if(hello)
{
echo "the something is false!";
}
What i meant with this something code, is that whenever you pass the first "if" to the "else if", you can assume it turned false.