.html url中的$ _GET问题 [英] $_GET problem in .html url
本文介绍了.html url中的$ _GET问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的网址:
http://mysite.com/contact.html?id=5
我想在我的php文件的URL中获取id的值.我尝试 $ _ GET ['id']
,但不返回任何内容.
I want to get the value of id in the url in my php file. I try $_GET['id']
but it doesn't return anything.
我怎么得到它?
推荐答案
此处的问题是文件是 .html
而不是 .php
,因此不会由PHP解析.如果您希望PHP也可以在 .html
上运行,请将其添加到您的 .htaccess
文件中:
The issue here is that the file is .html
instead of .php
, so it will not be parsed by PHP. If you want PHP to also work on .html
, add this like to your .htaccess
file:
AddType application/x-httpd-php .html
但是,我不推荐这样做,因为它不是真正的标准.在大多数情况下,最好将文件重命名为 .php
.
I wouldn't recommend it, though, since it's not really standard. In most cases, you're better off just renaming the file to .php
.
这篇关于.html url中的$ _GET问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文