David Saunders David Saunders - 2 months ago 7
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?

A



{if $searchCount > 0}


B



{if $searchCount}


C



{if $searchCount == 0}


D



{if !$searchCount}

Answer

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.

Comments