note 46778 deleted from function.php-check-syntax by nlopess

From: Date: Thu, 08 Dec 2005 16:49:03 +0000
Subject: note 46778 deleted from function.php-check-syntax by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-99760@lists.php.net to get a copy of this message
Note Submitter: dan dot ostrowski at gmail dot com ---- 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

« previous php.notes (#99760) next »