php variables & comments 01

Post on 24-Dec-2014

1.634 Views

Category:

Education

7 Downloads

Preview:

Click to see full reader

DESCRIPTION

PHP Course by:engsaad http://itbigdig.com

TRANSCRIPT

PHP CoursePHP is a server scripting language, powerful tool for

making dynamic and interactive Web pages..

This presentation provide you with PHP source code and the HTML

output of that code………….Enjoy!.

PHP Course Info@ITBigDig.com

Instructor Name: Mohamed Saad.

Email: Engsaad_aly@hotmail.com

Occupation: Web Developer In IT Big Dig.

PHP Course Info@ITBigDig.com

PHP Course1: Variables & Comments

PHP Course Info@ITBigDig.com

Naming Rules

PHP Course Info@ITBigDig.com

• $ sign then Name of the variable.

• Begin with a letter or the underscore character.

• Name can only contain alpha-numeric characters

and underscores.

• Name Should not contain spaces.

• Variable names are case sensitive.

• No command for declaring a variable.

Variables

VariablesScopes

PHP Course Info@ITBigDig.com

Global Declared outside of any function.

LocalDeclared within a PHP function can only be accessed

within that function

Static

When a function is completed, all of its variables are

normally deleted. However, sometimes you want a local

variable to not be deleted. use the static keyword .

Paramet

er

A parameter is a local variable whose value is passed to

the function by the calling code.

VariablesData Types

PHP Course Info@ITBigDig.com

String Hello Mohamed Saad

Integer 48, -5, 160,…

Double 2.209, -1.3, 3.14,…

Boolean True or False

Date 2015-12-31 12:55:22

PHP Course Info@itBigDig.com

Athematic Operators

Operator Name Description

A + B Addition Sum of A and B

A - B Subtraction Difference of A and B

A * B Multiplication Product of A and B

A / B Division Quotient of A and B

A % B Modulus Remainder of A divided by B

A . B Concatenation Concatenate two strings

Dreamweaver Create New Site

PHP Course Info@itBigDig.com

Dreamweaver C

S 6

Dreamweaver From Site menu Select New Site

PHP Course Info@itBigDig.com

project

Navigate to desktop and create New Folder

Dreamweaver C

S 6

Dreamweaver Configure Your Server

PHP Course Info@itBigDig.com

Navigate to desktop and create New Folder

Dreamweaver C

S 6

Dreamweaver Configure Your Server

PHP Course Info@itBigDig.com

Configure your server

Dreamweaver C

S 6

Dreamweaver Configure Your Server

Dreamweaver C

S 6

PHP Course Info@itBigDig.com

Server name

any name

FTB Address Domain

Username FTP User

Password FTP Pass

Root Folder on your host

For this Tutorial I created a Demo folder on my host and we will use it along

Dreamweaver Configure Your Server

Dreamweaver C

S 6

PHP Course Info@itBigDig.com

Dreamweaver Rename File: variables.php

Dreamweaver C

S 6

PHP Course Info@itBigDig.com

PHP Tag Open variables.php and insert basic code

<?php

?>

PHP Course Info@itBigDig.com

Copy Code Open variables.php and insert basic code

<?php

?>

PHP Course Info@itBigDig.com

<!DOCTYPE html><html>

<body><?php

?>

</body></html>

PHP String Data Output Data

<?php

echo “ ”;

?>

PHP Course Info@itBigDig.com

PHP String Data Store & Output Data

<?php

$VariableName= ‘Saad’ ;

?>

PHP Course Info@itBigDig.com

PHP String DataConcatenation Operator

<?php

echo $first . " " . $last ;

?>

PHP Course Info@itBigDig.com

PHP String DataGet Type Function

<?php

echo gettype($user);

?>

PHP Course Info@itBigDig.com

<?php

echo strlen($user);

?>

PHP Course Info@itBigDig.com

PHP String DataString Length Function

<?php

echo strpos("Hello","H")

?>

PHP Course Info@itBigDig.com

PHP String DataSearch for a text

<?php

echo chr(65)

?>

PHP Course Info@itBigDig.com

PHP String DataCharacter Function

<?php

echo chr(65)

?>

PHP Course Info@itBigDig.com

PHP String DataCharacter Function

CommentsInsert comments & add remarks to your code.

PHP Course Info@ITBigDig.com

Single Line

• //Comments here

Multi Lines

• /* • Comments here

• Comments here

*/

Dig …?calculate the Area of square which have the

Length of 4 cm.Print the result in

• Meter (m). • Centimeter (Cm). • Millimeter (mm).

PHP Course Info@ITBigDig.com

mm• *1000

Cm• *1000

M• *1000 KM

Answer

PHP Course Info@ITBigDig.com

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Square Area</title></head><body><?php

$x=1;//legnth in centimeterecho "Length of the square =$x <br/>";//Print out the length

$meter=$x/1000;//legnth in meter$Ameter =$meter*$meter;//Area in meterecho "Area of the square= $Ameter M<sup>2</sup> <br/>";

$Acent = $x*$x;//Area in centimeterecho "Area of the square= $Acent Cm<sup>2</sup> <br/>";

$milli =$x*1000;//legnth in millimeter$Amilli=$milli*$milli;//Area in millimeterecho "Area of the square= $Amilli mm<sup>2</sup>";

?></body></html>

PHP Course Info@ITBigDig.com

Copy Code

We hope You enjoy This Tutorial.

For any Suggestions Please email Us

Info@ITBigDig.com

PHP Course Info@ITBigDig.com

EndVariables & Comments

Itbigdig.com

top related