Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Multiple Line Comment inside Multiple Line Comment

Tags:

comments

php

<?php
/*
    /* this is a comment */
*/
?>

PHP returns "syntax error"... Is this just a completely wrong way to use multiple line comment?

Sometimes I need to comment out a big block of code for testing, and this block contains hundreds of lines and there are many multiple line comments inside.

What's the best way to comment out this big block? Besides removing it temporarily from the file?

like image 640
dudeMatt Avatar asked Aug 08 '11 03:08

dudeMatt


People also ask

How do you make a multi-line comment with a multiline string?

To comment out multiple lines in Python, you can prepend each line with a hash ( # ). With this approach, you're technically making multiple single-line comments. The real workaround for making multi-line comments in Python is by using docstrings.

How do you insert a comment with multiple lines?

Multi-line comments start with /* and end with */ . Any text between /* and */ will be ignored by JavaScript.

What's the following PHP comment syntax multiple line comment?

PHP supports both one-line and multi-line comments. A one-line comment starts with the # or // . A multi-line comment starts with /* and end with */ .


1 Answers

From the PHP manual:

'C' style comments end at the first */ encountered. Make sure you don't nest 'C' style comments. It is easy to make this mistake if you are trying to comment out a large block of code.

<?php
 /*
    echo 'This is a test'; /* This comment will cause a problem */
 */
?>

:(

like image 199
karim79 Avatar answered Sep 18 '22 00:09

karim79