Professional Documents
Culture Documents
PHP Tutorial Variables & Comments 01
PHP Tutorial Variables & Comments 01
PHP Tutorial Variables & Comments 01
This presentation provide you with PHP source code and the HTML
output of that code.Enjoy!.
PHP Course Info@ITBigDig.com
PHP Course
Instructor
Name: Mohamed Saad. Email: Engsaad_aly@hotmail.com Occupation: Web Developer In IT Big Dig. PHP Course Info@ITBigDig.com
PHP Course
1: Variables & Comments
PHP Course Info@ITBigDig.com
Variables
Naming Rules
$ sign then Name of the variable. Begin with a letter or the underscore character. Name can only contain alpha-numeric characters and
Variables
Scopes
Global Local
Declared outside of any function.
Static
deleted. However, sometimes you want a local variable to not be deleted. use the static keyword .
Parameter
PHP Course
Variables
Data Types
String Integer Double Boolean
Hello Mohamed Saad 48, -5, 160, 2.209, -1.3, 3.14, True or False
Date
2015-12-31 12:55:22
PHP Course
Info@ITBigDig.com
Athematic Operators
Operator A+B A-B A*B A/B A%B Name Addition Subtraction Multiplication Division Modulus Description Sum of A and B Difference of A and B Product of A and B Quotient of A and B Remainder of A divided by B
A.B
Concatenation
PHP Course
Info@itBigDig.com
Dreamweaver
Create New Site
Dreamweaver CS 6
PHP Course
Info@itBigDig.com
Dreamweaver
From Site menu Select New Site
Dreamweaver CS 6
project
PHP Course
Info@itBigDig.com
Dreamweaver
Configure Your Server
Dreamweaver CS 6
PHP Course
Info@itBigDig.com
Dreamweaver
Configure Your Server
Dreamweaver CS 6
PHP Course
Info@itBigDig.com
Dreamweaver
Configure Your Server
Dreamweaver CS 6
For this Tutorial I created a Demo folder on my host and we will use it along PHP Course Info@itBigDig.com
Dreamweaver
Configure Your Server
Dreamweaver CS 6
PHP Course
Info@itBigDig.com
Dreamweaver
Rename File: variables.php
Dreamweaver CS 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
<?php
echo ;
?>
PHP Course
Info@itBigDig.com
<?php
$VariableName= Saad ;
?>
PHP Course
Info@itBigDig.com
<?php
PHP Course
Info@itBigDig.com
<?php
echo gettype($user);
?>
PHP Course
Info@itBigDig.com
<?php
echo strlen($user);
?>
PHP Course
Info@itBigDig.com
<?php
echo strpos("Hello","H")
?>
PHP Course
Info@itBigDig.com
<?php
echo chr(65)
?>
PHP Course
Info@itBigDig.com
<?php
echo chr(65)
?>
PHP Course
Info@itBigDig.com
Comments
Insert comments & add remarks to your code.
Single Line
//Comments here
Multi Lines
Dig ?
calculate the Area of square which have the
Length of 4 cm.
PHP Course
Info@ITBigDig.com
Answer
PHP Course
Info@ITBigDig.com
Copy Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.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>";
PHP Course
Info@ITBigDig.com
PHP Course
Info@ITBigDig.com