1.指定某个域名访问:
header('Access-Control-Allow-Origin:www.lihuyong.com');
2.允许多个域名访问
$origin=isset($_SERVER['HTTP_ORIGIN'])?$_SERVER['HTTP_ORIGIN']:'';
$allow_origin=array('www.lihuyong1.com','www.lihuyong2.com');
if(in_array($origin,$allow_origin)){
header('Access-Control-Allow-Origin:'.$origin);
}
3、允许所有域名访问
header('Access-Control-Allow-Origin:*');