Results 1 to 2 of 2

Thread: PHP Course : Basics

  1. #1
    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)

    Explanations

    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):

    Code:
    <? 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.

  2. #2
    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:

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

    variables

    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:

    Code:
    <? 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:

    Code:
    <? 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):

    Code:
    <? 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.

Similar Threads

  1. Basics of My SQL
    By L 4 Life in forum Software Development
    Replies: 6
    Last Post: 01-03-2011, 09:13 AM
  2. Basics of accounting
    By Baijnath in forum Off Topic Chat
    Replies: 4
    Last Post: 19-11-2010, 03:23 PM
  3. Basics of PL/SQL programs
    By Laquan in forum Software Development
    Replies: 5
    Last Post: 15-02-2010, 04:35 PM
  4. Basics of NetBeans IDE
    By - Empty Shell - in forum Software Development
    Replies: 4
    Last Post: 14-02-2010, 04:56 AM
  5. Java Programming Language Basics: Reflection Basics and Class Class
    By mayuri_gunjan in forum Guides & Tutorials
    Replies: 6
    Last Post: 29-08-2005, 12:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,653,952.28540 seconds with 17 queries