bugzy Posted July 27, 2012 Share Posted July 27, 2012 Just a beginner question guys. Since empty() is treating number 0 as NULL I wonder if this is an okey alternative so 0 is going to be accepted.. <?php $is_num = strlen(trim($item_stock)); if($is_num < 1) { //is empty } else { //has a value } ?> Link to comment https://forums.phpfreaks.com/topic/266314-is-it-ok-to-use-strlen-over-empty/ Share on other sites More sharing options...
scootstah Posted July 27, 2012 Share Posted July 27, 2012 You could just do if ($is_num !== "") Link to comment https://forums.phpfreaks.com/topic/266314-is-it-ok-to-use-strlen-over-empty/#findComment-1364764 Share on other sites More sharing options...
bugzy Posted July 27, 2012 Author Share Posted July 27, 2012 You could just do if ($is_num !== "") Thanks scootah.. but you think using strlen will be fine also? Link to comment https://forums.phpfreaks.com/topic/266314-is-it-ok-to-use-strlen-over-empty/#findComment-1364766 Share on other sites More sharing options...
scootstah Posted July 27, 2012 Share Posted July 27, 2012 It will probably work, but it's not the best solution. Link to comment https://forums.phpfreaks.com/topic/266314-is-it-ok-to-use-strlen-over-empty/#findComment-1364769 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.