Forum Moderators: coopster
Kind of a silly question, but a friend of mine was saying that using <? instead of <?php was better because a) it reduces file size (obviously not much) and b) it speeds up render time.
Does it actually speed up the render time? I'm sure it's barely noticable, but every little bit helps, right?
Any other shorthand tips?
In speed there's no difference. What difference is in reading 3 bytes more, especially as you use new line breaks and many spaces.
Best regards
Michal Cibor
PS. I use both versions, whichever I write works :)
[us2.php.net...]
There are four sets of tags which can be used to denote blocks of PHP code. Of these, only two (<?php. . .?> and <script language="php">. . .</script>) are always available; the others can be turned on or off from the php.ini configuration file. While the short-form tags and ASP-style tags may be convenient, they are not as portable as the longer versions. Also, if you intend to embed PHP code in XML or XHTML, you will need to use the <?php. . .?> form to conform to the XML....The second way is not available always. Short tags are available only when they have been enabled. This can be done via the short_tags() function (PHP 3 only), by enabling the short_open_tag configuration setting in the PHP config file, or by compiling PHP with the --enable-short-tags option to configure. Even if it is enabled by default in php.ini-dist, use of short tags are discouraged.
Dang, I use short tags alot too.
Note that although the file size will be smaller, what is sent to the end user (over the internet, the slowest chain in the link) is exactly the same because the <? and <?PHP are never sent. The output of the PHP programming is sent. So the space saving ONLY applies to your bandwidth when you upload the files and this will normally be minimal. As file sizes are in segments on a hard disk, a one byte file can occupy the same amount of disk space as a 200 byte file. So your server space usage in unlikely to be affected much at all.
remember, as Birdman said,
"only two (<?php. . .?> and <script language="php">. . .</script>) are always available"
Note that php and many OSes are case-sensitive, so I would take the official word to mean that <?php is always available, but <?PHP really shouldn't be.
When I'm being good, I use <?php. I'm not often good. Fortunately, there's always grep.
Tom