我正在尝试做一个数字游戏,其中生成两个数字,并且每次键入答案时都会相加或相减。我可以让数字显示,但我不能让操作员显示。我会怎么做?这里是我的代码:不能在php中显示运算符
PHP
<?php
$num1 = rand(0, 20);
$num2 = rand(0, 20);
$operators = array(
"+",
"-",
);
switch ($operators[array_rand($operators)]) {
case "+":
$result = $num1 + $num2;
break;
case "-":
$result = $num1 - $num2;
break;
}
echo'
<div class="row">
<div class="col-md-3 col-md-offset-1">'. $num1 .'</div>
<div class="col-md-3 col-md-offset-1">'. $operators .'</div>
<div class="col-md-3 col-md-offset-1">'. $num2 .'</div>
</div>
'
?>
谢谢指点先生! – Rgoat
你好!请投票并接受答案! – Naga