Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

Learning Python For PHP Programmers

As an individual that spends the majority of time programming PHP / mySQL, I had wanted to see what all of the Python hype was about. I have heard so many positive remarks about it for custom scripts and web programming.

However, the main reason that put it on my list for learning was the Raspberry Pi. Since python has a GPIO library, it was a great tool for taking input and delivering output with the Raspberry Pi. In fact, any tutorial I can remember that would do this used Python and the GPIO library.

Shortly after I decided to learn C, I decided to dive into Python. So, there I was, using Gedit and running code blocks on Ubuntu. Immediately, I was impressed with its lean and clean presentation.

Coming from a PHP background, I will attempt to summarize the differences I experienced.

  • Does not use $ to declare strings
  • The lines do not end with a semi-colon (;)
  • Printing is a lot like C or sprintf with PHP
  • You import libraries you need at the top of the file
  • The syntax for arrays is different. Also, the author called an array a ‘list’
  • The loop syntax is different. This should be easy to interpret; especially if you run a code sample.
  • Curly brackets {} are not used in loops, functions, classes
  • Using methods from libraries is very similar to using Jquery

If you have fairly strong PHP skills, you will find you can convert to a Python mindset rather easy. Even though I like Python’s simple, clean syntax, I do not plan throw away everything I have done with PHP. In fact, I would continue with PHP for web applications since I have been hand coding it for a long time and its usages makes coding a dynamic website very quick and easy. But, a new programmer could easily become efficient with Python.

However, if I ever plan to integrate a Raspberry Pi into a web page on a remote server, I would not hesitate to take advantage of its GPIO library and its ability to read or write to files or a database. This allows for many more possibilities to the creation of dynamic websites.