Reputation:
UPDATED
Is there any way to force case sensitive function names in PHP, even if it means re-compiling PHP?
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()
?
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.
I know many PHP developers do not care too much about "case-sensitivity" and do not see the need for this; 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.
Upvotes: 5
Views: 1842
Reputation:
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:
Here's a few pointers that may be useful:
sensitiv
& case_
in their contents; however, it is likely in here: ./Zend/zendAPI.c
(citation needed)CONST_CS
and its value, defined in ./Zend/zend_constants.h
file as it is used frequently/etc/php
To make your changes be configurable in php.ini
./Zend/zend_ini.c
file./Zend/zend_ini_scanner.*
files.
To make your changes be configurable in Apache config & .htaccess
mod_php5.c
source code that corresponds relatively with the PHP & Apache versions: 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.
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.
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)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.
Upvotes: 2