【发布时间】:2014-03-12 21:33:23
【问题描述】:
我有这个 php 代码:
<?php
echo '<form action="index.php" method="post">
<h3>ggjnjskrngjekrng</h3>
<p>
<input type="text" name="nbmatchs" />
<input type="submit" value="ok" />
</p>
</form>';
echo getLastMatchs($nbmatchs);
?>
我的功能:
function getLastMatchs(int $nb) {
$i=0;
while ($nb < $i )
{
return 'hello';
$i++;
}
}
例如,如果 nbmatchs 为 5,我想返回,返回 5x“Hello”。 我该怎么办?
我有这个错误:
Notice: Undefined variable: nbmatchs in C:\...
Catchable fatal error: Argument 1 passed to getLastMatchs() must be an instance of int, null given, called in C:\.. and defined in C:\...
【问题讨论】:
-
来自 php.net:类型提示不能用于标量类型,例如 int 或 string。也不允许使用资源和特征。