Suggestion for fix to whitespace after ?> problems

Suggestion for fix to whitespace after ?> problems

by Phil Driscoll -
Number of replies: 0
I'm new to the Moodle forums so please forgive me if I'm posting this in the wrong place.

Browsing the archives, I see that people have recurring problems with whitespace after ?> at the end of php files (e.g. config.php) - often inserted by text editors. The whitespace then stops headers being sent by subsequent code.

The easy way to fix this once and for all is to remove the ?> from the end of every php file in Moodle.

Whilst PHP requires the <?php to get it to start processing php code, the ?> is only necessary if you have some plain html you want to output after the php block.

Note that this is not just a quirk of the way PHP currently works, it is a documented feature, so it is not a behaviour that will mysteriously disappear one day!

http://docs.php.net/en/language.basic-syntax.html#language.basic-syntax.instruction-separation
Average of ratings: -