PDA

View Full Version : PHP tutorial for total noobs :p



T0X!C-uk
29-04-2006, 11:11 PM
Ok some of you may have read my tutorial that has been sticked for over a year :p http://www.habboxforum.com/showthread.php?p=476142 im going to write another one now but try and explain things as much as possible. Ill write a few tutorials over several weeks and then code a simple program write it up in a tutorial and hopefully from that you will learn a thing or 2 about how PHP works:

First off what is PHP?
the actual name is Hypertext Preprocessor but was given the abbreviation PHP because it sounded better then HPP. PHP is server side code meaning it can only be read by a server with PHP installed. If you tried to view PHP from your computer it wouldnt work unless you had PHP (and mysql if need be)installed on your computer. When a server recognises a web page contains PHP, normally by the file extension i.e. .php, the page is first sent to the PHP processor. The PHP processor then runs the PHP code, and sends the results back to the web server, either as an instruction such as to redirect the user to another page, or as standard HTML which the web server can then send to the browser. If you want to learn more about how PHP works visit www.php.net (http://www.php.net) or you can PM me :)

Ok you may be a little bored after reading that but you need to know your history knowing your history can get you along way in life ;).
Anyways lets get to learning some PHP only this time in more detail.

PHP Syntax
You need to follow these rules in order to create a properly structured code. If you dont know how to use these PHP will be usless. Syntax may sound like its going to be difficult but once i have explained it will become clear and simple.


<?php
?>

Confused? Well you shouldnt be :p the above code is the opening and closing tags of PHP ALL PHP code must start and end with the above code <?php is the opening line and ?> is the closing line.

Example:


<?php
echo "Visit Habblog.com :)";
?>

(forget everything between the <?php and ?> as I will explain those later or you can just read my other tutorial.

Semicolons
Semicolons are very important when using php these are a comman script error because people forgot to use them. a Semicolon is ; if you didnt know already :p. The semicolon signifies the end of a PHP statement and should NEVER be forgotten. look at the example below everyline that says Visit Habblog.com has a Semicolon on the end.

Example:


<?php
echo "Visit Habblog.com :)";
echo "Visit Habblog.com :)";
echo "Visit Habblog.com :)";
echo "Visit Habblog.com :)";
echo "Visit Habblog.com :)";
?>


White Space
White space is sometimes a big problem for someone who does not know alot about PHP. When you use a program such as Dreamweaver to code a webpage in html and you hit Enter it creates a line break automatically, if however you did this with PHP would would just create whitespace within your coding and would not change when view on a webpage. in order to create a line break in PHP you need to use the <br /> code.

Example


<?php
echo
"visit habblog.com<br />
visit habblog.com";
?>

You may have noticed that the <br /> code is contained within the speachmarks of the code. this is important because if you did the <br /> outside of the speachmark it would not work.

I will continue this tomorrow sometime as i need sleep :p.
If you thought any of this was hard or confusing try looking PHP up on google see what you find :) it may help you understand things alot better than what i am able to explain.

additional
30-04-2006, 08:23 AM
*reads title* woohoo something for me :eusa_danc

lol, nice. +rep

Recursion
30-04-2006, 08:28 AM
I let Dreamweaver do all the easy tasks hence i cannot make a dj panel or even a news system :D

Flisker
30-04-2006, 11:52 AM
-Visits Habblog.com- PMSL All it says Through out the Tut Lol

T0X!C-uk
30-04-2006, 12:52 PM
-Visits Habblog.com- PMSL All it says Through out the Tut Lol

couldnt think of anything else to put :p
ill add some more shortly next up is Variables :)

Want to hide these adverts? Register an account for free!