Re: [PHP] Syntax
- Date: Wed, 23 Sep 2015 13:24:42 +0200
- From: "B. Aerts" <ba_aerts@xxxxxxxxx>
- Subject: Re: [PHP] Syntax
On 23/09/15 09:33, Karl DeSaulniers wrote:
And on a side note, what is up with the default on a switch statement?
That thing always fires no matter what, I essentially never use it because of this.
The default should fire if none of the preceding tests pass.
Of course, if the last test doesn't hold a 'break', the default will be
executed too, as any test that doesn't terminate with a break.
test 'A' :
// code for condition 'A'
test 'B' :
// code for condition 'B'
// *** mind the missing 'break ;' ***
// code for condition 'C'
If condition equals 'B', this will run both the code for 'B' and the
If condition equals 'C', it will run the default code only.
Sure you haven't omitted a break before your default-always-firing
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php