Heim >Backend-Entwicklung >PHP-Tutorial >关于PHP的POST请求问题

关于PHP的POST请求问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:18:141282Durchsuche

比如访问一个网址 http://localhost/api/
对应的目录和文件应为 E:\www\api\index.php,因为apache设置了DirectoryIndex index.php,默认访问index.php。
通过get请求这个网址 $_SERVER['REQUEST_METHOD'] 为get,
但是通过post请求这个网址 $_SERVER['REQUEST_METHOD'] 还是为get而且得不到传输的值,
最后修改如下网址http://localhost/api/index.php,post请求才得以访问,请教一下这个是什么原因呢?

回复内容:

比如访问一个网址 http://localhost/api/
对应的目录和文件应为 E:\www\api\index.php,因为apache设置了DirectoryIndex index.php,默认访问index.php。
通过get请求这个网址 $_SERVER['REQUEST_METHOD'] 为get,
但是通过post请求这个网址 $_SERVER['REQUEST_METHOD'] 还是为get而且得不到传输的值,
最后修改如下网址http://localhost/api/index.php,post请求才得以访问,请教一下这个是什么原因呢?

你是通过是什么方式提交的,我试了一下没问题的哈!

apache的设置只是给浏览器请求的时候给他一个默认首页 在post的时候并没有将参数转发给index.php 如果要转发 可以开启apache的重写模块

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn