PHP: How to safely include file with possible parse errors?
Recently I had written a class and it had to save bits of information somewhere. I wanted to make the script installable just by placing it on a server so I didn’t want to use any database. Instead I figured out I should save the data in a simple file. I could use serialize and file_put_contents which is very easy to write, but modifying such files manually in a text editor is a nightmare. So I decided to save the contents in a PHP file.
Unfortunately if there is an error in such file you will get parse error when including it.
Parse error: parse error, expecting `T_PAAMAYIM_NEKUDOTAYIM’
I just got this error. After doing some googling I found an explanation in Wikipedia:
“In PHP, the scope resolution operator is also called Paamayim Nekudotayim, which means “twice colon” or “double colon” in Hebrew. It may be helpful to note that in some cases this error may occur when the $ symbol is not included in the use of a variable.”