I have a function that can either be called by echo or load, in turn also 0 or 1 for echo or load. But, since adding the number variable to the function options, it no longer always works.
Can you please help me?
Here is my function:
// GET MAIN INFORMATION
function get_info ($KEY, $OUTPUT = 0) {
$KEY = "_" . strtoupper($KEY);
if ($OUTPUT == "echo" || $OUTPUT == 0):
echo "echo " . constant($KEY);
elseif ($OUTPUT == "load" || $OUTPUT == 1):
return "load " . constant($KEY);
endif;
}
now when I try to call the function like this:
echo 1;
get_info('scripts_url', 'echo');
echo "<br>" . 2;
get_info('scripts_url', 0);
echo "<br>" . 3;
echo get_info('scripts_url', 'load');
echo "<br>" . 4;
echo get_info('scripts_url', 1);
This is my output:
1echo scripts/ (This is correct!)
2echo scripts/ (This is correct!)
3echo scripts/ (This is not correct!)
4load scripts/ (This is correct!)
So there is an issue when I try to use the numbers. Can you see the error and help me correct it?
Thanks