Hello all,
I am trying to create a function that will take a var and see if it is defined if so then it displays that var value, if its undefined then it does not display any value.
This would allow me to have one form and have it be able to be used for new input and editing of old input, see when I get data from the db I convert it to the input names so they would be the same var?
this is what I got so far:
<?php
function isset_var($var)
{
if(isset($var))
{
return( $var );
}
else
{
$var = '';
return($var);
}
}
// $test = 'test';
echo isset_var($test);
?>
if you notice I have a var called $test now when I don't have it blocked it works the way it should, but when I // the var $test then it gives me the following error:
Notice: Undefined variable: test in /home/dev/www/query/isset_var.php on line 18
So the question is how can I do this so that I don't have to have on every input field a if(isset($...)){echo $...;}
Thanks for any advice with this piece of code!
Sincerely,
christopher