Take the 2-minute tour ×

I created a user model in Code Igniter.

class User extends CI_Model {
    function __construct() {

    public function new($username, $email, $password, $studentID="") {
        $this->db->query("INSERT INTO user VALUES (0, '$username', '$email', '$password', '$studentID')");

However, I am getting this PHP error.


Line 12, by the way, is this line.


What is a T_NEW? Why am I getting the error?

share|improve this question
public function new should be public function newUser. New is for creating instances of classes. And the keyword cannot be used as a function name. BTW Isn´t your code highlighting already telling you this? –  PeeHaa Mar 5 '12 at 23:17

2 Answers 2

up vote 8 down vote accepted

new is a reserved word for creating new objects, like new Person('Joe'). You should rename your function.

See http://php.net/manual/en/reserved.keywords.php for reference.


share|improve this answer

The new function is a reserved keyword for instantiating an object and isn't an overridable function.

share|improve this answer

Your Answer


