note 51896 deleted from function.include by peehaa
| From: | peehaa@php.net | Date: | Fri, 09 Dec 2016 22:55:00 +0000 |
| Subject: | note 51896 deleted from function.include by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208399@lists.php.net to get a copy of this message | ||
Note Submitter: gillis dot php at TAKETHISAWAY dot gillis dot fi
----
This is not directly linked to the include function itself. But i had a problem with dynamically
generated include-files that could generate parse errors and cause the whole script to parse-error.
So as i could not find any ready solution for this problem i wrote the mini-function. It's not
the most handsome solution, but it works for me.
<?php
function ChkInc($file){
if(substr(exec("php -l $file"), 0, 28) == "No syntax errors detected in"){
return true;
}else{
return false;
}
}
?>
if someone else has a better solution, do post it...
Note. remember that this function uses unchecked variables passed to exec, so don't use it for
direct user input without improving it.
//Gillis Danielsen