Do not mis interpret
<?php echo 'Ending tag excluded';
with
<?php echo 'Ending tag excluded';
<p>But html is still visible</p>
The second one would give error. Exclude ?> if you no more html to write after the code.
C ya da Perl'de olduğu gibi, PHP de deyimlerin birbirlerinden her bir deyimin sonuna konulacak noktalı virgülle ayrılmasını gerektirir. Bir PHP kod bloğunun sonunda yer alan kapanış etiketi kendinden önceki deyim için noktalı virgül işlevi görür; yani, bir PHP bloğunun son satırının sonuna noktalı virgül koymak zorunda değilsiniz. Kapanış etiketi aynı zamanda satırsonu karakterini de kendisi ekleyecektir.
<?php
echo 'Bu bir denemedir';
?>
<?php echo 'Bu bir denemedir' ?>
<?php echo 'Son kapanış etiketini koymadık';
Bilginize:
Dosya sonunda PHP kapanış etiketini kullanmak isteğe bağlıdır, hatta dosya sonlarında istemdışı boş satırlar oluşması gibi durumlarda include, require gibi işlevlerin kullanımında yararlı bile olabilir, dahası sonradan yanıta başlık eklemeye devam edebilirsiniz. Bu özellik ayrıca, çıktı tamponlama kullanıyorsanız ve betiğe include ile eklediğiniz dosyalar tarafından üretilen kısımların sonunda gereksiz boş satırların oluşmasını istemediğinizde de işe yarar.
Do not mis interpret
<?php echo 'Ending tag excluded';
with
<?php echo 'Ending tag excluded';
<p>But html is still visible</p>
The second one would give error. Exclude ?> if you no more html to write after the code.
If you want to keep the newline after a closing tag in the output, just add a space after the closing tag, and the newline will not be ignored.
One thing to remember is, if you decide to omit the closing PHP tag, then the last line of the file should be ended with semi colon. If you add the closing tag then last line doesn't need to end with semi colon.
<?php
echo "First line";
echo "Last line"
The above code throws error as it neither has closing tag nor semicolon ending. So it should be replaced with either of the below two
<?php
echo "First line";
echo "Last line";
or
<?php
echo "First line";
echo "Last line" ?>