更改“上次修改”的响应

There emerged a problem I could not cope with. I need to set Last Modified response. If I write the following code, everything is fine:

header('Last-Modified: '.gmdate('D, d M Y H:i:s', $mt).' GMT');

But if I then add echo 'Test'; in the end:

header('Last-Modified: '.gmdate('D, d M Y H:i:s', $mt).' GMT');
echo 'Test';

it fails. Last Modified header is not displayed in response headers.

What’s the problem with it? Thanks a lot!

You have a syntax error.

After Test you try to finish your string literal with a U+2019 : RIGHT SINGLE QUOTATION MARK character instead of with a U+0027 : APOSTROPHE.

This causes PHP to throw an error page.

If you replace with ' it works normally, and the header is set.