Browsing articles from "November, 2008"
Nov 28, 2008

php

introduction
php is a scripting language originally designed for producing dynamic web pages. it has evolved to include a command line interface capability and can be used in standalone graphical applications.

while php was originally created by rasmus lerdorf in 1995, the main implementation of php is now produced by the php group and serves as the de facto standard for php as there is no formal specification. php is free software released under the php license, however it is incompatible with the glp due to restrictions on the usage of the term php.

php is a widely-used general-purpose scripting language that is especially suited for web development and can be embedded into html. it generally runs on a web server, taking php code as its input and creating web pages as output. it can be deployed on most web servers and on almost every operating system and platform free of charge. php is installed on more than 20 million websites and 1 million web servers. the most recent major release of php was version 5.2.6 on May 1, 2008.

history
php originally stood for personal home page. it began in 1994 as a set of common gateway interface binaries written in the c programming language by the danish/greenlandic programmer rasmus lerdorf. lerdorf initially created these personal home page tools to replace a small set of perl scripts he had been using to maintain his personal homepage. the tools were used to perform tasks such as displaying his resume and recording how much traffic his page was receiving. he combined these binaries with his form interpreter to create php/fi, which had more functionality. php/fi included a larger implementation for the c programming language and could communicate with databases, enabling the building of simple, dynamic web applications. lerdorf released php publicly on june 8, 1995 to accelerate bug location and improve the code. this release was named php version 2 and already had the basic functionality that php has today. this included perl-like variables, form handling, and the ability to embed html. the syntax was similar to Perl but was more limited, simpler, and less consistent.

zeev suraski and andi gutmans, two israeli developers at the technion iit, rewrote the parser in 1997 and formed the base of php 3, changing the language’s name to the recursive initialism php: hypertext preprocessor. the development team officially released php/fi 2 in n1997 after months of beta testing. afterwards, public testing of php 3 began, and the official launch came in june 1998. suraski and gutmans then started a new rewrite of php’s core, producing the zend engine in 1999. they also founded zend technologies in ramat gan, israel.

on may 22, 2000, php 4, powered by the zend engine 1.0, was released. on July 13, 2004, php 5 was released, powered by the new zend engine II. php 5 included new features such as improved support for object-oriented programming, the php data objects extension (which defines a lightweight and consistent interface for accessing databases), and numerous performance enhancements. the most recent update released by the php group is for the older php version 4 code branch. as of august, 2008 this branch is up to version 4.4.9. php 4 is no longer under development nor will any security updates be released.

in 2008, php 5 became the only stable version under development. late static binding has been missing from php and will be added in version 5.3. php 6 is under development alongside php 5. major changes include the removal of register_globals, magic quotes, and safe mode.

php does not have complete native support for unicode or multibyte strings; unicode support will be included in php 6. many high profile open source projects ceased to support php 4 in new code as of february 5, 2008, due to the gophp5 initiative, provided by a consortium of php developers promoting the transition from php 4 to php 5.

it runs in both 32-bit and 64-bit environments, but on windows the only official distribution is 32-bit, requiring windows 32-bit compatibility mode to be enabled while using iis in a 64-bit windows environment. there is a third-party distribution available for 64-bit windows.

usage
php is a general-purpose scripting language that is especially suited for web development. php generally runs on a web server, taking php code as its input and creating web pages as output. it can also be used for command-line scripting and client-side gui applications. php can be deployed on most web servers, many operating systems and platforms, and can be used with many relational database management systems. it is available free of charge, and the php group provides the complete source code for users to build, customize and extend for their own use.

php primarily acts as a filter, taking input from a file or stream containing text and/or php instructions and outputs another stream of data; most commonly the output will be html. it can automatically detect the language of the user. from php 4, the php parser compiles input to produce bytecode for processing by the zend engine, giving improved performance over its interpreter predecessor.

originally designed to create dynamic web pages, php’s principal focus is server-side scripting, and it is similar to other server-side scripting languages that provide dynamic content from a web server to a client, such as mcrosoft’s asp.net system, sun microsystems’ jsp, and mod_perl. php has also attracted the development of many frameworks that provide building blocks and a design structure to promote rapid application development (rad). some of these include cakephp, prado, symfony and zend framework, offering features similar to other web application frameworks.

the lamp architecture has become popular in the web industry as a way of deploying web applications. php is commonly used as the ‘p’ in this bundle alongside linux, apache and mysql, although the ‘p’ may also refer to python or perl.

as of april 2007, over 20 million internet domains were hosted on servers with php installed, and php was recorded as the most popular apache module. significant websites are written in php including the user-facing portion of facebook, wikipedia (mediawiki), yahoo!, myyearbook, and tagged.

Nov 26, 2008

gnu general public license

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Continue reading »

Nov 26, 2008

what is ‘open source’

introduction
open source doesn’t just mean access to the source code. the distribution terms of open-source software must comply with the following criteria:
Continue reading »

Nov 18, 2008

traversing the XML DOM

in one of my earlier posts about the i discussed how to bring in data via using the . i mentioned two ways of retrieving the information from an external file. the first was responseText and the other was responseXML. in this article i will demonstrate how to use the responseXML to retrieve information from an external xml file using the xml dom. (for this example lets assume you are using the xml example from the post, and that you have already returned the xml dom object and stored it in xmlDoc)

to get the information out of this file we will need to use getElementsByTagName. this will return an array containing all dom object that match the tag we reference:

var user = getElementsByTagName("user");

in the example we had 2 user elements. so the variable user now contains both those elements. now lets create a loop so we can cycle through all the elements a pull out whatever we need.

for (var i = 0; i < user.length; i++) {
}

now within the loop we need to add whatever code we want to retrieve the information we desire. lets say we want to grab the name and age tags. since these are childNodes of the user tag, we will add a second loop to cycle through all childNodes of the current user iteration.

	var child = user[i].childNodes;
	for (var j = 0; j < child.length; j++) {
	}

so now we are looping through every user element, and for each one we are then looping through all its childNodes. Now we can pull out the information withing the childNodes and display that information on the screen:

		document.write(child[j].firstChild.nodeValue);

the firstChild represents the text stored withing the element’s tags, however it doesn’t represent the value of the text, just the textNode itself. nodeValue represents the actual value of the textNode. so in plain english, that line of code is retrieving the child element, then getting the text node out of the element, retrieving the value of that text, and displaying it. if we put the whole code together it looks like this:

var user = getElementsByTagName("user");
for (var i = 0; i < user.length; i++) {
	var child = user[i].childNodes;
	for (var j = 0; j < child.length; j++) {
		document.write(child[j].firstChild.nodeValue);
	}
}

and will out put:

John Doe25Jane Smith28

with a little added formatting, or perhaps the use of some to create new elements, the text can be formatted and displayed in a slightly more appealing manor, but you get the point.

Uncategorized
Nov 18, 2008

xml syntax

intro
xml has rapidly become one of the most popular languages on the web. xml stands for eXtensible Markup Language. it was designed to transport and store data. it allows you to create your own tags, add any number of attributes to those tags as well as assign the tag a value. it is extremely useful for dynamic websites where information needs to be stored and updated externally and then delivered to a web page when called on. so lets just jump right into it shall we…
Continue reading »