Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP: Hypertext Processor Fred Durao

Similar presentations

Presentation on theme: "PHP: Hypertext Processor Fred Durao"— Presentation transcript:

1 PHP: Hypertext Processor Fred Durao

2 Origins and Uses of PHP - Origins - Rasmus Lerdorf - 1994 - Developed to allow him to track visitors to his Web site - PHP is an open-source product - PHP was originally an acronym for Personal Home Page, but later it became PHP: Hypertext Preprocessor - PHP is used for form handling, file processing, and database access PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

3 Overview of PHP - PHP is a server-side scripting language whose scripts are embedded in HTML documents - Similar to JavaScript, but on the server side - PHP syntax is similar to that of JavaScript For a browser read and interpret the PHP commands, the file must be have an extension.PHP EXAMPLE - before myPage.html - now myPage.php More at

4 General Syntactic Characteristics - PHP code can be specified in an HTML document internally or externally: Internally: <?php.......php code goes here......... ?> Externally: include ("") - the file can have both PHP and HTML - Comments - three different kinds //... #... /*... */ - Output from a PHP script is HTML that is sent to the browser. - PHP code is placed in the body of an HTML document

5 A little bit of “Programming” -It is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. - This source code is written in a programming language. - The code may be a modification of an existing source or something completely new. - The purpose of programming is to create a program that exhibits a certain desired behavior (customization).

6 A little bit of “Programming” (continue) -The details look different in different languages, but a few basic instructions appear in just about every language: - input: Get data from the keyboard, a file, or some other device. - output: Display data on the screen or send data to a file or other device. - arithmetic: Perform basic arithmetical operations like addition and multiplication. - conditional execution: Check for certain conditions and execute the appropriate sequence of statements. - repetition: Perform some action repeatedly, usually with some variation. THE program languages such as PHP, JAVA, C, JAVASCRIPT,... Implement these instructions though commands. Usually each program language has its own syntax.

7 PHP –> VARIABLE Variables are used for storing values, like text strings, numbers or arrays. When a variable is declared, it can be used over and over again in your script. All variables in PHP start with a $ sign symbol. Example $var_name = value;

8 PHP –> Control Statements - Relational operators - same as JavaScript, (including === and !== ) - Boolean operators – “OR” and “AND” - Selection statements - if, if - else, elseif - HTML can be intermingled with PHP script <?php $a = 7; $b = 7; if ($a == $b) { $a = 3 * $a; } ?>

9 User-Defined Functions - Syntactic form: function function_name ( formal_parameters ) { … } - General Characteristics - Functions need not be defined before they are called - The return function is used to return a value; - If there is no return, there is no returned value EXAMPLE function set_max(&$max, $first, $second) { if ($first >= $second) $max = $first; else $max = $second; }

10 PHP –> COMMANDS - > ECHO PHP has a number of predefined functions ready use. Echo () PHP Function - is used to output the given argument. <?php Echo "Hello"; //Outputs a string Echo $variable; //Outputs a variable Echo "Multiple things ". $on. " one line"; //Outputs a string, then a variable, then a string. All are separated with a [.] period ?>

11 PHP –> COMMANDS -> MAIL PHP has a number of predefined functions ready use. Mail () PHP Function - is used to send an email. mail ($to, $subject, $message, $headers) // headers are optional <?php $to = ''; $subject = 'the subject'; $message = 'hello'; $headers = 'From:'. "\r\n". 'Reply-To:'. "\r\n". mail($to, $subject, $message, $headers); ?>

Download ppt "PHP: Hypertext Processor Fred Durao"

Similar presentations

Ads by Google