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
php //PHP Script to find Document Root of Application $docroot = getenv("DOCUMENT_ROOT"); echo $docroot; ?> As per above PHP script actual DOCUMENT ROOT of application will be stored in $docroot variable which can be used further in application.
$_SERVER['DOCUMENT_ROOT'] returns. The document root directory under which the current script is executing, as defined in the server's configuration file.
You can change this permanently by hacking internal Finder options (Google for details), or more simply to make an occasional change, just use the "Go > Go to folder" menu option which will let you open hidden folders directly by name.
The document root is the folder where the website files for a domain name are stored. Since cPanel allows for multiple domain names (addon domains and subdomains), you need to have a unique folder for each domain.
$files = glob($_SERVER["DOCUMENT_ROOT"]."/myFolder/*");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With