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?
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?
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.