short form or complete form

Due to some work requirements I needed to install LAMP (Linux Apache Mysql y Php) over Windows (some new headache).

I downloaded, installed and configured the last version of every service without problems ( no comparison with sudo apt-get install mysql-server php5-mysql ).

When I try to test if the configuration is working I write a “phpinfo.php” file with the content:
< ? phpinfo() ? >

But when I open the page http://localhost/phpinfo.php I find that it’s completely empty.

So, I started looking into the log and restarting services/os until I think about changing the test code for:

< ? php phpinfo() ? >

which happened to work properly.

The problem was that one of the configuration options of php.ini, short_open_tag (that states if the short form of the opening tag “< ?” can be used instead of the complete form “< ? php” . Until now, this value was true by default, but it has been changed to false, so that the short tag was not recognized by the php module.

The reason for this is to allow the use of other tags starting with “< ?” like ‘< ?xml’ (in fact it’s still possible to use them by < ? echo '< ?xml'; ? >).

The general recommendation is to use always the complete form if it is necessary to have a portable code, because it is quite probable that otherwise, in a future, trying to run the code will not work.

9 Responses to “short form or complete form”

  1. Titiritero says:

    Pero ingrato que fuente de tipo de letra has utilizado. Al menos mi hosting titiritero desde hace ya más de un mes no da problemas de disponibilidad y eso que es gratuito.

    ¡Pero como un hosting de pago tiene tantos problemas!

    Y yo siempre utilizo ?php y si ves el código de wordpress siempre viene con ?php en vez del solo ?. Es que quien demonios te ha enseñado a poner solo ?, un maestro de ingratos supongo.

  2. Titiritero says:

    Me olvidaba, el mismo que no utiliza windows ni para c**** utilizando windows, vaya hombre.

  3. Alfredo says:

    He tenido problemas para publicar este articulo porque wordpress no asimila bien que se escriba la etiqueta de apertura de codigo php

  4. Alfredo says:

    En cuanto a lo del como este programado wordpress me parece muy bien, pero el proyecto en el que yo estoy trabajando tiene un 98% de apariciones de la forma corta con respecto a la completa.

  5. Titiritero says:

    Entonces como tu dices, tu proyecto es en cierto modo menos portable. Menudo proyecto estarás haciendo, yo no lo he visto pero si lo viera botón suprimir ya.

  6. Alfredo says:

    No te confundas, nuestro proyecto es portable hasta el punto de que, hasta ahora, he estado trabajando en él completamente en linux.
    El unico problema es que nuestro proyecto depende de otro (jClips) que está dando problemas en linux (a pesar de que tambien es gnu)

  7. Alfredo says:

    Si quieres darle al boton de suprimir a algo daselo a jClips.

  8. Titiritero says:

    No si el proyecto en serio me da igual. Mientras recibas tu sueldo está bien, si no funciona más o menos bien pues que contraten a más gente (yo) jajaja.

  9. Alfredo says:

    Pues la cuestion es que funciona, ya te enseñare algun video mostrando lo que hace.

Leave a Reply


+ 6 = 15