All posts by stoimen

jQuery – accessing a child element

Let’s assume you have a <div> element with 20 <a> tags inside, and each <a> tag has a <span> somewhere inside it. If you’d like to access all those spans you should use this jQuery line:

$('div a').children(':first-child')

Common mistake is to query like that:

$('div a:first-child')

but that is completely other thing, and will return the first <a> tag, not the <span> inside all of them.

Dependency Injection

Fabien Potencier writes about the Dependency Injection

With a series of interesting posts Fabien Potencier explains what is a dependency injection and how to use it. Actually as the author says almost everyone of us has used it without even know it’s called ‘dependency injection’. Follow these two links to understand this technique by a given collection of very good examples:

  1. What is dependency injection
  2. Do you need a dependency injection container?

Related Links

  1. Martin Fowler – Inversion of Control Containers and the Dependency Injection pattern

Lambda functions in PHP?

What’s new in PHP 5.3.

When I heart about the new PHP 5.3 feature – the lambda functions I was really surprised. Yes really after we have in JavaScript such a powerfull tool, why not having it in PHP. Other new feature, waited so much, are the namespaces.

Anonymous Functions?

The anonymous functions is really a functional programming language feature such as scheme. There are lots of talks about the functional nature of JavaScript, but PHP was really different.

What about anonymous objects

I’d like to see anonymous objects, yet again like in JS, in PHP. This is really powerfull, I hope more programmers would like to see such features in PHP.

Related Links

  1. Namespaces has PHP 5.3. (Or the other way around)
  2. What’s new in PHP 5.3.
  3. Lambda functions are coming to PHP