Last active
February 16, 2016 09:44
-
-
Save DQNEO/09ee78f8af7f71b07db3 to your computer and use it in GitHub Desktop.
PHP5.5で、終了タグ "?>" の有無でパーサの挙動が変わるケース
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(encoding='UTF-8'); | |
/* あ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(encoding='UTF-8'); | |
/* あ */ | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ php -l a.php | |
PHP Warning: Unexpected character in input: ' in a.php on line 6 | |
$ php -l b.php | |
No syntax errors detected in b.php | |
$ php -i | grep _encoding | sort -r | |
zend.script_encoding => EUC_JP => EUC_JP | |
mbstring.internal_encoding => EUC-JP => EUC-JP | |
iconv.output_encoding => ISO-8859-1 => ISO-8859-1 | |
iconv.internal_encoding => ISO-8859-1 => ISO-8859-1 | |
iconv.input_encoding => ISO-8859-1 => ISO-8859-1 | |
$ php --version | |
PHP 5.5.12 (cli) (built: May 2 2014 19:53:49) | |
Copyright (c) 1997-2014 The PHP Group | |
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies | |
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies |
➜ php-5.5.14 ./sapi/cli/php -d zend.multibyte=On -d zend.script_encoding="EUC_JP" /vagrant/a.php
Warning: Unexpected character in input: ' in /vagrant/a.php on line 6
[Wed Jul 23 13:54:03 2014] Script: '/vagrant/a.php'
/home/vagrant/src/php-5.5.14/ext/mbstring/mbstring.c(612) : Freeing 0x7F34B19D51B0 (109 bytes), script=/vagrant/a.php
=== Total 1 memory leaks detected ===
➜ php-5.5.14 ./sapi/cli/php -v
PHP 5.5.14 (cli) (built: Jul 23 2014 13:46:57) (DEBUG)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
php5.7.0-devでも発生
➜ php-src git:(master) ./sapi/cli/php -d zend.multibyte=On -d mbstring.internal_encoding="EUC_JP" /vagrant/a.php
Warning: Unexpected character in input: ' in /vagrant/a.php on line 6
➜ php-src git:(master) ./sapi/cli/php -v
PHP 5.7.0-dev (cli) (built: Jul 23 2014 15:45:55) (DEBUG)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.7.0-dev, Copyright (c) 1998-2014 Zend Technologies
本家にissue登録した。
https://bugs.php.net/bug.php?id=67681
PHP 5.6.17でも発生。
PHP7.0.3 だと直っていた。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PHP 5.4でも再現した。