1

In Notepad++ I want temporary turn of this block of code:

Number of registered users: <?php echo $objUsers->users['total']; ?><br/>
Newest user: <?php echo $objUsers->users['last']; ?>
<h5>Online users:</h5> <?php echo $objUsers->users['online']; ?>

html comment markup - doesn't work.
php comment markup - doesn't work.

I can't believe that I must comment separately html and php code - 3+3 times ?

3 Answers 3

7

You can comment out all of your code by surrounding the whole thing in a PHP block comment. It would look something like:

<?php /* ?>
Number of registered users: <?php echo $objUsers->users['total']; ?><br/>
Newest user: <?php echo $objUsers->users['last']; ?>
<h5>Online users:</h5> <?php echo $objUsers->users['online']; ?>
<?php */ ?>

Of course, putting the block comments in a separate PHP tag is not necessary. A reduced version looks like:

<?php /* ?>
Number of registered users: <?php echo $objUsers->users['total']; ?><br/>
Newest user: <?php echo $objUsers->users['last']; ?>
<h5>Online users:</h5> <?php echo $objUsers->users['online']; */ ?>
Sign up to request clarification or add additional context in comments.

1 Comment

This way PHP will not be processed, in contrast to the favoured answer. Correct me if I'm wrong.
3

Just wrap the code in HTML comments:

<!--
Number of registered users: <?php echo $objUsers->users['total']; ?><br/>
Newest user: <?php echo $objUsers->users['last']; ?>
<h5>Online users:</h5> <?php echo $objUsers->users['online']; ?>
-->

4 Comments

Be careful with that. The PHP code will still execute even though nothing will be rendered by the browser. If you include any code that has side effects, those effects will still occur even if you don't see the results.
@MJD, thanks a lot. I didn't knew that. How it is possible ? The code will execute itself, although being commented ?
@Alegro, PHP ignores the HTML arround it. So even though you commented you the HTML code, PHP is not aware of that. So it executes the PHP code you have, and outputs it. But if you view the page in a browser, the HTML comments hide everything. If you view the page source, you will see that the PHP code still happened. That's why I suggested using PHP's comments instead. This blocks the PHP code, and thus blocks PHP from spitting out the HTML to begin with.
In Notepadd++: press CTRL+K.
2

You have to use both html markups and php comment chars in php block. E.g.

<!-- Number of registered users: <?php //echo $objUsers->users['total']; ?><br/>
Newest user: <?php // echo $objUsers->users['last']; ?>
<h5>Online users:</h5> //<?php echo $objUsers->users['online']; ?> -->

Better comment each line out as:

<!-- Number of registered users: <?php //echo $objUsers->users['total']; ?><br/> -->
<!-- Newest user: <?php // echo $objUsers->users['last']; ?> -->
<!-- <h5>Online users:</h5> //<?php echo $objUsers->users['online']; ?> -->

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.