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";? "
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.
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:
<html> <head> <title> my page title </ title> </ head> <body> <? Php echo "hello world"; > </ body> </ html>
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"; >
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  = "Monday"; $ jours_semaine  = "Tuesday"; $ jours_semaine  = "Wednesday"; $ jours_semaine  = "Thursday"; $ jours_semaine  = "Friday"; $ jours_semaine  = "Saturday"; $ jours_semaine  = "Sunday"; >
<? Php $ jours_semaine = array ( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); >
|Thread Tools||Search this Thread|
|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 09:13 AM|
|Basics of accounting||Baijnath||Off Topic Chat||4||19-11-2010 03:23 PM|
|Basics of PL/SQL programs||Laquan||Software Development||5||15-02-2010 04:35 PM|
|Basics of NetBeans IDE||- Empty Shell -||Software Development||4||14-02-2010 04:56 AM|
|Java Programming Language Basics: Reflection Basics and Class Class||mayuri_gunjan||Guides & Tutorials||6||29-08-2005 01:04 AM|