- (, sqlite), @use Nev .
...
, , , ( ), .
- , , , .
,
function doMagic(){
if ($_SESSION['use_black_magic'] == true){
$_SESSION['magic_results'] = 'dead chicken';
}else{
$_SESSION['magic_results'] = 'unicorn';
}
}
$_SESSION['use_black_magic'] = false;
doMagic();
echo $_SESSION['magic_results'];
function doMagic( $use_black_magic = true ){
if ($use_black_magic == true){
return 'dead chicken';
}else{
return 'unicorn';
}
}
$magic_results = doMagic( false );
echo $magic_results;
Thus, doMagic () should not know anything about where the results should be stored, and where to find the value of the parameter. And the external code, you do not need to know that the doMagic () function does something with the $ _SESSION variables.
Once your code has grown a bit, supporting, sharing, debugging and distributing such code becomes a nightmare ...
source
share