|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-05-30 09:37 UTC] andrew at grillet dot co dot uk
Description:
------------
I am using PHP with FPM on OpenBSD, but I do not think that is relevant.
The issue is that I have html comments in my HTML (duh!). They are comments, not for end user consumption. They are served to the client. It is true that the browser will hide them from users, but, unless debugging, I would prefer the user can't see the comments by enabling debugging in the browser.
I would like to have a php.ini setting, or possibly php_fpm setting, that strips html comments while serving.
I agree that the server could/should do this, but I also use Apache on Ubuntu, and have colleagues using nginx on Macs, and the situation is the same. All use php, so it seems to me that php is where to fix this issue.
Test script:
---------------
index.html
-----%<-------------------
<html>
<head>
</head>
<body>
<?php
print("See this, Jimmy!<br>
(C) 1987, British Rail and others<br>");
?>
<!--
This is a comment, not for end-user consumption. I want this stripped while serving unless debugging.
-->
</body>
</html>
-----%<-------------------
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 03:00:01 2025 UTC |
This sounds like a job for a function: ``` function c($string) { if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) { echo $string; } } <?php c('This is a comment, not for end-user consumption. I want this stripped while serving unless debugging.'); ?> ```