note 114418 added to control-structures.declare
| From: | php at niekbosch dot nl | Date: | Tue, 18 Feb 2014 16:17:57 +0000 |
| Subject: | note 114418 added to control-structures.declare | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198543@lists.php.net to get a copy of this message | ||
Basically 'declare( encoding = .... );' overrides the zend.script_encoding configuration
option (as set in php.ini). However, keep in mind that:
* the file encoding must be compatible (at least in the ASCII range of characters) to the
zend.script_encoding setting. If you set 'zend.script_encoding' to UTF-8 and save the file
in UTF-16, PHP will not be able to interpret the file, let alone the declare statement. As long as
you use ASCII compatible encodings (i.e. ISO-8859-1(5), UTF-8 etc) for both the file encoding as the
zend.script_encoding, you should be fine. (However, I have not experimented with adding non-ascii
characters in comments above the declare statement).
* PHP string literals are converted from your source code encoding (either set with the declare
statement or else according to zend.script_encoding) to the mbstring.internal_encoding as set in
your php.ini (even if you change the setting using mb_internal_encoding). As an example:
php.ini:
mbstring.internal_encoding = UTF-8
test.php:
<?php
declare(encoding = 'ISO-8859-15');
mb_internal_encoding( 'ISO-8859-15' );
echo 'aäaÃ' . "\n";
?>
This will still output the string UTF-8 encoded; in a terminal/browser with encoding
'ISO-8859-15' the string will look (something) like this: aÃâ¬aÃÂ
----
Server IP: 83.137.20.135
Probable Submitter: 188.207.83.48
----
Manual Page -- http://php.net/manual/en/control-structures.declare.php
Edit -- https://master.php.net/note/edit/114418
Del: integrated -- https://master.php.net/note/delete/114418/integrated
Del: useless -- https://master.php.net/note/delete/114418/useless
Del: bad code -- https://master.php.net/note/delete/114418/bad+code
Del: spam -- https://master.php.net/note/delete/114418/spam
Del: non-english -- https://master.php.net/note/delete/114418/non-english
Del: in docs -- https://master.php.net/note/delete/114418/in+docs
Del: other reasons-- https://master.php.net/note/delete/114418
Reject -- https://master.php.net/note/reject/114418
Search -- https://master.php.net/manage/user-notes.php