Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么这个php不工作?_Php_Html_Css - Fatal编程技术网

为什么这个php不工作?

为什么这个php不工作?,php,html,css,Php,Html,Css,所以我从代码学院得到了这个代码。它应该结合php、html和css在while循环中随机输出硬币样式的div,只要结果是正面的。但是,它不起作用,所有的php都在显示,我不知道为什么 .硬币{ 高度:50px; 宽度:50px; 边界半径:25px; 背景颜色:灰色; 文本对齐:居中; 字体大小:粗体; 字体系列:无衬线; 颜色:白色; 利润率:10px; 显示:内联块; 线高:50px; 字体大小:20px; } 更多的投币 只要结果是正面的,我们将继续掷硬币 问题是关闭div附近while

所以我从代码学院得到了这个代码。它应该结合php、html和css在while循环中随机输出硬币样式的div,只要结果是正面的。但是,它不起作用,所有的php都在显示,我不知道为什么

.硬币{ 高度:50px; 宽度:50px; 边界半径:25px; 背景颜色:灰色; 文本对齐:居中; 字体大小:粗体; 字体系列:无衬线; 颜色:白色; 利润率:10px; 显示:内联块; 线高:50px; 字体大小:20px; } 更多的投币 只要结果是正面的,我们将继续掷硬币


问题是关闭div附近while循环中的报价

正确的PHP应该是:

回声“H”中的qoute不匹配

使用以下命令:-

<!DOCTYPE html>
<html>
<head>
    <link type='text/css' rel='stylesheet' href='style.css'>
    <title>More Coin Flips</title>
</head>
<body>
<p>We will keep flipping a coin as long as the result is heads!</p>
<?php
$flipCount = 0;
do {
    $flip = rand(0,1);
    $flipCount ++;
    if ($flip){
        echo "<div class='coin'>H</div>";
    }
    else {
        echo "<div class='coin'>T</div>";
    }
} while ($flip);
$verb = "were";
$last = "flips";
if ($flipCount == 1) {
    $verb = "was";
    $last = "flip";
}
echo "<p>There {".$verb."} {".$flipCount."} {".$last."}!</p>";
?>
</body>

您需要将wamp或xampp等Web服务器配置到您的计算机。错误?您是否配置或安装了wamp/lamp/mamp?基本上你能运行php吗?有一个片段bro@kebs比php显示的要多,我不知道为什么php没有启用或扩展不正确。你甚至有一个本地主机Web服务器或任何服务器来运行代码吗?是的,但这不会导致所描述的问题。这会引发语法错误。我是个白痴。难怪我投了反对票。谢谢fam
<!DOCTYPE html>
<html>
<head>
    <link type='text/css' rel='stylesheet' href='style.css'>
    <title>More Coin Flips</title>
</head>
<body>
<p>We will keep flipping a coin as long as the result is heads!</p>
<?php
$flipCount = 0;
do {
    $flip = rand(0,1);
    $flipCount ++;
    if ($flip){
        echo "<div class='coin'>H</div>";
    }
    else {
        echo "<div class='coin'>T</div>";
    }
} while ($flip);
$verb = "were";
$last = "flips";
if ($flipCount == 1) {
    $verb = "was";
    $last = "flip";
}
echo "<p>There {".$verb."} {".$flipCount."} {".$last."}!</p>";
?>
</body>