1 / 11

Introduction of PHP

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.

Télécharger la présentation

Introduction of PHP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 – <html> <head> <title> Hello World</title> </head> <body> <?php echo “Hello!”; ?> </body> </html> 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 with<?php and ends with ?> . A PHP scripting block can be placed anywhere in the document

  9. PHP Variable DeclarationAll variables in PHP begin with the $ sign.Ex.<?php$my_variable = 20;$my_variable2 = “Hello World”;?> • Variable RulesYou have to follow some rules when naming a variable:A 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 Variables<?php$my_string = “Hello everybody”;echo $my_string;?>

  10. strlen() functionThe PHP strlen() used to get length of string<?phpecho strlen("I’m sorry dave, I’m afraid I can’t do that.");?>The 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() can’t find the character in the string, it will return FALSE.<?phpecho strpos(“Open the pod bay doors please, HAL”,”HAL”);echo strpos(“Open the pod bay doors please, HAL”,”H”);?>The 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 (.) <?php$str_one=”Hello“;$str_two=”World!”;echo $str_one . “ “. $str_two;?>The result will be “Hello World!”.

More Related