簡體   English   中英

PHP - Echo無法正確顯示

[英]PHP - Echo is not displaying correctly

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>

我試着在這里粘貼它,但格式搞砸了。

每當我嘗試加載頁面時,它只是說“未來值是/ $$值。”; ?>“而不是顯示”未來的價值是4660.96美元。“

我完全迷失在我做錯的事情上。

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

$是一個特殊字符,所以你需要逃避它。 或者你總是可以只是連接你的字符串和變量來避免這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM