20
PHP Sriram A

Learn PHP PPT

Embed Size (px)

Citation preview

Page 1: Learn PHP PPT

PHP

Sriram A

Page 2: Learn PHP PPT

Introduction

Hypertext Preprocessor. Server-side scripting language. Efficient alternative to competitors such

as Microsoft's ASP . Works on a number of platforms and

supports many databases. Extension -".php", ".php3", or ".phtml"

Page 3: Learn PHP PPT

Basic Syntax

<html><body>

<?phpecho "Hello World"; //This prints Hello world

?>

</body></html>

PHP ignores white space

Page 4: Learn PHP PPT

PHP Variables

Loosely typed language. $var_name = value; case-sensitive

Page 5: Learn PHP PPT

Echo

Echo is a language construct Language construct Vs. Functions

Page 6: Learn PHP PPT

Arrays

In PHP, there are three kind of arrays:• Numeric array - An array with a numeric

index $cars=array("Saab","Volvo","BMW","Toyota");

• Associative array - An array where each ID key is associated with a value

$ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);

• Multidimensional array - An array containing one or more arrays

Page 7: Learn PHP PPT

String Creation

Single Quote Double Quote $my_string = “Tizag - Unlock your potential!”; Heredoc - Multi-line strings

Page 8: Learn PHP PPT

PHP Operators and Decision Controls

Operators Assignment Operators Arithmetic Operators Comparison Operators String Operators Combination Arithmetic & Assignment

Operators

If statement Else statement Elseif statement Switch case

Page 9: Learn PHP PPT

Include and Require

Header.php

Footer.php

Page 1 Page 2 Page 3 Page 4

Page 10: Learn PHP PPT

PHP Forms POST and GET

Page 11: Learn PHP PPT

PHP Functions

Page 12: Learn PHP PPT

Loops

Page 13: Learn PHP PPT

PHP Magic Quotes & Stripslashes INPUT: "It's a beautiful day outside and I like

to use \'s."

Page 14: Learn PHP PPT

HTML Entities

Prevents attackers from running html code and scripts that may be harmful to your visitors

Changes the data at three different levels: in PHP, in raw HTML and in the web browser.

Page 15: Learn PHP PPT

PHP Strings

String Position

String Replace

SubString Replace

strtoupper strtolower ucwords

Explode - also has limit

Implode

Page 16: Learn PHP PPT

PHP Sessions

session_start(); $_SESSION associative array isset unset session_destroy();

Page 17: Learn PHP PPT

PHP Cookies

setcookie(name, value, expire, path, domain);

isset() $_COOKIE associative array print_r($_COOKIE);

Page 18: Learn PHP PPT

PHP Files

fopen$ourFileHandle = fopen($ourFileName, 'w') or die("can't

open file");

fclose fread

$fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile));

fwrite and fgets$stringData = "Pointy Pinto\n"; fwrite($fh, $stringData);fgets($fh);

Page 19: Learn PHP PPT

File Unlink unlink($myFile); File upload HTML Form

PHP Code

Page 20: Learn PHP PPT

Thank You