note 46778 modified in function.php-check-syntax by sean
| From: | sean@php.net | Date: | Sat, 23 Oct 2004 03:33:29 +0000 |
| Subject: | note 46778 modified in function.php-check-syntax by sean | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78977@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( );
}
?>
**Editor's note: (sean)
Agreed, this function is poorly documented, but there is no clear direction for the docs, see:
http://bugs.php.net/27728
and
http://bugs.php.net/27406
--was--
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( );
}
?>
http://php.net/manual/en/function.php-check-syntax.php