![]() |
How to handle eror message in controller ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: How to handle eror message in controller ? (/showthread.php?tid=44402) |
How to handle eror message in controller ? - El Forum - 08-13-2011 [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 ? How to handle eror message in controller ? - El Forum - 08-13-2011 [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. How to handle eror message in controller ? - El Forum - 08-13-2011 [eluser]CI_adis[/eluser] Solution also mentioned here: http://stackoverflow.com/questions/2013873/optional-parameters-in-codeigniter How to handle eror message in controller ? - El Forum - 08-13-2011 [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 ![]() |