the php hypertext pre-processor (php) is a programming ... · php is basically used for developing...

33
PHP: The PHP Hypertext Pre-processor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. Introduction: PHP is a recursive acronym for "PHP: Hypertext Preprocessor". PHP is a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites. It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server. PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on the Unix side. The MySQL server, once started, executes even very complex queries with huge result sets in record-setting time. PHP supports a large number of major protocols such as POP3, IMAP, and LDAP. PHP4 added support for Java and distributed object architectures (COM and CORBA), making n-tier development a possibility for the first time. PHP is forgiving: PHP language tries to be as forgiving as possible. PHP Syntax is C-Like. Common uses of PHP: PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them. PHP can handle forms, i.e. gather data from files, save data to a file, thru email you can send data, return data to the user. You add, delete, modify elements within your database thru PHP. Access cookies variables and set cookies. Using PHP, you can restrict users to access some pages of your website. It can encrypt data. Characteristics of PHP Five important characteristics make PHP's practical nature possible: Simplicity Efficiency Security Flexibility Familiarity B.Tech 3rd year (CS) PHP Notes SHADAB IRFAN

Upload: others

Post on 19-Jul-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

PHP:

The PHP Hypertext Pre-processor (PHP) is a programming language that allows web

developers to create dynamic content that interacts with databases.

PHP is basically used for developing web based software applications.

Introduction:

PHP is a recursive acronym for "PHP: Hypertext Preprocessor".

PHP is a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.

It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.

PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on the Unix side. The MySQL server, once started, executes even very complex queries with huge result sets in record-setting time.

PHP supports a large number of major protocols such as POP3, IMAP, and LDAP. PHP4 added support for Java and distributed object architectures (COM and CORBA), making n-tier development a possibility for the first time.

PHP is forgiving: PHP language tries to be as forgiving as possible.

PHP Syntax is C-Like.

Common uses of PHP:

PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.

PHP can handle forms, i.e. gather data from files, save data to a file, thru email you can send data, return data to the user.

You add, delete, modify elements within your database thru PHP.

Access cookies variables and set cookies.

Using PHP, you can restrict users to access some pages of your website.

It can encrypt data.

Characteristics of PHP

Five important characteristics make PHP's practical nature possible:

Simplicity

Efficiency

Security

Flexibility

Familiarity

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 2: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Simple PHP Program :

<html> <head> <title>Hello World</title> <body> <?php echo "Hello, World!";?> </body> </html> It will produce following result: Hello, World!

Running PHP Script from Command Prompt:

<? php

Echo “Hello in PHP”; ?>

To run the file: $ php test.php

PHP Variable Types :

Example:

$x = 123;

$y= -123 + 321;

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 3: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

PHP Operator Types:

PHP Decision Making:

If-else Statement:

----------------------------------------------------------------

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 4: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

The ElseIf Statement:

The Switch Statement:

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 5: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

PHP Loop Types

The for Loop Statement

The While Loop Statement

The do… while Loop Statement

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 6: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Syntax:

Example:

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 7: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Example:

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 8: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Example:

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 9: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 10: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Example:

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 11: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 12: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 13: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 14: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 15: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Creating PHP Function:

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 16: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 17: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 18: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 19: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Using PHP With HTML Forms

Create a HTML form

Order.html code:

<html><body>

<h4>Tizag Art Supply Order Form</h4>

<form action="process.php" method="post">

<select name="item">

<option>Paint</option>

<option>Brushes</option>

<option>Erasers</option>

</select>

Quantity: <input name="quantity" type="text" />

<input type="submit" />

</form>

</body></html>

Create a”process.php” file which will process the HTML information:

We want to get the "item" and "quantity" inputs that we have specified in our HTML form. Using an associate array, we can get this information from the $_POST associative array. The proper way to get this information would be to create two new variables, $item and

$quantity and set them equal to the values that have been "posted". The name of this file is

"process.php".

<html><body>

<?php

$quantity = $_POST ['quantity'];

$item = $_POST ['item'];

echo "You ordered ". $quantity . " " . $item . ".<br />";

echo "Thank you for ordering from Tizag Art Supplies!";

?>

</body></html>

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 20: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

PHP- GET:

The alternative to the post method is get. If we were to change our HTML form to the get

method, it would look like this:

<form action="process.php" method="get">

<select name="item">

...

<input name="quantity" type="text" />

The get method is different in that it passes the variables along to the "process.php" web page by appending them onto the end of the URL. The URL, after clicking submit, would have this added on to the end of it:

"?item=##&quantity=##" The question mark "?" tells the browser that the following items are variables. Now that we

changed the method of sending information on "order.html", we must change the "process.php" code to use the "$_GET" associative array.

PHP Code Excerpt:

$quantity = $_GET['quantity'];

$item = $_GET['item'];

After changing the array name the script will function properly. Using the get method displays

the variable information to your visitor, so be sure you are not sending password information or

other sensitive items with the get method.

PHP - File Upload:

A very useful aspect of PHP is its ability to manage file uploads to your server.

Before you can use PHP to manage your uploads, you must first build an HTML form that lets

users select a file to upload. See our HTML Form lesson for a more in-depth look at forms.

<form enctype="multipart/form-data" action="uploader.php" method="POST">

<input type="hidden" name="MAX_FILE_SIZE" value="100000" />

Choose a file to upload: <input name="uploadedfile" type="file" /><br />

<input type="submit" value="Upload File" />

</form>

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 21: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

// Where the file is going to be placed

$target_path = "uploads/";

/* Add the original filename to our target path.

Result is "uploads/filename.extension" */

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

$_FILES['uploadedfile']['tmp_name'];

NOTE: You will need to create a new directory in the directory where uploader.php resides, called "uploads", as we are going to be saving files there. We now have all we need to successfully save our file to the server. $target_path contains the

path where we want to save our file to.

Now all we have to do is call the move_uploaded_file function.

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 22: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

echo "The file ". basename( $_FILES['uploadedfile']['name']).

" has been uploaded";

} else{

echo "There was an error uploading the file, please try again!";

}

If the upload is successful, then you will see the text "The file filename has been uploaded". This is because $move_uploaded_file returns true if the file was moved, and false if it had a problem. If there was a problem then the error message "There was an error uploading the file, please try

again!" would be displayed.

PHP Sessions – Overview

A PHP session allow you to store user information on the server for later use (i.e. username, shopping cart items, etc). However, this session information is temporary and is usually deleted very quickly after the user has left the website that uses sessions.

It is important to ponder if the sessions' temporary storage is applicable to your website. If you require a more permanent storage you will need to find another solution, like a MySQL database. Sessions work by creating a unique identification(UID) number for each visitor and storing

variables based on this ID. This helps to prevent two users' data from getting confused with one

another when visiting the same webpage.

Starting a PHP Session

Before you can begin storing user information in your PHP session, you must first start the session. When you start a session, it must be at the very beginning of your code, before any HTML or text is sent. Below is a simple script that you should place at the beginning of your PHP code to start up a

PHP session.

<?php

session_start(); // start up your PHP session!

?>

This tiny piece of code will register the user's session with the server, allow you to start saving

user information and assign a UID (unique identification number) for that user's session.

Storing a Session Variable:

When you want to store user data in a session use the $_SESSION associative array. This is

where you both store and retrieve session data.

<?php

session_start();

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 23: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

$_SESSION['views'] = 1; // store session data

echo "Pageviews = ". $_SESSION ['views']; //retrieve data

?>

Cleaning and Destroying your Session:

Although a session's data is temporary and does not require that you explicitly clean after yourself, you may wish to delete some data for your various tasks. Imagine that you were running an online business and a user used your website to buy your

goods. The user has just completed a transaction on your website and you now want to remove

everything from their shopping cart.

<?php

session_start();

if(isset($_SESSION['cart']))

unset($_SESSION['cart']);

?>

You can also completely destroy the session entirely by calling the session_destroy function.

<?php

session_start();

session_destroy();

?>

Databases and MySQL: MySQL: open-source database, relatively easy to set up, easy to use with PHP. MySQL database server can contain many databases, each of which can contain many tables

resource type. We use this variable to refer to the connection created .

mysql_query(query_string, db_resource);

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 24: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

ECT: returns a resource $result = mysql_query(query_string, $db); In this case, this resource is stored in the variable $result .

PHP mail() Function:

The mail() function allows you to send emails directly from a script.

Syntax

mail (to, subject ,message, headers, parameters);

Parameter Description

to Required. Specifies the receiver / receivers of the email

subject Required. Specifies the subject of the email. Note: This parameter cannot contain any newline characters.

message

Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters. Windows note: If a full stop is found on the beginning of a line in the message, it might be removed. To solve this problem, replace the full stop with a double dot: <?php $txt = str_replace("\n.", "\n..", $txt); ?>

headers

Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n). Note: When sending an email, it must contain a From header. This can be set with this parameter or in the php.ini file.

parameters Optional. Specifies an additional parameter to the sendmail program (the one defined in the sendmail_path configuration setting). (i.e. this can be used to set the envelope sender address when using sendmail with the -f sendmail option)

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 25: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Send a simple email:

<?php // the message $msg = "First line of text\nSecond line of text"; // use wordwrap() if lines are longer than 70 characters $msg = wordwrap($msg,70); // send email mail("[email protected]","My subject",$msg); ?>

Example 2

Send an email with extra headers:

<?php $to = "[email protected]"; $subject = "My subject"; $txt = "Hello world!"; $headers = "From: [email protected]" . "\r\n" . "CC: [email protected]"; mail($to, $subject, $txt, $headers); ?>

PHP Error Handling:

When creating scripts and web applications, error handling is an important part. If your code

lacks error checking code, your program may look very unprofessional and you may be open to

security risks.

Different error handling methods:

Simple "die()" statements

Custom errors and error triggers

Error reporting

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 26: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Basic Error Handling: Using the die() function

The first example shows a simple script that opens a text file:

<?php

$file=fopen("welcome.txt","r");

?>

If the file does not exist you might get an error like this:

Warning: fopen(welcome.txt) [function.fopen]: failed to open stream:

No such file or directory in C:\webfolder\test.php on line 2

To prevent the user from getting an error message like the one above, we test whether the file

exist before we try to access it:

<?php if(!file_exists("welcome.txt")) { die("File not found"); } else { $file=fopen("welcome.txt","r"); } ?>

Creating a Custom Error Handler:

Creating a custom error handler is quite simple. We simply create a special function that can be

called when an error occurs in PHP.

This function must be able to handle a minimum of two parameters (error level and error

message) but can accept up to five parameters (optionally: file, line-number, and the error

context):

Syntax:

error_function(error_level,error_message,

error_file,error_line,error_context)

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 27: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Parameter

Description

error_level Required. Specifies the error report level for the user-defined error. Must be a value number. See table below for possible error report levels

error_message Required. Specifies the error message for the user-defined error

error_file Optional. Specifies the filename in which the error occurred

error_line Optional. Specifies the line number in which the error occurred

error_context Optional. Specifies an array containing every variable, and their values, in use when the error occurred

What is an Exception:

Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception. This is what normally happens when an exception is triggered:

The current code state is saved The code execution will switch to a predefined (custom) exception handler function Depending on the situation, the handler may then resume the execution from the saved

code state, terminate the script execution or continue the script from a different location in the code

Basic Use of Exceptions

When an exception is thrown, the code following it will not be executed, and PHP will try to find the matching "catch" block.

If an exception is not caught, a fatal error will be issued with an "Uncaught Exception" message.

Lets try to throw an exception without catching it:

<?php

//create function with an exception

function checkNum($number) {

if($number>1) {

throw new Exception("Value must be 1 or below");

}

return true;

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 28: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

}

//trigger exception

checkNum(2);

?>

The code above will get an error like this:

Fatal error: Uncaught exception 'Exception'

with message 'Value must be 1 or below' in C:\webfolder\test.php:6

Stack trace: #0 C:\webfolder\test.php(12):

checkNum(28) #1 {main} thrown in C:\webfolder\test.php on line 6

Try, throw and catch

To avoid the error from the example above, we need to create the proper code to handle an exception.

Proper exception code should include:

1. Try - A function using an exception should be in a "try" block. If the exception does not trigger, the code will continue as normal. However if the exception triggers, an exception is "thrown"

2. Throw - This is how you trigger an exception. Each "throw" must have at least one "catch"

3. Catch - A "catch" block retrieves an exception and creates an object containing the exception information

Lets try to trigger an exception with valid code:

<?php

//create function with an exception

function checkNum($number) {

if($number>1) {

throw new Exception("Value must be 1 or below");

}

return true;

}

//trigger exception in a "try" block

try {

checkNum(2);

//If the exception is thrown, this text will not be shown

echo 'If you see this, the number is 1 or below';

}

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 29: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

//catch exception

catch(Exception $e) {

echo 'Message: ' .$e->getMessage();

}

?>

The code above will get an error like this:

Message: Value must be 1 or below

In the above code -The "catch" block retrieves the exception and creates an object ($e) containing the exception information. The error message from the exception is echoed by calling $e->getMessage() from the exception object.

PHP Filters:

Validating data = Determine if the data is in proper form.

Sanitizing data = Remove any illegal character from the data.

The PHP Filter Extension

PHP filters are used to validate and sanitize external input.

The PHP filter extension has many of the functions needed for checking user input, and is designed to make data validation easier and quicker.

The filter_list() function can be used to list what the PHP filter extension offers:

Example

<table>

<tr>

<td>Filter Name</td>

<td>Filter ID</td>

</tr>

<?php

foreach (filter_list() as $id =>$filter) {

echo '<tr><td>' . $filter . '</td><td>' . filter_id($filter) . '</td></tr>';

}

?>

</table>

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 30: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Why Use Filters?

Many web applications receive external input. External input/data can be:

User input from a form Cookies Web services data Server variables Database query results

ODBC:

Open DataBase Connectivity is an Application Programming Interface (API) that allows a

programmer to abstract a program from a database. When writing code to interact with a

database, you have to add code that talks to a particular database using a proprietary API.

When programming to interact with ODBC you only need to use the ODBC API (a combination

of ODBC extension function calls and the SQL language) to talk to different database products.

The ODBC Manager will figure out how to contend with the type of database you are targeting.

Regardless of the database type you are using, all of your calls will be to the ODBC API.

Creating A ODBC Data Source Name (DSN)

After you have ensured that the ODBC driver for your database is installed, you normally need

to create a Data Source Name (DSN), which contains all the connection details required to login

(accept maybe id and password).

Connecting to ODBC

<? # connect to a DSN "mydb" with a user and password "marin" $connect = odbc_connect("mydb", "marin", "marin");

# query the users table for name and surname

$query = "SELECT name, surname FROM users";

# perform the query

$result = odbc_exec($connect, $query);

# fetch the data from the database

while(odbc_fetch_row($result)){

$name = odbc_result($result, 1);

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 31: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

$surname = odbc_result($result, 2);

print("$name $surname\n");

}

# close the connection

odbc_close($connect); ?>

Component Object Model (COM):

COM is a binary-interface standard for software components introduced by Microsoft in

1993. It is used to enable inter-process communication and dynamic object creation in a large

range of programming languages. COM is the basis for several other Microsoft technologies and

frameworks, including OLE, OLE Automation, ActiveX, COM+, DCOM, the Windows

shell, DirectX, UMDF and Windows Runtime.

The essence of COM is a language-neutral way of implementing objects that can be used in environments different from the one in which they were created, even across machine boundaries. For well-authored components, COM allows reuse of objects with no knowledge of their internal implementation, as it forces component implementers to provide well-defined interfaces that are separated from the implementation. The different allocation semantics of languages are accommodated by making objects responsible for their own creation and destruction through reference-counting. Casting between different interfaces of an object is achieved through the QueryInterface method. The preferred method of inheritance within COM is the creation of sub-objects to which method calls are delegated.

