Skip to content Skip to sidebar Skip to footer

How To Comment Out Both HTML And PHP In PHP Inside HTML?

Here is a line of code that I want to comment out,

Solution 1:

<!--    <h1 class="post_title">
<a href="<?php // the_permalink();?>" title="<?php the_title_attribute(); ?>">
<?php // the_title(); ?></a>
</h1>
-->

This will comments only HTML portion, where as you'll find rendered PHP code in view source of webpage..

better way..

 <?php /*    <h1 class="post_title">
    <a href="<?php // the_permalink();?>" title="<?php //the_title_attribute(); ?>">
    <?php // the_title(); ?></a>
    </h1>
    */ ?>

Solution 2:

try this

<?php 
/*
 * <h1 class="post_title"><a href="<?php the_permalink();?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
 */
?>

Solution 3:


Solution 4:

For that functionality you would have to refactor your code.

<?php
//print('<h1 class="post_title"><a href="'. the_permalink() . '" title="' . the_title_attribute() . '">' . the_title() . '</a></h1>');
?>

If all your code is within PHP then commenting out some of it becomes an easy thing, you would simply use PHP's commenting rules.


Solution 5:

If you want to print only the result from php functions. I hope this should help you.

<?
$var = //"<h1 class='post_title'><a href=".
    "'php the_permalink()' ".
    //"  title=".
    "'php the_title_attribute() ' ".
    //">".
    "'php the_title()' ".
    //"' </a></h1>";
echo $var;
?>

or

<?

$var = /*"<h1 class='post_title'>.*/
         /*"<a href='".*/"'php the_permalink()' "./*"  title=".*/"'php the_title_attribute() ' "./*">".*/
             "'php the_title()' ".
        /*"</a>".
    "</h1>"*/;


echo $var;
    ?>

Post a Comment for "How To Comment Out Both HTML And PHP In PHP Inside HTML?"