0

I just want to ask if is it okay that I use native PHP language?

Example:

public function updatePost(){
if(!empty($_POST['name'])){
    return true;
}else{
      return false;
    }
}

CodeIgniter:

public function updatePost{
    $this->form_validation->set_rules("name","Name","trim|required");
    if($this->form_validation->run()==false){
          return false;
    }else{
                  return true;
            }
}

Thanks in advance!

3 Answers 3

3

You can use native PHP language in codeigniter without any problems. Only difference is that Codeigniter has functions that can help you keep your code simple and clean. So if you already using codeigniter I would recommend that you try and use as many functionalities of Codeigniter as possible.

Sign up to request clarification or add additional context in comments.

2 Comments

I agree with this generally but I'd add that their are occasions when native php will perform better e.g file parsing large files.
Yep, I had a problem with codeigniter session variables when I was building a shopping cart. It's storing it in a cookie that has memory limit of 4kB. And using a database is a problem also, when you have a website that has over 5000 visits a day. The number of queries that are executing is just unacceptable!
2

There is no problem using native PHP, but I recommend sticking with the frameworks functions. Especially if you are thinking about having multiple programmers working on the same code base. Having to work with inconsistent code is hard and can create unnecessary complications. Best to stick with a specific rule (frameworks functions) in my opinion.

Comments

1

CodeIgniter is a PHP framework so you would be using PHP, anyways.

As for your question, if you only goal is to check that the POST variable isn't null, you could do it this way:

return ($this->input->post('name')) ? true : false;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.