Introduction to PHP PHP PHP started out as
- Slides: 27
Introduction to PHP
PHP? PHP started out as a small open source project that evolved as more and more people found out how useful it was. Rasmus Lerdorf unleashed the first version of PHP way back in 1994. PHP: PHP Hypertext Preprocessor Syntax is C-Like Server side scripting language that is embedded in HTML PHP supports a large number of major protocols
Characteristics of PHP Simplicity Efficiency Security Flexibility Familiarity
Popularity of PHP The PYPL Popularit. Y of Programming Language Index is created by analyzing how often language tutorials are searched on Google.
PHP Market Share
Usage of Server-side programming languages for websites
Escaping in PHP Canonical PHP tags: Short-open (SGML-style) tags: <? . . . ? > Set the short_open_tag setting in your php. ini file to on. This option must be disabled to parse XML with PHP because the same syntax is used for XML tags. ASP-style tags <? php. . . ? > <%. . . %> HTML script tags: <script language="PHP">. . . </script>
Exercise Create your first PHP script. Write the string “Hello world. . is it me you’re looking for? ”
Commenting PHP code Single-line comments #This is a comment //This is a comment Multi-lines /* comments This is a comment for multiple lines */
Things to Remember PHP is whitespace insensitive PHP is case sensitive Statements are expressions terminated by semicolons Expressions are combinations of tokens Braces make blocks
Variables All variables in PHP are denoted with a leading dollar sign ($). The value of a variable is the value of its most recent assignment. Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right. Variables can, but do not need, to be declared before assignment. Variables in PHP do not have intrinsic types - a variable does not know in advance whether it will be used to store a number or a string of characters. Variables used before they are assigned have default values. PHP does a good job of automatically converting types from one to another when necessary. PHP variables are Perl-like.
PHP Data Types Integer Doubles Booleans NULL String Array Object Resources Simple Types Compound Types Special variables that reference to external resources
Variable Scopes Local variables – variable declared in a function, and can only be referenced in that function.
Variable Scopes Function parameters - are declared after the function name and inside parentheses.
Variable Scopes Global variables – can be accessed in any part of the program. Must be declared using the keyword GLOBAL
Variable Scopes Static variables – does not lose the value when the function exits and will still hold the value when it is called again. Uses the keyword STATIC
Variable naming Variable names must begin with a letter or underscore character. A variable name can consist of numbers, letters, underscores but you cannot use characters like + , - , % , ( , ). & , etc There is no size limit for variables.
Operator types Arithmetic Operators
Operator types Comparison Operators
Operator types Logical Operators
Operator types Assignment Operators
Operator types Conditional Operators
Precedence of PHP Operators
If…else statement
Else. If statement
Switch statement
Exercise 1. Create a variable named count and assign the number 0 2. Create a
- One direction figurative language
- Web.facebook.com /profile.php
- Php php://input
- Put out the light and then
- Robert frost poems
- Out of sight out of mind psychology
- Out out- analysis
- Loto safety talk
- Out out personification
- Out of sight out of time
- Self righteous
- Loto
- Out, damned spot! out, i say!
- Harmony not discord
- Makna out of sight out of mind
- Log out tag out deutsch
- When was globalization started
- What is urdu hindi controversy
- When islam started
- Known as the continuing professional development act
- Who is the founder of samaritan's purse
- Getting started with vivado ip integrator
- Getting started with unix
- Getting started with splunk
- Rancher slack channel
- Getting started with excel
- English for presentation unit 1
- Domino theory