codeigniter display warning error if argument in URL not provided codeigniter display warning error if argument in URL not provided codeigniter codeigniter

codeigniter display warning error if argument in URL not provided


just learned that the solution is simple:

function id($id=NULL){ if ($id===NULL) {  redirect.... }}


you can also use:

$this->uri->segment(2); // gets 'id'$this->uri->segment(3); // gets '45'

then do a redirect, check out:

http://codeigniter.com/user_guide/helpers/url_helper.html


use default values for your function

function id($id=0){   if(there any record with $id being provided){        //do something}else{       //id not provided,set to default values 0 and then   show_404(); }}

no way there could be id = 0 so its automatically showerror without redirect, if user enter the url www.example.com/profile/id ,