Php Geo Book

  • View
    19

  • Download
    0

Embed Size (px)

DESCRIPTION

PHP learn in georgian

Text of Php Geo Book

  • 2007

    PHP

    |Gnome

    2007 , PHP- .

  • I

    PHP

    PHP

    ?

    php- , :

    HTML / XHTML

    HTML- : http://ka.wikibooks.org/wiki/HTML

    PHP?

    PHP , , Hypertext Preprocessor( )

    PHP , ASP

    PHP

    PHP (MySQL, Informix, Oracle, Sybase, Solid,

    PostgreSQL, Generic ODBC ..) PHP (OSS) PHP -

    PHP ?

    PHP , HTML

    PHP , HTML

    PHP : ".php", ".php3", ".php4", ".php5", ".phtml"

    MYSQL?

    MySQL

    MySQL

    MySQL SQL- MySQL

    MySQL-

    PHP + MYSQL

  • PHP MySQL - ( , Windows- Unix )

    PHP?

    PHP (Windows, Linux, Unix ..)

    PHP , - (Apache, IIS ..)

    PHP

    ?

    Apache server, Windows-, Linux -

    PHP , Windows-, Linux - MySQL , Windows-, Linux -

    PHP INSTALL

    ?

    , , PHP, MySQL, Apache Server.

    PHP - , ! , .php . PHP-.

    , PHP-, PHP. PHP- :

    http://www.php.net/manual/en/install.php

    PHP

    PHP: http://www.php.net/downloads.php

    MYSQL

    MySQL : http://www.mysql.com/downloads/index.html

    APACHE

    Apache : http://httpd.apache.org/download.cgi

    PHP

  • PHP

    PHP : . PHP .

    , , : .

    , :

    PHP HTML , , HTML PHP

    .

    PHP , "Hello World" :

    PHP- -. - , .

    PHP- : echo print. echo.

    PHP-

    PHP-, // -, , /* */

    .

    PHP

  • PHP-

    , ,

    , .

    , .

    PHP- : $.

    PHP- :

    $var_name = value;

    :

    PHP

    PHP-

    , , PHP- .

    PHP .

    , : _

    (a-Z, 0-9, _ )

    .

    , ($my_string), ($myString)

    PHP

    PHP-

    , .

    .

    , .

    , PHP "Hello World" $txt :

  • $txt="Hello World";

    echo $txt;

    ?>

    :

    Hello World

    .

    (.) .

    :

    :

    Hello World 1234

    ,

    . . .

    STRLEN()

    strlen() .

    "Hello world!" :

    :

    12

    STRPOS()

    strpos() , .

    , . , : FALSE.

  • :

    : 6

    "world" .

    , 0- 1-.

    PHP

    + X=2; x+2 4

    - X=2; 5-x 3

    * X=4; x*5 20

    / 15/5 3

    % 5%2 1

    ++ X=5; x++ X=6

    -- X=5; x-- X=4

    ...,

    = X=y x=y

    += X+=y x=x+y

    -= x-=y x=x-y

    *= X*=y x=x*y

    /= X/=y x=x/y

    %= X%=y x=x%y

    == 5==8, False

    != 5!=8, True

    > 5>8, False

    < 5= , 5>=8, False

  • && And x=6 y=3

    (x < 10 && y > 1) true

    || Or x=6 y=3

    (x==5 || y==5) false

    ! Not x=6 y=3 !(x==y) true

    PHP IF. ..ELSE

    , ,

    .

    .

    if...else - ,

    , .

    elseif - if...else- , .

    IF...ELSE

    :

    if (condition)

    code to be executed if condition is true;

    else

    code to be executed if condition is false;

    :

    "Have a nice weekend!" , "Have a nice day!":

  • ELSEIF

    :

    if (condition)

    code to be executed if condition is true;

    elseif (condition)

    code to be executed if condition is true;

    else

    code to be executed if condition is false;

    :

    "Have a nice weekend, Friday, "Have a nice Sunday!", . "Have a nice day!":

    PHP SWITCH

    , Switch .

    switch if..elseif..else .

    :

    switch (expression)

    {

    case label1:

    code to be executed if expression = label1;

    break;

    case label2:

  • code to be executed if expression = label2;

    break;

    default:

    code to be executed

    if expression is different

    from both label1 and label2;

    }

    :

    :

    .

    .

    , .

    , break

    .

    (default) .

    PHP

    ?

    PHP-, , .

    , .

    ID, .

    :

  • Numeric array( ) - ID Associative array( ) - , ID

    .

    Multidimensional array( ) - .

    .

    1:

    , ID :

    $names = array("Peter","Quagmire","Joe");

    2:

    , ID :

    $names[0] = "Peter";

    $names[1] = "Quagmire";

    $names[2] = "Joe";

    ID :

  • ,

    :

    $ages['Peter'] = "32";

    $ages['Quagmire'] = "30";

    $ages['Joe'] = "34";

    ID :

    :

    Peter is 32 years old.

    :

    , ID

    :

    $families = array

    (

    "Griffin"=>array

    (

    "Peter",

    "Lois",

    "Megan"

    ),

    "Quagmire"=>array

    (

    "Glenn"

    ),

    "Brown"=>array

    (

    "Cleveland",

    "Loretta",

    "Junior"

    )

    );

    , :

    Array

    (

    [Griffin] => Array

    (

    [0] => Peter

    [1] => Lois

    [2] => Megan

    )

    [Quagmire] => Array

  • (

    [0] => Glenn

    )

    [Brown] => Array

    (

    [0] => Cleveland

    [1] => Loretta

    [2] => Junior

    )

    )

    2:

    :

    echo "Is " . $families['Griffin'][2] .

    " a part of the Griffin family?";

    :

    Is Megan a part of the Griffin family?

    PHP

    , , . .

    PHP- :

    while -

    do...while -

    for - n- foreach -

    WHILE

    while (condition)

    code to be executed;

    , i , 5-. i 1-:

  • DOWHILE

    do

    {

    code to be executed;

    }

    while (condition);

    i- i- 5:

    FOR

    for (initialization; condition; increment)

    {

    code to be executed;

    }

    : For . ,

    .

    , , .

    True, False.

  • "Hello World!"- :

    FOREAC H

    , $value -

    , .

    foreach (array as value)

    {

    code to be executed;

    }

    PHP

    PHP

    , .

    PHP :

    "function()"

    - .

    .

    "{" - .

  • "}" -

    PHP

  • :

    My name is Kai Jim Refsnes.

    My name is Hege Refsnes.

    My name is Stale Refsnes.

    2

    :

    :

    My name is Kai Jim Refsnes.

    My name is Hege Refsnes!

    My name is Stle Refsnes...

    PHP -

  • :

    1 + 16 = 17

    PHP

    PHP

    :

    Name:

    Age:

    HTML .

    , "welcome.php" .

    "welcome.php" :

    Welcome .

    You are years old.

    :

    Welcome John.

    You are 28 years old.

    PHP $_GET

  • THE $_GET

    $_GET HTTP GET

    .

    $_GET method="get"- . , GET (

    ) (. 100

    ).

    Name:

    Age:

    , URL :

    http://geocg.myweb.ge/welcome.php?name=Peter&age=37

    "welcome.php" $_GET

    :

    Welcome .

    You are years old!

    $_REQUES T

    PHP $_REQUEST : $_GET, $_POST, $_COOKIE.

    PHP $_REQUEST , GET POST .

    :

    Welcome .

    You are years old!

    PHP $_POST

    $_POST

    $_POST HTTP POST .

  • $_POST method="post"- . , POST .

    Enter your name:

    Enter your age:

    , URL :

    http://geocg.myweb.ge/welcome.php

    "welcome.php" $_POST

    :

    Welcome .

    You are years old!

  • II

    PHP

    PHP

    PHP DATE()

    :

    date(format,timestamp)

    .

    . .

    PHP - ?

    , January 1, 1970 at 00:00:00 GMT. Unix .

    PHP -

    date() /

    . / .

    , :

    d - / (01-31)

    m - (01-12)

    Y -

    , "/", ".", "-"

    :

    :

  • 2007/07/11

    2007.07.11

    2007-07-11

    PHP -

    date() .

    . ,

    .

    , mktime() .

    mktime() Unix .

    :

    mktime(hour,minute,second,month,day,year,is_dst)

    mktime():

    :

    Tomorrow is 2006/07/12

    PHP -

    PHP ,

    include(), require() . , . include()

    ( ) , require() ( ).

    , , ,

    ,

    .

    .

    , .

    , ,

    , .

  • INCLUDE()

    include()

    .

    1:

    , "header.php".

    , include() :

    Welcome to my home page

    Some text

    2:

    .

    :

    Home |

    About Us |

    Contact Us

    , "index.php", "about.php", "contact.php" "menu.php" .

    :

    Welcome to my home page

    Some text

    :

    Home |

    About Us |

    Contact Us

    Welcome to my home page

    Some text

    REQUIRE( )

  • include()