Missing php closing tag ?> in php file

Discuss coding issues, and scripts related to PHP and MySQL.
beegee
Posts:7

Missing php closing tag ?> in php file

Just so you know in some php files from your scripts you left out the closing "?>".
I put it in and looks good thank you.

Admin Posts:805
In php files, if after the last line of code there isn't other content, like html, there is not need for the closing tag "?>".
The closing tag is necessary if there is other type of code /content after the php code.
For example, in a file called "test.php":
- This is correct:

Code: Select all

<?php
$vr ='some text';
echo $vr;
//here isn't necessary the ?> because there is not other content after this line of php code
- In the following example it is applied the closing php tag ?> because the file has other content after the php code:

Code: Select all

<?php
$vr ='some text';
?>
<h1>Title</h1>
<div>
<?php echo $vr; ?>
</div>

Similar Topics