Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in 1995. PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).

Similar presentations


Presentation on theme: "PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in 1995. PHP stands for PHP: Hypertext Preprocessor (a recursive acronym)."— Presentation transcript:

1 PHP By Dr. Syed Noman Hasany

2 PHP PHP was originally created by Rasmus Lerdorf in 1995. PHP stands for PHP: Hypertext Preprocessor (a recursive acronym). Hypertext is the underlying concept defining the structure of the World Wide Web, is the text displayed on a computer or other electronic device with references (hyperlinks) to other text. PHP has term “preprocessor” because PHP libraries are already compiled and processed. when any person request any PHP page in browser address bar that request first go to server for example Apache which interprets PHP files and return back response in form of HTML.

3 PHP PHP is a server-side scripting language, like ASP An embedded scripting language for HTML. 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 software, so it is free to download and use

4 PHP file PHP files can contain text, HTML tags and scripts PHP files are returned to the browser as plain HTML

5 Why PHP? PHP runs on different platforms (Windows, Linux, Unix, etc.) PHP is compatible with almost all servers used today (Apache, IIS, etc.) PHP is easy to learn ( syntax like C) and runs efficiently on the server side

6 MySQL MySQL is a database server MySQL is ideal for both small and large applications MySQL supports standard SQL MySQL compiles on a number of platforms MySQL is free to download and use

7 PHP + MySQL + Apache PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a Unix platform) To get access to a web server with PHP support, you can: Install Apache on your own server, install PHP, and MySQL Wamp server: All in one download and installation for Windows (visual C++ 2010 is needed) – http://sourceforge.net/projects/wampserver/files/latest/download http://sourceforge.net/projects/wampserver/files/latest/download – http://download.cnet.com/Microsoft-Visual-C-2010-SP1- Redistributable-Package-x86/3000-2247_4-75450985.html http://download.cnet.com/Microsoft-Visual-C-2010-SP1- Redistributable-Package-x86/3000-2247_4-75450985.html

8 Installing Wamp If the installation went well, you should have an new icon in the bottom right, where the clock is:

9 Localhost Localhost just refers to the server running on your own computer. Another way to refer to your server is by using the IP address 127.0.0.1

10 Running PHP scripts Suppose created php script name is first.php √ http://localhost/first.php http://localhost/first.php if a folder under www contains the file, then: √ http://localhost/folder_name/script_name.php http://localhost/folder_name/script_name.php Wrong formats: ×c:/wamp/www/test1.php ×http://localhost/www/test1.php

11 Basic PHP Syntax A PHP script starts with and can be placed anywhere in the document. On servers with shorthand-support,, but not recommended due to possible xml conflicts.

12 PHP Comments All php files are saved with extension.php Can be written in notepad or any text editor Single line comment – // this is single line comment Multi line comment – /*…. This is a multi line comment */

13 A PHP script The above program will display hello in the browser

14 Example 1: title Example

15 Variables Case sensitive Variables start with a $ symbol Variables can contain _ or numbers or alphabets $ should be followed by _ or alphabet and not by a number PHP is loosely typed language. There is no strict data typing Variable can be assigned with any values

16 Example 2 <?php echo "hello PHP"; $txt="Hello World!"; $x=16; echo $txt, $x; ?>

17 Conditions If else if(condn) {….} elseif(condn) {….} else { ….} Switch case switch(var) { case c1: statements;break. Default: statements; break; }

18 Example 3 "; echo “ Good bye”; } else { echo "Have a nice day!"; } ?> Extract 3 character value from the system date newline

19 Loops For for(intialisation;condition;increment/decrement) { statements } While while(condn) { ….} Do While do {….} while(condn);

20 Example 4 "; echo "The number is ". $i. " "; } while ($i, or. (dot) as concatenation operator


Download ppt "PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in 1995. PHP stands for PHP: Hypertext Preprocessor (a recursive acronym)."

Similar presentations


Ads by Google