Archive for the ‘PHP’ Category

About long, int and the php unpack function – or “where is the sign”? [UPDATED]

UPDATE:
Thanks to Ilia for reviewing and commiting the patch.

I recently noticed bug #38770 from the php bugtracker. It describes that pack behaves different on different platforms.
The problem occures due to a byte-wise convert from int to long (C-Language).

A programmer would expect the following code to pack an 32 bit int.

print_r(unpack(“N”, …

HTML_Template_IT 1.2.0 beta released

Today we released the 1.2.0 beta of HTML_Template_IT.
As I mentioned, an option was added to HTML_Template_ITX::setCallbackFunction() to determine if call_user_func or call_user_func_array is used to call the callback function.
Example:
function _numberFormatCallback($float, $decimals) {
return number_format($float, $decimals);
}

$tpl = new HTML_Template_ITX();
$tpl->setTemplate(‘callback:func_numberFormat(1.5, 2)’);
$tpl->setCallbackFunction(‘numberFormat’, ‘_numberFormatCallback’, ”, true);
$tpl->performCallback();
$tpl->show();
// prints “callback:1.50″

Look a the line:

$tpl->setCallbackFunction(‘numberFormat’, ‘_numberFormatCallback’, ”, …

Random Stuff

I really like apps working with random mechanism like this image:

IT[X]

IT was always my favorite template engine. It’s fast and has a simple API good enough for most of the use cases. I use it quite a lot and so I was pleased as Pierre asked me to help him with the IT development on PEAR since he was the only developer and he …