php get all php files in a directory
foreach(glob('includes/*.php') as $file) {
...
}
php get all php files in a directory
foreach(glob('includes/*.php') as $file) {
...
}
root directory in php
function getHtmlRootFolder(string $root = '/var/www/') {
// -- try to use DOCUMENT_ROOT first --
$ret = str_replace(' ', '', $_SERVER['DOCUMENT_ROOT']);
$ret = rtrim($ret, '/') . '/';
// -- if doesn't contain root path, find using this file's loc. path --
if (!preg_match("#".$root."#", $ret)) {
$root = rtrim($root, '/') . '/';
$root_arr = explode("/", $root);
$pwd_arr = explode("/", getcwd());
$ret = $root . $pwd_arr[count($root_arr) - 1];
}
return (preg_match("#".$root."#", $ret)) ? rtrim($ret, '/') . '/' : null;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us