# Propose changes to warning message in declare(encoding=...) when encoding is not a multibye-required encoding method

- Thread: https://externals.io/message/130741
- Original archive: https://news-web.php.net/php.internals/130741
- Started by 1372449351@qq.com on 2026-05-02T08:50:21+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #130741 — 1372449351@qq.com — 2026-05-02T08:50:21+00:00

URL: https://externals.io/message/130741#130741

Hi internals,


I am writing to ask for suggestions in bug Issue #21538 in php-src [1]. Currently when zend.multibyte=0, declare(encoding=...) will emit a warning for whatever the encoding is:


"PHP Warning: &nbsp;declare(encoding=...)&nbsp;ignored because Zend multibyte feature is turned off by settings in XXX"


And the problem is when the encoding is ASCII or UTF-8, which is, not a multibyte encoding method, the warning will still be emitted. So, if zend.multibyte=0 and you use files with declare(encoding=ASCII) it will emit the error message to make people want to remove them.


Now, since declare(encoding=UTF-8) behaves identically whether zend.multibyte is on or off, the warning is quite misleading. Also I think people might mostly use them as documenting codes to tell tools how to decode them because when zend.multibyte=0, PHP already parses source files as UTF-8 by default.&nbsp;


However, it is also reasonable to say people might want to use these warnings to check if their code bases have useless codes.


So I would suggest to change the warning message in those cases to&nbsp;


“PHP Warning: &nbsp;declare(encoding='UTF-8(or ASCII)') is useless, remove it.”


to make things clearer.


This would be a very minor change and do not worth a separate RFC. However, I think it is still important to send a email to gather opinions :) Also thank @alexdowad for giving me ideas. TiA :)


--Weilin Du


[1]: https://github.com/php/php-src/issues/21538

---

## #130805 — tim@bastelstu.be — 2026-05-08T07:44:14+00:00

URL: https://externals.io/message/130741#130805 · In reply to: #130741

Hi

Am 2026-05-02 10:50, schrieb LamentXU:
> I am writing to ask for suggestions in bug Issue #21538 in php-src [1]. 
> Currently when zend.multibyte=0, declare(encoding=...) will emit a 
> warning for whatever the encoding is:
> 
> […]
> 
> This would be a very minor change and do not worth a separate RFC. 
> However, I think it is still important to send a email to gather 
> opinions :) Also thank @alexdowad for giving me ideas. TiA :)

I suppose that `declare(encoding=…)` is so rarely used that folks will 
not have a strong opinion on it either way - except possible to remove 
the feature entirely to keep the parser simpler. That said: Suppressing 
the warning for ASCII and UTF-8 makes sense to me if folks want to 
explicitly specify it for some reason and zend.multibyte indeed has no 
effect at all on those encodings.

Best regards
Tim Düsterhus
