Advanced programmers know a secret. They know the secret refers to how a PHP program is built.
Here’s the secret:
“Complex programs are built from simple programs. If you can learn to create a simple program, you can learn how to build a complex program, no matter how complicated.”
A program can be constructed of only a few lines. Always begins in the same way. Start with PHP start tag, followed by the program, and finally the closing tag of PHP.
// program goes here
PHP application shown above has only three rows. Line 1 and 3, the start and end tags, line 2 is the functional code. In this case, however, Line 2 is a comment and will not perform any particular action to remind something. The interpreter does not process comments. When you find a comment, it is ignored.
// this is a comment
// This is another comment
// this is the last comment
The code in Example 1 works exactly like the code in Example 2. Although example 2 has two lines. If you noticed, additional lines in Example 2, only comments. When they are ignored by the interpreter PHP (PHP engine).
If there is a single comment or many comments, the interpreter will act the same way.
// in this line is a real programming PHP command
echo “My first real applications”;
In Example 3, you will see your first PHP program running. The command “echo” was added to this program is on line 3. An explanation of the “echo” is built on a PHP command that will output the following on screen. When you want something with PHP output to the screen, web browser, or visual representation. Use simple “echo” command.
As you can see, ” follows the command echo “. It is very important to enclose words to my first real applications” “words echoed” on the screen in single or double quotes. In this way, the echo command knows which character to start with, and which ends with the character, which generates output to the screen.
When you call the echo command, which takes the content of the quotes, and sends it to the screen – without the quotes. So the result is:
// The next line is the first echo
// The next line is the second echo command
// The next line is the last echo command
echo; “PHP applications.”
The output of this program would be:
You learn PHP applications.
When you start programming, there is no limit to the number of comments and commands can be entered in your program. Go ahead, do it yourself. You better not have many comments to remind you what you do in your program.
The sophisticated program consists of simple programs. Learn how to mix simple commands together, along with the start and end of PHP does a PHP application in full operation. As you learn, is a good suggestion to add as many comments as necessary to help you remember what you do. Comments are notes that are. As you get better at programming, which obviously face fewer comments. PHP “echo” command outputs characters on screen. Include all the characters after the command “echo” with single or double quotes.
Congratulations, you just write your first PHP program.