27

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

Hiroshi Rana
  • 978
  • 2
  • 9
  • 18

1 Answers1

47

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