Page 1 of 1

Missing php closing tag ?> in php file

Posted: 11 Jun 2017, 22:50
by beegee
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.

Missing php closing tag ?> in php file

Posted: 12 Jun 2017, 04:46
by Admin
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>