Tutorial: PHP Tutorial - the Basics
Author: laconix / inevitable_chaos
Difficulty: Easy
Description: Just the bare essentials to get you started in PHP.
Prerequisites: Basic html knowledge, a web server with PHP installed.

Step 1: The Basics


Okay to get started create a basic html page like such:
Okay you're familiar with this no doubt, now to add in the PHP.
<body><?phpecho "Hello World!";?></body></html>
All this simple code does is echo Hello World onto the page.
The 2 most used commands to output information in PHP are print and echo.
I purchased a handbag from brandbagshop.net. It only takes 3days to get it. So quickly.
doesn't even work.
Maybe because he forgot a space between the &lt;?php and echo<br />
I'm new to php and most of the web site stuff, so could you tell me what you mean when you say "a web server with PHP installed."
<a rel="nofollow" href="http://www.apachefriends.org">http://www.apachefriends.org</a><br/>
You may already know, but a webserver is what holds the website files and handles all the requests. You could open a regular html file in firefox or iexplorer but if you wanted to use javascript php asp xml sql etc... the site has to be viewed through a webserver. If you use an internet host to store your website files, they already have everything setup for you. If you want to view javascript and other languages beside html by reading the files directly off your computer you will need to setup up a webserver (such as apache or iis) and to view php pages on it you'll need to add the php.ini module to it. The easiest way to start up is to just get an online host and upload your files to it to get a basic understanding and as you move along eventually you'll want to setup a webserver. Note: Free hosted sites like geocities don't support things like sql databases or php code, some don't even support javascript. if you really are just getting started goto www.w3schools.com. They have awesome tutorials that cover a lot of whats out there.
not true... javascript and other similar languages that are proccessed use-side can be run from your won computer... it is only server-side languages that need a webserver with it installed...
Well you can have a very basic webserver with nothing but the ability to show html pages to people, and let the browse listings of files.. Or you can have a very extensible one that has support for languages such as PHP, or perhaps it may have a MySQL database. It is very uncommon, very very uncommon, to have a webserver nowadays that only supports html. Most good free webhosts will support PHP to an extent.
This is a nice little instructable but you don't realy cover much on how to run the php files, ect. I might make one that goes into deeper debth, maybe look at some functions and databse intergration.
Is it possible to open a php file without using the internet? (normally I run them by going to (my IP address)/filename.php)
Any comments/corrections are greatly appreciated. :D
A little simplistic. I'd recommend demonstrating how to interact with the user as well, (IE: Input a number...) and perhaps how to run a basic loop (while).
Yeah, i was hoping to keep it really basic to start off with. As not to scare anyone off learning it.
good instructable, are you going to follow up with any more?
Yep, hopefully soon.
Just something most self taught people over look.<br/><br/>== is equal to<br/>=== is equal to and of the same type<br/><br/>so a difference would be say:<br/>$true = TRUE;<br/>$a = 1;<br/><br/>if($a === $true){<br/>echo $a.&quot; = 1 and is BOL TRUE&quot;;<br/>}else{<br/>echo $a.&quot; = 1 and is NOT a bol&quot;;<br/>}<br/>

About This Instructable


11 favorites


More by inevitable_chaos: Batch Tutorial - Take 2 Batch Tutorial - Take 1 Learn how to program PHP style
Add instructable to: