note 80294 deleted from function.halt-compiler by nlopess

From: Date: Tue, 08 Jan 2008 22:08:42 +0000
Subject: note 80294 deleted from function.halt-compiler by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134952@lists.php.net to get a copy of this message
Note Submitter: tmpa at yahoo dot com ---- with php 4 __COMPILER_HALT_OFFSET__ was not being defined after calling __halt_compiler(). also, the data i had after __halt_compiler(); was in fact trying to be evaluated. it seems the construct itself exists in php 4 just not implemented perhaps? i'm not sure. anyway, my solution was on my final line to put __halt_compiler();//base64_encoded data or whatever with the // to make it a comment for php 4. then when i want to read the data, i do <?php $fp = fopen(__FILE__, 'rb'); if (!$fp) { die('Couldn\'t open __FILE__'); } if (!defined('__COMPILER_HALT_OFFSET__')) { define('__COMPILER_HALT_OFFSET__', // -2 because of +2 on next line filesize(__FILE__) - 1 - $dataLength - 2); } // +2 for the // before the data for php 4 compat fseek($fp, __COMPILER_HALT_OFFSET__ + 2); // read the data with fread as needed ?> do note that you need to determine the length of your data and set $dataLength for this method to work. i should mention that this code snippet should work with php 5, which i have not had trouble with __COMPILER_HALT_OFFSET__

« previous php.notes (#134952) next »