文章大纲

在phpstorm里怎么给php函数设置注释格式

2025-06-28 00:09:04

点击顶部File菜单,选择Settings,然后就按照下面步骤操作:

步骤流程:File >> Settings >> Editor >> CodeStyle >> File and Code Templates >> Includes >> PHP Function Doc Comment


我的注释格式如下:

txt
/**
${CARET}
${PARAM_DOC}
#if (${TYPE_HINT} != "void") * @return ${TYPE_HINT}
#end
${YEAR}-${MONTH}-${DAY} ${TIME} ${USER}
${THROWS_DOC}
*/


在函数外输入/**,再Enter键,就会自动显示如下格式的注释:

txt
/**
 *
 * @param $wordId
 * @param $arrWordId
 * @return int
 * 2025-06-27 23:28 coderzhai
 */

这里主要解释下CARET这一项。

上面英文解释是:

Marks a position where the caret must be moved after the comment is added

翻译过来是:注释添加后,标记光标应该展示的位置。(caret是光标的意思)


本文为翟码农个人博客下技术主题里PHP分类下的原创文章,转载请注明出处:http://www.zhai14.com/blog/how-to-set-the-format-of-comment-for-function-in-phpstorm.html


我要评论
评论列表