2. IntroductionIntroduction
Text Book/Reference MaterialsText Book/Reference Materials
ContentsContents
AssessmentAssessment
QuizQuiz 10%10%
Ass/PRAss/PR 20%20%
Mid Quarter ExamMid Quarter Exam 30%30%
Final ExamFinal Exam 40%40%
Rules of the classRules of the class
Mobiles on “Silent” please MSCMobiles on “Silent” please MSC – CSE, Lecturer: Engr. Ayub– CSE, Lecturer: Engr. Ayub
HusseinHussein
““No class within class” pleaseNo class within class” please
3. Introduction to PHP
●
Today’s web user’s expect exciting pages that are
updated frequently and provide a customized
experience for them.
●
Web sites are more like communities to which
they will return time and again.
4. Cont.
At the same time, website administrators want sites that are
easier to update , maintain and understanding , that is the only
real way to keep up with visitor’s expectations.
For these reasons and more, PHP and MYSQL have become
the fact standards for creating dynamic, database-driven
websites.
5. PHP History
●
1994: Created by Rasmis Lesdorf, software engineer (part
of Apache Team)
●
1995: Called Personal Home Page Tool, then released as
version 2 with name PHP/FI (Form Interpreter, to analyze
SQL queries)
●
Half 1997: used by 50,000 web sites
●
October 1998: used by 100,000 websites
●
End 1999: used by 1,000,000 websites
6. Alternatives to PHP
●
Practical extraction and Report Language (Perl)
●
Active Server Pages (ASP)
●
Java server pages (JSP)
●
Ruby
7. (Good) Topics about PHP
●
Open-source
●
Easy to use ( C-like and Perl-like syntax)
●
Stable and fast
●
Multiplatform
●
Many databases support
●
Many common built-in libraries
●
Pre-installed in Linux distributions
8. MySQL
●
MySQL is the world’s most popular open-
source database.
●
MySQL is a database management system
(DBMS) for relational databases, therefor
MySQL is an RDBMS.
9. Cont.’
●
A database , in the simplest terms is a
collection of interrelated data, be it text,
numbers or binary files that are stored and
kept organized by the DBMS.
●
MySQL is an open-source application like
PHP, meaning that it is free to use or even
modify.
10. Cont.’
●
MySQL software consist of several pieces,
including the MySQL server (mysqld which runs
& manges the databases ), the MySQL
client( mysql, which gives you an interface to the
serves ) and numerous utilities for
maintenance and other purposes.
●
MySQL can handle databases as large as
60,000 tables with more than five billions
rows.
11. What you’ll need
1. Web server applications ( e.g. apacha, Abyes or IIS)
2. PHP
3. MySQL
4. A web browser ( e.g. Microsoft’s Internet Explorer and
Mozilla’s Firefox )
5. A text editor, PHP-capable such as Adob’s
Dreamweaver qualifies or IDE
6. An FTP application, if using a remote server.
12. How PHP generates
HTML/JS Web pages
1: Client from browser send HTTP request (with POST/GET
variables)
2: Apache recognizes that a PHP script is requested and sends the
request to PHP module
3: PHP interpreter executes PHP script, collects script output and
sends it back
4: Apache replies to client using the PHP script output as HTML
output
2
Client
Browser
1 PHP
module3
4
Apache
13. Hello World! (web oriented)
<html>
<head>
<title>My personal Hello World! PHP script</title>
</head>
<body>
<?
echo “Hello World!”;
?>
</html>
PHP tag, allow to insert PHP
code. Interpretation by PHP
module will substitute the code
with code output
14. Sending data to the web bowser
●
To create dynamic websites with PHP, you must know
how to send data to the web browser.
●
PHP has a number of built-in functions for this purpose,
the most common being echo( ) and print ()
●
e.g: echo ‘ Hello world ‘ ;
●
All PHP statement must end with semicolon.
●
PHP is case-insensitive when it comes to function names,
so Echo ( ), echo ( ), eCHo ( ) will all work.
15. Writing Comments
●
PHP supports three comments types.
●
The first uses the Pound or number symbol ( # ).
●
e.g. # this is a comment
●
The second uses two slashes.
●
e.g. // this is also comment
●
Both of these cause PHP to ignore everything that
follows untill the end of line, thus these two
comments are for single lines only.
16. Cont.
A third style allows comments to run over multiple lines.
e.g. /* this is a larger comments that spans too lines of comments. */
17. ●
Variables are containers used to temporarily store
values, these values can be numbers , text or
much more complex data.
●
PHP has eight types of variables.
●
These include four scalar (single –valued) types
Bolean ( true or false), integer, floating point
(decimals ) and strings (characters ); two
nonscalar ( multi-valued) array and object, plus
resource (DB) and null (no value).
What are variables?
18. Rules of variable
●
Regardless of what type you are creating, all
variables in PHP follow certain syntactical rules.
1. A variable’s name also called its identifier must
start with a dollar sign ($) . E.g. $name
2. The variable’s name can contain a combination of
strings, numbers and the underscore. E.g. $My-
report1.
3. The first character after dollar sign must be a letter
or an underscore ( not be in a number).
19. Cont.
●
4. Variable names in PHP are case –sensitive.
●
This is very important rule. It means that $name
and $Name are entirely different variables.
●
Note: before getting into a script, there are two
more things you should know, first , variables can
be assigned values using the equal sing ( = ) also
called the assignment operator.
●
Second , variables can be printed with out
quotation mark. E.g.: print $some_var;
20. Cont.
●
# variables must be printed within double
quotation mark.
●
e.g. : print “ Hello, $name “;
●
# You can not print variables within single
quotation marks.
●
e.g. : print ‘ Hello, $name ‘ ; // won’t work.