Yes. To use variables from outside do this: function addslashes2($value) { return addslashes($value); } $username = addslashes2($username); PHP:
but my function lives in another file, i was reading that you can use static variables to replace globals, is this true?
use pass by reference : e.g. $a=3; ref($a); function ref(& $v){ $v=$v+1; } echo $a; Code (markup): or most commonly used by globals global $a; $a=3; ref(); function ref(){ global $a; $a=$a+1; } echo $a; Code (markup):