PHP “short tags”: a bad practice

11 November 2009 at 3:42 PM | Posted in PHP | 1 Comment
Tags: , ,

The use of php “short tags”( example: <? echo “Hola Mundo!” ?>) is a bad and common practice that many PHP developers still use. The shortags format is only aviable using the function short_tags() in PHP3 or activating the short_open_tag in php.ini configuration file(it comes activated by default). I dont recommend to use it when you develop applications to redistribute or use in external servers because it can cause conflicts for user if short tags are not enabled. In the official PHP manual and the Zend Framework manual  recommends not use “short tags” and it going to be deleted in version 6 of PHP. Remember that clearness is very important to a professional coder: use ever <?php echo “Hola Mundo!” ?>.

Calcular el trimestre actual en PHP

7 May 2009 at 5:45 PM | Posted in PHP, Programming | 4 Comments

Hola amigos, ayer mientras trabajaba me vi en la necesidad de calcular el trimestre del año dado el número del mes y cree esta pequeña función en PHP que permite realizar este cálculo, si no se le pasa ningún mes ella tomará el mes actual por defecto. Aquí les dejo el código para quien pueda ser útil:

<?php
function trimestre($mes=null)
{
$mes = is_null($mes) ? date('m') : $mes;
$trim=floor(($mes-1) / 3)+1;
return $trim;
}
?>

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.

Follow

Get every new post delivered to your Inbox.