26.06.2017, 18:10
Switch and if got their own usage.
If you use if in switch place it will be slow and if you use switch in if place it will be slow.
How?
Lets say you need to check for 1 and 3000 by switch you do
At this case switch used in if place and will be slow so have to use
So we get to this point switch is faster when switch is needed ( your above post declears switch example )
And if is faster when if is needed.
If you use if in switch place it will be slow and if you use switch in if place it will be slow.
How?
Lets say you need to check for 1 and 3000 by switch you do
PHP код:
switch(var)
{
case 1..3000:
{
}
default:
{
}
}
PHP код:
if(0 < var < 3001)
{
}
And if is faster when if is needed.