You are on page 1of 34

:

:
php


html css .
:

1..................................................................................................................................................
: 3.............................................................................................................. php
: 7.........................................
: - 14...............................................
: 17........................................................................................................................
: 22.....................................................................................................................
: 24.......................................................................................................................
: 28................................................................................................................
34.................................................................................................................................................... :

PHP

4 5
.

()
. php

php

:
- :
HTML CSS
( )

.
- :
HTML CSS
PHP MYSQL
.

!!..

- .

- () .

:
( = ..

.
- :
.

- :
()
php
=<

- : PHP

PHP .

.


php .

php 1994 Rasmus Lerdorf


Personal Home Page
C Java Perl
PHP 5
.
: 1968

..
.

() .
.

..

: .

: .
:> >
: <> .. <>

--------------------------------

( ) .
:

- : Notepad ++Notepad
- : .

: Localhost
.

: Apache -

: PHP - plug-in Apache

: MySql -

WampServer

appserv...

Wamp

html.28739/01net.com/telecharger/windows/Internet/editeur_de_site/fiches.http://www

taskbar

Exit .

WampServer :

:localhost -
.
:
http://localhost
IP

127.0.0.1//:http

:phpMyAdmin -

:

- C:\wamp\www

.
.

html xhtml .
php php html
.

:1

html
><html dir=rtl
><head
><meta http-equiv=Content-Type content=text/html; charset=utf8- /
> </title ><title
></head
><body


><br /
.

></body
></html

1
html
:

.

:2 1

><html dir=rtl
><head
><meta http-equiv=Content-Type content=text/html; charset=utf8- /
> </title ><title
></head
><body

<?php
;> . <br / print
; . print
>?

></body
></html

php. +
page
C:\wamp\www
2 localhost

:

.
print echo.
php:

<?php

>?



: echo

commentaires



.

source.


// .
:
*/



*/


< ?php
// Name of my father
; >echo Elhaj Addi <br /
*/
The next line refers to the name of my grandmother.
Of note: My grandmother from my father
*/
echo elhaja Mahjouba om Elhaj Addi
>?
:
Elhaj Addi
elhaja Mahjouba om Elhaj Addi

Variables
:

<>
.
.
:
- : <> .
- : <> .
$ :
: $ .

:
;$name=yassine
;$age=21
$message=this forum is the best

:
:
: string -
int: integer-
:float- double -
bool: boolean- true or false :
.
:Null -
:array -

<?php
;>$name= yalsne <br /
;$nickname= king of the programming
;echo $name
;echo $nickname
>?

:
yalsne
king of the programming

:
:
-1
:
3$amal= i don>t now.. any work for example: <policeman> lol
3amal

-2 :
name$ Name$

-3 :
;$name= >Acadamy the php
:
;$name= Acadamy the php
-4 _ : underscore :
;$_year=2010
;$programming_language=php

-5 :

<?php
;" $a="programming language
;"$b="php
;$c= 5
$d=$a.$b.$c
;echo $d
>?

d a , b ,c +
. string
.


* :
/ :
- :
+ :
% :

<?php
// ;7=1 $Number
// ;5=2 $Number

// ;2 $sum=$Number1 + $Number
// ;2 $subtraction=$Number1 - $Number
// ;2 $multiplication=$Number1 * $Number
// ;2 $division=$Number1 / $Number
// ;2 $rest_division=$Number1 % $Number

;>echo $sum .<br /


;>echo $subtraction .<br /
;>echo $multiplication .<br /
;>echo $division .<br /
;>echo $rest_division .<br /
>?

:
12
2
35
1.4
2


:
( )
:
.

.

:
.

..
.
if
:
) (if
{

}

<?php

;$length=75
)if ($length<=78
{
;"echo "proper length
}

>?
length 78
proper length :
length 75 75 78
proper length :
:
== : "=" "==" " "...
<:
..
>:
...
<= :
..
>=:
..
!= :

.

if ... else
.



.
:

)(if
{

}
else
{

}
:
<?php

;$length=79
)if ($length<=78
{
;"echo "proper length
}

else
{
;"echo "length is not suitable
}

>?

length is not suitable :


:
.


.

: ( .. ) ..

:
<?php
;$length=79
)if ($length<=78
{
;echo proper length
}
)elseif($length==79
{
;echo length is not suitable
}
else
{
;echo large length
}
>?

length is not suitable :


elseif
.

:
:
: AND "" &&

: OR "" ||

:
<?php
;"$name="mohamed
; $age= 99
)if($name=="mohamed" && $age==99
{
;"echo "true
}
else
{
"echo "false
}
>?

true :
:2
<?php
;"$name="mohamed
; $age= 98
)if($name=="mohamed" || $age==99
{
;"echo "true
}
else
{
;"echo "false
}
>?

true ..

.

: switch
switch if else .
.
:

<?php
;$age = 99
switch ($age) //
{
// :10 case 10
;"echo "you are a child
;break
// :25 case 25
;"echo "you are man
;break
// :99 case
;"echo "you are old man
;break
// :130 case
;"echo "you are so old man
;break
default:
;"echo "sorry, i don't have any sentence for your age
}
>?
.
:99 case
you are old man :
:default
age :
;7=age$
:
sorry, i don't have any sentence for your age
;break
switch .
130 99
99 break .
break 99
99 .99


Loops
:
100 :
-
-
-
-
-
.
.
.
-
100


loops

.
:
while -

for -

while.

( .. ).

while
:
) ( while
{
...
}
:
<?php
;$n = 1
)while ($n <= 100
{
;'>.<br / ' echo
;$n++
// $n = $n + 1
}
>?
": "

n
1 ()
n
100
:

n




n
100
.

for


while

for


()for

while

for
:
<?php
)for ($n = 1; $n <= 100; $n++
{
;'> <br / ' echo
}
>?

.
-
- .
:
: .

.

- :


..
.
:
http://fr.php.net/manual/en/funcref.php



:
-
-
-
-
- ...
-
-
-
-
- ...

:
strlen

- - .

<?php
;"$sentence= "yalsne is the king of PIA
;)$length = strlen($sentence

;echo 'number of characters of the sentence \" ' . $sentence . '"/ is: <br />' . $length
>?

:number of characters of the sentence \" yalsne is the king of PIA"/ is
25

-
str_replace
..
:

<?php
;)'$sentence = str_replace('evening', 'morning', 'good evening sir

