PHP is a server-side code, meaning its processed before you even see the page, client-side coding is like javascript, and is processed as/when the page is loaded - Correct me if I'm wrong."PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly."
In order to start a PHP code, you have to use the correct syntax (The rules that must be followed to write properly structured code.) There are a few ways to start / end the PHP page, either: (I use the first one.)
orPHP Code:<?
?>
All PHP pages, have to end with the ".php" extension, if not the code won't work. EG: if your page is "index.html" and contains PHP then rename it to "index.php"PHP Code:<?php
?>
Echos
Lets just say, its basically like "Shouting", onto a page... There are different ways to echo
PHP Code:<?
echo("Hello World!");
?>Different people use different methods, but at the end of the day they both do the same principle.PHP Code:<?
echo "Hello World";
?>
Try making a page called "driftpanzy.php" - Please check if you have PHP installed on your server/hosting or just ask me for 10MB Hosting + 100MB Bandwidth free of charge, TOS applies
Once you've made the file, try doing HTML + PHP, I don't recommend building big systems like this, but you can get the hang of it.
It will display:PHP Code:<html>
<head>
<title>PHP DriftPanzy</title>
</head>
<body>
<?
echo("Hello World");
?>
</body>
</html>
Semicolons...Hello World
Semicolon ends a line of PHP code, signifying the end of a PHP statement and should never be forgotten. EG: If we repeated "Hello World" code several times, then we would need to place semicolons at the end of each statement
PHP Code:<html>
<head>
<title>PHP DriftPanzy</title>
</head>
<body>
<?
echo("Hello World");
echo("Hello World");
echo("Hello World");
echo("Hello World");
?>
</body>
</html>You can add "<br>" after the Hello World, before the LAST quotation.Hello WorldHello WorldHello WorldHello World
Variables
A variable is a means of storing temporary data, such as a text string "Hello World" or an integer value. A variable can be reused throughout the coding process, to define a variable try the following...
You can call $newvar anything, but has to start with a dollar sign ($)PHP Code:<?
$newvar = "Hello World";
?>
You can also use the echo feature above on it, eg:
Displays:PHP Code:<?
$newvar = "Hello World";
echo($newvar);
?>
As you can see I didn't include the quotations, i've just placed the var in, if you want to include text/html into the echo you can do thisHello World
Displays:PHP Code:<?
$newvar = "Hello World";
echo("<br>".$newvar." World is great");
?>
A bit more information on variablesHello World World is great
You've covered today: Basic PHP; Echos, showing information on the page; Variables/Strings, how to store temporary data to use later on in the php page.
- Must start with a letter or underscore "_".
- May only be comprised of alpha-numeric characters and underscores. a-z, A-Z, 0-9, or _ .
- Variables with more than one word should be separated with underscores. $my_variable
- Variables with more than one word can also be distinguished with capitalization. $myVariable
Any more help just e-mail me! [email protected]
Depending on how much views and how much I help people, I will continue explaining how EASY PHP really is!
Edited by Favourtism (Forum Super Moderator): Thread Closed to avoid constant arguing.











