16
Horizon Software Solutions http://phptraininginjaipur.info/

Intro about PHP,PHP Training in jaipur

Embed Size (px)

Citation preview

Page 1: Intro about PHP,PHP Training in jaipur

Horizon Software Solutions

http://phptraininginjaipur.info/

Page 2: Intro about PHP,PHP Training in jaipur

http://phptraininginjaipur.info/

PHP Introduction

Page 3: Intro about PHP,PHP Training in jaipur

What is PHP ??

PHP is Hyper Text Processor

– Other Names : Personal Home Page, Professional Home Page

• Is a server side scripting language.– Capable of generating the HTML pages

• HTML generates the web page with the static text and images.

• However the need evolved for dynamic web based application, mostly involving database usage.

• http://phptraininginjaipur.info/

Page 4: Intro about PHP,PHP Training in jaipur

How PHP Works??

http://phptraininginjaipur.info/phttp://phptraininginjaipur.info/

Page 5: Intro about PHP,PHP Training in jaipur

PHP Language Features

• PHP language features such as control structures, operators, variable types, function declaration, class/object declaration are almost similar to any compiled or interpreted language such as C or C++.

• http://phptraininginjaipur.info/

Page 6: Intro about PHP,PHP Training in jaipur

PHP Data Types

Three basic data types– Integer– Double– String

• More data types– Array– Object

• PHP is an untyped language – variables type can change on the fly.

– http://phptraininginjaipur.info/

Page 7: Intro about PHP,PHP Training in jaipur

PHP Constants

• ..values that never changes• Constants are defined in PHP by using the define()

function.– For e.g.

define(“NCST”, “National Centre for Software Technology”)

• defined() function says whether the constant exists or not.

• http://phptraininginjaipur.info/

Page 8: Intro about PHP,PHP Training in jaipur

PHP Variables

• The variables in PHP are declared by appending the $ sign to the variable name.– For e.g

$company = “NCST”;

$sum = 10.0;

• variable’s data type is changed by the value that is assigned to the variable.

• Type casting allows to change the data type explicitly.

• http://phptraininginjaipur.info/

Page 9: Intro about PHP,PHP Training in jaipur

PHP Operators

• All the operators such as arithmetic, assignment, Comparison, and logical operators are similar to the operators in C and C++.

• In PHP the string concatenation operator is denoted by ‘.’.– For e.g.

• $name = “My name is”.$myname;

• http://phptraininginjaipur.info/

Page 10: Intro about PHP,PHP Training in jaipur

PHP Statements

• IF statement if (<condition>) {

//php code goes here}

else {//php code goes here}

• Alternative Syntaxif(<condition>) :

//html code goes here

else ://html code goes here

endif;http://phptraininginjaipur.info/

Page 11: Intro about PHP,PHP Training in jaipur

PHP Statements (cont.)

• For loopfor($i=0;$i < 10;$++i) {

echo(“the value is :”. $i);

}– Alternative Syntax

for($i=0;$i < 10;$++i) :// html code goes here

endfor;

• While loop

• Do-While loop

• http://phptraininginjaipur.info/

Page 12: Intro about PHP,PHP Training in jaipur

Arrays

. contains value set• each element has a value, data stored in the element.

• And has a key by which the element can be referred to

• http://phptraininginjaipur.info/

Page 13: Intro about PHP,PHP Training in jaipur

Initializing Arrays

• No of ways to initialize the array.– For e.g.

• $ncststaff[] = “amrish”;

$ncststaff[] = “murali”;

$ncststaff[] = “narayan”;• $ncststaff[123] = “amrish”;

$ncststaff[122] = “murali”;

$ncststaff[121] = “narayan”;• $ncststaff = array (“amrish”, “murali”, “narayan”);

– to change the indices of the array use => operator.

–http://phptraininginjaipur.info/

Page 14: Intro about PHP,PHP Training in jaipur

Accessing the Array Elements

– 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_walk ($ncststaff, printstaff);

// function to print each element of the array

function printstaff($names) {

echo “<B>$names</B><BR>\n”;}

http://phptraininginjaipur.info/

Page 15: Intro about PHP,PHP Training in jaipur

To see more:http://phptraininginjaipur.info/

Page 16: Intro about PHP,PHP Training in jaipur

Thank You !!

Horizon Software Solutions http://phptraininginjaipur.info/