Download presentation
Presentation is loading. Please wait.
Published byAngela Mitchell Modified over 9 years ago
1
AIT 616 Fall 2002 PHP
2
AIT 616 Fall 2002 PHP Special scripting language used to dynamically generate web documents Open source – Free!!! Performs common server-side tasks Platform independent Similar in concept to ColdFusion and ASP Instructions embedded with HTML template Instructions are parsed out and processed by a special program running on the Web server Output from the instruction are incorporated back into the HTML template and sent to the client’s browser
3
AIT 616 Fall 2002 PHP A relative newcomer in the server-side development arena Gained a large following with its simple syntax and comprehensive function library Attractive alternative to ASP for new developers Dubbed by some to be the ‘Perl Killer’ of the server-side scripting world
4
AIT 616 Fall 2002 Support Servers Windows environment Personal Web Server Internet Information Server (IIS) Apache Unix Environment Apache (pre-configured on linux)
5
AIT 616 Fall 2002 Writing PHP Code PHP code coexists with HTML code in the same file Must enclose PHP code with special delimiters … HTML code …. <?php … php code … ?> … HTML code …
6
AIT 616 Fall 2002 Writing PHP Code …. <?php echo “ Hello, World ” ?> Server-side script
7
AIT 616 Fall 2002 Writing PHP Code …. Hello, World Client-side source code delivered to a browser
8
AIT 616 Fall 2002 Writing PHP Code Comments Double forward slash (//) echo command Prints out and include a \n character Comma Separates commands
9
AIT 616 Fall 2002 PHP Variables Stores literal values Two types Scalar Holds one value String, integer, floating Array Holds multiple values Case sensitive <?php $lang=‘PHP’ $num=1 ?>
10
AIT 616 Fall 2002 PHP Variables Predefined Provides a large number to any script Are dependent upon which server is running Version, setup, other factors Scope Is the context within which it is defined For the most part, all variables have single scope
11
AIT 616 Fall 2002 PHP Variables <?php $a=1 function Test() { $b=$a echo $b } ?> Global Scope Local Scope
12
AIT 616 Fall 2002 PHP Operators Common mathematical functions Concatenation Dot (.) operator Comparison operators Returns true or false Boolean arithmetic <?php $x=‘ Hello,’ $y=‘World! ’ $z=$x.$y echo $z ?> Hello, World!
13
AIT 616 Fall 2002 PHP Decision Structures Decision making during course of scripting processing if statement <?php $age=26 if($age>=18) { echo ‘Register to vote!’ } ?>
14
AIT 616 Fall 2002 PHP Looping Structure Iterative execution of a set of instructions for loop while loop <?php $num=7 $square=$num*$num while($num<$square) { if($num%2==0) { echo ‘ $num ’ } $num=$num+1 } ?>
15
AIT 616 Fall 2002 PHP Functions Performs many common tasks Large number of built-in functions Define your own function Functions Apache-specific Database specific Network service Mathematical String PDF File system XML parser Session maintenance
16
AIT 616 Fall 2002 PHP Header() Function Useful built-in function Used to add a line to the HTTP header Functionality Type of file being sent to client Cookies Redirect Host of other bits of information
17
AIT 616 Fall 2002 Built-in Function <?php function myFactorial($x) { $f=1 for($k=1;$k<=$x;$k++) { $f=$f*$x; } return $f } $yourNumber=4 echo ‘factorial of $yourNumber is: ‘ echo myfactorial($yourNumber) ?>
18
AIT 616 Fall 2002 Common Web Tasks Responding to a form submission PHP engine automatically stores the form data into an associative array Using environmental variables Stores information about a client Function getenv() Sending email Function mail() Placing a cookie Function setcookie() Database access
19
AIT 616 Fall 2002 Common Web Tasks Implementation of basic HTTP authentication to protect resources on the server File access on the server (r/w) Handle file uploads from a client Session tracking
20
AIT 616 Fall 2002 PHP Summary Advantages Fairly easy to learn Everything is built right into the language Cross platform Its Free!! Active user community Disadvantages Language was designed to be programmer-friendly, which unfortunately makes it a little less friendly to non-programmers
21
AIT 616 Fall 2002 PHP Summary Target Developer Web developers on a budget who enjoy simple programming PHP gives you a great deal of power with relatively simple code structure May not be suited to very high end applications that aren’t supported by its built-in features
22
AIT 616 Fall 2002 PHP vs Perl Biggest advantage of PHP over Perl is that PHP was designed for scripting for the web PHP is less confusing and a stricter format without losing flexibility PHP is easier to integrate into existing HTML then Perl PHP has pretty much all the ‘good’ functionality of Perl Perl is a very tried and true language, its been around since the late 80s, but PHP is maturing very quickly
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.