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:
Now we gonna create your first PHP page.
As you can see can you jump in and out of php mode anytime you want with:
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
is a variable, something that is essential in any programming language.
The variable name have the value James.
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
footer.php
variable.php
index.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
- 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>
PHP Code:
<?php // starts php mode
?> // ends php mode
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";
The variable name have the value James.
PHP Code:
print("I, ".$name.", knows PHP!");
About variables:
$<variable name> = "<value here>";
Now, how to include:
header.php
PHP Code:
<html>
<head>
<title>PHP is so funny! HAHAHA!</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");
?>
This was a tutorial for VDCore, written by mitsurug1.
PM if you got any Q's, or reply here.
Also check:
www.php.net
