Hudzilla.org - the homepage of Paul Hudson
Contents > Wish List | Report Bug | About Me ]

21     Alternative PHP uses

This 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 contents

21.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



<< 20.10 Next chapter   21.1 What else can be done with PHP? >>
Table of Contents
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!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
nick.state@hotmail.com - 04 Jul 2008

<a href=http://www.searchlyrics.awardspace.com>Search Lyrics</a><br><br>
All scripts are working!
Th u!

http://www.searchlyrics.awardspace.com - 04 Jul 2008

Good job!!!
Thx!

A PHP User - 04 Jul 2008

ITS SUPERB..............

REALLY A GOOD ONE.

THANX A LOT...

lmartinez@ecologic-peru.com - 04 Jul 2008

Theis page is very important; it's no the official php site but the knowledge is very practical.
My skills in php are regular, then this page helps me to know a bit more about php.
I'm a PHP language fan, not by the name or by posses; it's about simplicity, versatility; few days ago i had to know about the SDL and php-sdl bindings, then I test the samples and now I'm going to learn more intensively the whole thing.
My work is programming and designing, I see that this tools can be joined to make a great tools for many applications.

Good luck and go ahead

Luis Martinez

Eco Logic EIRL
Lima Peru



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is four plus eight?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow