Req->Bug #76393 [Wfx->Nab]: serving comments

From: Date: Wed, 30 May 2018 09:52:16 +0000
Subject: Req->Bug #76393 [Wfx->Nab]: serving comments
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215425@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76393&edit=1 ID: 76393 Updated by: danack@php.net Reported by: andrew at grillet dot co dot uk Summary: serving comments -Status: Wont fix +Status: Not a bug -Type: Feature/Change Request +Type: Bug -Package: Scripting Engine problem +Package: FPM related Operating System: OpenBSD PHP Version: 5.6.36 Block user comment: N Private report: N New Comment: 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.'); ?> ``` Previous Comments: ------------------------------------------------------------------------ [2018-05-30 09:52:15] danack@php.net 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.'); ?> ``` ------------------------------------------------------------------------ [2018-05-30 09:40:12] spam2 at rhsoft dot net PHP has no business here at all - PHP cares only about stuff between <?php ?> or <?=?> and anything else is a plain passthru if you want to solve that don't mix HTML and code or use ob_start() combined with ob_get_clean(), strip comments with php userland code and echo the filtered output to the client this is not the job of the scripting language itself and never will be ------------------------------------------------------------------------ [2018-05-30 09:37:08] 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> -----%<------------------- ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76393&edit=1

« previous php.bugs (#215425) next »