Server Document Root Path in PHP [closed]

这一生的挚爱 提交于 2019-11-27 17:22:51

问题


I have a php code line like below

$files = glob('myFolder/*');

I want to use absolute path to myFolder in above by using server document root, like below

$_SERVER["DOCUMENT_ROOT"]."/myFolder/"

It should be like below

$files = glob('$_SERVER["DOCUMENT_ROOT"]."/myFolder/*"');

But this is not working

How to correct this?

Actually I am trying to do this:

<?php
//Delete All files from folder
// $files = glob('myFolder/*');

$files = glob($_SERVER["DOCUMENT_ROOT"]."/myFolder/*");

foreach($files as $file){
if(is_file($file))
unlink($file);
} 
?>

Code below is working

$files = glob('myFolder/*');

This below is not working

$files = glob($_SERVER["DOCUMENT_ROOT"]."/myFolder/*");

I want to use absolute path to myFolder


回答1:


$files = glob($_SERVER["DOCUMENT_ROOT"]."/myFolder/*");



来源:https://stackoverflow.com/questions/15211231/server-document-root-path-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!