Code does not run on command line

5

I have a teste.php file with the following code.

 <?
 echo "teste";
 ?>

When I run the command, the php -f teste.php command will output my code:

 <?
 echo "teste";
 ?>

instead of:

teste

What's happening?

    
asked by anonymous 11.11.2014 / 16:16

1 answer

5

The problem is in your opening of tags <?

In order to use them, you must enable php.ini to short_tags_open option in the configuration of on . More information about this setting here .

On the other hand, it is highly advisable to use short_tags_open because they can conflict with the file header XML ( <?xml version="1.0"?> ).

So much so that this setting might be removed in the future version in PHP , as is the case with ASP style tags <% %> (setting asp_tags )

Summarizing

Use <?php in all your scripts.

It is safer because it will work on any PHP server, it will not be removed in the future and you will not have headaches when working with XML.

    
11.11.2014 / 16:42