- Variable Variables
In PHP, variables are denoted by a $ in front of the variable name.
Now since we have these two parts that make up a variable we can do something special. If we take two $ and then a variable the expression will resolve quite differently.
Where it really comes in handy is when you are doing form validation. If I have a form that has an input for name and email, and I send them back to my page via $_POST, I can simply grab them back into their field names as variables. Which brings me to my next point.. - Ease of User Interface
When learning computer science in school, you often will write one-off programs that may do something cool, but they are usually run in the compiler or command line. PHP gave me an outlet to actually create deliverables and turn my love for computer science into something practical I could apply to real world jobs. HTML forms are the corner stone of interactivity with a website. It turns static data on a screen into something that the user can interact with. PHP deals with forms very easily, take for example this code that lets say is on a file page.php. It will do some basic form validation: The page will output a simple input field that will give a message if the submitted text does not equal "test", and it will persist the input provided in the text box. Very useful for input error handling on registration forms for example.
Check out the sample code in action @ http://swedutch.net/page.php - Ease of Database Interaction
Taking it one step further, to make a website even more interactive you will probably need some sort of database. PHP has very easy to use API's for interacting with many different kinds of databases (MySql, Postgres, etc..). The main type of database I use is MySql, and the methods of running queries could not be easier:I could list more examples but the simplicity remains the same. Interacting with databases with PHP is easy and tieing this in with forms, creating complex websites from simple parts becomes very easy.
- Type-less Variables
Well not exactly typeless, PHP does have variable types, but they are hidden and implicitly converted on the fly. So it would be more accurate to call it loosely typed. Regardless, the fact that you don't need to worry about declaring and initializing your variables makes coding PHP a breeze, with little forethought required. This can however lead to sloppy coding practices, but not having to create a bunch of frivolous variables to hold many different values at some point along a function, and rather just use one throwaway temp var is something I really enjoy. Being able to assign a variable a string one second, an int the next, and then make it an array with array index "somestring" is great for someone whole does less planning and more coding like myself :) - Overall low complexity
The biggest general reason I have stuck with PHP over the years is it's simplicity in all things. If there is something I don't know how to do with PHP, I can often simple search "thing-i-want-to-do php" and get the solution, usually through PHP.net and its online API documentation.
EDIT: When I was working a web development job for work-study @ BU, I actually had to train some other people how to do some web work. To that end I created a brief tutorial on the basics html forms and php/mysql usage (I may touch up and make this its own post eventually).
http://swedutch.net/tutorial.php






