Upload
guru99
View
403
Download
0
Tags:
Embed Size (px)
DESCRIPTION
PHP stands for "PHP Hypertext Preprocessor” An embedded scripting language for HTML like ASP or JSP A language that combines elements of Perl, C, and Java
Citation preview
DEVELOPING WEB APPLICATIONS WITH PHP
RAD for the World Wide Web
Guru99
By. Krishna Rungta
Guru99
INTRODUCTION
W
hat is PHP?• PHP stands for "PHP Hypertext Preprocessor”• An embedded scripting language for HTML like ASP
or JSP• A language that combines elements of Perl, C, and
Java
Guru99
INTRODUCTION
H
istory of PHP• Created by Rasmus Lerdorf in 1995 for tracking
access to his resume• Originally a set of Perl scripts known as the
“Personal Home Page” tools• Rewritten in C with database functionality• Added a forms interpreter and released as PHP/FI:
includes Perl-like variables, and HTML embedded syntax
Guru99
PHP LANGUAGE BASICS
H
ello World!: An Example• Like Perl, there is more than one way to do it
• <?php echo “Hello World!”; ?> • <?php
$greeting = “Hello World!” printf(“%s”, $greeting);php?>
Guru99
PHP LANGUAGE BASICS
C
onstants, Data Types and Variables• Constants define a string or numeric value• Constants do not begin with a dollar sign• Examples:
• define(“COMPANY”, “Acme Enterprises”);• define(“YELLOW”, “#FFFF00”);• define(“PI”, 3.14);• define(“NL”, “<br>\n”);
Guru99
PHP LANGUAGE BASICS
C
onstants, Data Types and Variables• Using a constant
• print(“Company name: “ . COMPANY . NL);
Guru99
PHP LANGUAGE BASICS
C
onstants, Data Types and Variables• Data types
• Integers, doubles and strings• isValid = true; // Boolean• 25 // Integer• 3.14 // Double• ‘Four’ // String• “Total value” // Another string
Guru99
PHP LANGUAGE BASICSC
onstants, Data Types and Variables• Data types
• Strings and type conversion• $street = 123;• $street = $street . “ Main Street”;• $city = ‘Naperville’;
$state = ‘IL’;• $address = $street;• $address = $address . NL . “$city, $state”;• $number = $address + 1; // $number equals 124
Guru99
PHP LANGUAGE BASICS
C
onstants, Data Types and Variables• Data types
• Arrays• Perl-like syntax
• $arr = array("foo" => "bar", 12 => true); • same as
• $arr[“foo”] = “bar”;• $arr[12] = true;
PHP LANGUAGE BASICS
C
onstants, Data Types and Variables• Arrays (cont.)
• <?php $arr = array("somearray" => array(6 => 5, 13 => 9, "a" => 42));
echo $arr["somearray"][6]; // 5 echo $arr["somearray"][13]; // 9 echo $arr["somearray"]["a"]; // 42?>
PHP LANGUAGE BASICS
C
onstants, Data Types and Variables• Objects
• Currently not much more advanced than than associative arrays Using constants
• Before version 5.0, objects are passed by value• Slow• Functions can not easily change object
variables
TRICKS AND TIPS
D
ebugging• Feature: PHP is not a strongly typed language
• Variables can be created anywhere in your code
• Undocumented Feature: PHP is not a strongly typed language• Typos in variable names will cause stuff to happen
RESOURCES
• To Learn more thing about PHPJust Visit our site
• http://web.guru99.com/
• Thank You