WebDevelopmet Lec2
WebDevelopmet Lec2
WebDevelopmet Lec2
WEB APPLICATION
DEVELOPMENT COURSE
LECTURE 2
Introduction
2
• What is PHP?
Language developed by Rasmus Lerdorf from the Apache
Group
Its primary use is for server-side scripting
• Ex: To process HTML forms
• Ex: To perform a DB query and pass on results
• Ex: To dynamically generate HTML
PHP scripts are often embedded within HTML documents
• The server processes the HTML document, executing the PHP
segments and substituting the output within the HTML document
Intro to PHP
6
Form processing
Output / generate various types of data (not just text)
Database access
Allows for various DBs and DB formats
Object-oriented features
Somewhat of a loose hybrid of C++ and Java
Ex: http://wordpress.org/
<?php
as Escaping to php.
• Consider the following PHP file
12
<!DOCTYPE html>
HTML 5 Document
<html>
Root HTML Tag
<head>
<title>Simple PHP Example</title> Document Head
</head>
<body>
D <?php echo "<p><h1>Output</h1>";
echo "<h2>Output</h2>";
O echo "<h3>Output</h3></p>";
C ?> PHP Code
<script language="PHP">
echo "\n<b>More PHP Output</b>\n";
B echo "New line in source but not rendered";
O echo "<br/>";
D echo "New line rendered but not in source";
</script>
Y
</body>
</html>
PHP Syntax Rules
13
PHP Hello World