It might be nice to define a local constant within the scope of a function in PHP.
Thus, anyone who reads this function will know that this definition is final in the function and does not affect external code.
Something like this (Invalid syntax):
public function laughManiacally($count){ const LAUGH = 'HA'; for($i=0;$i<$count;$i++){ echo LAUGH; } };
Or perhaps (again invalid):
... final $laugh = 'HA'; ...
Is there anyway to do this? And if not, then why?
source share