You are on page 1of 12

Web Development with PHP

Powered by Mohamed El-Sherbiny

M.ElSherbiny90@yahoo.com
DAY 1
INTRODUCTION TO PHP

All Rights Reserved © 2011 - Powered by


2
M.ElSherbiny90@yahoo.com Mohamed El-Sherbiny
Outline:-
 What is PHP?
 History of PHP
 What can PHP do?
 What do I need?
 How PHP work
 PHP Syntax
 PHP Hello World Script
 PHP Comments

All Rights Reserved © 2011 - Powered by


3
M.ElSherbiny90@yahoo.com Mohamed El-Sherbiny
What’s PHP?
PHP
Open source scripting language used to developed
dynamic web pages.
PHP code is embedded into HTML.
 Interpreted by a web server.
In the past recursive to Personal Home Page.
Now recursive to Hypertext Preprocessor.
PHP is in use on more than 20 million domains
All Rights Reserved © 2011 - Powered by
M.ElSherbiny90@yahoo.com 4
Mohamed El-Sherbiny
History of PHP

• PHP was created by  Rasmus Lerdorf in 1995


but named by PHP/FI
• At this time PHP was not a programming
language, it just be some scripts build by Perl

• PHP reassemble as we know it today by Andi


Gutmans and Zeev Suraski in 1997 as a
complete rewrite

• PHP reassemble again and provides with ZEND


Engine in 1998
All Rights Reserved © 2011 - Powered by
M.ElSherbiny90@yahoo.com 5
Mohamed El-Sherbiny
What can PHP do?
• PHP is used in three main areas :-

 Server-side Scripting (Websites and web applications …).

 Command line Scripting (Simple text processing tasks…).

 Desktop (GUI) applications (PHP GTK…). http://www.gtk.php.net/

All Rights Reserved © 2011 - Powered by


M.ElSherbiny90@yahoo.com 6
Mohamed El-Sherbiny
What do I need?
• Web browser
– Firefox
– Chroom
– Safari , etc….
• Web server
– Apache server
– Wamp server , etc….
• PHP editor
– Notepad++
– PHP designer
– Dreamwaver
– Netbeans ,etc….
All Rights Reserved © 2011 - Powered by
M.ElSherbiny90@yahoo.com 7
Mohamed El-Sherbiny
How PHP Work

User type URL in address Browser send request to


bar bring this file from web
(www.php.net) server

The Web server starts scanning the file in HTML mode. It assumes the statements are
HTML and sends them to the browser without any processing.
The Web server continues in HTML mode until it encounters a PHP opening tag (<?PHP).
When it encounters a PHP opening tag, the Web server switches to PHP mode. This is
sometimes called escaping from HTML. The Web server then assumes that all statements are
PHP statements and executes the PHP statements. If there is output, the server sends the
output to the browser.
The Web server continues in PHP mode until it encounters a PHP closing tag (?>).

When the Web server encounters a PHP closing tag, it returns to HTML mode. It resumes
scanning, and the cycle continues from Step 1.

All Rights Reserved © 2011 - Powered by


M.ElSherbiny90@yahoo.com 8
Mohamed El-Sherbiny
How PHP Work

 The PHP interpreter processes the page, communicating with file systems,
databases, and email servers as necessary, and then delivers a web page to the web
server to return to the browser.

All Rights Reserved © 2011 - Powered by


M.ElSherbiny90@yahoo.com 9
Mohamed El-Sherbiny
PHP Syntax

<?php
Default style ●
// your code

?>


<?
Short style ●
// your code

?>


<script language="php">
Script style ●
// your code

</script>
All Rights Reserved © 2011 - Powered by
M.ElSherbiny90@yahoo.com 10
Mohamed El-Sherbiny
PHP Hello World Script

<? Php

echo "Hello World";

?>

All Rights Reserved © 2011 - Powered by


M.ElSherbiny90@yahoo.com 11
Mohamed El-Sherbiny
PHP Comments
• One line comments we will use
// Your line comment

• Multiline comments
 /*
Your multiline comments
Your multiline comments
*/
All Rights Reserved © 2011 - Powered by
M.ElSherbiny90@yahoo.com 12
Mohamed El-Sherbiny

You might also like