harmor submitted a new Article:
Learning PHP for the first time
Read more about this article here...
Learning PHP for the first time
When you're learning a programming language you may become overwelmed with the complexity.
I was very overwelmed when I started to learn PHP for the first time over a year ago.
After I grasped how the syntax worked I could learn new methods more easily.
In this article I'll be giving you tutorials on PHP.
Inorder for you to run the PHP scripts you must have a host that supports PHP (atleast 4.1.0).
If you need hosting you can go to Xen Web Hosting and recieve hosting there.
I highly recommend Crimson Editor for a PHP editor
-- Writing your first PHP program --
Any file that contains PHP must have the extension .php (eg. test.php)
Open Crimson Editor and start a new document (Ctrl + n).
The first thing I'll show you is how to output text using "echo".
To output (or print) text to the browser you can use several statements.
In this article I'll be using the "echo" statement.
Outputting text using PHP is pointless in my opinion but beginners need to start somewhere.
The word "echo" tells PHP to output the text between the two quotes to the screen.PHP:<?php echo "This is a string"; ?>
The semicolon tells PHP to end the statement (in this case the "echo" statement)
I recommend that you write more "echo" statements to familiarize yourself with the syntax.
I've seen scripts where the coder repeatively uses the "echo" statement for a block of text.
To give you an idea of what I mean imagine copying the "echo" statement and pasting multiple instances of it.
Doing that is unneccesary. In my opinion it makes the code look sloppy.
The way to output a block of text is presented below
-- Variables --PHP:<?php echo "Hello, my name is Andrew Harmor I'm 20 years old and I'm attending Waynesburg College located in Pennsylvania"; ?>
Variables are going to be your friend because you'll be using them a lot.
The naming convention of a variable consists of the dollar sign and almost any name (eg. $header)
A variable cannot start with a number and it cannot have a special character anywhere in the variable name.
The equals sign assigns the string to the variable. So when you "echo" (output) the variable it'll displayPHP:<?php $name = "Andrew Harmor"; echo $name; ?>
the string that is assigned to that variable.
You may have noticed that the "echo" statement does not contain any quotes.
When dealing with variables encasing...
Read more about this article here...
Last edited by a moderator: