I am a little versed in functions to understand their use a little more. I ran into a problem that I cannot find the answer to, well, at least I cannot relate this problem.
<?php
$firstName = "foo";
$surname = "bar";
function myName ($firstName, $surname) {
echo "Hello $firstName $surname. <br>";
}
myName($firstName, $surname);
?>
As you can see if both $ firstName and $ username exist, everything is fine, however, if $ surname does not exist and the script is somewhere else, which leads the information to only verify the existence of $ first_name, then the function will fail.
So my question is how can I check inside the function if there are values for both variables and is there a way to prevent it from crashing in the event, for example, that there is only $ firstName.