Tag Info

New answers tagged

3

To draw the line between exceptions and return values, I would try to stick to the following: - Anytime an instruction breaks the expected flow of execution, you expect an error to be thrown. - If the expected function of procedure may have different outcomes, you will want to work with return values. In the examples that you are stating, it seems very ...


1

The first thing I can suggest you is to take out the Logic from Mark-up or basically avoid to write in-line logic in your mark-up. So you can re-write your first example like this: if ( in_array('name', $error) ) { $class = 'form-error'; } else { $class = null; } // or ... $class = in_array( 'name', $error ) ? 'form-error' : null; if ( isset($name) ...


4

You should consider that alternative systems can also be acceptable design decisions. Shells: 0 exit status is true, non-zero is false The example of shells treating a 0 exit status as true has already been mentioned. $ ( exit 0 ) && echo "0 is true" || echo "0 is false" 0 is true $ ( exit 1 ) && echo "1 is true" || echo "1 is false" 1 is ...



Top 50 recent answers are included