note 51896 added to function.include

From: Date: Thu, 14 Apr 2005 09:47:42 +0000
Subject: note 51896 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-87993@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51896 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51896&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51896&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51896&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51896&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51896&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51896&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87993) next »