newnew Posted March 13, 2009 Report Share Posted March 13, 2009 Kā labāk rakstīt: if (!isset($var) || empty($var)) vai vienkārši if (empty($var)) Tas no stila viedokļa...? Quote Link to comment Share on other sites More sharing options...
Kaklz Posted March 13, 2009 Report Share Posted March 13, 2009 ar empty() pietiek, jo tas sevī ietver arī isset pārbaudi. Quote Link to comment Share on other sites More sharing options...
bubu Posted March 13, 2009 Report Share Posted March 13, 2009 Tik tad būs jāliek priekšā @ simbols. Jo ja mainīgais nav definēts, tad empty bļaustīsies (pie ieslēgtām noticēm). Quote Link to comment Share on other sites More sharing options...
marcis Posted March 13, 2009 Report Share Posted March 13, 2009 bubu, nebūs taisnība (vismaz php5+) Quote Link to comment Share on other sites More sharing options...
bubu Posted March 13, 2009 Report Share Posted March 13, 2009 hm, tiešām. Nezināju. Quote Link to comment Share on other sites More sharing options...
newnew Posted March 13, 2009 Author Report Share Posted March 13, 2009 Tātad secinājums - ja PHP 5+, tad pietiekami korekti ir rakstīt if (empty($var)) ja PHP 5-, tad korekti ir rakstīt if (@empty($var)) Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted March 13, 2009 Report Share Posted March 13, 2009 @ rakstīt ir korekti tad un tikai tad, ja pats esi apņēmies apstrādāt šo kļūdu. Quote Link to comment 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.