AgerNic.com/ro
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
Tutorial

Tutorial PHP» Variabile

Un concept fundamental al oric?rui limbaj de programare sunt variabilele. Variabilele pot con?ine valori de orice fel, de exemplu linii simple sau texte, dar ?i structuri mai complexe, precum liste sau chiar imagini. Īn aceast? sec?iune, ve?i afla elementele de baz? despre cum s? utiliza?i variabile.

Elementele de baz?

Īn PHP, textele sau numerele sunt stocate īn a?a-numitele variabile PHP sau doar variabile, astfel īncāt acestea pot fi ulterior emise folosind asa numitul - ecou -.

Variabilele din PHP īncep īntotdeauna cu un semn dolar ($), urmat direct de numele variabilei, urmat de un „semn egal” (=), iar apoi textul inclus īn ghilimele ("), urmat de punct ?i virgul? ca terminator de comand? (;).

Variabilelor li se poate da un nume adecvat arbitrar, cu toate acestea, trebuie acordat? aten?ie literelor mari ?i minuscule. A? scrie variabilele īntotdeauna mici, astfel īncāt s? nu apar? confuzii ?i astfel s? nu apar? surse de eroare.

O variabil? īn PHP poate fi de exemplu de acest fel:

<?php
$name = "Anton Ion";
echo "Numele lui este $name";
?>

Ca ie?ire ob?inem:
Numele lui este Anton Ion

Desigur, putem īnlocui din nou con?inutul unei variabile, pur ?i simplu alocānd noua valoare variabilei:

<?php
$name = "Anton Ion";
echo "Numele lui este $name";
echo "<br />";
$name = "Anton Marin";
echo "Acum numele lui este $name";
?>

Atentie: In PHP fiecare comanda este terminata cu ; (punct si virgula)
Tags: Variabile in PHP, Exemple

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


analytics piwika