I often get in this situation where I have an if statement and I can't deside where to put it. As a wrapper around the function or inside the function?
Is one of the two solutions here better than the other? If so, why?
Solution 1
function one($something) {
if( $something === 'yes') {
two();
}
}
function two() {
echo 'ok';
}
one('yes');
Solution 2
function one($something) {
two($something);
}
function two($something) {
if( $something === 'yes') {
echo 'ok';
}
}
one('yes');
Aucun commentaire:
Enregistrer un commentaire