[Tutorial] Getting started 12-21-2013, 03:35 AM
#1
What is PHP?:
PHP stands for Hypertext Preprocessor and is a famous programming language for creating websites. These big websites all use it
So how do I get started?:
First of you need to get a web server to host your website. Head over to
Xampp and download the installer version for your OS. I am not going to go through how to install these as they are pretty straight forward.
Okay, I've installed Xampp what now?:
Now a control panel should popup. Just click on "Start" on the Apache. If you are having problems starting it then check this
guide if you have Skype installed as they interfere with eachother.
If Apache's background is now green then head on over to your web browser and type in localhost or 127.0.0.1 either will go to the same destination; your computer. You should be greeted with a Xampp logo and some language options. If you are then continue to the next step. If you're not then double check if Apache is actually running.
Head over to C:\xampp\htdocs (If this doesn't exist then replace C with your system drive or check that you installed the program correctly)
You should be greeted with a bunch of files. Delete them as they are no longer in use.
Now create a file called "index.php". You're gonna see the index file when visiting localhost. It shows as up default basically.
Now for coding I would suggest getting Notepad++ as it supports a lot of programming languages and got nicely added syntax highlighting. Download it here
Now edit the index.php file with whatever text editor you choose to have.
Programming Part:
Now the fun part begin!
http://www.youtube.com/watch?v=F9FMW-m4gvo
The first thing you wanna do is add the following to your file
This simply declares that the following code is PHP and should be treated that way.
Print text(echo):
For a simple "hello world" script we'll be using the "echo" command. So we're gonna place that in between the <?php and ?> like the following
Save that and open localhost in your browser. It should say "Hello World" in a black text. If it does the same for you then congratulations, you've successfully made your first Hello World website!
Variables:
When programming you often wanna set a value as a variable. Basically you're setting a text as a "fixed" name so you can get it later on.
using the code. This sets a variable "greeting" to "hello" so let's play around with it.
This code will show exactly what it did before on your browser but the only change is that you've now integrated a variable! Now if we'd be changing the "greeting" variable to let's say "Good bye" we'd simply just do the following
Now if you update the website in your browser you'll see "Good Bye World". Now you can change the greeting variable to whatever you want as it'll just show whatever the greeting variable is declared as. If you wanna change the variable name to something else this is just fine. Example below:
Which will simply output "Historic forum is: Awesome"
If statements:
If statements are basically there so you can compare texts and variables and vice versa.
If statements work similar to this
so let's do an example script
Alright let's debunk all of this code. First we've already talked about variables and we know that the variable "hf" is equals to "cool" but what then? Now our code is checking if $hf really is equal to "cool" and if it is it'll say "Yeah man HF is cool!" but if we were to change the "hf" variable into "stupid" our if statement would say "Nah man I'm not feeling you..". Because $hf's content is equal to "Stupid" and "Stupid" is not the same as "cool".
End
I'm actually gonna stop the tutorial here due to being to tired. I might continue if people want me to add other features(however this is just a getting started thread) or want me to change something because it was hard to understand. You can always PM me or post here for help. However I am gonna leave this out here because it'll be helpful for you in the future.
Don't use http://www.w3schools.com as they don't think of security in their code. Alot of their codes are vulnerable to attacks. Use http://php.net
When you're getting better with PHP I suggest you start reading
http://www.php.net/manual/en/security.da...ection.php
and
http://php.net/htmlentities
as they will protect you against attacks such as XSS(Cross site scripting) and SQLi(Structured Query Language Injection)
PHP stands for Hypertext Preprocessor and is a famous programming language for creating websites. These big websites all use it
- Facebook
- Apple
- Wikipedia
- Yahoo
- Flickr
- Vimeo
- iStockPhoto
- Susprod
So how do I get started?:
First of you need to get a web server to host your website. Head over to
Xampp and download the installer version for your OS. I am not going to go through how to install these as they are pretty straight forward.
Okay, I've installed Xampp what now?:
Now a control panel should popup. Just click on "Start" on the Apache. If you are having problems starting it then check this
guide if you have Skype installed as they interfere with eachother.
If Apache's background is now green then head on over to your web browser and type in localhost or 127.0.0.1 either will go to the same destination; your computer. You should be greeted with a Xampp logo and some language options. If you are then continue to the next step. If you're not then double check if Apache is actually running.
Head over to C:\xampp\htdocs (If this doesn't exist then replace C with your system drive or check that you installed the program correctly)
You should be greeted with a bunch of files. Delete them as they are no longer in use.
Now create a file called "index.php". You're gonna see the index file when visiting localhost. It shows as up default basically.
Now for coding I would suggest getting Notepad++ as it supports a lot of programming languages and got nicely added syntax highlighting. Download it here
Now edit the index.php file with whatever text editor you choose to have.
Programming Part:
Now the fun part begin!
http://www.youtube.com/watch?v=F9FMW-m4gvo
The first thing you wanna do is add the following to your file
Code:
<?php
?>This simply declares that the following code is PHP and should be treated that way.
Print text(echo):
For a simple "hello world" script we'll be using the "echo" command. So we're gonna place that in between the <?php and ?> like the following
Code:
<?php
echo "Hello World";
?>Save that and open localhost in your browser. It should say "Hello World" in a black text. If it does the same for you then congratulations, you've successfully made your first Hello World website!
Variables:
When programming you often wanna set a value as a variable. Basically you're setting a text as a "fixed" name so you can get it later on.
using the code
Code:
$greeting = "Hello";Code:
<?php
$greeting = "Hello";
echo "$greeting World";
?>This code will show exactly what it did before on your browser but the only change is that you've now integrated a variable! Now if we'd be changing the "greeting" variable to let's say "Good bye" we'd simply just do the following
Code:
<?php
$greeting = "Good bye";
echo "$greeting World";
?>Now if you update the website in your browser you'll see "Good Bye World". Now you can change the greeting variable to whatever you want as it'll just show whatever the greeting variable is declared as. If you wanna change the variable name to something else this is just fine. Example below:
Code:
<?php
$historicforums = "Awesome";
echo "Historic forum is: $historicforums";
?>Which will simply output "Historic forum is: Awesome"
If statements:
If statements are basically there so you can compare texts and variables and vice versa.
If statements work similar to this
Code:
if($variable == "text") {
do the following inside this code
} else {
this is not true variable isn't equals to text at all..
}so let's do an example script
Code:
<?php
$hf = "cool";
if($hf == "cool") {
echo "Yeah man HF is cool!";
} else {
echo "Nah man I'm not feeling you..";
}
?>Alright let's debunk all of this code. First we've already talked about variables and we know that the variable "hf" is equals to "cool" but what then? Now our code is checking if $hf really is equal to "cool" and if it is it'll say "Yeah man HF is cool!" but if we were to change the "hf" variable into "stupid" our if statement would say "Nah man I'm not feeling you..". Because $hf's content is equal to "Stupid" and "Stupid" is not the same as "cool".
Code:
<?php
$hf = "Stupid";
if($hf == "cool") {
echo "Yeah man HF is cool!";
} else {
echo "Nah man I'm not feeling you..";
}
?>End
I'm actually gonna stop the tutorial here due to being to tired. I might continue if people want me to add other features(however this is just a getting started thread) or want me to change something because it was hard to understand. You can always PM me or post here for help. However I am gonna leave this out here because it'll be helpful for you in the future.
Don't use http://www.w3schools.com as they don't think of security in their code. Alot of their codes are vulnerable to attacks. Use http://php.net
When you're getting better with PHP I suggest you start reading
http://www.php.net/manual/en/security.da...ection.php
and
http://php.net/htmlentities
as they will protect you against attacks such as XSS(Cross site scripting) and SQLi(Structured Query Language Injection)

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
![[Image: lonoTbJ.png]](http://i.imgur.com/lonoTbJ.png)



I tried to learn Objective C but had little luck
![[Image: ghost_loading_sig_by_exposedgraphics-d75fc5u.gif]](http://fc04.deviantart.net/fs71/f/2014/037/2/1/ghost_loading_sig_by_exposedgraphics-d75fc5u.gif)












![[Image: dHJ4Beo.gif]](http://i.imgur.com/dHJ4Beo.gif)