Why doesn't PHP permit private const?

…衆ロ難τιáo~ 提交于 2019-11-27 20:20:46
sudhir chauhan

Use private static properties.

In that case you will have the same variable throughout all objects and if you want to extend its scope to nested, you can expose a getter method to get its value and restrict variables settings.

As of PHP 7.1, there are real private constants.

private const PRIVATE_CONST = 0;

See the Class Constant Visibility RFC for more information.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!