It might be nice to be able to define a local constant within the scope of a function in PHP
This way anyone reading the function would know that that definition is final within the function and doesn't affect any external code
Something like this (Not valid syntax):
public function laughManiacally($count){
const LAUGH = 'HA';
for($i=0;$i<$count;$i++){
echo LAUGH;
}
};
Or possibly (Again not valid):
...
final $laugh = 'HA';
...
Is there anyway to do this? And if not why not?
UPDATE
The way that JavaScript allows block level constant declaration is similar to the functionality I was searching for
function laughManiacally(count) {
const LAUGH = 'Ha';
for (let i = 0; i < count; i++) {
console.log(LAUGH);
}
}