Since Jah requested this series to be made and I've been wanting to start a new tutorial series I figured what better time than now to write a new PHP programming tutorial series. In this series we'll be taking you from the extreme basics of PHP, to a working knowledge that should allow you to find you way around most web development environments.
What is PHP?
PHP is a recursive initial which stands for "PHP hypertext pre-processor". PHP is an extremely popular server side scripting language which is compatible with almost every modern web server and all major operating systems. PHP is the backbone for a majority of webpages, CMSs (Content management system), Frameworks, and anything of the like.Why should I learn PHP?
PHP is a handy scripting language for any programmer to know, and is essential knowledge for any web development/design environment.How do I set up a PHP development environment on my computer?
Check out the video below, since there are so many great video tutorials on the subject, there's no need for me to write out a few paragraphs explaining the process.I have a question and you didn't answer it .
Windows
Os x
Linux
Then post your question below and stop taking up room in my post ಠ_ಠ.
Now that we have covered the basics of what PHP is, we'll get started in coding our very first PHP script! Today's script will be extremely simple, since this is lesson #1. The difficulty will increase with each tutorial.
Script #1 - Hello World!
Today we'll be coding a simple hellrld script. The purpose of this script will be to introduce you to how you should start a PHP document, and introduce you to notation and the echo language construct.
When starting a PHP script you always use PHP tags. You will put your code between the PHP tags. PHP tags are what tells the -insert thing here- how to render the script properly.
PHP Code:
<?php
?>
Now we'll introduce you into notations. Notations are used to help clean your code and make it easier for other developers to quickly understand the intended purpose specific segments of your code.
Anything following a notation mark on the same line will not be rendered. If you were to open the PHP document below you would only see a blank page.
PHP Code:
<?php
//This is a notation
//Anything you type following a "//" will not be rendered. You can put any code here and nothing will happen.
//For example: echo "You won't be seeing this";
?>
Now that you know what notations are we'll be moving onto the echo language construct. If you were wondering, a language construct is a syntactically allowable part of a program that may be formed from one or more lexical tokens in accordance with the rules of a programming language.
Echo can be used to print text or HTML.
If you were to open the following code in a browser you would see the text "Hello World".
PHP Code:
<?php
echo "Hello World";
?>
Echo can also be used to print out HTML code such as <BR>, <div>, etc. You can find an example of using echo for HTML below.
PHP Code:
<?php
echo '<div align="right"> Hello </div>';
?>
If you look closely, you'll notice that this time we used single quotations instead of double quotations. You use single quotations when you do not want anything inside the quotes to be rendered. This is useful when what you're echoing contains another double quote, a variable you don't want passed publicly, etc. We'll go further into detail with this later in the series.
You may view the finished product of today's tutorial by following the link below.
http://toastur.com/projects/tutorials/1.php
If you have any questions post below and I'll try to answer as many as I can.
Results 1 to 6 of 6
Thread: [PHP] Lesson #1 - The basics
- 04 Feb. 2012 01:35am #1
[PHP] Lesson #1 - The basics
Last edited by Elliot; 07 Feb. 2012 at 09:02pm.
// Signature
- 04 Feb. 2012 11:42am #2
- 14 Mar. 2012 02:50am #3
Good tuto, rep+. I'm starting with programming on PHP and found this too useful.
- 14 Mar. 2012 10:43am #4
- Age
- 28
- Join Date
- Nov. 2009
- Location
- Asia
- Posts
- 2,701
- Reputation
- 72
- LCash
- 0.00
- Awards
Thanks. I needed this. Working on C++ atm.
Humans yawn when they think of it.
- 14 Mar. 2012 06:02pm #5
Don't forget about multilined comments.
/* hello I'm a comment
I'm a comment on a different line.
*/
- 15 Mar. 2012 02:52pm #6