Posted on November 2nd, 2007
1100 views
Hi!
I'm Friiks, the owner of this site and I'm going to teach you some basics of php. First off PHP stands for PHP: Hypertext Preprocessor. It's a server side scripting...like ASP and it's scripts are executed on the server. It's similar to PERL and C so if you know any of them it will be way easier for you to learn PHP. This tutorial will require: * Text editor like notepad. * Server that can run PHP files (PHP Installed). Well enough talking - lets start! [1] Echoing (outputting) information. Lets learn how to actually output something! Open up your text editor and create a blank file. I called it first.php (Be sure to make the extension .php). Ok, that wasn't hard, wasn't it? Now put type <?php in first and ?>in second lines of your file. Scripting block always starts with <?php and ends with ?>. You can use <? and ?> as well but I recommend standard form [<?php]! Now your document should look like this <?php Now that you have that done put echo "Hello World!";in between the <?php and ?> tags! The file should look like this. <?php If so - upload your php file to the server and run it. It should look like this. [2] Variables in PHP. Variables in PHP are defined with an $ in front of the variable name. Like this
Variable names can only contain alpha-numeric characters and underscores (a-Z, 0-9, and _ ). You can echo variables like this
Try it out and see what it outputs! Oh, yea, numbers are set like this
Try combining two strings like this
[3] If & Else statements IF you're going to code PHP more then you'll notice how much if and else statements you will use. If you have ever coded GML, for example, you'll notice it's not much different although you have to always use brackets. Lets check if 2 numbers are equal!
Put this into a file, upload it and see what it outputs! ;) Oh and my last note! = and == has difference in PHP. = - Sets variable to a value given! == - Checks if 2 values given are equal! You can read more about operators here. Well that's pretty much all for today [I'm ill and can't write anything good anymore] so wait for second part of the tutorial! :) |