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 } ?> Quote 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 !== "") Quote 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? Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.