第一个肯定是可行的,但下面哪一个是有效的方式?
switch($type) { case 1: print 'success'; break; case 2: print 'success'; break; case 3: print 'success'; break; case 4: print 'success for type 4'; break; }
由于1,2和3打印相同,我可以这样做吗?
switch($type) { case 1, 2, 3: print 'success'; break; case 4: print 'success for type 4'; break; }
要么
switch($type) { case 1: case 2: case 3: print 'success'; break; case 4: print 'success for type 4'; break; }
Nescio.. 19
switch($type) { case 1: case 2: case 3: print 'success'; break; case 4: print 'success for type 4'; break; }
是要走的路!
switch($type) { case 1: case 2: case 3: print 'success'; break; case 4: print 'success for type 4'; break; }
是要走的路!