I’m going to try and focus some time on building out the PHP section of the site now – here’s a useful technique, in shortening and tidying various cases of if/then/else.
This simply operates as:
Consider the following code:
We can shorten this using the ternary operator:
Or even:
For more information, see http://uk.php.net/ternary. This is supported in both PHP4 and PHP5
Tags: PHP, rand, ternary operator
You must be logged in to post a comment.