{"id":21925,"date":"2012-08-03T05:36:49","date_gmt":"2012-08-03T09:36:49","guid":{"rendered":"http:\/\/www.templatemonster.com\/help\/?p=21925"},"modified":"2013-08-08T10:15:31","modified_gmt":"2013-08-08T14:15:31","slug":"how-to-adduse-comments-in-html-css-php-js","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/how-to-adduse-comments-in-html-css-php-js.html","title":{"rendered":"How to add\/use comments in HTML, CSS, PHP, JS"},"content":{"rendered":"<p>This tutorial  is going to show you how to add and use comments in PHP, HTML, CSS, JS files. <\/p>\r\n\r\n<p><strong>A comment <\/strong>is a  string of code or text within HTML, XML, CSS, JS\u00a0 and other  programming languages that is not visible in your web browser. It  serves to give some  information about the code, to temporarily disable it, or to provide other feedback from the code developers. <\/p>\r\n\r\n<h3>HTML comment<\/h3>\r\n\r\n<p>  Used to temporarily \u00a0comment  out elements that you might  need later without removing them, write notes inside HTML, for debugging.  Add the opening comment tag \u00a0<strong>&lt;!&#8211;<\/strong> \u00a0before  your code and the closing tag<strong> &#8212; &gt;<\/strong> after it. <\/p>\r\n\r\n<p>Example:<\/p>\r\n\r\n<pre class=\"brush:html\">\r\n  &lt;!-- {%FOOTER_LINK} --&gt;\r\n  &lt;\/div&gt; \r\n  &lt;\/div&gt;\r\n  &lt;\/footer&gt;\r\n  &lt;\/body&gt;\r\n  &lt;\/html&gt;<\/pre>\r\n\r\n<h3>CSS comment<\/h3>\r\n\r\n<p>Used to  easily switch on and off CSS  blocks and make it easier to understand them. It  starts with<strong> \/* <\/strong>and ends  with<strong> *\/. <\/strong><\/p>\r\n\r\n<p>Example:<\/p>\r\n\r\n<pre class=\"brush:css\">\r\n  \/* Global Structure---------------------------------------- *\/\r\n  .main {\r\nmargin:0 auto;\r\nwidth:940px;\r\nposition:relative;\r\n\/*\r\n  h2 \r\nfont-size:26px;\r\nline-height:28px;\r\n}\r\n*\/ <\/pre>\r\n\r\n<h3>PHP comment<\/h3>\r\n\r\n<p>There are  two types of comments you  can add: <\/p>\r\n\r\n<ol>\r\n  <li><strong>single line comment<\/strong>  used for  quick notes about complex code or to temporarily disable a line of  PHP code. You need to add <strong>\/\/<\/strong> or <strong>#<\/strong> before the code.<\/li>\r\n<p>Example:<\/p>\r\n\r\n<pre class=\"brush:php\">\/\/My comment goes here\r\n#define('TABLE_HEADING_WRITABLE', 'Writable');<\/pre>\r\n\r\n<li><strong>multi-line comment<\/strong>  used to comment out large blocks of  code or writing multiple line comments. You need to add <strong>\/*<\/strong> before  and  <strong>*\/<\/strong> after the code.<\/li>\r\n<p>Example:<\/p>\r\n<pre class=\"brush:php\">\/*$Id$\r\nosCommerce, Open Source E-Commerce Solutions\r\nhttp:\/\/www.oscommerce.com\r\nCopyright (c) 2010 osCommerce\r\nReleased under the GNU General Public License\r\n  *\/<\/p><\/ol>\r\n\r\n<h3>JavaScript comment<\/h3>\r\n<p>  There are also two types of comments you  can add:<\/p>\r\n<ol>\r\n  <li><strong>single  line comments<\/strong>  used to comment  out single lines of code and writing small notes. You need to Add\u00a0 <strong>\/\/<\/strong> before your code or text. All text to the right of them  will be ignored till the next line. \r\n  Example:\r\n  <pre class=\"brush:js\">\/\/verify if value is in the array\r\n  function in_array(value, array)\r\n  {\r\nfor (var i in array)\r\nif (array[i] == value)\r\nreturn true;\r\nreturn false;\r\n}<\/pre><\/li>\r\n\r\n  <li><strong>multi-line  comments<\/strong> used to disable long segments of code. You need to add <strong> \/*<\/strong> before your code and <strong>*\/<\/strong> after it.<br><br>\r\n  Example:<\/li>\r\n\r\n<pre class=\"brush:js\">\/*function in_array(value, array){\r\nfor (var i in array)\r\n\tif (array[i] == value)\r\n\treturn true;\r\n        return false;}*\/\r\n&lt;\/script&gt;<\/pre>\r\n<\/ol>","protected":false},"excerpt":{"rendered":"<p>This tutorial  is going to show you how to add and use comments in PHP, HTML, CSS, JS files.<\/p>\n","protected":false},"author":30,"featured_media":21927,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[355,256,253,270],"tags":[1331,514,2411,1086,911],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/21925"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=21925"}],"version-history":[{"count":0,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/21925\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media\/21927"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=21925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=21925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=21925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}