PHP Ajax 跨域请求允许多个域名

    $origin = isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN'] : '';
    $allow_origin = array(
        'http://a.com',
        'http://b.com'
    );
    if(in_array($origin, $allow_origin)){
        header('Access-Control-Allow-Origin:'.$origin);
    }
    header("Access-Control-Allow-Credentials: true");
    header('Access-Control-Allow-Headers: X-Requested-With, Content-Type');