21 Alternative PHP usesThis is NOT the latest copy of this book; click here for the latest version.
As you probably know, PHP is a recursive acronym for "PHP: Hypertext Preprocessor", so why should a product designed for the web ever stray from its original goal? Quite simple, because PHP is cool, and if I could use PHP to do everything , I'd certainly give it a try, if only for the challenge!
In this chapter we're going to be looking at other uses you can put PHP to in order to extend its usefulness. One key thing to remember is that you can use what you have learnt so far wherever else you use PHP, but you will find as you read on that there is a lot of specific information to absorb about individual uses.
Hopefully this chapter will inspire you to try to transfer your PHP skills to other areas - it is a big world out there!
The topics covered in this chapter are:
-
How to use PHP to write shell scripts
-
How the CLI SAPI differs from "normal" PHP
-
Interacting with the dialog program to create command-line user interfaces
-
Using GTK+ to create graphical user interfaces
-
Using Glade to automatically generate GTK+ GUIs
-
Making text-based games with PHP
-
Making graphical games with PHP and SDL
-
Creating your own miniature language with PHP
Chapter contents21.1. What else can be done with PHP?
21.2. Command-line scripting
21.2.1. Why use shell scripts?
21.2.2. CLI SAPI differences
21.2.3. Your first CLI script
21.2.4. Advanced command-line parsing: getopt()
21.2.5. Getting down and dirty
21.2.6. Getting into the swing of things
21.2.7. Sending code direct to PHP
21.2.8. The grand finale
21.2.9. CLI Conclusion
21.3. Graphical user interfaces
21.3.1. Getting started
21.3.2. GUI toolkits
21.3.3. A Basic GUI
21.3.4. Multiple Windows
21.3.5. Handling popup menus
21.3.6. Advanced GUIs
21.3.7. Using Custom Parameters
21.3.8. GUI Themes
21.3.9. Distributing your apps
21.3.10. Graphical Interfaces Conclusion
21.4. Making games
21.4.1. Text-based world planning
21.4.2. Text game v1
21.4.3. Getting graphical
21.4.4. Getting it to work
21.4.5. First steps
21.4.6. Moving our sprite: phpSDL_GetKeyState()
21.4.7. Clearing the screen: phpSDL_MapRGB() and phpSDL_FillRect()
21.4.8. Last tweaks: phpSDL_WM_SetCaption(), phpSDL_SetColorKey(), and phpSDL_GetTicks()
21.4.9. Games conclusion
21.5. Making your own language
21.5.1. Why make your own language?
21.5.2. The elements of a compiler
21.5.3. Analysis
21.5.4. Output
21.5.5. Planning it out
21.5.6. How to parse text into tokens
21.5.7. What is a token?
21.5.8. How parsing works
21.5.9. Finally, execution
21.5.10. If you have made it this far...
21.5.11. Operator precedence
21.5.12. The script in (almost) full
21.5.13. Mini-language conclusion
21.6. Summary
21.7. Further reading
21.8. Next chapter
|
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!
|