In Part 1, we mentioned how a marketer like you can leverage even a basic knowledge of PHP for marketing success. And so far we’ve developed an image based on events to frame an understanding of PHP.
To review: you type facebook.com into your laptop, a server with PHP gets a message and sends back your newsfeed which is then displayed on your laptop screen.
We’ve also talked about what is inside the server, PHP files inside of which are pieces of HTML mix with pieces of PHP code. More on this later.
You can see sets of layers forming; ideas broken down into groups and associations. We can use this on wider concepts as well but only if you understand each subsection in turn.
This is in contrast to the common approaches to understanding programming we talked about in the first part. As we discussed, these have their drawbacks. It might be worth revisiting them.
The first was steps.
You are walked through a set of tasks as though in a workshop trying to do something useful. The problem is that it’s environment-specific.
Any practical knowledge you gain may not transfer well.
If I give instructions for Windows it won’t help those using a Mac. Time is also a factor. I could break down steps for a website but it may no longer exist when reading the article.
That doesn’t degrade the benefit one could get from going through a step-by-step process. In the end, you have to know how to do things because in the end that’s the whole point.
Completed tasks serve as anchors holding your understanding together, which is why the more diverse the task, the better.
Here, the point is to appreciate how you don’t need to understand all the idioms and structures of a language in order to gain use out of it.
Rather work on a per-problem basis and don’t get overwhelmed by the history of the math and linguistics behind the programming paradigm.
In essence, you want the machine to do something. And you do not need to have a degree in math or symbolic logic to do it.
This has the same problem as the previous. A lot of noise is made making things seem complicated.
As with logic, the point is to ignore calls on how things work and how clever they are.
Rather, the point is to simply wait until a problem occurs and then refer to the manual, which is the singular document that lies behind them all.
For the most prolific systems such that hold together the internet, this is referred to as the standard because they’ve been submitted for induction into international clubs. Note that PHP is not one of these.
Let’s get to an example. This is a piece of PHP. In fact, it’s an entire PHP file.
As we’ve said, PHP is HTML with bits of PHP code in it. And HTML is what ends up in your browser. So this file is transformed into a piece of pure HTML (more on this later).
It’s worth explaining about HTML. It describes things in terms of content. The simplest piece of HTML looks like this.
This is a screenshot of a text editor (Sublime if you’re interested). The 1 is the line number of the file and has nothing to do with HTML.
Next, we have an angle bracket, which is followed by an exclamation point. We then have the word DOCTYPE, all in caps. Next, we have a space. And finally, we have the word html in small letters plus another angle bracket.
This is the only essential part of an HTML file. It says what the format of the document to follow is. Here it’s saying “This document is HTML”.
It may seem redundant, but there used to be many competing standards and versions. The doctype use to have lots of information about the format. Thankfully it’s now simplified to just html.
There are several other things you will always see. The first is called the html block and it’s declared like this.
Note the line numbers have increased. Again, these are part of the editor and aren’t part of the document contents.
What we’re seeing is the word html repeated twice but also some other symbols.
Firstly, we have more of angle brackets. They are the greater and less signs on your keyboard above the comma and full stop. They’re also referred to as crocodiles.
The crocodile symbols encapsulate the name of a block. They are meant to make a diamond shape around the word of interest.
In the second occurrence of html we see a forward slash.
The forward slash is there to mark the end of a block. So what we see above is a doctype declaration and an html block.
The point is to allow things to go inside. So anything that is typed between these markers belongs in the block.
To illustrate we introduce the other essential parts of HTML: the head and body sections.
These define two more blocks. One is called head and the other is body. And what’s important to note is they are both inside of the html block.
Everything in HTML is broken down into parts likes these. The official word for them is elements. The top section head describes document details like the title and how to display on different devices. The body section is the content.
This amounts to three things:
One also gets the occasional textbox for writing into.
Each of these is written as a block (element) using the same convention as the head and html.
That’s it for HTML. If you want details you go to the manual.
HTML is so popular it has a standard. However, people write so much about it one can also just Google questions like “How do I make text bold in html?”
Once you know the name of the block (and something else we haven’t covered called attributes) you can control the language and what it does.
Back to PHP.
PHP is one in several solutions to the problem of making HTML more flexible. Here is some HTML which tells the time.
The problem is that this will say it’s 12:30pm on Thursday all the time. So we replace the part where time is displayed with some kind of symbolism for the current time.
These parts are not HTML. We could not take this form of the document and ask your laptop browser to display it.
Instead we’ve created a new hybrid standard that includes some other format and explicitly declare these sections. In PHP this is done with a question mark and the letters php.
Anything between these markers is a new language. Before sending the file to the client we pass the hybrid document to the PHP processor and it strips out the PHP sections and perhaps puts in new sections of HTML.
This approach of mixing HTML with another language is widely used on the internet. PHP is the most popular. The next is Microsoft’s ASP. There is another in the Java world called JSP.
Learning the words and symbols is not as important as understanding what is happening. The PHP code to do what we wanted looks like this.
But specifics are not as interesting as the fundamental structures that hold everything together.
Now, as a marketer, what you just learned here places you at a great advantage as you:
The moment you begin incorporating the latest technologies into your marketing strategy, is when your knowledge about PHP will snap into place, giving you a distinct edge over less knowledgeable competitors.