PHP Begginners Guide

PHP Begginners Guide

Posted By: mitsurug1 on Mar 06, 2005

Get a basic understanding of PHP

Wan't to start with PHP? This guide is for people with no experience with scripting at all. First of all, what do you need? You need:
  • Notepad or any other text editor of your choise
  • Server with PHP or PHP installed on your workstation

Now we gonna create your first PHP page.
PHP Code:
<html>
<head>
<title>Hello World</title>
</head><body>

<?php
// Prints Hello World on the page
print("Hello World<br>");
echo(
"I know PHP");
?>
</body>
</html>
As you can see can you jump in and out of php mode anytime you want with:
PHP Code:
<?php // starts php mode
?> // ends php mode
As you may have understood the // is comments.
Other comments tags:
#
/* */

Print shows what we write in the brackets and then shows it on the page. Echo is just like print, it's does the same thing. As you also can see can you use HTML in the php functions, <br> is new line if you didn't know.

Save the the page above as hello.php and upload it to your webserver and run it, or just browse it on your workstation if you have PHP installed.

Now on to create a new page. Call this page var.php
PHP Code:
<html>
<head>
<title>PHP is fun</title>
</head><body>
<?php

$name 
"James";

print(
"I, ".$name.", knows PHP!");

?>

</body>
</html>
PHP Code:
$name "James"
is a variable, something that is essential in any programming language.
The variable name have the value James.
PHP Code:
print("I, ".$name.", knows PHP!"); 
Shows what you have wrote on the page and $name becomes what the variable has as value. You can offcourse change the value to whatever you want.

About variables:
$<variable name> = "<value here>";

Now, how to include:

header.php
PHP Code:

<html>

<
head>

<
title>PHP is so funnyHAHAHA!</title>

</
head><body

footer.php
PHP Code:
</body></html

variable.php
PHP Code:
<?php
// A variable

$name "James";



?>

index.php
PHP Code:
<?php

include("header.php");


include(
"variabel.php");


echo(
"GAY!<br>");



require(
"footer.php");



?>
Include is perfect for dynamic websites.

This was a tutorial for VDCore, written by mitsurug1.
PM if you got any Q's, or reply here.
Also check:
www.php.net
  • Comment on this tutorial
  • View the Printable Version

Posted On: Mar 06, 2005

Hits: 7811 - Unique: 6177

Advertise Here!

Quick Tutorial Search

VDC - Visual Design Core on Facebook

Our Popular Tutorials

Signature Backgrounds

Abstract Wave Technique

Abstract Airbrushing

Cinema 4d Materials Tutorial

Rusty Metal Plate

Dark Art Guide

Trendy Grunge Background

Abstract Renders in Cinema 4d