Three curly brackets together in php source code

一笑奈何 提交于 2020-01-10 17:13:53

问题


I just downloaded complete source code of PHP from php.net (PHP 5.4.0 [tar.bz2]). They are often using three curly brackets together as given below (The following code snippet extracted form ext/ctype/ctype.c.)

/* {{{ proto bool ctype_digit(mixed c)
   Checks for numeric character(s) */
 static PHP_FUNCTION(ctype_digit)
 {
  CTYPE(isdigit);
 }
/* }}} */

Does anyone have the idea why they are using these three curly brackets together?


回答1:


They are vim fold markers, they make it easy to collapse and expand the text inbetween the triple curly braces in vim, in the example shown alternating between:

...

/* {{{ proto bool ctype_digit(mixed c)
   Checks for numeric character(s) */
static PHP_FUNCTION(ctype_digit)
{
    CTYPE(isdigit);
}
/* }}} */

...

and just

...

/* {{{ proto bool ctype_digit(mixed c)

...

If you look at the end of the file where you find them, you'll often find a block like this:

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: sw=4 ts=4 fdm=marker
 * vim<600: sw=4 ts=4
 */

Which is another more-obvious indicator that these comments relate to vim.



来源:https://stackoverflow.com/questions/9714863/three-curly-brackets-together-in-php-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!