php tutorial variables & comments 01

29
PHP Course PHP 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 [email protected]

Upload: mohamad-saad

Post on 31-Oct-2015

60 views

Category:

Documents


0 download

DESCRIPTION

PHP CourseWE will present this tutorial using web host to compile php code if you don`t have a web host you have to configure your PC AS a server to run PHP codeProvided By:http://itbigdig.com

TRANSCRIPT

Page 1: PHP Tutorial Variables & Comments 01

PHP Course PHP 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 [email protected]

Page 2: PHP Tutorial Variables & Comments 01

Instructor Name: Mohamed Saad.

Email: [email protected]

Occupation: Web Developer In IT Big Dig.

PHP Course [email protected]

Page 3: PHP Tutorial Variables & Comments 01

PHP Course 1: Variables & Comments

PHP Course [email protected]

Page 4: PHP Tutorial Variables & Comments 01

Naming Rules

PHP Course [email protected]

• $ 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

Page 5: PHP Tutorial Variables & Comments 01

Variables Scopes

PHP Course [email protected]

Global Declared outside of any function.

Local Declared 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 .

Parameter A parameter is a local variable whose value is passed to the

function by the calling code.

Page 6: PHP Tutorial Variables & Comments 01

Variables Data Types

PHP Course [email protected]

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

Page 7: PHP Tutorial Variables & Comments 01

PHP Course [email protected]

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

Page 8: PHP Tutorial Variables & Comments 01

Dreamweaver Create New Site

PHP Course [email protected]

Dreamweaver CS 6

Page 9: PHP Tutorial Variables & Comments 01

Dreamweaver From Site menu Select New Site

PHP Course [email protected]

project

Navigate to desktop and create New Folder

Dreamweaver CS 6

Page 10: PHP Tutorial Variables & Comments 01

Dreamweaver Configure Your Server

PHP Course [email protected]

Navigate to desktop and create New Folder

Dreamweaver CS 6

Page 11: PHP Tutorial Variables & Comments 01

Dreamweaver Configure Your Server

PHP Course [email protected]

Configure your server

Dreamweaver CS 6

Page 12: PHP Tutorial Variables & Comments 01

Dreamweaver Configure Your Server

Dreamweaver CS 6

PHP Course [email protected]

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

Page 13: PHP Tutorial Variables & Comments 01

Dreamweaver Configure Your Server

Dreamweaver CS 6

PHP Course [email protected]

Page 14: PHP Tutorial Variables & Comments 01

Dreamweaver Rename File: variables.php

Dreamweaver CS 6

PHP Course [email protected]

Page 15: PHP Tutorial Variables & Comments 01

PHP Tag Open variables.php and insert basic code

<?php

?>

PHP Course [email protected]

Page 16: PHP Tutorial Variables & Comments 01

Copy Code Open variables.php and insert basic code

<?php

?>

PHP Course [email protected]

<!DOCTYPE html> <html>

<body> <?php ?> </body>

</html>

Page 17: PHP Tutorial Variables & Comments 01

PHP String Data Output Data

<?php

echo “ ”;

?>

PHP Course [email protected]

Page 18: PHP Tutorial Variables & Comments 01

PHP String Data Store & Output Data

<?php

$VariableName= „Saad‟ ;

?>

PHP Course [email protected]

Page 19: PHP Tutorial Variables & Comments 01

PHP String Data Concatenation Operator

<?php

echo $first . " " . $last ;

?>

PHP Course [email protected]

Page 20: PHP Tutorial Variables & Comments 01

PHP String Data Get Type Function

<?php

echo gettype($user);

?>

PHP Course [email protected]

Page 21: PHP Tutorial Variables & Comments 01

<?php

echo strlen($user);

?>

PHP Course [email protected]

PHP String Data String Length Function

Page 22: PHP Tutorial Variables & Comments 01

<?php

echo strpos("Hello","H")

?>

PHP Course [email protected]

PHP String Data Search for a text

Page 23: PHP Tutorial Variables & Comments 01

<?php

echo chr(65)

?>

PHP Course [email protected]

PHP String Data Character Function

Page 24: PHP Tutorial Variables & Comments 01

<?php

echo chr(65)

?>

PHP Course [email protected]

PHP String Data Character Function

Page 25: PHP Tutorial Variables & Comments 01

Comments Insert comments & add remarks to your code.

PHP Course [email protected]

Single Line

• //Comments here

Multi Lines

• /*

Comments here

Comments here */

Page 26: PHP Tutorial Variables & Comments 01

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 [email protected]

Page 27: PHP Tutorial Variables & Comments 01

Answer

PHP Course [email protected]

Page 28: PHP Tutorial Variables & Comments 01

<!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 centimeter echo "Length of the square =$x <br/>";//Print out the length $meter=$x/1000;//legnth in meter $Ameter =$meter*$meter;//Area in meter echo "Area of the square= $Ameter M<sup>2</sup> <br/>"; $Acent = $x*$x;//Area in centimeter echo "Area of the square= $Acent Cm<sup>2</sup> <br/>"; $milli =$x*1000;//legnth in millimeter $Amilli=$milli*$milli;//Area in millimeter echo "Area of the square= $Amilli mm<sup>2</sup>"; ?> </body> </html>

PHP Course [email protected]

Copy Code

Page 29: PHP Tutorial Variables & Comments 01

We hope You enjoy This Tutorial.

For any Suggestions Please email Us

[email protected]

PHP Course [email protected]

End Variables & Comments

Itbigdig.com