Search This Blog



Heredoc and Nowdoc

Heredoc and Nowdoc (also known as "here document" and "now document") are two alternative representation of strings in PHP (as double quotes and single quotes are).

This post presents these two language features and how to use them.


Language Constructions

PHP language, like any programming language, is composed by language constructions. Beyond the basic programming structures (conditional, loop, classes syntax, functions syntax, etc), the language has some built-in functions. They are functions compiled in the core language.


Care about Entity-Relationship Model

Entity-Relationship Model is the famous model of databases and their entities, properties and relationships.

At first, it looks a simple model if we concentrate in the reality. This is true, if the properties of each entity and the relationship between entities are realy consistent with truth at any condition. It is important to take care about the names used for each entity and the point in wich they can be broken into other entities to avoid duplicate data.

Although, there are details that I have saw recently: I think there is a natural trend for modelers to link some entities to entities that represent actors (people) instead of linking where they really would need to be linked (to preserve the referential integrity).


Foreach vs. For


Last year, at a PHP mailing list discussion, I was surprised with the information that the loop structure "for" was faster than "foreach". After, I receive the source of that information: The PHP Benchmark. The site's author said the "for" is faster for write operations, but is slower for reading traveled items. Taking a look at the source-code, I came to the conclusion it was wrong a little strange.


Error control

Error control is a strategy used to catch situations that blocks a sucessful result of an application operation. This can be viewed in diferent levels of an application. At low level: one function could receive a unespected parameter. At high level, a tool could not accept a specific set of actions from the user.



If you work with Web programming, you might have used character encoding. At begining, computers have used ASCII, that provides basic symbols of English language and some special computer control characters. It was done using 1 byte per character, that could provide 256 characters. In practice, there were only 128 characters, because the first bit was not used.

When other countries starts to use computer, they needed to work with their own language, but ASCII did not provide all language symbols. To resolve that, it was created table maps that associates a symbol with a specific byte. One common charset was ISO-8859-1, that provides Latin symbols. Although, was created many different charsets, incompatible between them and was hard to make programs that suports many languages (many charsets).

To solve this new problem, the Unicode was created. This article shows what unicode is, what are its benefits and how to work with it.


Scheduled Tasks

Information Systems often have tasks that should be done by schedule. This feature usually is needed because two reasons:

  1. because the task needs to be called at a specific moment;
  2. because the task is too long and it is impractible to take the user waiting while the task does not finish.