![]() |
Undefined variable error short workaround help - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Undefined variable error short workaround help (/showthread.php?tid=39895) |
Undefined variable error short workaround help - El Forum - 03-23-2011 [eluser]Unknown[/eluser] I have a conditional statement that will print a defined value if the db field is null, but if the user is about to create a new record the db query isnt run so i get an undefiend varibale error were i would like it to just assume that the variable is null. Code: ($info->title == '' ? 'Add title' : $info->title) Can anyone recommend a way to write this while keeping it as short as possible. Cheers Undefined variable error short workaround help - El Forum - 03-24-2011 [eluser]iloveci[/eluser] I believe you want to use isset() http://php.net/manual/en/function.isset.php. Also I wouldn't worry about making code 'short' as it's far more important that your code is readable. |