note 46778 added to function.php-check-syntax
| From: | dan dot ostrowski at gmail dot com | Date: | Fri, 22 Oct 2004 21:50:54 +0000 |
| Subject: | note 46778 added to function.php-check-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78961@lists.php.net to get a copy of this message | ||
This function is not documented all that well. The point they leave out is that php_check_syntax
INCLUDES THE FILE for you as of php 5.0.2. Not only that, but even if you use include_once( ) it
will still give a redeclaration error. ( Provided of course, there's something declared in the
file in question ).
It does NOT, as one might be led to believe, check the syntax just to let you know whether it's
valid or not.
This will try to include the file twice, despite the fact that include_once is used:
<?php
$filename = '/path/to/whatever.php';
$errs = (string) null;
if( php_check_syntax( $filename, $errs ) ) {
// include
include_once( $filename ); // REDECLARATION ERROR
} else {
print "Syntax error";
die( );
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.php-check-syntax.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46778
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46778&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46778&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46778&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46778&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46778&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46778&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46778&report=yes
Search -- http://master.php.net/manage/user-notes.php