I have been scripting (some may say programming) in PHP for last 5 years but never faced this issue. Interesting!
Say for example, I created a custom function with one argument:
function myFunc($arg1) {
echo $arg1;
}
Now, if I call this function without supplying any argument it doesn't give any error/warning. Any other high level language like C++ or Java would produce error in this case. So, I had to modify my code as follows:
function myFunc($arg1) {
if (!isset($arg1)) {
echo "Missing argument 1";
}
echo $s;
}
But this is annoying. Now I have to add these EXTRA lines of code in every function and class methods I have created. Is there any shortcut/easy method that the script will always produce an error if its missing any required argument? I have tried with adding error_reporting(E_ALL); at the very beginning of my code. But it still didn't work out. By the way, I am using PHP 5.3.1 on Apache/2.2.14 (Unix).
Any suggestion will be appreciated.