BSNNetwork Forums

Full Version: PHP basics
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What is PHP?
PHP is a programming language designed for making dynamic web content. It can(and should) be use in addition with HTML.

How do I make a page in PHP?
To make a page in PHP first you make a normal HTML page but instead of naming it .html you name it .php.

How do I add PHP code?
Like this...

PHP Code:
<?php
//php code here
?>

In this example // makes that line a comment, and <?php tells the computer to interpret the next lines until the ?> as php.

How do I do and "if then" statement in PHP?
Like this...

PHP Code:
<?php
$number
=3;
if (
$number==3)
{ echo(
"hello"); }
else
{ echo(
"goodbye"); }
?>

In php variables are defined with a $ before them, so when the code above says $number=3 it is saying that the variable number is equal to 3. The if statement is comparing the variable number to the number 3. (the == means that it should compare the 2) Echo is a function that can be used to print words on the screen. The ; sign means that it is the end of a statement.

Where can I learn more about PHP?
http://php.net/ (the official php website) is a good place to start.

Thanks for posting this, very helpful.Smile
Reference URL's