php

13
DEVELOPING WEB APPLICATIONS WITH PHP RAD for the World Wide Web Guru99 By. Krishna Rungta Guru9 9

Upload: guru99

Post on 12-Jan-2015

403 views

Category:

Education


0 download

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

TRANSCRIPT

Page 1: Php

DEVELOPING WEB APPLICATIONS WITH PHP

RAD for the World Wide Web

Guru99

By. Krishna Rungta

Guru99

Page 2: Php

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

Page 3: Php

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

Page 4: Php

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

Page 5: Php

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

Page 6: Php

PHP LANGUAGE BASICS

C

onstants, Data Types and Variables• Using a constant

• print(“Company name: “ . COMPANY . NL);

Guru99

Page 7: Php

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

Page 8: Php

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

Page 9: Php

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;

Page 10: Php

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?>

Page 11: Php

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

Page 12: Php

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

Page 13: Php

RESOURCES

• To Learn more thing about PHPJust Visit our site

• http://web.guru99.com/

• Thank You