PHP:Codeigniter 样式 url:s?

发布于 2024-09-13 00:46:52 字数 164 浏览 3 评论 0原文

我正在寻找一些有关如何为我自己的 PHP Pet 应用程序创建 URL 重写 CodeIgniter 功能的帮助。 我知道 .htaccess 文件发挥了一部分作用,但是根据 URI 处理 URL 分割和控制器/方法调用的 PHP 文件看起来如何呢?

非常感谢您的帮助!

I am looking for some help on how to create the sort of URL-rewriting CodeIgniter features for my own PHP pet application.
I know that the .htaccess-file does one part of the magic, but how does a PHP file looks that handles the URL splitting and calling of controllers/methods accordingly to the URI?

Thanks a lot for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

她比我温柔 2024-09-20 00:46:52

这是 phpro.org 上的一个很好的教程:

模型视图控制器 MVC

您需要查看 router 类。如果您阅读整个教程,事情就会变得更加清楚。

Here is a good tutorial on phpro.org:

Model View Controller MVC

You need to have a look at router class. Things will be much clear if you read entire tutorial.

淡淡的优雅 2024-09-20 00:46:52

MicroMVC 中,我这样做是为了获取页面的 URL:

function uri()
{
//The SERVER values to look for the path info in
$server = array('PATH_INFO', 'REQUEST_URI', 'ORIG_PATH_INFO', 'REDIRECT_URL');

// Try each server var for the page URL
foreach($server as $item)
{
    if( ! empty($_SERVER[$item]) AND $uri = trim($_SERVER[$item]))
    {
        // Remove the query string (if given)
        $uri = parse_url($uri, PHP_URL_PATH);

        if($uri)
        {
            return $uri;
        }
    }
}
}

您还可以查看 gluephp 项目。

In MicroMVC I do this to get the URL of the page:

function uri()
{
//The SERVER values to look for the path info in
$server = array('PATH_INFO', 'REQUEST_URI', 'ORIG_PATH_INFO', 'REDIRECT_URL');

// Try each server var for the page URL
foreach($server as $item)
{
    if( ! empty($_SERVER[$item]) AND $uri = trim($_SERVER[$item]))
    {
        // Remove the query string (if given)
        $uri = parse_url($uri, PHP_URL_PATH);

        if($uri)
        {
            return $uri;
        }
    }
}
}

You can also look at the gluephp project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文