Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Presented by
M. IQBAL BHAT
Government Degree College
Pulwama
Three-tiered Web Site: LAMP
Client example request Server
User-agent: Firefox GET / HTTP/1.1 Apache HTTP Server
Host: www.tamk.fi
User-Agent: Mozilla/5.0 (Mac..)
...
response PHP
Database
MySQL
Server Side Techniques
• Server side scripting requires installation on
the server side
• Typically client siis only xhtml and it unaware
that the xhtml was produced by a server side
script
• Does not require any installations or add-ons
on the client
Server Side Techniques
• PHP
• Java EE: Servlet, JSP
• .NET
• CGI / Perl (Very old)
• Ruby
• …
Client Side Techniques
• Requires that the client supports the technique
• JavaScript, Applet, Flash…
Web Application Frameworks
• A web application framework is a software
framework that is designed to support the
development of dynamic websites, Web
applications and Web services.
• Numerous frameworks available for many
languages
Web App vs. Web Site?
• What’s the difference between Web App and
Web Site?
• Rich Internet Application?, AJAX?, Thin Client?
• Full application running in your browser or just
a web site?
PHP: HYPERTEXT PREPROCESSOR
Introduction to PHP
• PHP is a computer scripting language.
• Originally designed for producing dynamic web pages
• Appeared in 1995
• PHP Group is responsible for the language, no formal
specification
• Free software
• Runs on most operating systems and platforms
• URL: http://www.php.net
Response
Introduction to PHP Syntax
• PHP has quite easy syntax, if you are familiar
with any c-type language
• It has all the same structures that you are
familiar with other programming languages
• PHP is designed to output to browser, but it is
possible to do also CLI apps.
Example
<?php
print "What is your name?\n";
$name = trim(fgets(STDIN));
print "Hello " . $name;
?>
Variables
• Variables in PHP are represented by a dollar
sign
• PHP supports eight types:
– boolean, integer, float, double, array, object,
resource and NULL
Example (php.net)
<?php
$a_bool = TRUE; // a boolean
$a_str = "foo"; // a string
$a_str2 = 'foo'; // a string
$an_int = 12; // an integer
Equals
$i = 0;
do {
print $i;
} while ($i > 0);
?>
For
<?php
print "<p>Hello from PHP!</p>";
?>
</body>
</html>
Better ways
• Use functions
• Use OO
PHP AND USER INPUT
PHP and User Input via Forms
• See
– http://php.tpu.fi/~pohjus/lectures/php/forms-and-
php.html