I have the following doubt, I have an if that if it is a process it shows some things but if it is any other it shows other things. At a glance like this:
<?php
if($proceso == 'Tp'){
echo "Todo esto que ve TP";
}
else{
echo "Todas estas cosas que ven los otro";
}
?>
How can I add a process that sees what 'Tp' sees and what the others see, that Tp sees what Tp sees, the others see their things and that new specific process sees what Everyone sees and what the others see?
Is it with an if or do I have to use a Switch?
Case 1 ve esto
Case 2 ve esto
Default Case 1 Case 2
I didn't find it, but can I set a case to see what other Cases see and for default to ring what case 1 and case 2 have?
If it looks bad, excuse me, I'm from a cell phone and I don't see if what is code fits well.
Something like what you propose, using
switch
, would be a bit tedious, since if we remove the statementbreak
, after eachcase
, we can execute the following sections untildefault
.An example of this would be:
What we have done is remove all the statements
break
, which allows one tocase
skip to the other, ignoring whether or not the condition is met .What is the problem?
Short answer: Preconditions for the value we are evaluating are ignored.
What will give us as a result:
Ignoring the condition:
Solution
The solution, closest to what you are looking for, would consist of doing something like this:
What we have done is summarize the processes of the
case
functions and run them all in thedefault
.In this way, reusing, we would obtain as a result: