$_GET and URL Rewriting for PHP(PHP 的 $_GET 和 URL 重写)
问题描述
URL 重写如何影响 PHP 的 $_GET 参数?
假设我有一个像 http://example.com/index.php?p=contact
这样的 URL,我使用 $_GET['p']
来告诉index.php
提供联系页面.如果我使用重写规则将 URL 转换为 http://example.com/contact
,$_GET['p']
是否仍能按预期工作?>
如果是这样,你能详细说明它为什么起作用吗?如果不是,可以使用什么策略来解决问题,以便页面在重写和不重写的情况下都能正常工作?
是的,这会按预期工作.
How does URL rewriting affect the $_GET
parameter for PHP?
Say I have a URL like http://example.com/index.php?p=contact
and I use $_GET['p']
to tell index.php
to serve the contact page. If I use a rewrite rule that converts the URL to http://example.com/contact
, will $_GET['p']
still work as expected?
If it does, could you elaborate on why it works? If not, what strategies could be used to solve the problem so that the page will work both with and without the rewrite?
Yes, that will work as expected.
这篇关于PHP 的 $_GET 和 URL 重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP 的 $_GET 和 URL 重写


- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- PHP - if 语句中的倒序 2021-01-01