Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 PHP


  What to Look for in PHP 5.4.0

PHP 5.4.0 will arrive soon. The PHP team is working to bring to some very nice presents to PHP developers. In the previous release of 5.3.0 they had added a few language changes. This version is no different. Some of the other changes include the ability to use DTrace for watching PHP apps in BSD variants (there is a loadable kernel module for Linux folks). This release features many speed and security improvements along with some phasing out of older language features (Y2K compliance is no longer optional). The mysql extensions for ext/mysql, mysqli, and pdo now use the MySql n...

2,982 0       PHP NEW FEATURE TRAIT 5.4 BUILT-IN SERVER


  Cracks in the Foundation

PHP has been around for a long time, and it’s starting to show its age. From top to bottom, the language has creaky joints. I’ve decided to take a look at how things got to this point, and what can be (and is being) done about it. I start out pretty gloomy, but bear with me; I promise it gets better.In the Beginning, There Was Apache and CGIAnd there was much rejoicing.In 1994, Rasmus Lerdorf created the “Personal Home Page Tools,” a set of CGI binaries written in C. These tools looked little-to-nothing like the PHP we know today. Embedded in HTML comments, and using ...

2,525 0       PHP HISTORY FOUNDATION DESIGN COMPATIBILITY


  How big are PHP arrays (and values) really? (Hint: BIG!)

Upfront I want to thank Johannes and Tyrael for their help in finding some of the more hidden memory usage.In this post I want to investigate the memory usage of PHP arrays (and values in general) using the following script as an example, which creates 100000 unique integer array elements and measures the resulting memory usage:<?php$startMemory = memory_get_usage();$array = range(1, 100000);echo memory_get_usage() - $startMemory, ' bytes';How much would you expect it to be? Simple, one integer is 8 bytes (on a 64 bit unix machine and using the long type) and you got 100000 integers...

2,564 0       PHP ARRAY MEMORY OCCUPATION GARBAGE COLLECTION


  10 rules of PHP-masters

1. Use PHP only when it is necessary – Rasmus LerdorfThere is no better source than the creator of PHP, to learn what he can do. Rasmus Lerdorf created PHP in 1995. Since then, the language has spread like a wildfire rate in the developer community, incidentally changing the face of the Internet. However, Rasmus did not create PHP with these intentions. PHP was created for the needs of web development. As is the case with many other projects with open source, have become popular, philosophy or even narcissism has never been the driving force. It wa...

7,150 0       PHP EXPERIENCE ADVICE MASTER


  Easy Parallel Processing in PHP

The proliferation of multicore CPUs and the inability of our learned CPU vendors to squeeze many more GHz into their designs means that often the only way to get additional performance is by writing clever parallel software. One problem we were having is that some of our batch processing jobs were taking too long to run. In order to speed the processing, we tried to split the processing file into half, and let a separate PHP process run each job. Given that we were using a dual core server, each process would be able to run close to full speed (subject to I/O constraints).Here is our technique...

6,713 0       PHP PARALLEL PROCESSING MULTITHREADING LIKE SLEEP


  PHP's Output Buffering

While profiling our application I came across a a rather strange memory usage by the ob_start() function. We do use ob_start() quite a bit to defer output of data, which is a common thing in many applications. What was unusual is that 16 calls to ob_start() up chewing through almost 700kb of memory, given that the data being buffered rarely exceeds 1-2kb, this was quite unusual.I started looking at the C code of the ob_start() function and found this interesting bit of code inside php_start_ob_buffer()initial_size = 40*1024;block_size = 10*1024;Which directs PHP to pre-allocate 40kb of data fo...

4,030 0       PHP MEMORY OB_START() SOURCE 40KB


  If PHP Were British

When Rasmus Lerdorf first put PHP together, he - quite sensibly, despite his heritage - chose not to write it in Greenlandic or Danish. Good job too - that would have been rather unpleasant to work with. He opted instead, being in Canada at the time, for the local tongue. No, not French - that bastard dialect of the Queen's English commonly referred to as "US English"1.PHP developers in Britain have been grumpy about this ever since. What was he thinking? And more importantly, how do we undo this travesty? How do we developers ensure the traditions of the British Empire continue to be upheld, ...

2,779 0       PHP CLASS BRITISH STATEMENT ENGILISH LIKE


  JavaScript-style object literals in PHP

The object literal notation in JavaScript looks like:var fido = {name: "Fido", barks: true};or var fido = {};fido.name = "Fido";fido.barks = true;From assoc arrays to objectsIn PHP you would call that an associative array. $fido = array( 'name' => "Fido", 'barks' => true);And you can easily make it an object too:$fido = (object)$fido;echo gettype($fido); // "object"Or if you want to start with a blank object and add stuff to it:$fido = (object)array();or$fido = new StdClass();and then$fido->name = "Fido";$fido->barks = true;A little explanation maybe: objects in JavaScript are ha...

3,482 0       PHP JAVASCRIPT OBJECT FUNCTION CALL SELF VS THIS