|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-07-15 17:31 UTC] php-bugs at thequod dot de
Description: ------------ I could not find (useful) documentation for the "enable-zend-multibyte" configure option. It is mentioned to be a requirement for declare(encoding) [1], but a) apparently the Windows builds do not have it enabled (according to phpinfo output b) I cannot see how this can get detected on runtime (e.g. via some defined function) - I need to know if declare(encoding) processing is being done or not (and convert source files manually if declare(encoding) is ignored). [1] http://php.net/manual/en/control-structures.declare.php PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 21:00:02 2025 UTC |
Hi, sadly the multibyte mode isn't exposed, so the only way to check for it is by sniffing phpinfo() which is really hacky. I wrote up a small script for you to see what I mean by hacky: <?php $zend_multibyte = false; ob_start(); phpinfo(INFO_GENERAL); $buffer = ob_get_clean(); $pos = strpos($buffer, 'Zend Multibyte'); $buffer = substr($buffer, $pos); if(PHP_SAPI == 'cli') { $buffer = ltrim($buffer); $zend_multibyte = (trim(substr($buffer, 25, strpos($buffer, "\n") - 25)) == 'enabled'); } else { $zend_multibyte = (trim(strip_tags(substr($buffer, 28, strpos($buffer, "</tr>") - 28))) == 'enabled'); } unset($buffer, $pos); var_dump($zend_multibyte); ?> As for the documentation, I have added a note on the declare() construct's page that its "impossible" to determine whether the build have multibyte support or not.Someone on internals requested I added this here: «The problem in 5.3 is not as grave as the bug report paints it, you don't need to sniff phpinfo() to see whether PHP was compiled with --enable-zend-multibyte. You can use, for instance: key_exists("detect_unicode", ini_get_all())»