打开网站显示PHP Parse error: syntax error, unexpected token "$b", expecting "," or ")" in ...(示例1);syntax error, unexpected token "echo", expecting ";" in ...错误怎么办|已解决
错误提示:PHP Parse error: syntax error, unexpected token "$b", expecting "," or ")" in ...(示例1);syntax error, unexpected token "echo", expecting ";" in ...(示例2)
原因:函数定义时,参数之间需用逗号分隔;类方法、函数体内的语句需符合基本语法(如分号、括号匹配)。
解决方案:补全参数分隔符、分号等,修正后:
<?php
// 示例1修正
function add($a, $b) {
return $a + $b;
}
add(1,2);
// 示例2修正
class Test {
function sayHello() {
echo "Hello";
}
}
$test = new Test();
$test->sayHello();
?>

扫码添加技术【解决问题】
专业解决各种疑难杂症,您有任何问题都可联系我们技术人员。
本文来自博客园,作者:可有仙子迎风立,转载请注明原文链接:https://www.cnblogs.com/xztime/p/19706198

浙公网安备 33010602011771号