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 [...]
Category > PHP
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.
In fact, [...]
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 [...]
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 so [...]
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
[...]
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 now, I’m [...]
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 say [...]
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 [...]
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 PHP [...]
Español