Why isn’t this working? I’m trying to make a php user profile URL.
<?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);
}
}
}
?>
Parse error: parse error, expecting `’)” in C:\wamp\www\system\application\controllers\users.php on line 7
You probably meant to give
$ida default value ofnullusing the=assignment operator, like this:Your posted code uses the
==equality operator in the function declaration, which is a syntax error.