在Controller.php中更正语法

时间:2018-03-13 11:42:09

标签: php codeigniter

View.php 文件中<?php echo $ticket->player_id ?>正在运行。但是在 controller.php 中,它无效。 Controller.php的正确语法是什么?

我想在这里使用它

'include_player_ids' => array('<?php echo $ticket->player_id ?>'),

以下是来自控制器文件的示例代码,它们正常工作

// Send Email
            $email_template = $this->home_model->get_email_template_hook("ticket_reply", $lang);
            if($email_template->num_rows() == 0) {
                $this->template->error(lang("error_48"));
            }
            $email_template = $email_template->row();

            if(isset($ticket->client_username)) {
                $username = $ticket->client_username;
                $email = $ticket->client_email;
                $first_name = $ticket->first_name;
                $last_name = $ticket->last_name;
            } else {
                $username = $ticket->guest_email;
                $email = $ticket->guest_email;
                $first_name = $ticket->guest_email;
                $last_name = "";
            }

3 个答案:

答案 0 :(得分:3)

controller.php 中,

$data['ticket'] = 'your data will be here';

view.php 中,

'include_player_ids' => array($ticket->player_id),

希望你明白。

答案 1 :(得分:0)

它已经在php标签中,所以你不需要再次放置<?php ?>只需直接分配变量

'include_player_ids' => array($ticket->player_id),

答案 2 :(得分:0)

应该是

'include_player_ids' => array($ticket->player_id),

请发布$ ticket

的输出