Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Is there any rationale for the lack of local constants in PHP?
The last few years, PHP has basically exploded with lots of modern language constructs that makes the life easier.
But local constants are still missing, and I find that very strange. I have found many questions online that asks for this, so it is obviously something many programmers want. Just for clarity, I'm looking for something like this:
class Foo {
public function bar($a, $b) {
const $sum = $a + $b;
const
can be used for class members or in global scope, but it cannot be used for creating local constants.
Furthermore, I would consider the following statements facts, or at least as close to facts to make the difference not matter
- Local constants is a common concept that exists in many other languages
- Many PHP developers want local constants
- In other languages, local constants are successfully used to create more reliable code with fewer bugs
- It is very unlikely that those who develop the PHP language does not know the above statements
So I assume that there has to be a reason for this. They cannot simply have not thought about it.
So what is the rationale behind this? Or is my assumption wrong?
0 comment threads