问题
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