Req #52348 [ReO->Csd]: Ability to detect zend multibyte mode at runtime
| From: | Kalle@php.net | Date: | Thu, 11 Nov 2010 01:44:18 +0000 |
| Subject: | Req #52348 [ReO->Csd]: Ability to detect zend multibyte mode at runtime | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-155935@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52348&edit=1
ID: 52348
Updated by: Kalle@php.net
Reported by: php-bugs at thequod dot de
Summary: Ability to detect zend multibyte mode at runtime
-Status: Re-Opened
+Status: Closed
Type: Feature/Change Request
Package: PHP options/info functions
PHP Version: 5.3.3RC3
Assigned To: kalle
Block user comment: N
New Comment:
Added, this will be available in PHP 5.3.4+ ;-)
Previous Comments:
------------------------------------------------------------------------
[2010-11-11 02:43:55] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=305266
Log: Added new constant; ZEND_MULTIBYTE to check whether PHP was
compiled using --enable-zend-multibyte or not instead of sniffing
phpinfo() (FR #52348)
------------------------------------------------------------------------
[2010-10-23 19:14:02] kalle@php.net
Done, I can add such a constant to the 5.3 branch and trunk sometime
this weekend
------------------------------------------------------------------------
[2010-10-23 17:46:17] php-bugs at thequod dot de
Thank you!
Can you forward / re-assign the bug maybe so that it is possible to
detect this during runtime, please?
Please leave a short reply, if you won't do it, so I will do this.
------------------------------------------------------------------------
[2010-10-23 15:19:57] kalle@php.net
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.
------------------------------------------------------------------------
[2010-10-23 15:19:49] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=304658
Log: Added remark about zend-multibyte mode, that its only exposed by
phpinfo() (Bug #52348)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=52348
--
Edit this bug report at http://bugs.php.net/bug.php?id=52348&edit=1