Save Interactive Shell History via readline_list_history()

I often test code I write in the Interactive shell of PHP, until now, I usually copied and pasted the bits I needed, one by one into my project.

Not anymore, today I discovered this little snippet:


    file_put_contents("history.php", implode("\n", readline_list_history()));

It writes the entire history of the interactive shell into a file. That's all.