21.5 Making your own languageThis is NOT the latest copy of this book; click here for the latest version.
The very first release of PHP was actually little more than a collection of Perl scripts, and, although it was fairly limited by not being a full-blown language in its own right, it was powerful enough to gain quite a following. Things have come full circle now, as PHP is able to be a host to your own mini-language, and this is what we'll be looking at here.
If you've any experience with the back end of PHP, you should be aware that it is made up of four parts: lexical analyser, parser, the Zend Engine, and PHP itself. Of these four, the first two are very closely interrelated and are not noticeable from a user perspective, but they form the key to the whole system. The Zend Engine can be thought of as the executor of the code and also the manager of the system, and the PHP core itself is where all the functions lie. To write our own language, we need to have everything but our own version of the Zend Engine, and this is no easy task: a fair amount of theory is involved, although I have done my best to simplify the system for the sake of learning, and you should really not be attempting this example unless you have a fairly complete grasp of the other topics that have been covered.
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|