PHP HyPertext : Preprocessor

30
PHP HYPERTEXT: PREPROCESSOR By: Justin T. Pleva

description

PHP HyPertext : Preprocessor. By: Justin T. Pleva. What is PHP?. General purpose Server-side web development Console application. Background. First created in 1994 by Rasmus Lerdorf Designed to streamline web tasks Designed to access databases for storing data. Used for web forms - PowerPoint PPT Presentation

Transcript of PHP HyPertext : Preprocessor

PHP HyPertext: Preprocessor

PHP HyPertext: PreprocessorBy: Justin T. Pleva1What is PHP?General purposeServer-side web developmentConsole application2BackgroundFirst created in 1994 by Rasmus LerdorfDesigned to streamline web tasksDesigned to access databases for storing data.Used for web formsFirst public release in 1995

3BackgroundUsed primarily as website scriptingText Interpreter/filterInstalled on over 20 million websites and domainsCan install multiple versionsCurrent version 5.4Object-Oriented4HistoryOriginally named Personal Homepage ToolsRewritten in 1997 using C, released publiclyRenamed to Hypertext PreprocessorVersion 4 introduced command line functionalityVersion 5 rewrote Object supportVersion 6 has been postponed5LicensingOpen sourcePHP LicenseTerm PHP cannot be used directly in a project.6Operating EnvironmentsWindowsMacLinuxAlmost any othersBuilt from source

Web serversApacheIISLighttpd7StacksComes bundled with many Linux DistributionsBundles for Mac: MAMP (Mac, Apache, MySQL, PHP)Linux: LAMP (Linux, Apache, MySQL, PHP)Windows: WAMP

8How it worksClient Request sent to Web serverWeb server directs to PHP filterPHP processes data and sends to web serverWeb server sends back to client9SyntaxSimilar to major programming languages

CJava

Can be embedded inside other languages such as HTML10Syntax : DeclarationsDeclared PHP code with delimiters

ASP Style

Code is only executed between these delimiters11Syntax: VariablesLoosely typed, unlike C/Java

// Create an integer and set equal to 3$myVariable = 3;

Prefixed name with $

Notice no type specified, this can be a string value of 3, character 3 or integer value of 3. Depends upon notation!

Need to be careful with variable types!12Syntax: CommentingSimilar to other langues// This is a single line comment/* This is a block style comment */13Syntax: FunctionsFunctions declarations similar to C/Java

Function myFunction($value1, $value2){ return $value1 + $value2;}

Can be value returning or not!14Syntax: LoopsSimilar to C/JavaFor While Do While for each

$i = 0;While ( $i != 5 ){ echo Number is: . $i .
; $i++; }

Notice the .!Syntax: File handlingCan Open and write to file systemUsed to read/write from a server for web contentBuilt in file support for:XMLFTPZipCookies16Syntax: Get/PostCan get data using $_Get[ ]Useful for retrieving data from url.Can send data using $_Post[ ]Useful for submitting user forms such as request information forms.Syntax: ObjectsPHP is Object-OrientedCan create classes and objects of any typeSimilar to C/JavaCan have private/public methods and data membersArrow notation instead of dot notation18Syntax: MailBuilt in Email supportCreate text based emailSend via 1 function.File ExtensionsStandard extension: .phpCan have others.phtml.php5If multiple versions are installed, .php5 will refer to version 5 installed20UsageCommand lineDynamic websitesContent ManagementCan be used for Desktop applicationsGUI controls21Database SupportBuilt to work primarily with MySQLCapable of working with others:MS SQLOraclePostgresPDO Driver22SecurityVery little security holes have been found with core PHP applicationSecurity risks come from each individual programmer, not the PHP filter!Bad programming habits23Web Presence20 Million domains/websitesComes pre installed with many Linux distributions.Content Management Systems24Web Presence: CMSMany Content Management Systems are built with PHPJoomlaWordpressDrupalFar more built with PHP than others such as .Net25Community SupportNeed help? Google it.Since PHP is so widely used, there is great community supportContent Management Systems are sometimes community built26Script availabilityCommunity SupportOpen Sourcehttp://www.hotscripts.com

27DevelopmentCode in NotepadIDE SupportNetbeansZend StudioEclipseCodelobster

28ConclusionGeneral Scripting lanaguageOver 20 million domainsCommand line/Web server-sideVarious database supportThousands of pre-built scriptsOpen source29Questions?30