tibberous Posted August 14, 2008 Share Posted August 14, 2008 I while ago I would have said variable variables. Now I'm going with: __halt_compiler Seriously, has anyone ever used this? I read the docs for five minutes and still don't know what it does or when I would ever use it. Variable variables are at least useful, just kind of hard to explain. Quote Link to comment https://forums.phpfreaks.com/topic/119719-most-obsure-and-hard-to-use-core-function/ Share on other sites More sharing options...
448191 Posted August 14, 2008 Share Posted August 14, 2008 Hard to use? No. Obscure? A little. Basically __halt_compiler() is used to insert binary data into the same file PHP code is in. Apparently it's pretty useful in combination with Phar. I've never used it though. Quote Link to comment https://forums.phpfreaks.com/topic/119719-most-obsure-and-hard-to-use-core-function/#findComment-616806 Share on other sites More sharing options...
tibberous Posted August 14, 2008 Author Share Posted August 14, 2008 Really, that's all it does? Maybe it's just poorly named and documented? Quote Link to comment https://forums.phpfreaks.com/topic/119719-most-obsure-and-hard-to-use-core-function/#findComment-616848 Share on other sites More sharing options...
448191 Posted August 14, 2008 Share Posted August 14, 2008 No, it's perfectly named. It halts the compiler, so you can insert arbitrary data after it. It also defines a constant which corresponds to the line number the compiler is halted at. I think the example from the manual is pretty clear about it: <?php // open this file $fp = fopen(__FILE__, 'r'); // seek file pointer to data fseek($fp, __COMPILER_HALT_OFFSET__); // and output it var_dump(stream_get_contents($fp)); // the end of the script execution __halt_compiler();the installation data (eg. tar, gz, PHP, etc.) Quote Link to comment https://forums.phpfreaks.com/topic/119719-most-obsure-and-hard-to-use-core-function/#findComment-616852 Share on other sites More sharing options...
tibberous Posted August 14, 2008 Author Share Posted August 14, 2008 So the file opens itself, then outputs itself... I still don't get it... Quote Link to comment https://forums.phpfreaks.com/topic/119719-most-obsure-and-hard-to-use-core-function/#findComment-616891 Share on other sites More sharing options...
corbin Posted August 14, 2008 Share Posted August 14, 2008 No. In that example, it would output the installation data (eg. tar, gz, PHP, etc.) Quote Link to comment https://forums.phpfreaks.com/topic/119719-most-obsure-and-hard-to-use-core-function/#findComment-616936 Share on other sites More sharing options...
tibberous Posted August 15, 2008 Author Share Posted August 15, 2008 I tried it - I kind of get what it does... it lets you print <?php without escaping it. Why would you use it though? I think I might get how you'd use it... I still stand by my claim Quote Link to comment https://forums.phpfreaks.com/topic/119719-most-obsure-and-hard-to-use-core-function/#findComment-617086 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.