Category > PHP

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

, ,

Emulate short tags in PHP when short_open_tag = off

Yesterday I was playing with PHP 5.3. It seems that the default configuration comes with short_open_tag disabled 🙁 The short open tags is what allows to write code like this <?=”algo”?> instead of having to write <?php echo “algo”?>. Something REALLY INTERESTING, it makes PHP code really clear when looking at templates from my point […]

Continue reading

, , ,

Multilingual support for WordPress: improved!

I’ve been using wordpress ZdMultilang plugin to  write articles in several languages. The truth is that the plugin is awesome. It works great! The only thing I missed was the lack of support for keeping separate comments, so the users reading the post in English only see the comments that the English-readers version made, and […]

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

, ,

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

, , ,

Manso Trick: Updating the order of a row in a table

This time, the article is not about javascript or PHP, but SQL. The idea of this article is to review different methods for updating the order of a row in a table (trying to touch only the row we want to change, keeping intact the rest of rows). To start with a simple example, let’s […]

Continue reading

, , , , ,

The PHP empty function is wrong!!

After 20  minutes debugging code (BTW, what a great tool are debuggers), and you realize that the bug that manifests on A, does not come from A, not B, C or D, but it comes from far far away, something like Z you realize, as may other times, that a “bug” in a remote place […]

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

, , , , , , ,