GET变量和漂亮的URL [英] GET variables and pretty urls

查看:94
本文介绍了GET变量和漂亮的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这是一个noob问题,但在这里。



我试图在PHP中更好地理解$ _GET变量。很多CMS等都将site.com/?ID=42这样的东西转换成类似site.com/42的东西。

我的问题是,$ _GET变量会发生什么当这个情况发生时?我尝试在页面加载时打印GET数组,并且它是空的。

解决方案

如果您以这种方式传递参数,不再是GET变量,因为它们不是使用传统的 GET语法传递的。它们只是URL的一部分,将由您正在使用的CMS框架进行分析。

然而,如果您碰巧传递了传统GET变量并且想要在服务器上阅读它,则必须查阅CMS的文档。如果框架要使用漂亮的URL,它可能也会删除任何GET变量,因为它们不再是必需的。例如,CodeIgniter MVC框架(它本身不是CMS,但可用于构建它们)执行此操作。


i think this is a bit of a noob question, but here goes.

I am trying to get a better understanding $_GET variables in PHP. A lot of CMS's etc convert things like site.com/?ID=42 into something like site.com/42

My question is, what happens to the $_GET variables when this happens? I try and print the GET array on page load, and it is empty.

解决方案

If you pass arguments this way, they will no longer be GET variables as they are not passed using the traditional ? GET syntax. They are just part of the URL, which will be parsed by the "CMS" framework you are using.

However, if you happened to pass a "traditional" GET variable and want to read it on the server, you would have to consult the CMS's documentation. If the framework is going to use pretty URL's it will probably also remove any GET variables, as they are no longer necessary. For example, the CodeIgniter MVC framework (not a CMS on its own, but may used to build them) does this.

这篇关于GET变量和漂亮的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