Jump to content

PHP tutorial 00: introduction


Guest xaff
 Share

Recommended Posts

Basic PHP tutorial

 

I decided to make a short introduciton to PHP, I might write more tutorials if anybody would like me to.

 

What is PHP?

PHP is a scripting language, used to create dynamic webpages and retrive information from databases (such as MySQL).

 

Why use PHP/Who should use it?

Anyone who is going to run a large website would make their life easier with PHP and a database. It's easier to retrive content and it makes it possible for anyone with a webbroser to add content. (This allows you to make newsscripts, polls, counters, etc..) All in all it makes a webpage more interactive and fun to surf.

 

What you need

You will need a webserver to store your scripts on and knowlagde of HTML. Since you'll be using PHP it also has to support it. (If you're just going to play around then you could just host it yourself, PHP is avalible for both Windows and linux.) My httpd of choice is apache. PHP can be found here. In this tutorial I will not go through the installation of the server and php, as there are hundreds of tutorials on this subject to be found elsewhere on the internet. (Just google it)

 

Getting started

We'll start simple. To jump in and out of "PHP-mode" you simply:

 

<?php

// Anything put between the <?php and the ?> will be processed as PHP.

?>

 

That's easy. See the two slashes? (//) They are used for commenting, anything on a line that's behind them will not be processed. There are also other ways to comment, like "#" which does the same as "//", and "/*" and "*/". The last ones can be spread over as many lines as you like.

 

If you want something to output onto the page where the script is, you can use echo or print, two very similar commands.

 

<?php

echo("This is my first PHP-script!");

// This does the exact same as the above one

echo "Hello!";

?>

 

There are thousands of commands to be used, all of them can be found on the php website.

 

www.php.net

www.apache.net

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...