note 80294 added to function.halt-compiler

From: Date: Tue, 08 Jan 2008 20:57:47 +0000
Subject: note 80294 added to function.halt-compiler
Groups: php.notes 
Request: Send a blank email to php-notes+get-134950@lists.php.net to get a copy of this message
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__ ---- Server IP: 64.71.164.2 Probable Submitter: 70.15.41.173 ---- Manual Page -- http://www.php.net/manual/en/function.halt-compiler.php Edit -- https://master.php.net/note/edit/80294 Del: integrated -- https://master.php.net/note/delete/80294/integrated Del: useless -- https://master.php.net/note/delete/80294/useless Del: bad code -- https://master.php.net/note/delete/80294/bad+code Del: spam -- https://master.php.net/note/delete/80294/spam Del: non-english -- https://master.php.net/note/delete/80294/non-english Del: in docs -- https://master.php.net/note/delete/80294/in+docs Del: other reasons-- https://master.php.net/note/delete/80294 Reject -- https://master.php.net/note/reject/80294 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#134950) next »