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
What else can be done with PHP? 21.2.
Why use shell scripts? 21.2.2.
CLI SAPI differences 21.2.3.
Your first CLI script 21.2.4.
Advanced command-line parsing 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
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.
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 21.4.7.
Clearing the screen 21.4.8.
Last tweaks 21.4.9.
Games conclusion 21.5.
Making your own language
Why make your own language? 21.5.2.
The elements of a compiler 21.5.3.
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.
Further reading 21.8.
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? >>
Alternative PHP uses What else can be done with PHP? Command-line scripting Why use shell scripts? CLI SAPI differences Your first CLI script Advanced command-line parsing Getting down and dirty Getting into the swing of things Sending code direct to PHP The grand finale CLI Conclusion Graphical user interfaces Getting started GUI toolkits A Basic GUI Multiple Windows Handling popup menus Advanced GUIs Using Custom Parameters GUI Themes Distributing your apps Graphical Interfaces Conclusion Making games Text-based world planning Text game v1 Getting graphical Getting it to work First steps Moving our sprite Clearing the screen Last tweaks Games conclusion Making your own language Why make your own language? The elements of a compiler Analysis Output Planning it out How to parse text into tokens What is a token? How parsing works Finally, execution If you have made it this far... Operator precedence The script in (almost) full Mini-language conclusion Summary Further reading Next chapter
Table of Contents
Copyright ©2015 Paul Hudson.
Follow me: @twostraws.