Alternative PHP uses

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

  1. 21.1. What else can be done with PHP?
  2. 21.2. Command-line scripting
    1. 21.2.1. Why use shell scripts?
    2. 21.2.2. CLI SAPI differences
    3. 21.2.3. Your first CLI script
    4. 21.2.4. Advanced command-line parsing
    5. 21.2.5. Getting down and dirty
    6. 21.2.6. Getting into the swing of things
    7. 21.2.7. Sending code direct to PHP
    8. 21.2.8. The grand finale
    9. 21.2.9. CLI Conclusion
  3. 21.3. Graphical user interfaces
    1. 21.3.1. Getting started
    2. 21.3.2. GUI toolkits
    3. 21.3.3. A Basic GUI
    4. 21.3.4. Multiple Windows
    5. 21.3.5. Handling popup menus
    6. 21.3.6. Advanced GUIs
    7. 21.3.7. Using Custom Parameters
    8. 21.3.8. GUI Themes
    9. 21.3.9. Distributing your apps
    10. 21.3.10. Graphical Interfaces Conclusion
  4. 21.4. Making games
    1. 21.4.1. Text-based world planning
    2. 21.4.2. Text game v1
    3. 21.4.3. Getting graphical
    4. 21.4.4. Getting it to work
    5. 21.4.5. First steps
    6. 21.4.6. Moving our sprite
    7. 21.4.7. Clearing the screen
    8. 21.4.8. Last tweaks
    9. 21.4.9. Games conclusion
  5. 21.5. Making your own language
    1. 21.5.1. Why make your own language?
    2. 21.5.2. The elements of a compiler
    3. 21.5.3. Analysis
    4. 21.5.4. Output
    5. 21.5.5. Planning it out
    6. 21.5.6. How to parse text into tokens
    7. 21.5.7. What is a token?
    8. 21.5.8. How parsing works
    9. 21.5.9. Finally, execution
    10. 21.5.10. If you have made it this far...
    11. 21.5.11. Operator precedence
    12. 21.5.12. The script in (almost) full
    13. 21.5.13. Mini-language conclusion
  6. 21.6. Summary
  7. 21.7. Further reading
  8. 21.8. Next chapter

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: What else can be done with PHP? >>

Previous chapter: Next chapter

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.