Wednesday, July 9, 2008

About Phing

what is phing?

Phing is at heart a PHP clone of Ant, another common build and deployment tool.

Phing is a project build system based on Apache ant [ant]. You can do anything with Phing that you could do with a traditional build system like Gnu make [gnumake], and Phing's use of simple XML build files and extensible PHP "task" classes make it an easy-to-use and highly flexible build framework.


How it works?

Phing uses XML buildfiles that contain a description of the things to do. The buildfile is structured into targets that contain the actual commands to perform (e.g. commands to copy a file, delete a directory, perform a DB query, etc.). So, to use Phing, you would first write your buildfile and then you would run phing, specifying the target in your buildfile that you want to execute.

% phing -f mybuildfile.xml mytarget

By default Phing will look for a buildfile named build.xml (so you don't have to specify the buildfile name unless it is not build.xml) and if no target is specified Phing will try to execute the default target, as specified in the tag.


You can install Phing as follows.

pear channel-discover pear.phing.info
pear install phing/phing


Calling Phing

Command Line

Phing execution on the command line is simple. Just change to the directory where your buildfile resides and type

$ phing [targetname]

at the command line (where [targetname] is the target you want to be executed)

Monday, March 31, 2008

What are the differences between procedure-oriented languages and object-oriented languages?

Traditional programming has the following characteristics:Functions are written sequentially, so that a change in programming can affect any code that follows it. If a function is used multiple times in a system (i.e., a piece of code that manages the date), it is often simply cut and pasted into each program (i.e., a change log, order function, fulfillment system, etc).If a date change is needed (i.e., Y2K when the code needed to be changed to handle four numerical digits instead of two), all these pieces of code must be found, modified, and tested. Code (sequences of computer instructions) and data (information on which the instructions operates on) are kept separate. Multiple sets of code can access and modify one set of data. One set of code may rely on data in multiple places. Multiple sets of code and data are required to work together. Changes made to any of the code sets and data sets can cause problems through out the system.Object-Oriented programming takes a radically different approach:Code and data are merged into one indivisible item – an object (the term “component” has also been used to describe an object.) An object is an abstraction of a set of real-world things (for example, an object may be created around “date”) The object would contain all information and functionality for that thing (A date object it may contain labels like January, February, Tuesday, Wednesday.

It may contain functionality that manages leap years, determines if it is a business day or a holiday, etc., See Fig. 1). Ideally, information about a particular thing should reside in only one place in a system. The information within an object is encapsulated (or hidden) from the rest of the system.

A system is composed of multiple objects (i.e., date function, reports,order processing, etc., See Fig 2). When one object needs information from another object, a request is sent asking for specific information.(for example, a report object may need to know what today’s date is and will send a request to the date object) These requests are called messages and each object has an interface that manages messages.

OO programming languages include features such as “class”, “instance”,“inheritance”, and “polymorphism” that increase the power and flexibility of an object.

What are the features and advantages of object-oriented programming?

One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system
because it appeals to natural human cognition patterns.For some systems, an OO approach can speed development time since many
objects are standard across systems and can be reused. Components thatmanage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system

Wednesday, January 16, 2008

XMLHttpRequest Properties

onreadystatechange
– Event handler that fires at each state change
– You implement your own function that handles this
readyState – current status of request
– 0 = uninitialized
– 1 = loading
– 2 = loaded
– 3 = interactive (some data has been returned)
• This is broken in IE right now
– 4 = complete
status
– HTTP Status returned from server: 200 = OK
responseText
– String version of data returned from server
responseXML
– XML DOM document of data returned
statusText
– Status text returned from server

Methods available in XMLHttpRequest Object

open(“method”, “URL”)
open(“method”, “URL”, async, username, password)
– Assigns destination URL, method, etc.
send(content)
– Sends request including postable string or DOM object data
abort()
– Terminates current request
getAllResponseHeaders()
– Returns headers (labels + values) as a string
getResponseHeader(“header”)
– Returns value of a given header
setRequestHeader(“label”,”value”)
– Sets Request Headers before sending

why is AJAX so hot—NOW?

• Demand for richer applications is growing
– Broadband means we can—and want to—do more
• It has a name
– Think LAMP—helped solidify the thoughts/techniques in people’s
minds
• Recent Google applications have sparked people’s imagination
– Google gmail, Google suggests, Google Maps
• People are thinking of building APPLICATIONS…not just sites
• The Tipping Point
– All of this has made rich internet apps reach its tipping point—
where adoption spreads rapidly and dramatically

Definition - AJAX

Asynchronous Javascript and XML

• AJAX is not a new technology
– Google calls their technique: Javascript
– Also known as XMLHTTP technique
– In use since at least 1997
• A bundle of techniques
– XML data interchange only
– Passing Javascript methods to client
– DHTML widgets
– XML & XSLTs
• Core techniques are centered on asynchronous communication to the server without a page refresh

Thursday, January 3, 2008

Difference between echo() and print()

speed:

echo() is faster than print(). Because print() behave like a function. So it set a return value. But echo() doesn't set a return value.

Parameter:

echo() can take multiple parameters. But print() can take only one parameter.