Category Archives: General

Coding Standards

  • Indenting and Line Length
  • Control Structures
  • Function Calls
  • Class Definitions
  • Function Definitions
  • Arrays
  • Comments
  • Including Code
  • PHP Code Tags
  • Header Comment Blocks
  • Using SVN
  • Example URLs
  • Naming Conventions
  • File Formats
  • E_STRICT-compatible code
  • Error Handling Guidelines
  • Best practices
  • Sample File (including Docblock Comment standards)
  • The PEAR toolbox
  • Split function definitions onto several lines
  • Split function call on several lines
  • Split long assigments onto several lines
  • Split long if statements onto several lines
  • Ternary operators
  • Alignment of function parameters
  • Alignment of assignments
  • Array formatting
  • Recommendations
  • Notes

Chain-Of-Command Pattern

Building on the loose-coupling theme, the chain-of-command pattern routes a message, command, request, or whatever you like through a set of handlers. Each handler decides for itself whether it can handle the request. If it can, the request is handled, and the process stops. You can add or remove handlers from the system without influencing other handlers

EAV Model

EAV(Entity–attribute–value) is data model that is used in circumstances where the number of attributes  that can be used to describe a thing  is potentially very vast, but the number that will actually apply to a given entity is relatively modest

In an EAV data model, each attribute-value pair is a fact describing an entity, and a row in an EAV table stores a single fact. EAV tables are often described as “long and skinny”: “long” refers to the number of rows, “skinny” to the few columns.

Data is recorded as three columns:

The entity: the item being described.

The attribute or parameter: a foreign key into a table of attribute definitions. At the very least, the attribute definitions table would contain the following columns: an attribute ID, attribute name, description, data type, and columns assisting input validation, e.g., maximum string length and regular expression, set of permissible values, etc.

The value of the attribute.


jQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML. It was released in January 2006 at BarCamp NYC by John Resig. Used by over 55% of the 10,000 most visited websites, jQuery is the most popular JavaScript library in use today .

jQuery is free, open source software, dual-licensed under the MIT License or the GNU General Public License, Version 2. jQuery’s syntax is designed to make it easier to navigate a document, select DOM elements, create animations, handle events, and develop Ajax applications. jQuery also provides capabilities for developers to create plug-ins on top of the JavaScript library. This enables developers to create abstractions for low-level interaction and animation, advanced effects and high-level, theme-able widgets. The modular approach to the jQuery library allows the creation of powerful dynamic web pages and web applications.


The model–view–controller framework separates the representation of information in a computer program from the user’s interaction with it. The model consists of application data and business rules, and the controller mediates input, converting it to commands for the model or view. A view can be any output representation of data, such as a chart or a diagram. Multiple views of the same data are possible, such as a pie chart for management and a tabular view for accountants


Piggybacking on Internet access is the practice of establishing a wireless Internet connection by using another subscriber’s wireless Internet access service without the subscriber’s explicit permission or knowledge. It is a legally and ethically controversial practice, with laws that vary by jurisdiction around the world. While completely outlawed or regulated in some places, it is permitted in others.

A customer of a business providing hotspot service, such as a hotel or café, is generally not considered to be piggybacking, though non-customers or those outside the premises who are simply in reach may be. Many such locations provide wireless Internet access as a free or paid-for courtesy to their patrons or simply to draw people to the area. Others near the premises may be able to gain access.

The process of sending data along with the acknowledgment is called piggybacking. Piggybacking is distinct from wardriving, which involves only the logging or mapping of the existence of access points.


Short for relational database management system and pronounced as separate letters, a type of database management system (DBMS) that stores data in the form of related tables. Relational databases are powerful because they require few assumptions about how data is related or how it will be extracted from the database. As a result, the same database can be viewed in many different ways.
An important feature of relational systems is that a single database can be spread across several tables. This differs from flat-file databases, in which each database is self-contained in a single table.
Almost all full-scale database systems are RDBMS’s. Small database systems, however, use other designs that provide less flexibility in posing queries.


A database management system (DBMS) is a software package with computer programs that control the creation, maintenance, and use of a database. It allows organizations to conveniently develop databases for various applications by database administrators (DBAs) and other specialists. A database is an integrated collection of data records, files, and other objects. A DBMS allows different user application programs to concurrently access the same database. DBMSs may use a variety of database models, such as the relational model or object model, to conveniently describe and support applications.

It typically supports query languages, which are in fact high-level programming languages, dedicated database languages that considerably simplify writing database application programs. Database languages also simplify the database organization as well as retrieving and presenting information from it. A DBMS provides facilities for controlling data access, enforcing data integrity, managing concurrency control, and recovering the database after failures and restoring it from backup files, as well as maintaining database security.


A database is an organized collection of data, today typically in digital form. The data are typically organized to model relevant aspects of reality (for example, the availability of rooms in hotels), in a way that supports processes requiring this information (for example, finding a hotel with vacancies).

The term database is correctly applied to the data and their supporting data structures, and not to the database management system (DBMS). The database data collection with DBMS is called a database system.

Well known DBMSs include Oracle, IBM DB2, Microsoft SQL Server, Microsoft Access, PostgreSQL, MySQL, and SQLite. A database is not generally portable across different DBMS, but different DBMSs can inter-operate to some degree by using standards like SQL and ODBC together to support a single application.

Regular expression

• It describes a pattern

• PCRE (PERL Compatible RegularExpression)

• Delimiter

o usually “/”, “#”, or “!”
o used at beginning and end of each pattern

• Literals are any characters

• Boundaries (examples)

^ start of a line

$ end of a line

\A start of a string

\Z end of a string

• Character classes delimited with [ ]

o built-in character classes; capitalization indicates absence (example)

\d digit

\D no digit

• “greediness”

o maximum match is returned

o usually need to use parentheses with alternatives

• Quantifiers (examples)

* any number of times

+ any number of times, but at least once

? 0 or 1 combination of ? with * or + makes non-greedy

• Pattern matching

o use the preg_match(pattern, string) function

o returns number of matches

o optional third param defines match

o preg_match_all() returns all matches o returns all matches in an array

• Replacing

preg_replace(search pattern, replace pattern, string)

In computing, a regular expression provides a concise and flexible means to “match” (specify and recognize) strings of text, such as particular characters, words, or patterns of characters.PHP has three sets of functions that allow you to work with regular expressions.

The most important set of regex functions start with preg. These functions are a PHP wrapper around the PCRE library (Perl-Compatible Regular Expressions). Anything said about the PCRE regex flavor in the regular expression tutorial on this website applies to PHP’s preg functions. You should use the preg functions for all new PHP code that uses regular expressions. PHP includes PCRE by default as of PHP 4.2.0 (April 2002).

The oldest set of regex functions are those that start with ereg. They implement POSIX Extended Regular Expressions, like the traditional UNIX egrep command. These functions are mainly for backward compatibility with PHP 3, and officially deprecated as of PHP 5.3.0. Many of the more modern regex features such as lazy quantifiers, lookaround and Unicode are not supported by the ereg functions. Don’t let the “extended” moniker fool you. The POSIX standard was defined in 1986, and regular expressions have come a long way since then.

The last set is a variant of the ereg set, prefixing mb_ for “multibyte” to the function names. While ereg treats the regex and subject string as a series of 8-bit characters, mb_ereg can work with multi-byte characters from various code pages. If you want your regex to treat Far East characters as individual characters, you’ll either need to use the mb_ereg functions, or the preg functions with the /u modifier. mb_ereg is available in PHP 4.2.0 and later. It uses the same POSIX ERE flavor.