Jump to content

clean code?


php_b34st

Recommended Posts

That was going to be my suggestion too :P

Can you tell me though, with the case what if you have a multi line block of code to run in each case do you just put it in parenthesis with the break inside it? I can't remember and haven't done it in a while (but I'm going to switch most of my site over the the switch, case, default method of comparisons soon).

Link to comment
https://forums.phpfreaks.com/topic/118813-clean-code/#findComment-611790
Share on other sites

That was going to be my suggestion too :P

Can you tell me though, with the case what if you have a multi line block of code to run in each case do you just put it in parenthesis with the break inside it? I can't remember and haven't done it in a while (but I'm going to switch most of my site over the the switch, case, default method of comparisons soon).

Would be:

<?php

switch($positoin){

   case 1: $style = 'A lot
of code';
   echo 'A lot of code';
   break;

   case 1: $style = 'A lot
of code';
   echo 'A lot of code';
   break;

   case 1: $style = 'A lot
of code';
   echo 'A lot of code';
   break;

   case 1: $style = 'A lot
of code';
   echo 'A lot of code';
   break;
}
?>

No { } needed

Link to comment
https://forums.phpfreaks.com/topic/118813-clean-code/#findComment-611792
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.