introduction to PHP - PowerPoint PPT Presentation

About This Presentation
Title:

introduction to PHP

Description:

The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is a server-side scripting language, like ASP .PHP scripts are executed on the server.PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) .PHP is an open source language.PHP is basically used for developing web based software applications. – PowerPoint PPT presentation

Number of Views:137
Slides: 12
Provided by: sushniya
Category: Other

less

Transcript and Presenter's Notes

Title: introduction to PHP


1
Introduction ToPHP
2
  • PHP originally stood for "Personal Home Page".
  • The PHP Hypertext Preprocessor (PHP) is a
    programming language that allows web developers
    to create dynamic content that interacts with
    databases.
  • PHP supports many databases (MySQL, Informix,
    Oracle, Sybase, Solid, PostgreSQL, Generic ODBC,
    etc.)
  • PHP is a server-side scripting language, like ASP
  • PHP is an open source language.PHP is basically
    used for developing web based software
    applications

3
Common uses of PHP
  • PHP performs system functions, i.e. from files on
    a system it can create, open, read, write, and
    close them.
  • PHP can handle forms, i.e. gather data from
    files, save data to a file, through email you can
    send data, return data to the user.
  • You add, delete, modify elements within your
    database through PHP.
  • Access cookies variables and set cookies.
  • Using PHP, you can restrict users to access some
    pages of your website.
  • It can encrypt data.

4
Characteristics of PHP
  • Five important characteristics make PHP's
    practical nature possible -
  • Simplicity
  • Efficiency
  • Security
  • Flexibility
  • Familiarity

5
Features
  • In PHP there is no need to specify data type for
    variable declaration. Rather, it can be
    determined at the time of execution depends on
    the value of the variable. So that, PHP is called
    as loosely typed language.
  • PHP provides cross platform compatibility, unlike
    some other server side scripting language.
  • PHP programming structure includes variable
    variables that is, the name of the variable can
    be change dynamically.
  • This language contains access monitoring
    capability to create logs as the summary of
    recent accesses

6
  • Predefined error reporting constants are
    available to generate a warning or error notice.
    For example, when E_STRICT is enabled, a warning
    about deprecated methods will be generated.
  • PHP supports extended regular expression that
    leads extensive pattern matching with remarkable
    speed.
  • Since PHP is a single inheritance language, the
    parent class methods can be derived by only one
    directly inherited sub class. But, the
    implementation of traits concept, reduce the gap
    over this limitation and allow to reuse required
    method in several classes.

7
"Hello" Script in PHP
  • To get a feel for PHP, first start with simple
    PHP scripts. Since "Hello, World!" is an
    essential example, first we will create a
    friendly little "Hello, World!" script.
  • As mentioned earlier, PHP is embedded in HTML.
    That means that in amongst your normal HTML (or
    XHTML if you're cutting-edge) you'll have PHP
    statements like this
  • lthtmlgt
  • ltheadgt
  • lttitlegt Hello Worldlt/titlegt
  • lt/headgt
  • ltbodygt
  • lt?php echo Hello! ?gt
  • lt/bodygt
  • lt/htmlgt
  • It will produce following result -
  • Hello!

8
  • If you examine the HTML output of the above
    example, you'll notice that the PHP code is not
    present in the file sent from the server to your
    Web browser. All of the PHP present in the Web
    page is processed and stripped from the page the
    only thing returned to the client from the Web
    server is pure HTML output.
  • Most Basic PHP Syntax A PHP scripting block
    always starts withlt?php and ends with ?gt . A PHP
    scripting block can be placed anywhere in the
    document

9
  • PHP Variable DeclarationAll variables in PHP
    begin with the sign.Ex.lt?phpmy_variable
    20my_variable2 Hello World?gt
  • Variable RulesYou have to follow some rules when
    naming a variableA variable name cannot contain
    spaces.
  • A variable name must start with a letter or an
    underscore ( _ )
  • A variable name can only contain alpha-numeric
    characters and underscores (a-z, A-Z, 0-9, and _
    )
  • String Variableslt?phpmy_string Hello
    everybodyecho my_string?gt

10
  • strlen() functionThe PHP strlen() used to get
    length of stringlt?phpecho strlen("Im sorry
    dave, Im afraid I cant do that.")?gtThe
    result of the statement will be a number (the
    length of the string including space and signs,
    not only the characters), in this case the number
    43.
  • strpos() functionThe PHP strpos() function is
    used to search for a character or string within a
    string. If the character is found the strpos()
    function will return the position of the first
    match. If strpos() cant find the character in
    the string, it will return FALSE.lt?phpecho
    strpos(Open the pod bay doors please,
    HAL,HAL)echo strpos(Open the pod bay doors
    please, HAL,H)?gtThe position of the string
    HAL in the whole string is position 31 (the
    space before the string HAL.) The reason that it
    is 31 (space) and not 32 (the character H) is
    that the first position in the string is 0, and
    not 1.

11
  • Concatenation OperatorPHP has only one string
    operator. If you want to put two string values
    together you can use the concatenation operator
    (.) lt?phpstr_oneHellostr_twoWorld!e
    cho str_one . . str_two?gtThe result will
    be Hello World!.
Write a Comment
User Comments (0)
About PowerShow.com