pAdvanced programmers know a secret. The secret that they know
relates to how a PHP program is constructed.ppHere is the
secretppComplex programs are built up from simple programs. If you
can learn how to create a simple program, you can learn how to
build a complex program, no matter how complicated.ppA program can
be constructed of only a few lines. They always start the same way.
Start with the PHP start tag, followed by your programming code,
and last by the PHP end tag.pppblockquotexmpExample 1Line 1 php
line your program goes herephpxmpblockquotepThe PHP program shown
above has only 3 lines. Line 1 amp 3 are the start and end tags,
line 2 is your functional code. In this case however, line 2 is a
comment and will not perform any specific action other than to
remind you of something. Comments are not processed by the
interpreter. Once a comment is encountered, it is basically
ignored.pppblockquotexmpExample 2Line 1 php line this is one
comment another the lastphpxmpblockquotepThe code in example 1
behaves exactly as the code in example 2. Even though example 2 has
2 more lines. If you noticed, the additional lines in example 2 are
only comments. Once again they are ignored by the PHP interpreter
PHP Engine.ppIf there is one comment or multiple comments, the
interpreter will act the same way. It will ignore any comments that
it finds.pppblockquotexmpExample 3Line 1 php line below this is a
real php programming command echo first programphpxmpblockquotepIn
example 3 you will see your first functioning PHP program. The echo
command was added to this program, located on line 3. An echo
statement is a built in PHP command that will output whatever
follows it to the screen. Anytime you want to output something
using PHP to the screen, web browser, or visual display. Use the
simple echo command.ppAs you can see, the words My First Real
Program follows the echo command. It is very important to enclose
the words that you want echoed on the screen inside single or
double quotes. This way the echo command knows from what character
to start with, andbrwhat character to end with, as it generates the
output to the screen.ppWhen the echo command is called, it takes
the contents inside the quotes, and sends it out to the screen
minus the quotes. So the output would bepppblockquoteMy First Real
ProgramblockquoteppblockquotexmpExample 4Line 1 php line the next
is first echo command are second how to last in
phpphpxmpblockquotepThe output to this program would
bepppblockquoteYou are learning how to program in
PHP.blockquotepWhen you start programming, there is no limit to how
many comments and commands you can enter in your program. Go ahead,
try it yourself. As you get better you wont need so many comments
to remind you of what you are doing in your program.ppComplex
programs are made up of simple programs. Learning how to mix simple
commands together, along with PHP start and end tags makes a fully
functioning PHP program. As you are learning, a good suggestion is
to add as many comments as you need to help remember what you are
doing. Comments are like taking notes that you can refer back to.
As you get better at programming, you will naturally enter less
comments. The PHP echo command outputs characters to the screen.
Enclose all characters after an echo command with single or double
quotes.ppCongratulations, you just wrote your first PHP
program.ppbPaul Markovich is a Lead Technical Trainer.bppHe has
been designing and building custom web sites for entrepreneurs
since 1997. Hell help you get the answers to your burning open
source programming questions!ppbLooking For More PHP Programming
TipsbppDiscover Proven Programming Strategies.ppLearn to Program
faster, while saving time, energy, and money!ppa targetnew
hrefhttpcenteroftech.comhttpcenteroftech.comap
Date Published: