drwn65609 2011-02-10 20:19
浏览 33
已采纳

从'http://someplace.com/index.php/foo'中获取'/ foo'

As far as I know php has an function to get the '/foo/bar/' out of a URL like: 'http://someplace.com/index.php/foo/bar/'

Can't remember what the function is called.

[edit]

I remember using something like this in ExpressionEngine (see this). And later coming over an article explaining such a function build in PHP. However I can't recall what it was.

[edit #2]

I know that there are functions to get out the URL and several to manipulate it. However I clearly remember that there were one function doing just this specific thing. Look at the ExpressionEngine example I linked to too get a better understanding of what I mean.

[edit #3]

It wasn't ExpressionEngine I had used. It was CodeIngniter. But it's basically the same thing.

[edit #4]

Maybe I am wrong. I just remembering walking over just such a function in an article once... Case closed (unless someone stumble upon just such a function).

  • 写回答

4条回答 默认 最新

  • dongshiru5913 2011-02-10 20:22
    关注

    I believe you are looking for parse_url.

    parse_url('http://someplace.com/index.php/foo');
    /*
    Array
    (
        [scheme] => http
        [host] => someplace.com
        [path] => /index.php/foo
    )
    
    */
    

    You can then manipulate the path item to remove /index.php.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?