Words are meant to inform, not scare
Learning a new skill often comes with learning a new vocabulary. As I reflect on the skills I have learned (baking, photography, programming) I am often amazed at the terminology that comes with those respective fields
When listing ingredients (and troubleshooting their dough) baker’s often talk about baker’s percent. A Web designer discussing typography with a colleague may use terms like leading (the space between adjacent words) and x height (a way to measure glyph height). Well, I want to share a new term with you that I learned in my PHP studies.
Delimiter
A delimiter is just a fancy word for a keyword (or character) that separates out a plain text file. It creates clear boundaries in a text file, like a word document or in our case a .html
or .php
file. Some relatable examples are the commas in langues. It clearly separates words, acting as a “field delimiter” (thanks Wikipedia) in a series of comma, separated, values.
When it comes to programming languages, HTML
and PHP
also have delimiters. The purpose of the delimiter in these languages are the same as in English. They tell the computer where to start and stop reading (parsing) a language. Everything outside those tags (delimiters) will be ignored by whatever is parsing the programming language. Here are some examples from my own code.
HTML delimiters
As mentioned above, the HTML
delimiters tell the web browser where to start “marking up” (HTML
is a markup language, right?) the content.
Without these tags (and the .html file extension), the web browser that parse the file would have no idea that it is an HTML
file. As I alluded to in the figure above, there are other delimiters too! Anything with a <></>
is a delimiter.
PHP also has delimiters too! check this out
I was a bit more detailed in marking up that PHP
code since many deem PHP as unreadable/ugly. Similar to HTML
, the
<?php ?>
;
.
code are all examples of delimiters. They tell PHP
where to start and stop.
In the screenshots of the code above, you may have noticed some other stuff besides the delimiters. What is going on with all that “echo
” stuff?
Keywords
Keywords are as much a part of a programming language as the delimiters are! For example, the echo
keyword tells PHP
to output a “string” (a bunch of words surrounded by quotations) to the screen. Much like verbs in the English languge, they tell the programming language to do something.
The “.” is called the string concatenation operator. It tells PHP
to join together strings of text (essentially extending the original echo
statement). Im not sure if this is technically considered a keyword or not (since it isn’t a word), but it certainly is an important part of the language!
Operators and statements
Don’t worry, we are almost done with the vocabulary terms. We have already come across statements and operators in PHP
in some of the examples above. A statement is is essentially code that evaluates to something, as a result of logic. See the ($stringCount < 2)
code in the if() statement
above? That is a statement!
You also may have wondered where this operator I keep speaking of is located? Well, keep looking at that if() statement
. The “>” is called a comparison operator. An operator is anything that performs an operation on a variable or value.
The if/elseif/else
code we saw earlier also illustrate something called control flow. Control flow executes different types of code or “does stuff” based on certain conditions. This is very useful if you want to write code (like assigning a value to a variable) based on certain conditions.
For example, you may only want to show certain content to a user that is logged in to your website, and hide it from users who aren’t signed-in or registered. This is an example of control flow, and can be accomplished using some of the techniques I’ve already covered.
Well, I hope I didn’t get too nerdy in this post!! If you have any questions or suggestions, like always I welcome thoughtful comments!