此代码一直告诉我;
意外'(',期待'&'或变量(T_VARIABLE)in 第24行的C:\ wamp \ www \ project \ side_tab.php
function ongoing_cases_control(isAdmin()){
if(isAdmin() == 1) {
echo '
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">Ongoing Cases Panel</div>
<div class="panel-body">
<p>You can edit, add on ongoing cases</p>
</div>
</div>
</div>
';
}
答案 0 :(得分:1)
该函数期待一个变量,你给出了一个表达式,这就是为什么它是一个错误
function ongoing_cases_control(isAdmin())
这里isAdmin()
是一个函数,你必须在那里放一个变量。
答案 1 :(得分:0)
假设这是整个片段,你有2个问题。你不能在函数声明中放置一个表达式,并且错过了结束}
。
function ongoing_cases_control($isAdmin) { // <--- replace with a variable
if($isAdmin == 1) {
echo '
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">Ongoing Cases Panel</div>
<div class="panel-body">
<p>You can edit, add on ongoing cases</p>
</div>
</div>
</div>
';
} // <---- here
}
答案 2 :(得分:0)
您需要定义一个变量,然后您可以传递函数的结果
function ongoing_cases_control($isAdmin)
{
if ($isAdmin) { // Note "== 1" will be true for any value that evaluates to true, so might as well just check for any value that evaluates to true.
// Return the result so you don't have side effects
return '
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">Ongoing Cases Panel</div>
<div class="panel-body">
<p>You can edit, add on ongoing cases</p>
</div>
</div>
</div>
';
}
}
用法:
echo ongoing_cases_control(isAdmin());