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:
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.
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
PHP file PHP files can contain text, HTML tags and scripts PHP files are returned to the browser as plain HTML
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
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
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
Installing Wamp If the installation went well, you should have an new icon in the bottom right, where the clock is:
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
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
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.
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 */
A PHP script The above program will display hello in the browser
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