How to comment blocks of php without commented out html ending up in the source?


In the IDE I switched from (Dreamweaver), I could comment out a block of PHP code with mixed html, without any of the html ending up as commented out code in the source.

Example of Dreamweaver style php block commenting:

Original code:

<?php if ( $search = 1) : ?>
<div class="search">
<?php endif; ?>

Dreamweaver php block comment:

<?php /*?><?php if ( $search = 1) : ?>
<div class="search">
<?php endif; ?><?php */?>

Result: nothing in frontend source.

However with PHPSstorm the only block commenting option I can find leads to commented out html in the source:

PHPstorm on OSX, with CMD-SHIFT-/
Leads to commented out html in source

<?php /*if ( $search = 1) : */?><!--
<div class="search">
--><?php /*endif; */?>

which leads to this in the frontend source:

<div class="search">

Is there a way to achieve this kind of commenting that I am missing?

If not I would like to suggest this as a feature request, I used this all the time to comment out code I am temporarily not using but want to keep.


Hi there,

AFAIK it's the way how it always worked and it's not configurable.

You can file Feature Request ticket at Issue Tracker: (but please check for possibly existing tickets first -- there and in as well).


Partially related:


Ok, will do. Thanks.



Please sign in to leave a comment.