Sen kullanabilirsiniz short_open_tag
, which have to be enabled in your configuration, but that's not considered as a good practice, as it only works if those are enabled -- and they are not always (maybe not even by default)
Uzun etiketlerini kullanarak ve eko / baskı, evet uzun olabilir ... Ama ben kısa etiketleri kullanan kişiler tavsiye ve etmem.
Also note that you might need to escape your data, when it comes from an un-trusted source and/or might contain HTML you don't want to get injected in the page, to avoid injections of HTML/JS (see htmlspecialchars) :
EDIT after the comments, to add couple of things about short_open_tag
: strong>
Neden kısa açık etiketleri (at least by me ^^ ) kötü bir uygulama olarak kabul edilir?
Her şeyden önce, bazı kontrol ettikten sonra, bunlar varsayılan olarak etkin değildir:
For PHP 5.3 :
squale@shark:~/temp/php/php-5.3.0
$ grep 'short_open_tag' php.ini-development
; short_open_tag
short_open_tag = Off
squale@shark:~/temp/php/php-5.3.0
$ grep 'short_open_tag' php.ini-production
; short_open_tag
short_open_tag = Off
"development
" veya "production
" ayarlarında ya da varsayılan olarak devre dışı.
For PHP 5.2.10 (most recent version of PHP 5.2),
squale@shark:~/temp/php/php-5.2.10
$ grep 'short_open_tag' php.ini-dist
short_open_tag = On
squale@shark:~/temp/php/php-5.2.10
$ grep 'short_open_tag' php.ini-recommended
; - short_open_tag = Off [Portability]
short_open_tag = Off
"recommended
" ayarları varsayılan olarak devre
Considering these default settings are sometimes (often ?) kept by hosting services, it is dangerous to rely on short_open_tag
being activated.
(I have myself run into problem with those being disabled... And when you are not admin of the server and don't have required privilegies to modify that, it's not fun ^^ )
If you want some numbers, you can take a look at Quick survery: short_open_tag
support on or off by default?
(Not a scientific proof -- but show it could be dangerous to use those for an application you'd release to the public)
Like you said, those, when activated, conflict with XML declaration -- means you have to use something like this :
<?php echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?>
Kısa açık etiketleri dikkate alındığında var, ve sen, sen olsa, <?xml
hiç muhtemel kullanmamalısınız kullanacağız sunucuda aktif olabilir; çok kötü :-(
Actually, reading through the php.ini-recommended of PHP 5.2.10 :
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
PHP 6, bir daha da ilginç:
; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php and ?> tag combination. With the wide spread use
; of XML and use of these tags by other languages, the server can become easily
; confused and end up parsing the wrong code in the wrong context. But because
; this short cut has been a feature for such a long time, it's currently still
; supported for backwards compatibility, but we recommend you don't use them.
(Might be the same in PHP 5.3 ; didn't check)
There have been rumors short open tags could be removed from PHP 6 ; considering the portion of php.ini I just posted, it probably won't... but, still...
To give an argument pointing to the other direction (I've gotta be honest, after all) : using short open tags for template files (only) is something that is often done in Zend Framework's examples that use template files :
In our examples and documentation, we
make use of PHP short tags:
That said, many developers prefer to
use full tags for purposes of
validation or portability. For
instance, short_open_tag is disabled
in the php.ini.recommended file, and
if you template XML in view scripts,
short open tags will cause the
templates to fail validation.
(source)
Aksine, .php
dosyaları için:
Short tags are never allowed. For
files containing only PHP code, the
closing tag must always be omitted
(source)
I hope those informations are useful, and bring some kind of answer to your comment :-)