1.<html>
<head>
<title> health </title>
</head>
<body>
<?php
Echo "you have 5 health" ;
x=5
5-- ; 
5-- ;
Echo "you lost 2 health" ;
echo "You have 3 health left" ;
?>
</body>
</html>

or

2<html>
<head>
<title> health </title>
</head>
<body>
<?php
Echo "you have 5 health" ;
x=5 ;
5-- ; 
5-- ;
Echo "you lost 2 health" ;
echo "You have 3 health left" ;
?>
</body>
</html>

which should it be 1 or 2 or a diffrent 1?

Recommended Answers

All 4 Replies

ok i changed this a little

<html>
<head>
<title> health </title>
</head>
<body>
<?php
Echo "you have 5 health" ;
x=5
x-- ; 
x-- ;
Echo "you lost 2 health" ;
echo "You have 3 health left" ;
?>
</body>
</html>

its what the site told me to do it keeps saying error on line 8

you forgot to add the ';' after x=5

ah then is it correct?

im not sure what your code i supposed to do?

(also you forgot the $ symbol for you x value, all variables must have a $ symbol to siginify them.)

all it will do is echo a few statements and subtract 1 from 5 twice.

if you wanted to do somthing more meaning full you could write.

$health = 5;
$damage = 2;
//make sure correct damage was taken
echo "you have taken $damage damage<br />";
//echo how much health you should now have after damage was taken.
echo "you now have ";
$second_health = $health - $damage;
echo $second_health;
echo " health"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.