Jump to content

First steps into PHP - Part 1


Mattle

Recommended Posts

First steps into PHP

 

What is PHP?

PHP stands for Hypertext Preprocessor and is executed by a webserver instead of the browser, the program where are watching this page in. This means that the server executes all the pages who are containing actions, server-side and then passes the results to your browser.

 

You think, well whats the advantage of that? Well by this way you can make the page dynamic. With a normal file the whole file is send to the browser and the browser executes it. The result will be always the same because the file on the server won’t be edited at all without changes from the webmaster. When you use PHP you can execute the scripts on the server and get information from databases which you add to the pages when you run. By keeping this in your mind, you can imagine that you could create complex dynamic webpages like this forum which is also build on PHP.

 

What do I need?

In this tutorial I assume you have some basic skills like using FTP and creating HTML pages. If you don’t understand these things I would recommend stop reading this tutorial and first get some more experience in those other subjects.

 

Ofcourse you need a webhost who supports PHP. In these days almost all hosts offer this to their clients. If you are not sure, just ask them. You also need a program to create and edit PHP files. There are a bunch of programs for this, we are using however notepad as it is our beginning to PHP.

You know now the requirements and what PHP is, let’s get to the exciting part.

 

Creating a PHP file

To let the server know that he has to deal with a PHP file, all files are usually ending with the extension .php, for example index.php. In this file again we have to let the server know that a part is PHP code we simple use the following:

 

<?php
?>
These tags will contain our PHP code. It’s similar to the <body> tag in PHP. The easiest way to really show some text is to use the echo, like following:

 

<?php
Echo ‘Hello world!’;
?>
When you run this PHP code in your browser, you will only see the text Hello world and won’t see any PHP code. So, when you want to parse HTML code to the browser, you simply use the echo ‘’;

Use always the hooks around your text. Also use after every echo line a ; (dot comma). The server then knows a piece of code is finished.

 

Thanks for reading the first part of the multipart tutorial “First steps into PHP”.

If you have comments, suggestions, don’t be shy and send me those.

 

Thanks for reading smile.gif

Edited by Fearless Staff
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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.