Archive for April, 2008

Simple type checking in PHP

<?php     error_reporting(E_ALL | E_STRICT); /* Manual optional type checking for PHP functions     Basic example:         function log_error($line_number, $filename, $desc)     {         CheckFunctionArgs(‘integer’, ‘string’, ‘string’);         [snip]     }     Object example:         class LogObject {} [...]

Posted by Matthew on April 15th, 2008

Filed under php, programming | 3 Comments »

sizeof(int) = 68

Pankaj Kumar has a slightly disturbing look at memory usage in PHP. Each element requires a value structure (zval) which takes 16 bytes. Also requires a hash bucket – which takes 36 bytes. That gives 52 bytes per value. Memory allocation headers take another 8 bytes*2 – which gives 68 bytes. Pretty close to what [...]

Posted by Matthew on April 2nd, 2008

Filed under php, programming | No Comments »