<?php
$array = [
'name' => '张三',
'age' => 30,
'city' => '北京'
];
$json = json_encode($array, JSON_UNESCAPED_UNICODE);
echo $json;
die;
$str = "<h1>Hello WorldÆØÅÆØÅÆØÅÆØÅ!</h1>";
$newstr = filter_var($str, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
echo $newstr;
die;
function myException($exception) {
echo "<b>Exception:</b> ", $exception->getMessage();
}
set_exception_handler("myException");
throw new Exception("Uncaught exception occurred!");
die;
class customException
{
public function errorMessage()
{
return 'aaaaa';
}
}
$email = "someone@example...com";
try
{
if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE)
{
throw new customException($email);
}
}
catch (customException $e)
{
echo $e->errorMessage();
}
?>