CodeQ

Minggu, 17 Januari 2010

PHP Tanpa Tag Penutup

Di milis something and everything ada yang nanya kenapa pada beberapa file di framework CodeIgniter, Zend ngga ada tutup <?php nya. Sebenarnya saya juga penasaran sih kok begitu ya? Sontak lah para gegedug milis menjawabnya dengan aroma yang sama sebagai berikut:

  • Kalo menurut framework tetangga..alias framework zend untuk menghindari error ketika kita mengetik ?> tetapi ada space kosong setelah ?>...nah kalo gak di kasih ya otomatis error itu terhindari.
  • Supaya ga ada white space. load viewnya pake output buffering
  • Karena di situ sedang tidak pada posisi perlu balik ke HTML mode lagi
  • dari Zend Coding Standard : For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP, and omitting it´ prevents the accidental injection of trailing white space into the response
  • CodeIgniter Style Guide : The PHP closing tag on a PHP document *?>* is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages. For this reason, all PHP files should *OMIT* the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root. This allows you to still identify a file as being complete and not truncated.

Ooo jadi gitu tooh..

0 Komentar:

Poskan Komentar

Berlangganan Poskan Komentar [Atom]



<< Beranda