How to handle eror message in controller ? |
[eluser]Edy S[/eluser]
Hi Everybody, i have a problem with my controller programs. Here's my code : Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); It will display error message and disturb the website display when people visit http://www.mysite.com/home/pages/ without insert a value for $id And my question now, How to handle an empty $id, so that it will not display an error message ?
[eluser]Fireclave[/eluser]
Code: public function pages($id = false) What do you thing about this ? You can set an default value (in this case false). Then you check the value by an if statement.
[eluser]CI_adis[/eluser]
Solution also mentioned here: http://stackoverflow.com/questions/20138...odeigniter
[eluser]Edy S[/eluser]
[quote author="Fireclave" date="1313263751"] Code: public function pages($id = false) What do you thing about this ? You can set an default value (in this case false). Then you check the value by an if statement.[/quote] Hi Fireclave, thanks for your post ... It work well, now that i can redirect to other page while found an empty $id. To CI_adis i've read it Code: note that this is just not in codeigniter but throughout php in case you were wondering ![]() Thanks for you all ![]() |
Welcome Guest, Not a member yet? Register Sign In |