When using the PHP CLI interpreter, how might one redefine a function that has a bug. For instance, the original function declaration here lacks a newline character and I would like to fix it:
$ php -a
Interactive shell
php > function drinkBeer(){
php { echo "Carlsburg";
php { }
php >
php > drinkBeer();
Carlsburgphp >
php >
php > function drinkBeer(){
php { echo "Carlsburg" . PHP_EOL;
php { }
PHP Fatal error: Cannot redeclare drinkBeer() (previously declared in php shell code:2) in php shell code on line 3
php >
We have seen similar questions asking how to redefine a function when running a PHP script however none of the similar questions address the issue of redefining functions on the PHP CLI interpreter.
For instance, the Python interpreter allows this:
$ python3
>>> def drinkBeer():
... print('Carlsburg')
...
>>> drinkBeer()
Carlsburg
>>>
>>> def drinkBeer():
... print("You've had enough!")
...
>>> drinkBeer()
You've had enough!
>>>