我希望 $userhp1 打印到屏幕上,并保存到分配的 sql 表中。这很好用,但它们都返回不同的结果。反正有没有让它们返回相同的值?
ob_start();
vitality(); //runs vitality function
$uservit = ob_get_contents(); // stores result on $uservit
ob_end_clean();
echo "-Vitality:";
echo "$uservit<br />";// Prints vitality
$userhp1 = $uservit * 2.8; // multiplys vitality too create HP
$userhp2 = $userhp1;
echo "-HP From vit:";
echo "$userhp2"; // prints hp
$con=mysqli_connect("localhost", "***", "***", "***");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE users SET hp=$userhp2
WHERE id='1'");
mysqli_close($con);