Delete all files or directories from specified path using php

Please find below code for remove files and directories using PHP.

$folder = “test/test2/test3”; or $folder = “test/test.txt”;
deleteDirectory($folder);
function deleteDirectory($dir) {
if (!file_exists($dir)) { return true; }
if (!is_dir($dir) || is_link($dir)) {
return unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($item == ‘.’ || $item == ‘..’) { continue; }
if (!deleteDirectory($dir . “/” . $item, false)) {
chmod($dir . “/” . $item, 0777);
if (!deleteDirectory($dir . “/” . $item, false)) return false;
};
}
return rmdir($dir);
}

How to check cURL is supported or not using PHP

<?php
/* Check for curl extension */
function _iscurlsupported() {
if (in_array (‘curl’, get_loaded_extensions())) {
return true;
}
else {
return false;
}
}

if (_iscurlsupported()) {
echo “cURL is supported\n”;
}
else {
echo “cURL isn’t supported\n”;
}
?>