简体   繁体   English

PHP - Echo无法正确显示

[英]PHP - Echo is not displaying correctly

https://pastebin.com/pEg8ZARP https://pastebin.com/pEg8ZARP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Future Value</title>
</head>
<body>
<?php # Script 1.8 - futureValue.php.
// Set the variables:
$interest = .08;
$amount = 1000;
$years = 20;

// Calculate the value:
$value = $amount* pow( (1+$interest), $years);

// Format the total:
$value = number_format ($value, 2);

// Print the results:
echo "<p>The future value is <b>/$$value</b>.</p>";
?>
</body>
</html>

I tried pasting it here but the formatting got messed up. 我试着在这里粘贴它,但格式搞砸了。

Whenever I try to load the page it just says " The future value is /$$value. "; 每当我尝试加载页面时,它只是说“未来值是/ $$值。”; ?> " instead of displaying "The future value is $4660.96.". ?>“而不是显示”未来的价值是4660.96美元。“

I am totally lost at what I am doing wrong. 我完全迷失在我做错的事情上。

echo "<p>The future value is <b>$".$value."</b>.</p>";

$ is a special character so you need to escape it. $是一个特殊字符,所以你需要逃避它。 Or you can always just concat your string and variable to avoid this problem. 或者你总是可以只是连接你的字符串和变量来避免这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM