You are on page 1of 15

COLLEGE OF COMPUTING AND INFORMATICS

DEPARTMENT OF INFORMATION TECHNOLOGY

Course title: Advanced Internet Programming


Course Code: ITec 3092

Individual Assignment
Name: Zintalem Mezgebu
ID No. WU 0143/10

Submitted to: Ins. Tarekegn D.


Submission Date: November 21/2020
Assosa, Ethiopia

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).

3. Server-side Scripting Vs Client-side Scripting

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

Definition of Server-side Scripting


Server-side scripting is a technique of programming for producing the code
which can run software on the server side, in simple words any scripting or
programming that can run on the web server is known as server-side scripting.
The operations like customization of a website, dynamic change in the website
content, response generation to the user’s queries, accessing the database,
and so on are performed at the server end.
The server-side scripting constructs a communication link between a server
and a client (user). Earlier the server side scripting is implemented by the CGI
(Common Gateway Interface) scripts. The CGI was devised to execute the
scripts from programming languages such as C++ or Perl on the websites.
The server-side involves three parts: server, database, API’s and back-end
web software developed by the server-side scripting language. When a
browser sends a request to the server for a webpage consisting of server-side
scripting, the web server processes the script prior to serving the page to the
browser. Here the processing of a script could include extracting information
from a database, making simple calculations, or choosing the appropriate
content that is to be displayed in the client end. The script is being processed
and the output is sent to the browser. The web server abstracts the scripts
from the end user until serving the content, which makes the data and source
code more secure.
Server-side scripting languages:
After the advent of CGI, multiple programming languages were evolved such
as PHP, Python, Ruby, ColdFusion, C#, Java, C++ and so on for server-side
scripting among which some of them are described below:
4
PHP: It is the most prevalent server-side language used on the web which
was designed to extract and manipulate information in the database. The
language is used in association with SQL language for the Database. It is used
in Facebook, WordPress and Wikipedia.
Python: The language is fast and contains shorter code. It is good for
beginners as it concentrates on the readability and simplicity of the code.
Python functions well in the object-oriented environment and used in famous
sites like Youtube, Google, etc.
Ruby: It contains complex logic which packages the back-end with database
utility which can also be provided by PHP and SQL.
Definition of Client-side Scripting
Client-side scripting is performed to generate a code that can run on the
client end (browser) without needing the server side processing. Basically,
these types of scripts are placed inside an HTML document. The client-side
scripting can be used to examine the user’s form for the errors before
submitting it and for changing the content according to the user input. As I
mentioned before, the web requires three elements for its functioning which
are, client, database and server.
The effective client-side scripting can significantly reduce the server load. It
is designed to run as a scripting language utilizing a web browser as a host
program. For example, when a user makes a request via browser for a
webpage to the server, it just sent the HTML and CSS as plain text, and the
browser interprets and renders the web content in the client end.
Client-side scripting languages:
HTML: It is the fundamental building blocks of web programming which
provides the frame to the website. It describes the arrangement of the
content.
CSS: CSS provides the way to design the graphic elements which help in
making the appearance of the web application more attractive.
JavaScript: It is also a client-side scripting language which essentially
devised for the specific purpose, but currently there are various JavaScript
frameworks used as server-side scripting technology.
Key Differences Between Server-side Scripting and Client-side Scripting
4. Server-side scripting is used at the backend, where the source code is
not viewable or hidden at the client side (browser). On the other hand,
client-side scripting is used at the front end which users can see from
the browser.

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.

Basic PHP Syntax


A PHP file usually consists of HTML tags and PHP script, and its default file
extension is .php. You can put PHP script anywhere in the document, as long
as you surround it with <?php and ?>:

<?php
// Here is PHP code
?>

This is a simple PHP example with echo statement:


Example Copy

<!DOCTYPE html>

<html>

6
<head>

<style>

</style>

</head>

<body> <h1>My first PHP web page</h1> <?php echo "Hello Drago!"; ?>
<script></script> </body> </html>

5. PHP Data Types


Variables can store data of different types, and different data types can do different
things.

PHP supports the following data types:

• 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.

Rules for integers:

• An integer must have at least one digit


• An integer must not have a decimal point
• An integer can be either positive or negative
• Integers can be specified in: decimal (base 10), hexadecimal (base 16), octal
(base 8), or binary (base 2) notation

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.

A class is a template for objects, and an object is an instance of a class.

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 . "!";
}
}

$myCar = new Car("black", "Volvo");


echo $myCar -> message();
echo "<br>";
$myCar = new Car("red", "Toyota");
echo $myCar -> message();
?>

PHP NULL Value


Null is a special data type which can have only one value: NULL.

A variable of data type NULL is a variable that has no value assigned to it.

Tip: If a variable is created without a value, it is automatically assigned a value of


NULL.

Variables can also be emptied by setting the value to NULL:

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.

A common example of using the resource data type is a database call.


6.

Variables are "containers" for storing information.

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.

Think of variables as containers for storing data.

PHP Variables
A variable can have a short name (like x and y) or a more descriptive name (age,
carname, total_volume).

Rules for PHP variables:

• 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)

Remember that PHP variable names are case-sensitive!

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 . "!";
?>

The following example will output the sum of two variables:

Example
<?php
$x = 5;
$y = 4;
echo $x + $y;
?>

PHP is a Loosely Typed Language


In the example above, notice that we did not have to tell PHP which data type the
variable is.

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.

• // (C++ style single line comment)


• # (Unix Shell style single line comment)

<?php

// this is C++ style single line comment

# this is Unix Shell style single line comment

echo "Welcome to PHP single line comments";

?>

Output:

Welcome to PHP single line comments

PHP Multi Line Comments


In PHP, we can comments multiple lines also. To do so, we need to enclose all lines within /* */.
Let's see a simple example of PHP multiple line comment.

<?php

/*

Anything placed

within comment

will not be displayed

on the browser;

*/

echo "Welcome to PHP multi line comment";

?>

Output:

Welcome to PHP multi line comment

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.

Comments can be used to:

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

PHP supports several ways of commenting:

Example
Syntax for single-line comments:
<!DOCTYPE html>
<html>
<body>

<?php
// This is a single-line comment

# This is also 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

You might also like