In this PHP tutorial, we learn how to work with variables. We walk through preforming some simple calculations and outputting the data to the web browser.
In many languages, the type of case we use matters. For example: eCho and echo, could mean two different things. In PHP, commands are not case-sensitive. This makes coding easy, but I personally like to standardize on using all lower case, when working on projects.
On the other hand, variable names, are case sensitive. If you define a variable named num and call it Num, you are going to get a syntax error. In the two videos below, we explore case sensitivity in PHP.
As we continue our PHP series, we learn that we live and die by good or bad documentation. The practice of using comments in any project you do is crucial. Good comments are just as important as the program functioning correctly.
In this video tutorial, we will get our feet wet and program our first PHP script. It is not flashy, but it is a start to learning how PHP works. We also learn how to do a single line comment in this tutorial. The command we will learn is called echo. Echo displays PHP variable data in HTML format to the end user. This forms a statement and we learn that statements, must be closed with a semicolon.
We have started a great series on how to program in PHP. PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
The video below shows you how to use variables in PHP. A few important things to remember:
- PHP variables are case sensitive
- Variables start with $, followed by the name
- Variables must start with an underscore or letter
- Variables CANNOT start with a number
- Variables can only be alpha-numeric characters with the exception of underscores
Project Files: output-variables