<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">if ($variableList) {<br class=""></blockquote><br class="">would provide the same result? To me that simple if($var) statement says, "if $var is not equal to a boolean false, or 0, or null then continue"...</blockquote><div class=""><br class=""></div>Yup, $var = [] is still 0 so it’s a falsy value (love the C based programming languages).<div class=""><br class=""></div><div class="">I’d like to propose, let’s anticipate the rejection instead of nested ifs for the expected values (normally ifs should be used to handle exceptions not for the basic functionalities), like this:</div><div class=""><br class=""></div><div class=""><font face="Menlo" style="background-color: rgb(255, 255, 236);" class="">If(!$var) { // check what will break the code</font></div><div class=""><font face="Menlo" style="background-color: rgb(255, 255, 236);" class="">    // reject statement and exit routine</font></div><div class=""><font face="Menlo" style="background-color: rgb(255, 255, 236);" class="">}</font></div><div class=""><font face="Menlo" style="background-color: rgb(255, 255, 236);" class=""><br class=""></font></div><div class=""><font face="Menlo" style="background-color: rgb(255, 255, 236);" class="">// continue the normal flow</font></div><div class=""><br class=""></div><div class="">This would also improve readability as it’s short and you immediately see what can cause a break.</div><div class=""><br class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>Best Regards,<br class=""><b class="">Sukhdev Mohan</b> | <b class="">Software Developer</b></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">Il giorno 5 mag 2021, alle ore 16:14, Alan Lord <<a href="mailto:alanslists@gmail.com" class="">alanslists@gmail.com</a>> ha scritto:</div><br class="Apple-interchange-newline"><div class=""><div class="">In the fairly recent past there have been a number of minor commits made which, I guess, are to help prevent php WARNING and/or NOTICE type messages, e.g.<br class=""><br class="">Something like this:<br class=""><br class=""><blockquote type="cite" class="">if (count($variableList) > 0) {<br class=""></blockquote><br class="">became this:<br class=""><br class=""><blockquote type="cite" class="">if (!empty($variableList) && (count($variableList) > 0)) {<br class=""></blockquote><br class="">But this seem to be overkill...<br class=""><br class="">As I understand things simply doing this:<br class=""><br class=""><blockquote type="cite" class="">if ($variableList) {<br class=""></blockquote><br class="">would provide the same result? To me that simple if($var) statement says, "if $var is not equal to a boolean false, or 0, or null then continue"...<br class=""><br class="">count($var) would return an integer if $var is a string, so it is not a useful explicit test for an array.<br class=""><br class="">And from the php manual, empty($var) says "a variable is considered empty if it does not exist or if its value equals false"<br class=""><br class=""><br class="">Thoughts / Comments?<br class=""><br class=""><br class="">Al<br class=""><br class="">_______________________________________________<br class=""><a href="http://www.vtiger.com/" class="">http://www.vtiger.com/</a><br class=""></div></div></blockquote></div><br class=""></div></body></html>