Horizon Software Solutions
[Link]
[Link]
PHP
Introduction
What is PHP ??
PHP is Hyper Text Processor
Other Names : Personal Home Page, Professional
Home Page
s a ser!er si"e scripting language.
Capable of generating the HTML pages
HT#$ generates the %e& page %ith the static text an"
images.
Ho%e!er the nee" e!ol!e" for "ynamic %e& &ase"
application, mostly in!ol!ing "ata&ase usage.
[Link]
How PHP Works??
[Link]
p[Link]
PHP Language Features
PHP language features such as control structures,
operators, variable types, function declaration,
class/obect declaration are al!ost si!ilar to any
co!piled or interpreted language such as " or "##$
[Link]
PHP %ata &ypes
Three &asic "ata types
nteger
'ou&le
(tring
#ore "ata types
)rray
O&ject
PHP is an untype" language
!aria&les type can change on the fly.
[Link]
PHP "onstants
..!alues that ne!er changes
*onstants are "efine" in PHP &y using the "efine+,
function.
-or e.g.
"efine+.N*(T/, .National *entre for (oft%are Technology/,
"efine"+, function says %hether the constant
exists or not.
[Link]
PHP 'ariables
The !aria&les in PHP are "eclare" &y appen"ing the 0
sign to the !aria&le name.
-or e.g
0company 1 .N*(T/2
0sum 1 34.42
!aria&le5s "ata type is change" &y the !alue that is
assigne" to the !aria&le.
Type casting allo%s to change the "ata type explicitly.
[Link]
PHP (perators
)ll the operators such as arithmetic, assignment,
*omparison, an" logical operators are similar to the
operators in * an" *66.
n PHP the string concatenation operator is "enote" &y
7.5.
-or e.g.
0name 1 .#y name is/.0myname2
[Link]
PHP )tate!ents
- statement
if +8con"ition9, :
//php co"e goes here
;
else :
//php co"e goes here
;
)lternati!e (yntax
if+8con"ition9, :
//html co"e goes here
else :
//html co"e goes here
en"if2
[Link]
PHP )tate!ents *cont$+
-or loop
for+0i1420i 8 342066i, :
echo+.the !alue is :/. 0i,2
;
)lternati!e (yntax
for+0i1420i 8 342066i, :
// html co"e goes here
en"for2
<hile loop
'o=<hile loop
[Link]
,rrays
. contains !alue set
each element has a value, "ata store" in the element.
)n" has a key &y %hich the element can &e referre" to
[Link]
Initiali-ing ,rrays
No of %ays to initiali>e the array.
-or e.g.
0ncststaff?@ 1 .amrish/2
0ncststaff?@ 1 .murali/2
0ncststaff?@ 1 .narayan/2
0ncststaff?3AB@ 1 .amrish/2
0ncststaff?3AA@ 1 .murali/2
0ncststaff?3A3@ 1 .narayan/2
0ncststaff 1 array +.amrish/, .murali/, .narayan/,2
to change the in"ices of the array use 19 operator.
[Link]
,ccessing the ,rray .le!ents
Array_walk(<arrayname>,<function_name>)
function_name is the function that is written for every member of an
array.
For e.g
$ncststaff = array (amrish!" murali!" narayan!#$
array_wal% ($ncststaff" &rintstaff#$
'' function to &rint each element of the array
function &rintstaff($names# (
echo )*+$names)'*+)*,+-n!$
;
[Link]
&o see !ore/
http///phptraininginaipur$i
nfo/
Thank You !!
Horizon Software
Solutions
[Link]
fo/