D
D
denver2012-08-22 11:27:25
PHP
denver, 2012-08-22 11:27:25

Is it recommended to write

I heard something about the fact that as the very first opening <? it is recommended to put <?php, but I can't google why. It seems (but did not understand then why) on makosi files c <? they just threw out the content when included, as if it were html. Help me understand how to do it.
PS. I understand that “short_open_tag = on” is not recommended in itself, but we have been writing like this for a long time, and there have been no problems yet.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
FanatPHP, 2012-08-22
@denver

Never heard anything like that about the first opening tag.
About "falling out the contents" with the short_open_tag enabled - too. Most likely it was some kind of mistake or typo.
For "On the case" no recommendations are needed, you can write as you like.
If you want maximum compatibility, then in the short form we write only <?=, and in other cases - in the long one.

E
ertaquo, 2012-08-22
@ertaquo

You yourself have answered your own question. <? will only work with short_open_tag = on (otherwise throwing out all the content), and <?php with any value of this variable.
If you write purely for yourself, write in a way that suits you. If for someone - it's better to use <? php

M
Mikhail Osher, 2012-08-22
@miraage

This is the same Bad Practice.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question