Chapter 1: PHP Intro
introduction
3-tier Application Environment
User interaction is separated from the database through a middleware that act as a
connector.
Client : Used to display the interface of the application. The interface downloaded
form the server. Some logical operations done here. Eg: Web Browsers (IE,
Firefox, Opera, Safari, etc)
Web Server+Middleware : Store and host the interface. Provide the interface to
the client. Most operations are on data retrieval and manipulations.
Eg: Apache + PHP, IIS + ASP.
Database server : Store and host data/records. Receive request and send the
data/record to the web server. Eg : MySQL, SQL Server, PostgreSQL, etc…
Web page
HTTP
request Records
Database
Web server & Data
middleware request
What is dynamic website / active server pages?
Web site that provide web pages that the content may change with regard to the change of
the variables, such as users, browsers, geography, records in the database, etc…
What is a web server?
Program / computer application that receive request from the browsers.
Provide documents to requesting browsers.
It’s a slave program that only acts if a browser request.
Example of web servers;
o Apache
o IIS
o Xitami
o Apache Tomcat
o ColdFusion
Web Application Dev using PHP & MySQL - All rights reserved (2016) KERUL.net Chapter 1:1
Chapter 1: PHP Intro
What is a web browser?
Applications that act as clients on the web.
Request document from the web server.
The server locates the document.
The server sends the document to the web browser.
- Examples of web browsers;
o Google Chrome.
o Firefox from Mozilla.
o Safari from Apple Inc.
o Opera.
What is server-side scripting?
The script embedded inside the HTML page, interpreted and executed inside the
server (the web server) and the result/output of the execution is sent to the browser.
The script interpreted and executed inside the server.
The script won’t be sent to the client.
Example: PHP, ASP .NET, ASP, JSP, Perl, Phyton, etc…
What is client-side scripting?
The script embedded inside the HTML page, downloaded with the HTML page and
executed on the client (browser).
JavaScript (EcmaScript), VBScript, Jscript.
Web Application Dev using PHP & MySQL - All rights reserved (2016) KERUL.net Chapter 1:2
Chapter 1: PHP Intro
What is web programming?
Combination of server-side and client-side to develop a dynamic website. The
application is deployed in the web environment and can be access by multiple
concurrent users.
Exercise 1
1. What are the advantages and disadvantages of developing a web based application?
List and explain five advantages and five disadvantages.
2. Differentiate between server-side and client-side scripting. Explain five items.
A:. INTRO TO PHP
What is PHP?
PHP stands for PHP Hypertext Preprocessor.
Used to develop dynamic website
It is a server-side language.
The PHP script embedded in the web page.
The script is run (interpreted) on your web server, and the output from the process is
inserted to the web page as a part of the content before transmitted to the browser.
The script won’t be sent to the browser which request the web page, so the script is
not visible to the users.
It supports many database management system (Oracle, Postgre, DB2, Microsoft SQL
Server, etc).
And it’s free and powerful, that’s why PHP is very popular.
B:. THE PHP DEVELOPMENT TOOLS
by apachefriends.org
The text will refer the XAMPP compilation tools for web development using
Apache as the web server, PHP as
the server script interpreter and MySQL as the database server. These three
major tools are provided in the XAMPP and available for you in a single installation.
Installing XAMPP as the development tool.
Developed by a group of volunteer programmer as a tool to develop web
application using os/fs on Windows.
* in latest Linux distribution, Apache web server, MySQL database, and PHP
interpreter are installed as default for the server edition.
Web Application Dev using PHP & MySQL - All rights reserved (2016) KERUL.net Chapter 1:3
Chapter 1: PHP Intro
Before this, developer has to download and install 3 major applications for
developing web application using os/fs tools.
(Apache web server, MySQL database, and PHP interpreter)
phpDev combines three of them (plus few aditional software) in one installation.
download this compilation at http://www.apachefriends.org/en/xampp-
windows.html
Running XAMPP
After you downloaded and installed XAMPP for Windows on your system, turn on
all the server needed by clicking the
Start>Programs>XAMPP>Control Server Panel
***Pls stop the IIS service if you have installed it. Because Apache server is using
port 80 by default (similar as IIS).
After that, start the Apache server to use the web server application.
If you need to use MySQL, start the MySQL service.
The testing page will appear (if the installation succeed).
The web root is
c:\Program Files\xampp\htdocs\
Save all your php files inside
c:\Program Files\xampp\htdocs\yourFolder\
to create your own web application project.
To turn on/off the Apache
XAMPP Control Server Panel web server
To turn on/off the MySQL
For further documentation of XAMPP for Windows, go to :>database server
http://textbook.textpattern.net/wiki/index.php?title=Using_XAMPP_(Apache-MySQL-PHP-
Perl)_for_Windows To turn on/off the FileZilla
FTP server
Browse the installation
folder for XAMPP
Web Application Dev using PHP & MySQL - All rights reserved (2016) KERUL.net Chapter 1:4
Chapter 1: PHP Intro
XAMPP application folder
htdocs – the web root (this
is where we dump all the
HTML pages and the PHP
scripts)
mysql/data – where
MySQL store the database
records
phpMyAdmin – the web
based MySQL administrator
Web Application Dev using PHP & MySQL - All rights reserved (2016) KERUL.net Chapter 1:5
Chapter 1: PHP Intro
C:. TESTING YOUR FIRST PHP SCRIPT
Inserting PHP script inside HTML document.
The script below will display today’s date as available in the computer system.
<html>
<head><title>Today's Date</title></head>
<body>
Today's Date (according to this Web server) is <br>
<?php
echo( date("d/m/y") );
?>
</body>
</html>
Use your favorite web page editor such as Dreamweaver , or Notepad, or PHPDev
(phpdev.org), or Eclipse for PHP (easyeclipse.org). From my own experience,
FrontPage doesn’t support server side scripts very good. If you need to do PHP
development under Visual Studio, there is a PHP plugin you can download from .
Save the file inside the webroot of your web server as test.php. In this case, we
are using the XAMPP compilation. So by default the webroot is in
c:/Program Files/Xampp/htdocs
Output:
Go to your favorite web browser and type the address of your localhost plus the filename in
the address box. It would be;
http://localhost/test.php
Web Application Dev using PHP & MySQL - All rights reserved (2016) KERUL.net Chapter 1:6
Chapter 1: PHP Intro
References :
Sebesta, Robert W. 2003. Programming the World Wide Web. Pearson Education,
Inc.
http://wikipedia.org
http://apachefriends.org
http://dhost.info/kerul/webdev/
Web Application Dev using PHP & MySQL - All rights reserved (2016) KERUL.net Chapter 1:7