php跨域

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:29:15
Original
863 people have browsed it


跨域待测<?php$ret = array(    'name' => isset($_POST['name'])? $_POST['name'] : '',    'gender' => isset($_POST['gender'])? $_POST['gender'] : '');header('content-type:application:json;charset=utf8');$origin = isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN'] : '';$allow_origin = array(    'http://www.client.com',    'http://www.client2.com');if(in_array($origin, $allow_origin)){    header('Access-Control-Allow-Origin:'.$origin);    header('Access-Control-Allow-Methods:POST');    header('Access-Control-Allow-Headers:x-requested-with,content-type');}echo json_encode($ret);?>
Copy after login

转自:


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template