I’m getting feedback that you want more lessons. That was just the motivation I needed
.
Getting Started
If you’re just joining us, you may need to review some of the material we’ve already covered
1) Lesson 1: Using PHP for the first time
2) Comment Out PHP
Defining Variables
Variables are useful for storing information, especially dynamic information. If you have a quantity that might “vary” you probably want to make it a variable. To create a variable in PHP you simply have to put a dollar sign just before the variable’s name. For example: $my_variable.
Learning by example
Take a look at the following example:
<?php // This is a comment: Let's define our first variable. $i_am_a_variable = 5; // Let's add one to the variable and print it to the screen print $i_am_a_variable + 1; ?>
Copy and paste the above code into codepad as discussed in Lesson 1. If you execute the code in codepad you will find the result is 6.
Woohoo! Now that’s some real coding there. Hopefully, you’re beginning to see the power of PHP.
Some notes about variables
- Variables must be made up of letters (lower case or upper case) and numbers
- You may use underscores “_” too (look at the code above for an example)
- Variable names can’t start with a number, so don’t name your variable something like $789 or $8my_dinner_today!
- If you’re not a programmer don’t read on: PHP is a loosly typed language so PHP variables don’t need to be defined as a string, int, etc.
Back to Learn PHP in 24 Hours for more fun













My cousin recommended this blog and she was totally right keep up the fantastic work!
Good tutorial. I think we could all use some help with PHP coding.