I wrote my first programs in PHP today (with a lot of help from the internet). It's always exciting to learn something new. I am getting excited because I like knowing how my programming logic -- how instructions combine to do something -- applies to different languages. It's cool seeing what features a language does have, doesn't have, and implements differently from those that I already know. For instance, I learned today that PHP doesn't have an explicit "dictionary" data structure. Instead, you can create a dictionary-like object using an array. (Whereas in Python array and dictionary are explicit and different.)
I decided to dip my toe into PHP to see what I could build with it. I don't have any specific project in mind but I would like a new tool in my mental repoitoire of programming technologies. The more I learn, the better I will be able to make decisions about the right tool for a job. I haven't learned a new programming technology in a while, save for the week or so I spent playing around with Lisp earlier this year. I am not committing to learning the whole PHP language but I do want to play around and see what I like, dislike, and what the language does exceptionally well. I want to learn this through practice.
So far I like the idea of having logic in a document that can contain HTML rather than having logic entirely separate from the front-end. In Python Flask, the web development framework I have been using for the last few years, you can create templates with the jinja2 framework that pairs well with Flask. However, your back-end logic is still in Python. This is expected because Flask is a back-end framework. The important thing to note is that logic is in Python and templating is in HTML. This happens in different files, usually (although you could technically put your jinja2 templates in a Python file, that wouldn't look very nice nor accomplish exactly the effect that PHP does). PHP contains markup and logic in one file. I like this.
I am also finding the syntax of PHP to be relatively friendly. This opinion may change as I learn more about the language, but the fundamentals -- declaring a variable, making an array -- have not been too difficult to pick up. I was able to make a web request and parse its contents with JSON in only a few lines of code which was really cool. I always get excited when I'm learning something and see a tangible output quickly. This keeps me motivated.
I'm at the earliest possible stage of learning PHP so my thoughts on the language, as aforementioned, are likely to change over time. This blog post is partly for me to come back to later as a reminder of my attempting to learn a bit of PHP -- no matter what the outcome -- and also an excuse for me to continue writing. I'd rather get some thoughts written down. I would like to write more this year.
Read more content like this
Check out the other posts I have written related to this article.
Comment on this post
Respond to this post by sending a Webmention.