Introduction to PHP

Introduction To PHP-ppt Download

  • Date:11 Jul 2020
  • Views:34
  • Downloads:0
  • Size:203.21 KB

Share Presentation : Introduction To PHP

Download and Preview : Introduction To PHP

Report CopyRight/DMCA Form For : Introduction To PHP


Transcription:

UFCE8V 20 3Information Systems Development 3 SHAPE HK PHP 1 Data Types Control Structures DataStructures String Handling Input Output Pre amble 1 Web 1 0.
Basic web 1 0 architecture communication Pre amble 2 http request response cycle Pre amble 3 Web oriented 3 tier architecturetouch Browser HTTP SQL IE Chrome PHP script Database.
Opera Web Server Databasevision HTML Apache IIS tables PC or MAC Web ServiceRemote services.
PHP OriginsOriginally created by Rasmus Lerdorf born Greenland educated in Canada around 1995PHP originally abbreviated as Personal Home Pages nowknown as PHP Hypertext Pre processor .
Other key developers Zeev Surashi and Andi Gutmans Israel responsible for PHP 3 0 a complete re write ofthe original PHP F1 engine 1997 PHP is Open Source softwareFirst version PHP FI released 1995.
PHP 5 0 released July 2004Current stable version is 5 4 6 as of August 2012 PHP version 5 2 4 current at UWEPHP Version 6 due for release since late 2010 but PHP as a scripting language.
o A scripting language is often evolved not designed cross platform since interpreter is easy to port designed to support a specific task PHP Web support un typed variables but values are typed .
implicit variable declaration implicit type conversion stored only as script files compiled on demand may run on the server PHP Perl or the client Javascript .
o What are the potential differences in programming usingan interpreted scripting language like PHP in place of acompiled language e g Java in JSP NET C like languageo Free format white space is ignored.
o Statements are terminated by semi colon o Statements grouped by o Comments begin with or a set of comments o Assignment is a 6o Relational operators are not a single equal .
o Control structures include if cond else while cond for startcond increment endcond o Arrays are accessed with x 4 is the 5th element of the array x indexes start at 0o Associative Arrays hash array in Perl dictionary in Java are.
accessed in the same way y fred o Functions are called with the name followed by arguments in a fixedorder enclosed in substr fred 0 2 o Case sensitive fred is a different variable to FRED PHP Scripts.
o every PHP script is a collection of one or more statements thesestatements appear as a collection of names numbers and specialo individual statements are terminated by a semicolon and blocksof statements are contained within curly brackets o statements can be simple e g print or echo while others can be.
grouped statements e g the if elseif else block o PHP can use literal values such as numbers and blocks of text e g 9 or some text or give names to specific expressions e g variables functions or classes o operators are used to join values usually one value to the left of.
the operator and one to the right e g 9 3 Simple PHP script examplescripting delimiters DOCTYPE html single line comment use or .
declare a variable assign it a value name Popeye variable name with valueassignment Popeye title PHP Simple Example title .
p Welcome to PHP php echo name p html call to built in echo functionview script Data Types 1 o PHP has eight different data types 5 basic and 2.
composite types and 1 resource typeo The 5 basic data types are integers whole numbers in the range 2 147 483 648 to 2 147 483 647 on 32 bit architecture Can be octal prefixed by0 decimal and hexadecimal prefixed by 0x .
floating point real or doubles decimal can be written usingbase 10 notation e g 3900 3 9e3 strings sequence of characters contained by single ordouble quotes Within double quotes variables are replacedby their values interpolated Escape sequences are used to.
include special characters within double quoted strings e g toinclude a double quote and to include a backslash booleans the boolean data type evaluates to either true orfalse e g a b will evaluate to true if both variables containthe same value false otherwise.
null a special data type that stands for a lack of value Oftenused to initialize or reset variables Data Types 2 o arrays are a composite data type that collect values into a list The valuesof the array elements can be text a number or even another array Arrays.
can be from 1 to any number of dimensions arrays are referenced using square brackets cities 0 London cities 1 Bath cities 2 Bristol .
print I live in cities 2 br n an array can be indexed using a string value for the index calledassociative array or hash and are useful in situations where there is a needto collect different types of data into one array e g userInfo name Kevin .
array elements containing other arrays are used to build multi dimensional modules array ISD array ISDP array print modules ISD 2 .
Data Types 3 o objects are another composite data type fully supported by php php supports standard object oriented OO methodologies andtechniques such asinheritance the ability to derive new classes from existing.
ones and inherit or override their attributes and methods encapsulation the ability to hide data from users of the class the public protected and private keywords special methods for instance code that is automatically runwhen a object is created constructor or destroyed.
destructor polymorphism overloading a function so that a function callwill behave differently when passed variables of different type a good introducton to OO programming using php can be found athttp www slideshare net mgirou... .
o resources are a data type that hold handles to external resourcessuch as open files or database connections Control Structures 1 Control statements are a means of executing blocks of code depending on oneor more conditions .
if expression the simple if statement takes the following form if expression this block gets executed if the expression evaluates to trueif expression elseif expression else the compound ifstatement takes the following form .
if expression1 this block gets executed if expression1 is trueelseif expression2 this block gets executed if expression1 is falseand expression2 is true.
this block gets executed if both expression1 andexpression2 are false operator acts as a shortened version of the if statement It takes thefollowng form conditional expression true expression false expression .
Control Structures 2 switch expression case expression case expression default similar to the if elseif else structure where a single expressionis compared to a set of possible values and if a match is made theblock following the match is executed The break statement can be.
used to jump out of a switch structure A default expression can beused to execute code if none of the expressions evaluates to true o Loops allow for the repetition of blocks of code until acondition is met while expression when first reached the expression is.
evaluated and if true the block of code following the expression isexecuted otherwise the block is skipped The break statement canbe used to break out of a while block The continue statement canbe used to return control to the beginning of the block do while expression is a way of delaying the decision to.
execute a code block until the end for initialization continue increment used to carry out a blocka code a specific number of times foreach array as key value provides a formalized method foriterating over arrays .
Control Structures 3 exit die and return the exit statement is used to stopexecution it is useful when an error occurs and it couldbe harmful to continue execution the die statement is similar to exit but can be followed by.
an expression which is sent to the browser just before thescript is aborted for instance fp fopen somefile txt r OR die Could not openthe return statement can be used within functions seefollowing section but can also be used with the include.
statement If used within a script it stops execution withinthe current script and returns control to the script thatmade a call to include That is when a include is used the included script may return prematurely PHP Data Structures 1 .
arrays collect values into lists individual items elements are accessed using an index which can be an integer or you can build arbitrarily complex data structures using arrays within arrays that is a value within an array can hold another array multidimensional array single dimension arrays.
use square brackets to refer to an element arrays are treated like normal variables you can create it at the point of usewithout having to declare anything first example referencing array elementsNote if you leave out the.
index number php will teacher 0 Prakash start at 0 and use consecutive teacher 1 Paul integers thereafter .
teacher 2 Dan teacher 3 Chris echo teacher 3 teaches DSA br PHP Data Structures 2 arrays cont .
example counting and accessing values using a loop teacher Prakash teacher Paul teacher Dan teacher Chris .
indexCount count teacher for index 0 index indexCount index print Teacher index is teacher index br run script PHP Data Structures 3 .
arrays cont Associative Arrays Hashes in Perl HashMaps in Java create hash with data user Name Leon Trotsky user Location Coyoacan Mexico City .
user Occupation Revolutionary loop over the valuesforeach user as key value print key is value br run script.
String Handlingo String literals constants enclosed in double quotes or single quotes o Within variables are replaced by their value calledvariable interpolation My name is name I think .
o Within single quoted strings interpolation doesn t occuro Strings are concatenated joined end to end with thedot operator key board keyboard o Standard functions exist strlen substr etco Values of other types can be easily converted to and.
from strings numbers implicitly converted to strings in astring context o Regular expressions be used for complex pattern Input Output Disk Access 1 o Reading and Writing to Files.
Communicating with files follows the pattern of opening a stream to afile reading from or writing to it and then closing the stream fopen the fopen function opens a file for reading or writing Thefunction expects the name of a file and a mode e g fopen c temp myfile txt r .
which opens a file called myfile txt in the directory c temp in the read modeFile read write modes r reading onlyw write only create if necessary discard previous content.
a append to file create if necessary start writing at endr reading and writingw reading writing create if necessary discard previous contenta reading writing create if necessary start writing at end Input Output Disk Access 2 .
fclose resource file used to close a file feof resource file as a file is read php keeps a pointerto the last place in the file read the feof function returnstrue if the end of file is reached fgetcsv resource file integer length string separator .
used for reading comma separated data from a file Theoptional separator argument specifies the character toseparate fileds If left out a comma is used fgets resource file integer length returns a string thatreads from a file It will attempt to read as many.
characters 1 as specified by the length value Alinebreak character is treated as a stopping point as isthe end of the file fwrite resource file string data integer length writesa string to a file The length argument is optional and.
sets the number of bytes to write the exit and die functionso both the exit and die statements terminate theexecution of a script The two statements areequivalent .
o a message can be output as the script isterminated e g filename path to data file file fopen filename r or exit unable to open file filename .
PHP BooksIntermediate Nixon Robin Learning PHP MySQL JavaScript and CSS A Step by Step Guide to Creating Dynamic Websites.
Data Types (1) PHP has eight different data types – 5 basic and 2 composite types and 1 resource type. The 5 basic data types are: integers: whole numbers in the range -2,147,483,648 to +2,147,483,647 on 32-bit architecture.

