0
Guys to work with whole numbers what’s the best and the lightest? Switch or If
<?php if($lndet['tamanho'] == 0){ ?>
<td><input type="radio" name="tamanho" id="8.50" value="250GR" required="required"> 250GR </button></td>
<td><input type="radio" name="tamanho" id="10.50" value="400GR" required="required"> 400GR </button></td>
<td><input type="radio" name="tamanho" id="13.50" value="600GR" required="required"> 600GR </button></td>
<?php }elseif($lndet['tamanho'] == 1) { ?>
<td><input type="radio" name="tamanho" id="7.50" value="2 RECHEIOS" required="required"> 2 RECHEIOS </button></td>
<td><input type="radio" name="tamanho" id="10.50" value="4 RECHEIOS" required="required"> 4 RECHEIOS </button></td>
<td><input type="radio" name="tamanho" id="14.00" value="6 RECHEIOS" required="required"> 6 RECHEIOS </button></td>
<?php }elseif($lndet['tamanho'] == 2){ ?>
I use it this way shown above and it repeats itself until the $lndet['tamanho'] == 30
is correct or is it better to use the Switch?
Edited question, please take a look again
– Alfredo Lima
Good evening, this is the third time I’ve said this, don’t use the Stacksnippet unnecessarily, see the real reason for using it: http://meta.pt.stackoverflow.com/a/4463/3635 - I’m sure you’ll take my comment as a constructive criticism.
– Guilherme Nascimento
If you help understand: "stack snippet" is the icon with
< >
within a page. "code" is the square bracketed icon{ }
. The first is used for self-contained HTML + JS + CSS (which can be executed directly). The second is for all other code cases (languages other than HTML + JS + CSS or even these, if they are an isolated piece that is not executable). When in doubt use the icon{ }
to format your code.– Bacco
I started using it because several times I put my code in the other he just didn’t display.
– Alfredo Lima
@Alfredolima you should be using the
\
`ao invés do Ctrl+K (ou o icone de
{ }`), Just select the text that is code and press Ctrl+K, as I said already has a question mark on the side when this writing that has formatting tips. I hope the tips help.– Guilherme Nascimento
a quick answer on the question: None is more "light", the difference in performance will rarely be felt, you should take into account the case of need, note that
if
can do things thatswitch
cannot, however will have times that switch will be more practical (combine thecases
for example).– Guilherme Nascimento
Could you explain why this question is not a duplicate? If you think this is not a duplicate (and would like to have the question reopened), I recommend editing the question explaining why, in particular explaining what weighting you have and which is not addressed in the other question.
– Victor Stafusa