Home > Backend Development > PHP Tutorial > PHP 使网站进行跨域访问

PHP 使网站进行跨域访问

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:28:46
Original
1151 people have browsed it

如果需要从不同的服务器(不同域名)上获取数据就需要使用跨域 HTTP 请求。

跨域请求在网页上很常见。例如网页从不同服务器上载入 CSS , 图片,Js 脚本等。

浏览器中,为了数据的安全,所有请求被严格限制在同一域名下,如果需要调用不同站点的数据,需要通过跨域来解决。

<?phpheader("Access-Control-Allow-Origin: *");header("Content-Type: application/json; charset=UTF-8");?>
Copy after login


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