Hello evilzoners,
This is a very basic php tutorial, to get you motivated and let you see how easy php actually is.
Before we begin, you will probally need an webserver with php enabled , or you can install XAMP on your computer.
In this guide i will be using XAMP, and notepad++.
The installation of xamp is pretty easy, when you get the option to install as service, you probably won't need that.
At the end of the installation you get promted to open up xamp control panel, choose yes.
Next to "Apache" there is an start button hit it, apache is a webserver, in xamp php is installed into apache.
If everything is working right you can go to
http://localhost/ in your web-browser and the server will load.
Lets get started with an Hello world example:
Open up notepad++ or any text editor you like to use (I prefer netbeans, but you wont need that for the very basics).
Create a new file, then go to "syntax" in the toolbar, and select php.
As first you need to open the php code, in other words you tell the webserver there is an php script coming.
Type:
<?php
And go to the next line, this will be your first line of php code !!.
What do we want to do ??, we want the words "Hello World!!" to be printed on the website.
First we will write down the command, wich will be "echo".
Then we will write our text using quotations, and after that close the echo command using ";".
What we got :
<?php
echo "Hello World!!";
Okay, this does everything we need.
Then we need to close the php code by adding ?> to the last line.
As you notice its similar to <?php but the without php and in reverse.
So the final code should be :
<?php
echo "Hello World!!";
?>
Great!!, what we need to do now is to save it to the webserver directory.
Go to save as, The file name needs to be something like Helloworld.php.
Save it to your xamp install directory +htdocs for example : C:\xampp\htdocs
Great!!, now go to
http://localhost/Helloworld.php in your browser, an WHALA!, you got your first php website.
Tommorow or tonight i will continue with a "if statement" and the basics of using variables.
Stay tuned!.