[英]Forcing case sensitive functions in PHP :: by re-compiling the source?
UPDATED 更新
Is there any way to force case sensitive function names in PHP, even if it means re-compiling PHP? 有没有办法在PHP中强制区分大小写的函数名称,即使它意味着重新编译PHP?
php.ini
? php.ini
一些设置来实现吗? C
/ C++
source-code that could force global case-sensitivity --and make it available as an option in the php.ini
-which could be overridden by apache config, and .htaccess
, and during runtime with ini_set()
? C
/ C++
源代码 - 并使其作为php.ini
的选项可用 - 它可以被apache配置覆盖和.htaccess
,以及在运行时使用ini_set()
? There are plenty answers that confirm: 有很多答案证实:
This question is about taking control of the situation as it is quite painful if you have the following problem: 这个问题是关于控制情况,因为如果你遇到以下问题会非常痛苦:
<?
define('List', ':List:');
die(List);
?>
Parse error : syntax error, unexpected ')', expecting '('
解析错误 :语法错误,意外')',期待'(''
In the example above, the "intrinsic" function-name list
interferes with the "user-defined" constant List
and not in a "good" way - as it results in a Parse Error . 在上面的示例中,“内在”函数名称
list
干扰“用户定义”常量List
而不是“良好”方式 - 因为它会导致解析错误 。
I know many PHP developers do not care too much about "case-sensitivity" and do not see the need for this; 我知道许多PHP开发人员并不太关心“区分大小写”,并且不需要这样做; however, if you're building a neat boiler-plate, or a framework with well defined data-types as short words (for comparison reasons), then it is a problem as you are targeting a large audience.
但是,如果你正在构建一个整齐的锅炉板,或者一个定义明确的数据类型为短字的框架(出于比较原因),那么这是一个问题,因为你的目标是大量的受众。
Any input would be appreciated, thanks. 任何意见都将不胜感激,谢谢。
Finding clues on the net on how exactly to do this seems illusory; 在网上找到关于如何做到这一点的线索似乎是虚幻的; however, the following may be useful for anyone looking for clues in achieving something related.
但是,以下内容可能对寻找线索以实现相关内容的人有用。
To modify & compile the PHP source-code, see this article: 要修改和编译PHP源代码,请参阅以下文章:
How to modify the php source code and recompile it?
如何修改php源代码并重新编译呢?
Here's a few pointers that may be useful: 这里有一些可能有用的指针:
sensitiv
& case_
in their contents; sensitiv
& case_
文件; however, it is likely in here: ./Zend/zendAPI.c
(citation needed) ./Zend/zendAPI.c
(需要引证) CONST_CS
and its value, defined in ./Zend/zend_constants.h
file as it is used frequently CONST_CS
及其值,在./Zend/zend_constants.h
文件中定义,因为它经常使用 /etc/php
/etc/php
To make your changes be configurable in php.ini
要在
php.ini
配置您的更改
./Zend/zend_ini.c
file ./Zend/zend_ini.c
文件 ./Zend/zend_ini_scanner.*
files. ./Zend/zend_ini_scanner.*
文件。 To make your changes be configurable in Apache config & .htaccess
要使您的更改可以在Apache config和
.htaccess
进行配置
mod_php5.c
source code that corresponds relatively with the PHP & Apache versions: https://searchcode.com/codesearch/view/2479116/ mod_php5.c
源代码: https : //searchcode.com/codesearch/view/2479116/ The above may be helpful for re-building PHP, but, there may be a better and much quicker solution. 以上内容可能有助于重新构建PHP,但是,可能会有更好,更快的解决方案。
Constructive criticism 建设性的批评
Related to the nature this question specifically, editing & re-compiling the source may be overkill. 与此问题的本质相关,编辑和重新编译源可能是过度的。 Not only is it completely out of "PHP language" scope, but mentioning that this is targeted a large audience may defeat the purpose of the framework / boilerplate entirely.
它不仅完全脱离“PHP语言”范围,而且提到这是针对大量受众可能完全打败框架/样板的目的。
A better approach 更好的方法
The exact reason for why it is so crucial for case-sensitivity of these exact data-type constant words is unknown; 对于这些精确数据类型常量字的区分大小如此至关重要的确切原因尚不清楚; however, maybe re-naming them, or defining functions to use in stead of constant comparison could be beneficial, so:
但是,可能重新命名它们,或定义要使用的函数而不是持续比较可能是有益的,因此:
List
, how about ListDT
(for List-Data-Type) List
, ListDT
怎么ListDT
(对于List-Data-Type) isList()
isList()
After all: "speed of coding" could be more important than "speed of code" in many cases. 毕竟:在许多情况下,“编码速度”可能比“代码速度”更重要。
This approach may prevent the need for re-compiling PHP and the "target audience" won't need to manually obtain and install a very specific PHP version just because "the framework" demands some specific words. 这种方法可能会阻止重新编译PHP的需要,并且“目标受众”不需要手动获取和安装非常具体的PHP版本,因为“框架”需要一些特定的单词。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.