Hi Guys,
What does this function do?
function filterData($data){
if(is_array($data))
$data = array_map("filterData", $data);
else
$data = htmlentities($data, ENT_QUOTES, 'UTF-8');
return $data;
}
Hi Guys,
What does this function do?
function filterData($data){
if(is_array($data))
$data = array_map("filterData", $data);
else
$data = htmlentities($data, ENT_QUOTES, 'UTF-8');
return $data;
}
This escapes data for output to the browser.
If an array is passed then it uses recursion. Calling the same function for each array key value.
Thanks Chris! I assumed the same thing, but was not sure about the recursion.
I’ll never understand why the set variables in functions when they can just return…
function encodeHtml ( $data ) {
if ( is_array( $data ) )
return array_map( __FUNCTION__, $data );
return htmlentities( $data, ENT_QUOTES, 'UTF-8' );
}
Probably just me but I find that a little more clear and readable. Maybe…