Professional Documents
Culture Documents
TG Assignment
TG Assignment
Individual Assignment
Name: Zintalem Mezgebu
ID No. WU 0143/10
1
1. Difference between Web Browser and Web Server.
Web Browser is a software which is used to browse and display pages available over
internet whereas web server is a software which provides these documents when
requested by web browsers.
Following are the important differences between Web Browser and Web Server.
Sr. No. Key Web Browser Web Server
1 Purpose Web Browser is a Web server is a
software which is software which
used to browse and provides these
display pages documents when
available over requested by web
internet. browsers.
2 Process A web browser Web server sees
sends request to and approves those
server for web requests made by
based documents web browsers and
and services. sends the
document in
response.
3 Process Web browser sends Web server
an HTTP Request receives HTTP
and gets a HTTP Request and sends
Response. a HTTP Response.
4 Processing Model Web browser has Web server follows
no processing three major
model. processing models:
process based,
thread based or
hybrid.
5 Data Storage Web browsers Web server provide
stores user data in an area to store the
cookies in local website.
machine.
6 Installation Web Browser is Web server can be
installed on user's installed any where
machine. but it need to be on
a network or on
local computer.
7 Example Google Chrome Apache Server
2
2. What is the difference between webpage, website, web server, and search engine?
web server
A computer that hosts a website on the Internet.
search engine
A web service that helps you find other web pages, such as Google, Bing, Yahoo, or
DuckDuckGo. Search engines are normally accessed through a web browser (e.g. you
can perform search engine searches directly in the address bar of Firefox, Chrome,
etc.) or through a web page (e.g. bing.com or duckduckgo.com).
The scripts can be written in two forms, at the server end (back end) or at
the client end (server end). The main difference between server-side
scripting and client-side scripting is that the server side scripting involves
server for its processing. On the other hand, client-side scripting requires
browsers to run the scripts on the client machine but does not interact with
the server while processing the client-side scripts.
A script is generally a series of program or instruction, which has to be
executed on other program or application. As we know that the web works in
a client-server environment. The client-side script executes the code to the
client side which is visible to the users while a server-side script is executed
in the server end which users cannot see.
Comparison Chart
BASIS FOR SERVER-SIDE CLIENT-SIDE
COMPARISON SCRIPTING SCRIPTING
3
Basic Works in the back end Works at the front end
which could not be and script are visible
visible at the client end. among the users.
Processing Requires server Does not need
interaction. interaction with the
server.
Languages involved PHP, ASP.net, Ruby on HTML, CSS, JavaScript,
Rails, ColdFusion, etc.
Python, etcetera.
Affect Could effectively Can reduce the load to
customize the web the server.
pages and provide
dynamic websites.
Security Relatively secure. Insecure
5
5. When a server-side script is processed it communicates to the server.
As against, client-side scripting does not need any server interaction.
6. The client-side scripting language involves languages such as HTML,
CSS and JavaScript. In contrast, programming languages such as PHP,
ASP.net, Ruby, ColdFusion, Python, C#, Java, C++, etc.
7. Server-side scripting is useful in customizing the web pages and
implement the dynamic changes in the websites. Conversely, the client-
side script can effectively minimize the load to the server.
8. Server-side scripting is more secure than client-side scripting as the
server side scripts are usually hidden from the client end, while a client-
side script is visible to the users.
4.
PHP Code:
• Every PHP script has to stay between between <?php and ?>.
• Every PHP statement must end with a semicolon (;).
• Only variables are case-sensitive: functions or keywords are not.
<?php
// Here is PHP code
?>
<!DOCTYPE html>
<html>
6
<head>
<style>
</style>
</head>
<body> <h1>My first PHP web page</h1> <?php echo "Hello Drago!"; ?>
<script></script> </body> </html>
• String
• Integer
• Float (floating point numbers - also called double)
• Boolean
• Array
• Object
• NULL
• Resource
PHP String
A string is a sequence of characters, like "Hello world!".
A string can be any text inside quotes. You can use single or double quotes:
Example
<?php
$x = "Hello world!";
$y = 'Hello world!';
echo $x;
echo "<br>";
echo $y;
?>
Try it Yourself »
7
PHP Integer
An integer data type is a non-decimal number between -2,147,483,648 and
2,147,483,647.
In the following example $x is an integer. The PHP var_dump() function returns the
data type and value:
Example
<?php
$x = 5985;
var_dump($x);
?>
PHP Float
A float (floating point number) is a number with a decimal point or a number in
exponential form.
In the following example $x is a float. The PHP var_dump() function returns the
data type and value:
Example
<?php
$x = 10.365;
var_dump($x);
?>
PHP Boolean
A Boolean represents two possible states: TRUE or FALSE.
$x = true;
$y = false;
Booleans are often used in conditional testing. You will learn more about conditional
testing in a later chapter of this tutorial.
8
PHP Array
An array stores multiple values in one single variable.
In the following example $cars is an array. The PHP var_dump() function returns
the data type and value:
Example
<?php
$cars = array("Volvo","BMW","Toyota");
var_dump($cars);
?>
Try it Yourself »
PHP Object
Classes and objects are the two main aspects of object-oriented programming.
When the individual objects are created, they inherit all the properties and
behaviors from the class, but each object will have different values for the
properties.
Let's assume we have a class named Car. A Car can have properties like model,
color, etc. We can define variables like $model, $color, and so on, to hold the
values of these properties.
When the individual objects (Volvo, BMW, Toyota, etc.) are created, they inherit all
the properties and behaviors from the class, but each object will have different
values for the properties.
If you create a __construct() function, PHP will automatically call this function when
you create an object from a class.
Example
<?php
class Car {
public $color;
public $model;
public function __construct($color, $model) {
$this->color = $color;
$this->model = $model;
9
}
public function message() {
return "My car is a " . $this->color . " " . $this->model . "!";
}
}
A variable of data type NULL is a variable that has no value assigned to it.
Example
<?php
$x = "Hello world!";
$x = null;
var_dump($x);
?>
PHP Resource
The special resource type is not an actual data type. It is the storing of a reference
to functions and resources external to PHP.
10
Creating (Declaring) PHP Variables
In PHP, a variable starts with the $ sign, followed by the name of the variable:
Example
<?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
After the execution of the statements above, the variable $txt will hold the value
Hello world!, the variable $x will hold the value 5, and the variable $y will hold the
value 10.5.
Note: When you assign a text value to a variable, put quotes around the value.
Note: Unlike other programming languages, PHP has no command for declaring a
variable. It is created the moment you first assign a value to it.
PHP Variables
A variable can have a short name (like x and y) or a more descriptive name (age,
carname, total_volume).
• A variable starts with the $ sign, followed by the name of the variable
• A variable name must start with a letter or the underscore character
• A variable name cannot start with a number
• A variable name can only contain alpha-numeric characters and underscores
(A-z, 0-9, and _ )
• Variable names are case-sensitive ($age and $AGE are two different variables)
Output Variables
The PHP echo statement is often used to output data to the screen.
The following example will show how to output text and a variable:
11
Example
<?php
$txt = "W3Schools.com";
echo "I love $txt!";
?>
The following example will produce the same output as the example above:
Example
<?php
$txt = "W3Schools.com";
echo "I love " . $txt . "!";
?>
Example
<?php
$x = 5;
$y = 4;
echo $x + $y;
?>
PHP automatically associates a data type to the variable, depending on its value.
Since the data types are not set in a strict sense, you can do things like adding a
string to an integer without causing an error.
In PHP 7, type declarations were added. This gives an option to specify the data
type expected when declaring a function, and by enabling the strict requirement, it
will throw a "Fatal Error" on a type mismatch.
7.
PHP Comments
PHP comments can be used to describe any line of code so that other developer can understand
the code easily. It can also be used to hide any code.
PHP supports single line and multi line comments. These comments are similar to C/C++ and
Perl style (Unix shell style) comments.
12
PHP Single Line Comments
There are two ways to use single line comments in PHP.
<?php
?>
Output:
<?php
/*
Anything placed
within comment
on the browser;
*/
?>
Output:
Comments in PHP
A comment in PHP code is a line that is not executed as a part of the program. Its
only purpose is to be read by someone who is looking at the code.
13
• Let others understand your code
• Remind yourself of what you did - Most programmers have experienced
coming back to their own work a year or two later and having to re-figure out
what they did. Comments can remind you of what you were thinking when
you wrote the code
Example
Syntax for single-line comments:
<!DOCTYPE html>
<html>
<body>
<?php
// This is a single-line comment
</body>
</html>
Try it Yourself »
Example
Syntax for multiple-line comments:
<!DOCTYPE html>
<html>
<body>
<?php
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
?>
</body>
</html>
Try it Yourself »
14
Example
Using comments to leave out parts of the code:
<!DOCTYPE html>
<html>
<body>
<?php
// You can also use comments to leave out parts of a code line
$x = 5 /* + 15 */ + 5;
echo $x;
?>
</body>
</html>
15