![]() |
a couple of potentially useful helpers - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: a couple of potentially useful helpers (/showthread.php?tid=32) |
a couple of potentially useful helpers - Hobbes - 10-24-2014 These two helpers are a couple i use in my projects. Not sure if anyone will find them useful or not, but thought i would share them just in case. the first one is an alias function for both the php functions is_null() and empty() path/file name: application/helpers/variable_helper.php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); the next one contains two files. a config file and a helper file. It converts html to bbcode and bbcode to html. config file: in application/config/autoload.php add the below config file to your autoload config array. path/file name: application/config/bbcode.php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); add the below file to your autoload helpers array. path/file name: application/helpers/bbcode_helper.php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); well there you go, hopefully someone finds them useful RE: a couple of potentially useful helpers - Ivan's - 10-26-2014 This helpers is very useful For me. Thanks RE: a couple of potentially useful helpers - Hobbes - 10-27-2014 glad you could use them. ![]() RE: a couple of potentially useful helpers - Narf - 10-27-2014 You don't need is_null_or_empty(), empty() will return TRUE for NULLs. RE: a couple of potentially useful helpers - marcogmonteiro - 10-31-2014 First helper is kinda pointless. RE: a couple of potentially useful helpers - Hobbes - 10-31-2014 i created that helper quite awhile ago when i was getting errors passing nulls into the empty function. It was quite irritating, so basically it was put in as a work around for the problem. Still to this day not sure why i was getting that error with the empty function but yeah, that is why i wrote it. RE: a couple of potentially useful helpers - Narf - 10-31-2014 (10-31-2014, 07:59 AM)Hobbes Wrote: i created that helper quite awhile ago when i was getting errors passing nulls into the empty function. It was quite irritating, so basically it was put in as a work around for the problem. Still to this day not sure why i was getting that error with the empty function but yeah, that is why i wrote it. You might've had problems with passing function return values directly to empty(): PHP Code: // This only works on PHP 5.5+ This has nothing to do with nulls though. RE: a couple of potentially useful helpers - Avenirer - 10-31-2014 Maybe the problem then (and now) was that what is considered an empty variable is not necessarily a null one. ![]() RE: a couple of potentially useful helpers - Narf - 11-01-2014 (10-31-2014, 12:47 PM)Avenirer Wrote: Maybe the problem then (and now) was that what is considered an empty variable is not necessarily a null one. Which is just is_null(). RE: a couple of potentially useful helpers - Hobbes - 11-01-2014 no i do not typically pass a function call to the empty function. just variables. Plus, for me mainly being a C# and VB.Net developer using is_null_or_empty() is more natural. Even though at this point it is a useless function. lol |