10 articles Articles posted in php

Let’s countdown together

Let’s countdown together

This post will display bad in RSS readers and planet. Click here to read it on my site. Update: Better degradation for no-JS-users using a PHP script added. See below. So, the latest and greatest (and badly named ) Ubuntu is approaching and you want to help the community spreading out the word and build expectance ? Jaunty Jackalope, while being apparently not a big step forward in dekstop features, brings upgrade to all installed …

Continue reading →

How to create Private (and moderated) Forums BuddyPress and BBPress

If you develop on BuddyPress, you’re likely to get stuck while trying to get per-forum permissions. Indeed, it seems there’s not yet a way to make BBPress read the BuddyPress groups and hide the froums belonging to private  groups I had to develop a way myself. Furthermore, I needed to give forum moderation rights to the moderators of each group in BuddyPress on a per-forum basis. This is a quick and dirty tutorial for future …

Continue reading →

5 tips to make your PHP code beautiful (3)

Avoid unnecessary control structures. Brackets everywhere. Try to get rid of those as much as you can. Unnecessary brackets add visual complexity and make your code much longer. In real world situation, when you need to quickly browse through your code, they just add clutter //prints out the structure of a table function describe( $table ) { $query = “SHOW COLUMNS FROM `$table `”; $result =mysql_query( $query ); if ( ! $result ) { return …

Continue reading →

5 tips to make your PHP code beautiful (2)

Thoughtful minimalism Think about the most concise, clear and readable way to write the code your writing. Assume you were writing a function to get a file extension (.gif, .doc, etc.). You could be tempted to use string manipulation functions. $filename = ‘file.doc’; $dot_position = strpos( $filename, ‘.’ ); if ( $dot_position !== false ) { $extension = substr( $filename, $dot_position + 1 ); } var_dump($extension) It’s a lot of code for such a simple …

Continue reading →

5 tips to make your PHP code beautiful (1)

Get your brackets right ..and indent your code properly, always. Always give to each of your curly brackets their very own line. I am taking a snippet from Kohana to demonstrate this. (bad) What do you think of this code ? if ( ! is_array($data)){ if (strpos($data, ‘[') !== FALSE) {$data = preg_replace('/\[.*\]/’, ”, $data); }$data = empty($data) ? array() : array(‘for’ => $data);} (not nice) This is much better if ( ! is_array($data)){ if …

Continue reading →

How to build an absolute url in php

Today, I was looking for a way to make an url absolute. Ok, it’s easy. Guess I should think some good excuse for not being to able to do it in 5 minutes. The sad reality is I ended digging on google (again). I am posting what I found, for (main, and) your reference.

Continue reading →

A piece of story

What I found. Oh! Look, look ! As old-schoolers know Deja News, an historical Usenet repository was lately acquired by Google some year ago for Google Groups service, still conserves intact pieces of story of the web. Searching in google for google groups php at the first place what I found is (suspance): Rasmus Lerdorf’s first PHP stable release announce!!

Continue reading →

Xdump: a little piece of my story as developer

I am slowly beginning to pull online docs and samples for Xdump. Xdump was one debugging tool I had to develop for the reason that in some situations var_dump() simply is not enough. Here’s the overview of xdump. Of course one could say that as good programmer you should never ever findy yourself in such a situation which requires something more powerful than var_dump() or print_r(). I can understand this kind of point-of-view, but I …

Continue reading →

Need for Cache

After going through PhpThumb hell, I decided to develop one serious decent caching library for caching dynamically generated images.

Continue reading →

Xdump

When working with large arrays/objects,with complex references beetween variables or (again) php’s built-in var_dump() e debug_backtrace() shows their limits. Have you ever tried to var_dump $GLOBALS ? Even if when I started this lib there were already some classes which provided nice html formatted dump, in the moment I needed one, I couldn’t (my fault) find one.

Continue reading →

Page optimized by WP Minify WordPress Plugin