With the risk to blame myself to the bones, I still ask the question: Is there anything like "andif" in php or how could I solve the below in an elegant way?
Scenario: First test, if true, do some processing (e.g. contact server), then have a second test, do something ... have third test, and then do the result or -- if any of the above fail -- always output the same failure.
Instead of repeating the else statement every time ...
if ( ....) {
contact server ...
if ( ... ){
check ...
if ( ... ) {
success ;
} else { failure ... }
} else { failure ... }
} else { failure ... }
.. I look for something like that:
if ( ...) {
do something...
andif ( test ) {
do something more ...
andif ( test) {
do }
else {
collective error }
In a function I can use a 'fall through' simulation with return in case of success:
function xx {
if {... if {... if {... success; return; }}}
failure
}
.. but in the main program?
Aucun commentaire:
Enregistrer un commentaire