Tag Archive > PHP

http_build_query implemented in Python

I implemented a function in Python that mimics http_build_query function. ## # Mimics the behaviour of http_build_query PHP function # This method can be useful for sending data to flash applications ################################################## def http_build_query(params, topkey = ”): from urllib import quote   if len(params) == 0: return ""   result = ""   # is […]

Continue reading

, ,

Manso Trick: Detect the Operating System in PHP

There could be a lot of reasons to detect the OS in PHP, and I’m pretty aware that these reasons could open a discussion by themselves. Anyway, it could be useful to do some tweaks or optimizations, to run one commands or anothers, or simply  it can be useful as additional information for webmasters, developers […]

Continue reading

, , ,

TCPDF: excelent library for generating PDF in PHP

The other day I was looking how to create PDF files in PHP. The first thing that came to my mind was the PDFlib extension included in PHP since version 4. The problem with this library is that  I thought it was kind of low-level, and I didn’t had any idea on where to start. […]

Continue reading

, ,

PHP amazingly improves itself

This was me, looking how to install PHP 5.3 in the new Ubuntu Karmic, because using the new functionality of late static binding will simplify my code, and I’ve found something amazing. A new feature that was missing in PHP, but they have included in PHP 5.3… the… wait for it…. wait for it…. wait […]

Continue reading

, , , ,

Detecting an animated GIF in PHP

Following function detects if the GIF contains an animation (it has more than 1 frame) or is just a static file. function isAnimatedGif($filename) { $filecontents=file_get_contents($filename);   $str_loc=0; $count=0;   // There is no point in continuing after we find a 2nd frame while ($count < 2) { $where1=strpos($filecontents,"\x00\x21\xF9\x04", $str_loc); if ($where1 === FALSE) { break; […]

Continue reading

, ,

Keeping aspect ratio when scaling an image

Scaling an image to keep it under specific bounds, for visualizing purposes is a common task, but it’s even better if we can scale the image without deforming it. In this cases we have to scale the image and keep it’s original aspect ratio. Nowadays there are thousands of libraries for any general purpose language […]

Continue reading

, , , , ,

Convert UTF-8 string into an array of chars in PHP

I hope PHP 6 will solve all my problems with UTF-8, but it has not been released yet, and one has to keep coding with the tools it has available. I think I will probably be sharing the class for string manipulation that I’ve been coding (which of course is 100% compatible with UTF-8). For […]

Continue reading

, , ,

Superfast tokenizer in PHP

I am currently working on a PHP library/framework (I think it looks more like a library than a framework, and I think it’s better this way). The thing is that for some of the components I needed to parse some data (look at parser definition), and for that task I needed a PHP tokenizer (or […]

Continue reading

, , , , , , ,