检查URL是否为图片地址 getimagesize()
Function check_img($file) {
$x = getimagesize($file);
switch ($x['mime']) {
case "image/gif":
$response = 'this is a gif image.';
break;
case "image/jpeg":
$response = 'this is a jpeg image.';
break;
case "image/png":
$response = 'this is a png image.';
break;
default:
$response = 'This is not a image file.';
break;
}
return $response;
}
echo check_img('http://www.example.com/image.jpg');
页面跳转
function Redirect($url, $permanent = false)
{
if (headers_sent() === false)
{
header('Location: ' . $url, true, ($permanent === true) ? 301 : 302);
}
exit();
}
Redirect('http://www.google.com/', false);