Basic IF Question

Hi all,
Just wondering what these snippets actually mean, am I right in saying:

<?php if ($smart): ?>
<p>If $smart has a value, show this paragraph else don't show anything</p>
<?php endif; ?>
<?php if ($smart || $desktop): ?>
<p>If $smart and $desktop both have values, show this paragraph else don't show anything</p>
<?php endif; ?>

Are these simply shorthand if statements?
And what does || mean?

Thanks
Barry

http://php.net/manual/en/control-structures.alternative-syntax.php

http://php.net/manual/en/language.operators.logical.php

:cool:

Just what I thought, just tried this locally, works great, thanks for the links.

Not completely. It will show the text if $smart is set and has a “positive value”. For example, if $smart is set to false the text won’t show.
Please be aware that doing it this way can cause an E_NOTICE warning if $smart isn’t set at all. Better would be to check for isset($smart) to check if it has any value, or !empty($smart) to check check if it has any value and that value is not negative.

You may want to look those up in da manual: [fphp]isset[/fphp], [fphp]empty[/fphp]

|| means OR,
&& means AND