我有一个函数来显示来自控制器的数据,如下所示:
public function leaderboards()
{
if($this->ion_auth->logged_in()){
$leaderboard = $this->FrontModel->getLeaderboard();
$dataLeaderboard = ''; $no = 1;
foreach ($leaderboard as $row) {
$dataLeaderboard .='
<tr class="calculate-price-wrapper post">
<td>
<div class="mv-font-secondary mv-f-14"><strong>'.$no.'.</strong></div>
</td>
<td>
<div class="mv-font-secondary mv-f-14"><strong>'.$row['fname'].'</strong></div>
</td>
<td >
<div class="mv-font-secondary mv-f-14"><strong>'.$this->replace_character($row['email']).'</strong></div>
</td>
<td>
<div class="mv-font-secondary mv-f-14"><strong>'.$row['total_point'].'</strong></div>
</td>
</tr>
';
$no++;
}
/* pagination */
$config = array();
$config["base_url"] = base_url(). "leaderboards";
$config["total_rows"] = count($dataLeaderboard);
$config["per_page"] = 20;
$config["uri_segment"] = 3;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['dataLeaderboard'] = $dataLeaderboard($config["per_page"], $page);
$data['pagination'] = $this->pagination->create_links();
/* data template - header footer */
$template['menuActive'] = 'leaderboard';
$template['menuLoggedIn'] = $this->menuLoggedIn;
$this->load->view('front-end/template/header', $template);
$this->load->view('front-end/leaderboard', $data);
$this->load->view('front-end/template/footer', $template);
}else{
redirect('auth', 'refresh');
}
}
下面是我的观点:
<!-- .main-breadcrumb-->
<section class="mv-main-body cart-main mv-bg-gray mv-wrap">
<div class="container">
<div class="latest-blog-title mv-title-style-3 no-text-behind" style="padding-bottom:30px;">
<div class="title-3-text"><span class="main">LEADERBOARD</span></div>
<div class="title-3-line"></div>
</div>
<div class="cart-inner">
<div class="cart-block block-cart-table mv-bg-white mv-box-shadow-gray-1 mv-mb-50">
<div class="mv-table-responsive">
<table class="mv-table-style-2">
<thead>
<tr>
<th style="width:15%;">Pos.</th>
<th style="width:30%;">Name</th>
<th style="width:30%;">Email</th>
<th style="width:20%;">Point</th>
</tr>
</thead>
<tbody>
<?=$dataLeaderboard?>
</tbody>
</table>
<div class="mv-pagination-wrapper mv-mt-25 mv-mb-25">
<div class="mv-pagination-style-1 has-count-post">
<?php echo $pagination; ?>
</div>
<!-- .mv-pagination-style-1-->
</div>
</div>
</div>
</div>
</div>
</section>
但最后却出现了这样的错误:
Fatal error: Call to undefined function <tr class="calculate-price-wrapper post"> <td> <div class="mv-font-secondary mv-f-14"><strong>1.</strong></div> </td> <td> <div class="mv-font-secondary mv-f-14"><strong>Test Name</strong></div> </td> <td > <div class="mv-font-secondary mv-f-14"><strong>te*s*n*ame*g*ai*.c*m</strong></div> </td> <td> <div class="mv-font-secondary mv-f-14"><strong>55</strong></div> </td> </tr> <tr class="calculate-price-wrapper post"> <td> <div class="mv-font-secondary mv-f-14"><strong>2.</strong></div> </td> in C:\xampp5.6\htdocs\motogp2022\application\controllers\front-end\MainController.php on line 703
遇到PHP错误严重性:错误
消息:调用未定义的函数
1.测试名称tesn* name gai*.c*m 55
1.文件名:front-end/服务器配置文件. php
行号:703
回溯:
导致错误的行是我的控制器中的这一行:
$data['dataLeaderboard'] = $dataLeaderboard($config["per_page"], $page); //Line 703
有人知道解决这个问题的办法吗?任何帮助都是非常感谢的,谢谢!
1条答案
按热度按时间50pmv0ei1#
在此行中:
$data['dataLeaderboard'] = $dataLeaderboard($config["per_page"], $page);
你使用
$dataLeaderboard
作为一个函数,你把它设置成一个HTML字符串,因此你得到的HTML并不是一个函数。不知道你的完整代码,但我认为你需要做的是:
$dataLeaderboard .= ...
,而是$dataLeaderboard[] = ...
。$data['dataLeaderboard'] = $dataLeaderboard
。为了简单起见,可以在循环中直接将其设置为数组$data['dataLeaderboard']
。而不是将其设置为$dataLeaderboard(...)
。变量周围的圆括号表示您试图将变量用作函数,但实际上并非如此。在那之后可能会有更多的事情要做,但从那里开始。