PHP built in server, any way to configure it to show files of directory?

前端 未结 4 2019
醉梦人生
醉梦人生 2021-01-04 18:14

As yous may be aware, as of PHP 5.4 there is built in server available. However, if you browse to directory with no \"index\" file, instead if listing all available files/di

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-04 18:55

    php -S localhost:4443 -t . route.php

    route.php :

    $f=preg_replace('/\/$/','',__DIR__."{$_SERVER['REQUEST_URI']}");
    if(is_dir($f)){
    $abf=preg_replace('/\/$/','',$_SERVER['REQUEST_URI']);
    $fs=glob("$f/*");
    foreach($fs as $one){
        $one=str_replace($f.'/','',$one);
        echo "$one
    "; } return true; }else{ return false; }

提交回复
热议问题