Related Presentations

PHP An Introduction

service support education extensions open source companies IBM uses and develops Apache and Linux; created Secure Mailer and created other software on AlphaWorks Apple released core layers of Mac OS X Server as an open source BSD operating system called Darwin; open sourcing the QuickTime Streaming Server and the OpenPlay network gaming toolkit ...

34 Views0 Downloads

Introduction to PHP Chakarov

PHP: Introduction By Trevor Adams Topics Covered Server side web programming Client/Server systems Comparison with static HTML PHP - what is it? What does it do? PHP Language basics Syntax Variables, Constants, Operators Decision making PHP and the client Client/Server on the WWW Standard web sites operate on a request/response basis A user ...

17 Views0 Downloads

Introduction to PHP University of Michigan

Introduction to PHP Dr. Charles Severance www.php-intro.com Note from Chuck. If you are using these materials, you can remove my name and URL from this replace it with your own, but please retain the CC-BY logo on the first page as well as retain the entire last page when you remix and republish these slides.

9 Views0 Downloads

Introduction to PHP instesre org

Introduction to PHP – Chapter 8 Working with PHP JavaScript vs. PHP PHP scripts are similar to JavaScript scripts, but be careful with syntax! PHP variables always begin with a “$” symbol. There is no equivalent to JavaScript’s “var” data declaration. PHP scripts are embedded within a <?php … ?> tag.