COM is an interface technology defined and implemented as standard only on Microsoft Windows and Apple's Core Foundation 1.3 and later plug-in API, that in any case implement only a subset of the whole COM interface. For some applications, COM has been replaced at least to some extent by the Microsoft .NET framework, and support for Web Services through theWindows Communication Foundation (WCF). However, COM objects can be used with all .NET languages through .NET COM Interop. Networked DCOM uses binary proprietary formats, while WCF encourages the use of XML-based SOAP messaging. COM is very similar to other component software interface technologies, such as CORBA and Java Beans, although each has its own strengths and weaknesses.

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 32: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

Distributed Component Object Model (DCOM):

DCOM is a proprietary Microsoft technology for communication among software components distributed across networked computers. DCOM, which originally was called "Network OLE", extends Microsoft's COM, and provides the communication substrate under Microsoft's COM+ application server infrastructure.

The addition of the "D" to COM was due to extensive use of DCE/RPC (Distributed Computing Environment/Remote Procedure Calls) – more specifically Microsoft's enhanced version, known as MSRPC.

In terms of the extensions it added to COM, DCOM had to solve the problems of-

Marshalling – serializing and deserializing the arguments and return values of method calls "over the wire".

Distributed garbage collection – ensuring that references held by clients of interfaces are released when, for example, the client process crashed, or the network connection was lost.

It had to combine Hundreds/Tens of Thousands objects held in the client's browser with a single transmission in order to minimize bandwidth utilization.

One of the key factors in solving these problems is the use of DCE/RPC as the underlying RPC mechanism behind DCOM. DCE/RPC has strictly defined rules regarding marshalling and who is responsible for freeing memory.

DCOM was a major competitor to CORBA. Proponents of both of these technologies saw them as one day becoming the model for code and service-reuse over the Internet. However, the difficulties involved in getting either of these technologies to work over Internet firewalls, and on unknown and insecure machines, meant that normal HTTP requests in combination with web browsers won out over both of them. Microsoft, at one point, attempted and failed to head this off by adding an extra http transport to DCE/RPC called ncacn_http (Network Computing Architecture connection-oriented protocol). This was later resurrected to support a Microsoft Exchange 2003 connection over HTTP.

DCOM is supported natively in Windows NT 4.0, Windows 2000, Windows XP, and Windows Server 2003, as well as Windows 7, Windows 8, Windows 10, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2 and the Windows Server 2016 Technical Preview.

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN

Page 33: The PHP Hypertext Pre-processor (PHP) is a programming ... · PHP is basically used for developing web based software applications. Introduction: x PHP is a recursive acronym for

CORBA:

The Common Object Request Broker Architecture (CORBA) is a standard developed by the Object Management Group (OMG) to provide interoperability among distributed objects. CORBA is the world's leading middleware solution enabling the exchange of information, independent of hardware platforms, programming languages, and operating systems. CORBA is essentially a design specification for an Object Request Broker (ORB), where an ORB provides the mechanism required for distributed objects to communicate with one another, whether locally or on remote devices, written in different languages, or at different locations on a network.

The CORBA Interface Definition Language, or IDL, allows the development of language and location-independent interfaces to distributed objects. Using CORBA, application components can communicate with one another no matter where they are located, or who has designed them. CORBA provides the location transparency to be able to execute these applications.

CORBA is often described as a "software bus" because it is a software-based communications interface through which objects are located and accessed. The illustration below identifies the primary components seen within a CORBA implementation.

Data communication from client to server is accomplished through a well-defined object-

oriented interface. The Object Request Broker (ORB) determines the location of the target

object, sends a request to that object, and returns any response back to the caller. Through this

object-oriented technology, developers can take advantage of features such as inheritance,

encapsulation, polymorphism, and runtime dynamic binding. These features allow applications

to be changed, modified and re-used with minimal changes to the parent interface.

B.Tech 3rd year (CS) PHP Notes

SHADAB IRFAN