Reputation: 53
Currently I want to check if a specific file be used in php project
$target = "foobar.php";
$ beUsed = checkFile($target);
function checkFile($target){
//code to check be here
if (beUsed) return true;
return false;
}
thanks for reading, any help would be appreciated
Upvotes: 3
Views: 76
Reputation: 5539
You can use linux command
$target = "foobar.php";
searchFile($target);
function searchFile($target){
$file_name = basename(__FILE__);
$cmd = sprintf("grep -r --exclude='%s' %s ./* ",$file_name, $target);
$res = exec($cmd);
if($res){
echo "Exists!" . PHP_EOL;
print_r($res);
return true;
}
return false;
}
Upvotes: 2