Hey all–
I've got a function that uses data from a variable from a user. Originally it was set up as follows:
<?php
function($_POST['variable']) {
if (isset($_POST['variable']) && preg_match($_POST['variable'], $pattern)) {
//Do something
}
else {
//Do something else
}
?>
However, when I do this before giving any input, I get a notice saying that the variable isn't set. Now I realize that the notice is telling me something that I am accounting for in my function, and that the user won't see the notices when I turn off error reporting. However, the notice still makes me uncomfortable--should I be worrying about it? And, if so, how do I change it? I know that I can check to see if the variable is set before feeding it to the function, but this seems to partially defeat the purpose of having the function (if I need to re-write the same code over and over again each time I call it).
Any thoughts or advice?
Best,
–Davis