7 Views0 Downloads

Introduction to PHP Mahasarakham University

Web Development. FINAL 50%. Week5-6. Web Services. XML. Web Service Client. Web Service Server. Web2.0 Mashup. Week7. PHP template with Smarty

11 Views0 Downloads

Introduction to PHP WA4E

Introduction to PHP Last modified by: Sue Blumenberg Document presentation format: On-screen Show (16:9) Other titles: Helvetica MS Pゴシック Arial Gill Sans Lucida Grande ヒラギノ角ゴ ProN W3 Courier 1_Office Theme Office Theme PHP Arrays PHP Arrays Rock! Associative Arrays Integer Indices Key / Value Dumping an Array var_dump vs ...

14 Views0 Downloads

Introduction to PHP WPI

Introduction to PHP “PHP is a server-side scripting language designed specifically for the Web. Within an HTML page, you can embed PHP code that will be executed each time the page is visited. Your PHP code is interpreted at the Web server and generates HTML or other output that the visitor will see” (“PHP and MySQL Web Development ...

12 Views0 Downloads

Introduction to Server Side Development with PHP

PHP Comments. The types of comment styles in PHP are: Single-line comments. Lines that begin with a # are comment lines and will not be executed. Multiline (block) comments. These comments begin with a /* and encompass everything that is encountered until a closing */ tag is found. End-of-line comments

12 Views0 Downloads

Introduction to PHP and MySQL

Title: Introduction to PHP and MySQL Author: Lisa Dipippo Last modified by: Lisa DiPippo Created Date: 10/21/2003 8:11:01 PM Document presentation format

6 Views0 Downloads

Introduction to PHP

PHP and MySQL Web Development 2nd Edition, Welling & Thomson Web Database Applications with PHP & MySQL, O’Reilly Publishers PHP Cookbook, O’Reilly Publishers

12 Views0 Downloads

PHP MySQLPart 2 WordPress com

Advanced PHP. PHP includes. Including an external phpor html file in your PHP page – useful for reusing code/functions in many pages (navigational columns, database connections, session/cookie retrieval and validation etc…)

29 Views0 Downloads

PHP faculty utrgv edu

PHP History. Started as Personal Home Page Tools (PHP Tools) in 1995 with a goal to create a guestbook by gathering information from an online form and displaying it on a web page. The ability to communicate with a database was later added. With v3 in 1998, the name dropped since it sounded more of a hobbyist’s term.

45 Views0 Downloads