对于php函数代码,如何注释掉代码?这是正确的还是最好的方式?
function menu_element_builder($values) {
//$links = '';
}
答案 0 :(得分:3)
注释掉//
或#
的行,由您决定。
使用/* [commented code] */
注释部分行或整个代码块。
function menu_element_builder($values/*, $optional_value*/) {
#Commented out line
echo "Not commented out";
//Commented out line
echo "Not commented out";
/* Commented out code block
echo "Commented out"; */
echo "Not commented out"; //but this is ." and so's this";
echo "Not commented out" /* but this is */ ." and this isn't";
/* This is commented out */ echo "But this isn't";
}
答案 1 :(得分:0)
<?php
// This is a single-line comment
# This is also a single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
// Aswell you can use comments to hide part of your code from execution
$x = 5 /* + 15 */ + 5;
echo $x;
?>