Category Archives: micro tutorial

Event driven programming with jQuery – (part 1). What is event driven?

What is event driven?

Actually the real power of JavaScript libraries and in particular in jQuery is the usage of custom events. There you have the full power to implement what is called event driven programming. This of course is not a must. You can simply make a small js application with no usage of custom events at all. The problem is that in large scale js applications the development becomes really hard and difficult to maintain.

In fact all the major JavaScript libraries come with built in mechanisms to develop apps with custom events. And if you plan to make very large website, i.e. entirely on AJAX, whatever js library you use, you better start with making your app event driven.

That in very breve means that the different modules of the page must interact between themselves only by firing and listening for events. So you can fully change your page layout with no need to rewrite the code again and again. Continue reading Event driven programming with jQuery – (part 1). What is event driven? →

HTTP_REFERRER in Zend Framework

What is HTTP_REFERRER?

If you need to know how called a PHP script, it is normally setup in the $_SERVER variable of HTTP_REFERRER, or simply

$_SERVER['HTTP_REFERRER'];

but in the same time this does not work the same way in Zend Framework, just because everything is passing by the index.php or a custom bootstrap!

Unfortunately there’s no so many resources online, however there is a solution, which seems to be pretty natural. You can just use this chuck of code:

$this->getRequest()->getHeader('REFERER');

and that’s all!

Strict types in Zend Framework and in PHP

As you may know you can add strict types for a function parameters in PHP i.e.

public function func1(string $test)
{}

and this may be some simple function in some Zend Framework standard model! Now the problem comes with the instance of this function. If you call it like this:

func1('foo bar');

in a ZF controller, you simply will get an error.

It is strange …

isn’t it! But in PHP you can use strict types only for an array, which is built in type. In other words if some object implements the __toString() method than you can use string strict type.