Jump to content

Function Issue..


DamienRoche

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.