這個是學校,所以如果你不想幫助我,我提前警告你。爲什麼會發布操作將打印代碼打印爲打印字符串而不是結果? (php)
我有這樣的代碼在HTML頁面中,引用了一個名爲dieRoller.php頁:
<form method="post" action="dieRoller.php">
<label>Input how many sides your die has:</label>
<input type="numberInput" id="numberInput" name="numberInput" /><br />
<input type="submit" value="submit" name="submit" />
</form>
這是dieRoller.php:
<?php
$numberInput = filter_input(INPUT_POST, "numberInput");
$answerNum = rand(1,numberInput);
print " You've rolled a: " $answerNum;
?>
這可能是地球上最愚蠢的問題地球,但我不明白爲什麼,當我提交這個表單時,我的結果實際上是一個dieRoller.php文本文件,而不是打印輸出?我已經去過。我不明白。
非常感謝您的幫助。
這是在安裝了php的服務器上嗎? – Musa 2013-03-23 04:23:44
這是在一個測試安裝的xampp .... – 2013-03-23 04:25:34
你確定其他PHP文件運行? PHP是否加載了Apache?另外,'numberInput'不是[有效的'input'類型](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#attr-input-類型)。 – ajp15243 2013-03-23 04:26:05