Manixat Posted January 12, 2013 Share Posted January 12, 2013 (edited) Hello.. I have this shorthand if <div id='holder' style='overflow:<?php echo (isset($ad) and $write==0 ? "auto" : "hidden"); ?>;' > which no matter the conditions, always returns 1? <div id="holder" style="overflow:1;"> What is up with that? Edited January 12, 2013 by Manixat Quote Link to comment Share on other sites More sharing options...
kicken Posted January 12, 2013 Share Posted January 12, 2013 Use && for a logical-and, not 'and'. 'and' has low precedence so it is evaluated last. In other words, your code runs as if it were written like: $tmp = $write==0 ? "auto" : "hidden"; $tmp = isset($ad) and $tmp; echo $tmp; Quote Link to comment Share on other sites More sharing options...
Barand Posted January 12, 2013 Share Posted January 12, 2013 (edited) nm Edited January 12, 2013 by Barand Quote Link to comment Share on other sites More sharing options...
Manixat Posted January 12, 2013 Author Share Posted January 12, 2013 Well I've been using "AND" all the time and never experienced any issues, however this was the case here, I guess I have just been lucky. Thanks! 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.