Intoroduction to Adnvanced Internet Programming Chapter two.pptx
JerusalemFetene
22 views
16 slides
May 30, 2024
Slide 1 of 16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
About This Presentation
IT
Size: 224.82 KB
Language: en
Added: May 30, 2024
Slides: 16 pages
Slide Content
Chapter two Introduction to PHP Compiled By: Fekadu E. Email: [email protected] 1
Out Line In this session we will see The definition of PHP Basic Syntax in PHP Programming Operation in PHP Variables in PHP The Goal of this session Understand the basic Syntax of PHP Understand the use of operator in PHP Understand declare, scope of Variables in PHP 2
What is PHP? PHP is a popular high-level scripting language used by a range of organizations and developers. Originally developed as a small Perl project by Rasmus Lerdorf in late 1995, PHP was intended as a means to assist in developing his home page, and as such he named it Personal Home Page (PHP) Tools. When Lerdorf was contracted to work for the University of Toronto to build a dial-up system for students to access the Internet, he had no means of connecting Web sites to databases. To solve this problem, the enterprising Lerdorf replaced his Perl code with a C wrapper that added the capability to connect his Web pages to a MySQL database. As his small project grew, he gave away his changes on the Internet as an Open Source project and cordially received improvements from other programmers with an interest in PHP. The language was later renamed to the current recursive acronym PHP: Hypertext Preprocessor by Zeev Suraski and Andi Gutmans after they rewrote the parser in 1997. 3
Introduction PHP is an acronym for "PHP: Hypertext Preprocessor“ PHP is a server-side, open source scripting language PHP is cross platform PHP is a server side scripting language that is embedded in HTML It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites PHP provides a solid and well-defined programming language that includes support for object-orientated programming, file handling, arithmetic, and more 4
Common use of PHP PHP performs system functions, i.e. it can create, open, read, write, and close from files on a system PHP allows to add, delete, modify elements within your database Access cookies variables and set cookies restrict users to access some pages of your website encrypt data 5
Why I need PHP? PHP runs on different platforms (Windows, Linux, Unix, etc.) PHP is compatible with almost all servers used today like apache. PHP is FREE to download from the official PHP resource: www.php.net PHP is easy to learn and runs efficiently on the server side 6
PHP Syntax A PHP script always starts with <? php and ends with ?> A PHP script can be placed anywhere in the document. Syntax PHP code should enclosed within: <? php and ?> So that it is distinguished from HTML. Hence, the PHP parser only parses code which is in between <? php and ?> PHP code can be embedded in HTML 7
PHP Operators Operators are used to perform operations on variables and values . basically operators are divided in to the following group. Arithmetic operators Assignment operators Comparison operators Increment/Decrement operators Logical operators String operators 8
PHP Arithmetic Operators The PHP arithmetic operators are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc . Operator Name Example Result + Addition $x + $y Sum of $x and $y - Subtraction $x - $y Difference of $x and $y * Multiplication $x * $y Product of $x and $y / Division $x / $y Quotient of $x and $y % Modulus $x % $y Remainder of $x divided by $y 9
PHP Assignment Operators The PHP assignment operators are used with numeric values to write a value to a variable . The basic assignment operation in PHP is “=“. Assignment Same as... Description x = y x = y The left operand gets set to the value of the expression on the right x += y x = x + y Addition x -= y x = x - y Subtraction x *= y x = x * y Multiplication x /= y x = x / y Division x %= y x = x % y Modulus 10
PHP Comparison Operators The PHP comparison operators are used to compare two values (number or string ) Operator Name Example Result == Equal $x == $y Returns true if $x is equal to $y === Identical $x === $y Returns true if $x is equal to $y, and they are of the same type != Not equal $x != $y Returns true if $x is not equal to $y <> Not equal $x <> $y Returns true if $x is not equal to $y !== Not identical $x !== $y Returns true if $x is not equal to $y, or they are not of the same type > Greater than $x > $y Returns true if $x is greater than $y < Less than $x < $y Returns true if $x is less than $y >= Greater than or equal to $x >= $y Returns true if $x is greater than or equal to $y <= Less than or equal to $x <= $y Returns true if $x is less than or equal to $y 11
PHP Increment / Decrement Operators The PHP increment operators are used to increment a variable's value. The PHP decrement operators are used to decrement a variable's value. Operator Name Description ++$x Pre-increment Increments $x by one, then returns $x $x++ Post-increment Returns $x, then increments $x by one --$x Pre-decrement Decrements $x by one, then returns $x $x-- Post-decrement Returns $x, then decrements $x by one 12
PHP Logical Operators The PHP logical operators are used to combine conditional statements. Operator Name Example Result and And $x and $y True if both $x and $y are true or Or $x or $y True if either $x or $y is true xor Xor $x xor $y True if either $x or $y is true, but not both && And $x && $y True if both $x and $y are true || Or $x || $y True if either $x or $y is true ! Not !$x True if $x is not true 13
PHP String Operators PHP has two operators that are specially designed for strings Operator Name Example Result . Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2 .= Concatenation assignment $txt1 .= $txt2 Appends $txt2 to $txt1 14
What is Variable? Variable is a symbol or name that stands for a value. Variables are used for storing values such as numeric values, characters, character strings. Variable in PHP is case insensitive. 15
Activity??? What is PHP? What is open source? List Type of Operation. What is variable? How declare variable in PHP? 16