;echo $sentence
>?

:
good morning sir

.

-
str_shuffle


.
:
<?php
;'$sentence1 = 'thank you, it is very good
;)$sentence2= str_shuffle($sentence1

;echo $sentence2
>?

eysoinki hooy avgrd ,ttu
yn urdikgy s otti,voehao
go,haenouitvk ritdos yy
yton a tku s, ivgdoi hyreo
-
strtoupper

strtolower

.
:
<?php
;'$stenence1 = 'YALSNE
;)$stenence2 = strtolower($stenence1
;'$stenence3 = 'morocoo
;)$stenence4 = strtoupper($stenence3

;echo $stenence2.'<br />'. $stenence4


>?

yalsne
MOROCOO
.

:
)(date

...
:
:H
:i
:s
:d
:D
:m
:M
:Y
:
<?php

;)'$hour= date('H
;)'$minutes= date('i
;)'$day= date('d
;)'$month= date('m
;)'$year= date('Y

;echo 'The time now is ' . $hour .':'. $minutes . ' /on ' . $day . '/ ' . $month. ' / ' . $year
>?
:
The time now is 08:49 /on 2010 / 05 /07

.

.


.
:

)function name_of_function(variables
{

}
;)name_of_function(values
:
<?php
)function hello($name
{
;">echo "hi " . $name . " <br /
}

;)'hello('yalsne
;)'hello('batol
;)'hello('khaled

>?


