Go Back   TechArena Community > ARENA > Guides & Tutorials
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links

PHP Course : Basics

Guides & Tutorials

Thread Tools Search this Thread
Old 20-11-2008
Join Date: Aug 2008
Posts: 30
PHP Course : Basics

Introduction to PHP
Note that it is easier to start learning PHP with some basic HTML language, since both languages are often used together. To acquire these databases in HTML, there is nothing better than to install a html editor worthy of the name (Dreamweaver, GoLive, etc.). To begin to draw the elements of a web page with their assistants, and look at the code html went into parallel. (often, you'll have a code window and a window design that will allow you to match)


1. History and definitions

First, step a little beard, that you may pass, but which may be interesting to better understand the following and your general knowledge.

What does the acronym PHP? PHP is a programming language oriented web meant P ersonal H ome P age Tools at the outset, but became PHP: Hypertext Preprocessor.

This language is a scripting language that is run on the server side, which is important. It implies that the source code of websites developed in PHP are not visible, the server will interpret the code and returns HTML to the client.
For a file to be interpreted as a php script, the name must end with the extension. Php, and there must be php tags start and end script within that file. These tags are most often (beginning and end, respectively):
- <? Php

Php language has the great advantage of being free, a huge number of scripts circulating on the net, allowing beginners to be confirmed and helped save time, why not.
Php scripts can be run on Apache web servers, for example. Most web hosts have apache servers nowadays, but you can also install a home without a problem, either Linux or Windows, to include your tests. In following this tutorial, I assume that you have this kind of server for hosting php pages (at home or not).

2. Hello world

To not change the habits of good programming, we started with a hello world, which will be your first script. (this is to write "hello world" to the screen for those who do not know)

To do this, create a file named helloworld.php, for example, and type the following in (with a simple text editor or notepad style editor html):

<? Php echo "hello world";? "
Save the file, send it to the root of your web server and run it in your browser, you should see appears the text "hello world" on the screen.

The script can not be more basic, breaks down like this:
<? Php -> tag beginning of a php script (required)
echo-> PHP used very often, used to write text in the output window, the web browser that will run this script in this case.
> -> End tag for a php script (required)

NB: Please note that "hello world" in quotation marks means that the text should display echo instruction and that instructions php always end with a semicolon.

Reply With Quote
Old 20-11-2008
Join Date: Aug 2008
Posts: 30
Re: PHP Course : Basics

In PHP we can enter comments in our code (which is strongly advised to read your code elsewhere), by following ways:
/ / Everything that follows these two slashes is the comment will not be interpreted by the server
/ * All that is between these characters is the comment will not be interpreted by the server * /

It may also introduce php code in HTML, and yes! On the previous script hello world, so I could add a title to my page (for example) by writing:

<title> my page title </ title> 
</ head> 

<? Php 
echo "hello world"; 
</ body> 
</ html>
In this case php include in html, the file is named with an extension. Php forever.


Php variables, as in any programming language, are objects that can contain data. These data can be changed at will during the execution of a script. They are essential for programming!

Php variables can be named with letters, numbers, and the _, but the name can not start with a digit. These names are sensitive and they always (well in php) $ dollar sign in front. Example: $ nom_variable variable is a valid, but $ 89variable is not valid name.

PHP has another advantage with variables: there is no need to define or to typer. You can write:

$ pi = 3.14; / / php will while $ pi is a real point
$ pi_arrondi = 3 / / php $ pi_arrondi know that is an integer
$ sigle_html = "hypertext markup language"; / / here is a string

Here is a sample script php, performing calculations with variables, which should be fairly simple to understand:

<? Php 
largeur_rectangle = $ 5; 
$ longueur_rectangle = 10; 
$ surface_rectangle = 5 * 10; 
echo "The surface of the rectangle is equal to $ surface_rectangle"; 
Finally, there are variables one particularly because they can keep more data: the tables.
Thus, to illustrate the tables, if I need a variable containing all the days of the week to work with them days later in the script, I may define a table like this:

<? Php 
  $ jours_semaine [0] = "Monday"; 
  $ jours_semaine [1] = "Tuesday"; 
  $ jours_semaine [2] = "Wednesday"; 
  $ jours_semaine [3] = "Thursday"; 
  $ jours_semaine [4] = "Friday"; 
  $ jours_semaine [5] = "Saturday"; 
  $ jours_semaine [6] = "Sunday"; 
I can also write (which will return to the same thing):

<? Php 
$ jours_semaine = array ( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); 
One wonders at first sight, what can these arrays, but no worries, you will know quickly enough in handling PHP in practice.
Reply With Quote

  TechArena Community > ARENA > Guides & Tutorials

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: "PHP Course : Basics"
Thread Thread Starter Forum Replies Last Post
Basics of My SQL L 4 Life Software Development 6 01-03-2011 08:13 AM
Basics of accounting Baijnath Off Topic Chat 4 19-11-2010 02:23 PM
Basics of PL/SQL programs Laquan Software Development 5 15-02-2010 03:35 PM
Basics of NetBeans IDE - Empty Shell - Software Development 4 14-02-2010 03:56 AM
Java Programming Language Basics: Reflection Basics and Class Class mayuri_gunjan Guides & Tutorials 6 29-08-2005 12:04 AM

All times are GMT +5.5. The time now is 10:08 PM.