Professional Documents
Culture Documents
<?php
// Create a temporary file pointer
$fp = tmpfile();
// Without magic_quotes_runtime
rewind($fp);
set_magic_quotes_runtime(false);
// With magic_quotes_runtime
rewind($fp);
set_magic_quotes_runtime(true);
// Clean up
fclose($fp);
?>
Description
get_magic_quotes runtime and set_magic_quotes_runtime are useful when
you want to read some data in a binary file using fread() and some
bytes in such file may be interpreted as \ (backslash), " (double
quotes), ' (simple quote) or any "special" character that has a meaning
for string processing.
stripslashes()
<?php
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
// Example
$array = array("f\\'oo", "b\\'ar", array("fo\\'o", "b\\'ar"));
$array = stripslashes_deep($array);
// Output
print_r($array);
?>