Get a sub-directory folder in the URL and echo it .

前端 未结 3 1144
盖世英雄少女心
盖世英雄少女心 2021-01-16 20:13

How do I get the value of an URL eg. www.example.php/folders/crowd? I\'m trying to echo out crowd with PHP. I have tried using the $_SERVER [\'SCRIPTNAME\

3条回答
  •  一生所求
    2021-01-16 20:30

    To get the current directory of the file (which is just "crowd" in your "www.example.php/folders/crowd" example), use:

    $cur_dir = basename(dirname($_SERVER[PHP_SELF]))

    If you just want the file, then try this:

    $cur_file = $_SERVER[PHP_SELF];

提交回复
热议问题