David Saunders David Saunders - 1 year ago 111
Smarty Question

Which is better way to write an if condition in smarty?

Which is the better way to write an if condition in Smarty?


{if $searchCount > 0}


{if $searchCount}


{if $searchCount == 0}


{if !$searchCount}

Answer Source

It depends on what you want.

Example A:

  • Use this if you want to check if your $searchCount is greater than 0.

Example B:

  • Use this to check if your $searchCount is true. It's true if it's filled. No matter whats inside.

Example C:

  • This will check if $searchCount is equal to 0.

Example D:

  • Thats the opposite of Example B. There you check if $searchCount is false. It's false if its not filled or it's the bool false.

I hope this helps you to understand the operators.

See the PHP-Manual or W3-Schools for more informations.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download