【发布时间】:2014-04-18 13:00:11
【问题描述】:
我有这个功能:
function myFunction(string $name) {
$db = mysql_connect("localhost", "root", "");
mysql_select_db(...);
$insertplayer="INSERT INTO `...`(....)
VALUES (......')";
if (!mysql_query($insertplayer,$db))
{
die('Error: ' . mysql_error());
}
$id = mysql_insert_id();
echo 'done for player N°'.$id;
mysql_close($db);
}
以及我使用的形式:
<form action="insertplayer.php" method="post">
<input type="text" name="nameplayer" />
<input type="submit" value="ok" />
</form>
但是当我这样做时,我有这个错误:
Catchable fatal error: Argument 1 passed to myFunction() must be an instance of string, string given, called in C:.... on line 23 and defined in C:...
我有这个 int 问题的错误。我该如何解决?
【问题讨论】:
-
你不需要在你的函数中使用 php 中的 dataType 字符串
-
类型提示不适用于原始类型,php 正在寻找一个不存在的字符串类。删除该类型提示:myFunction($name) {
-
你能告诉我们你调用你定义的函数的代码吗?
-
谢谢,我只需要删除 myfunction(string $....) 中的字符串
标签: php string function arguments instance