DamienRoche Posted September 29, 2008 Share Posted September 29, 2008 Hi guys! I have created a function for cleaning user input. $var1 = "what now?"; $var2 = "whatever.."; $no1 = "/\./"; $no2 = "/\?/"; function clean_field($field, $illegals){ $field1 = mysql_real_escape_string($field); if($field1 == "False" || preg_match($illegals, $field1)){$field2 = "Bad";} else {$field2 = $field1;} return $field2; } clean_field($var1, $no1); clean_field($var2, $no1); Where the return is, I can echo the variable and I can see the function is working fine. What I want to do though is output the 'clean' var into a new var. Is it possible? to clarify. I want to take $var1 ---> put it through the function ---> create a new var. Really appreciate any help with this. Thanks. Link to comment https://forums.phpfreaks.com/topic/126252-function-issue/ Share on other sites More sharing options...
ranjuvs Posted September 29, 2008 Share Posted September 29, 2008 Like this $newVar = clean_field($var1, $no1); print $newVar; The function is returning a value. You can assign the same to the new variable. Link to comment https://forums.phpfreaks.com/topic/126252-function-issue/#findComment-652832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.