Eggzorcist Posted September 29, 2008 Share Posted September 29, 2008 So let say I have a function like this: function secure_var($var){ mysql_real_escape_string(htmlentities($var)) } if I do: secure_var($var1,$var2,$var3); would this do for all 3 variables? thanks Quote Link to comment https://forums.phpfreaks.com/topic/126270-function-variables-help/ Share on other sites More sharing options...
redarrow Posted September 29, 2008 Share Posted September 29, 2008 yes it would pal..... <?php $a="Hi there i like php <br>"; $b="php rocks <br>"; $c="apache and php are the best <br>"; $d="i use mysql database it wicked <br>"; function name($a,$b,$c,$d){ $a=mysql_real_escape_string($_POST['a']); $b=mysql_real_escape_string($_POST['b']); $c=mysql_real_escape_string($_POST['c']); $d=mysql_real_escape_string($_POST['d']); } function name($a,$b,$c,$d); ?> Quote Link to comment https://forums.phpfreaks.com/topic/126270-function-variables-help/#findComment-652899 Share on other sites More sharing options...
.josh Posted September 29, 2008 Share Posted September 29, 2008 all you are doing is passing the values to the function, you need to run mysql_... on all of them. Also, functions have their own variable scope. You need to actually return the values, make the vars global, or pass by reference, in order for the changes to take effect. Quote Link to comment https://forums.phpfreaks.com/topic/126270-function-variables-help/#findComment-652900 Share on other sites More sharing options...
PFMaBiSmAd Posted September 29, 2008 Share Posted September 29, 2008 If you want to use Variable-length argument lists, read this - http://us.php.net/manual/en/functions.arguments.php#functions.variable-arg-list Quote Link to comment https://forums.phpfreaks.com/topic/126270-function-variables-help/#findComment-652911 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.