hello :
name

.
:
<?php
)function calcul($n1,$n2,$n3
{
;echo $n$+1n$+2n3
}
;)calcul(10,20,30
>?
60


Arrays
:
()array
.

.
30

:

( )
.


.
:
:
:
:
212000000000 :

() :
-
-

.
--------------------------------------------------------------------------------------
- :
:
:
- - - .
( )

()Associative arrays


:
: - - -
: - - 212000000000 -

php
php

<?php
Identification_card. //

( $Identification_card = array
'name'=> 'Yassine',
'nationality' => 'Moroccan',
'city' => 'Midelt',
;)''phone_number' => 'Marseille
>?




.
<?php

;"$Identification_card["name"]="Yassine
;"$Identification_card["nationality"]="Moroccan
;"$Identification_card["city"]="Midelt
;"$Identification_card["phone_number"]="212000000000

>?

array [ ]
.
:

;$variable=array(elements) == $variable[ ]=elements

'' ( . )
:
<?php

;]"echo $Identification["nationality

>?
:
Moroccan

:

)for($i=0;$i<4;$i++
{
;">echo $Identification_card[$i]. "<br /
}
<: >/ br
:
.
:


0
1
2
0
4
0
6

:php

<?php
days //
;)'$days=array('Sunday','Monday','Tuesday','Wednesday','Thursday','friday','Sutrday
)for($i=0;$i<=6;$i++
{
;">echo $days[$i]."<br /
}

>?

:
Sunday
Monday
Tuesday
Wednesday
Thursday
friday
Sutrday

: 0
.

<?php
;'$days[0]='sunday
;'$days[1]='Monday
;'$days[2]='Tuesday
;'$days[3]='Wednesday
;'$days[4]='Thursday
;'$days[5]='friday
;'$days[6]='Sutrday
//
;]echo $days[5
//
>?

;]echo $days[5

;)print_r($days
print_r
.


.
( )
... .

-----------------------------------------------

php
.
:
--------------------------
:key

.
:

<?php
;)$a=array("name"=>"yassine","city"=>"midelt","phone"=>212000000000
;)$b=key($a
;echo $b

>?

:
name

---------------------

array_key_exists

:
<?php
;)$a=array("name"=>"yassine","city"=>"midelt","phone"=>212000000000
))if (array_key_exists('city', $a
{
;'echo 'yes
}
else
{
;"echo "no
}
>?
:
yes
a city

-----------------------------------

in_array

:
<?php
$a=array("name"=>"yassine","city"=>"midelt","phone"=>212000000000);
if (in_array('yassine', $a))
{
echo 'yes';
}
else
{
echo "no";
}
?>


yes
-----------------------------------------

array_push

:
<?php
$names=array("yassine ","sofia ","ahmed ");
array_push($names,"btisam ","ali");
for($i=0;$i<5;$i++)
{
echo $names[$i];
}
?>

array_pop
/
:
<?php
$a=array("yasso"," sofo", " hamo", " hado");
$b=array_pop($a);
for($i=0;$i<4;$i++)
{
echo $a[$i];
}
?>
:
hado
-------------------------------------

array_shift

<?php
;)"$a=array("yasso"," sofo", " hamo", " hado
;)$b=array_shift($a
)for($i=0;$i<4;$i++
{
;]echo $a[$i
}
>?

:
yasso
:
sofo hamo hado
---------------------------------------

array_unshift
.
:
<?php
;)" $a = array("yassine ", "sofia
;)" array_unshift($a, "ahmed ", "ali
)for($i=0;$i<4;$i++
{
;]echo $a[$i
}
>?


array_flip

:

<?php
;)$a = array("name" => 1, "age" => 2
;)$a = array_flip($a
;)print_r($a
>?


) Array ( [1] => name [2] => age


;)$a = array_flip($a

) Array ( [name] => 1 [age] => 2

php

.
php .



codm

:

:
yalsne@hotmail.com

212676539205

You might also like