PHP - Limbaj de Programare: Task!
PHP - Limbaj de Programare: Task!
<?php
. ?>
<?
echo Salut, lume;
Echo Salut, lume;
Print salut, lume;
?>
Pentru compilare este nevoie de un server local sau un hosting pentru lucrul cu php,
apache si sql. Server local compilator pentru php (de ex. Xampp sau Denver).
Task!
Info on Php Compilator Online.
Specificatoare:
/n -> rind nou la print
<?php
Echo <!doctype html>
<head>
<html><title> t </title>
</head>
<body>
Mesaj
</body>
</htmn>;
?>
Salvare: index.php
<!doctype html>
<head>
<html><title> t </title>
</head>
<body>
<p> nr este egal cu =
<?php echo$nume;?>
</body>
</html>
<!doctype html>
<head>
<html><title> t </title>
</head>
<body>
Calculul sumei
<?php $a=3; $b=4;?>
Este: suma= <?php
$s=a+b; echo $s; ?>
</body>
!!! Pe ecran va aparea Calculul sumei este: suma=7
Operatori:
$v=1; $v=1+2;
$v+=3; $v=$v+3;
$v-=4; $v=$v-4;
$v=$v*5; $v*=5;
$v%=2; $v=$v%2; restul impartirii la 2;
$v==$c egal
$v===$c identic
$v!=$c diferit de
$v<>$c
$a+=1; $a++
$a=3;
Print $a++; //3 (afiseaza si apoi adauga);
Print $a; //4 (afiseaza rezultatul adaugarii);
______
Print ++$a; //4 (adauga si apoi afiseaza);
Print $a; //4
Instructiuni:
If (conditie) instructiune;
<?php
$a=3; $b=4;
If ($a<$b)
Echo $b;
If (cond) instructiune;
Else instructiune;
Mr
3
Prenume
B
$a[10]=array(1,2,3)
0
1
2
3
1
2
6
7
Include (index1.php);
?>
Ex.:
<table><tr>
<td> colspan = 2 > Titlu </td> </tr>
<tr> <td> meniu < ul> <li> <a href = ?p=h> Acasa </a> </li>
<li> <a href = ?p=c> contacte </a> </li>
<li> <a href= ?p=n> noutati </a> </li>
</ul>
</td>
<td> <?php if (isset ($_GET[p]))
{switch ($_GET[p]) {
case h : include (home.html); break;
case c : include (contacte.html); break;
case n : include (noutati.html); break;
} default include (home.html);
} ?>
Cream un ciclu pentru a trece toate datele dintr-un tabel cu ajutorul while:
while ($rand= mysql_fetch_assoc($citire));
{$nume=$rand[nume];
Echo $nume;
} va afisa toate datele de la coloana nume