Web Engineering (Lecture 08) WAMP By: Mr. Sadiq Shah Lecturer (CS) Class BS(IT)-6 th semester
WAMP WAMP is all-in-one Apache/MySQL/PHP package WAMP stands for: i) Windows ii) iii) iv) Apache MySql PHP Wamp contains Apache: wampapache PHP MySQL database: Wampmysql
Server-side scripting-1 Server-side scripting is usually used to provide interactive web sites that interface to databases or other data stores. This is different from client-side scripting where scripts are run by the web browser. From a security point of view, server-side scripts are never visible to the browser as these scripts are executed on the web server.
Server-side scripting-2 Server-side scripting are used to create dynamic web pages. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP. PHP is a widely-used, open source scripting language Web server is needed to run server side scripts. Example of web servers are i.e Apache, IIS etc.
PHP Introduction PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language PHP scripts are executed on the server PHP supports many databases (MySQL, Oracle etc.) PHP is an open source software
PHP Introduction 2 PHP files can contain text, HTML tags and scripts PHP files are returned to the browser as plain HTML PHP files have a file extension of ".php", ".php3", or ".phtml PHP is free to download and use
How to install PHP install a web server install PHP install a database, such as MySQL WAMP is alternative to all the above
3-tier Architecture 3-tier Architecture Client Web server Database
PHP Advantages PHP runs on different platforms (Windows, Linux, Unix, etc.) PHP is compatible with almost all servers used today (Apache, IIS, etc.) PHP is easy to learn and runs efficiently on the server side PHP is open source
PHP Syntax A PHP scripting block starts with <?php and ends with?> For shorthand support you can start a scripting block with <? and end with?>. It is recommend to use the standard form (<?php and?>) rather than the shorthand form. A PHP scripting block can be placed anywhere in the document.
PHP Example <html> <body> <?php echo My First Program"; print BSIT-6 ;?> </body> </html>
PHP Echo statement In PHP there are two basic ways to get output: echo and print. The echo statement can be used with or without parentheses: echo or echo(). <?php echo "<h1>php is Fun!</h1>"; echo "Hello world!<br>"; echo "This ", "string ", "was ", "made ", "with multiple parameters.";?>
PHP print statement The print statement can be used with or without parentheses: print or print(). <?php print "<h2>php is Fun!</h2>"; print "Hello world!<br>"; print "I'm about to learn PHP!";?>
Variables in PHP Variables are used for storing values, like text strings, numbers or arrays. When a variable is declared, it can be used over and over again in your script. All variables in PHP start with a $ sign symbol. Example $name = value;
Naming Rules for Variables A variable name must start with a letter or an underscore "_" A variable name can only contain alphanumeric characters and underscores (a-z, A-Z, 0-9, and _ ) A variable name should not contain spaces. A variable name should not start with a number
Variables in PHP Example <?php $txt= Agriculture University"; $value=16;?> $result=true; PHP Variable
PHP is a Loosely Typed Language In PHP, it is not needed to tell PHP which data type the variable is. PHP automatically converts the variable to the correct data type, depending on its value.e.g. $name= yahoo ; $value=8; In PHP, the variable is declared automatically when you use it
Strongly typed programming language In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it. Java, C, C++ are strongly typed languages. For example in C language to declare an integer variable we write int value;
End lecture 08