CodeIgniter用户配置文件控制器

Tho*_*ggi 1 php codeigniter

为什么这不起作用?我正在尝试制作一个php用户个人资料网址.

<?php
class Users extends Controller {
  function Users() {
    parent::Controller();
  }
  function index($id == null) {
    if($id == null) {      
      redirect('/', 'refresh');      
    }
    else {
      $data['title']  = 'User Page';
      $data['result'] = $this->users_model->get_all_data();
      $data['userid'] = $id; // in the view, you can use $userid as a variable
      $this->load->view('users',$data);
    }
  }
}
?>
Run Code Online (Sandbox Code Playgroud)

解析错误:在第7行的C:\ wamp\www\system\application\controllers\users.php中解析错误,期待'')''

Jus*_*ier 5

你可能想给出$id一个null使用=赋值运算符的默认值,如下所示:

function index($id = null) {
Run Code Online (Sandbox Code Playgroud)

您发布的代码==在函数声明中使用了相等运算符,这是一个语法错误.