【问题标题】:Three curly brackets together in php source codephp源码中三个大括号放在一起
【发布时间】:2012-03-31 16:10:09
【问题描述】:

我刚刚从 php.net (PHP 5.4.0 [tar.bz2]) 下载了完整的 PHP 源代码。 他们经常一起使用三个大括号,如下所示(以下代码 sn-p 从 ext/ctype/ctype.c 中提取。)

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

有没有人知道为什么要同时使用这三个大括号?

【问题讨论】:

  • 一些编辑器使用它们来“折叠”代码块,因此只有注释行本身的文本可见,而实际代码被“折叠”掉了。
  • 我不认为只是为了折叠他们允许添加三个花括号。
  • @HabeebPerwad 它在评论区——他们可以“允许”任何他们想要的东西。 :)

标签: php vim folding curly-braces


【解决方案1】:

它们是vim fold markers,它们可以很容易地折叠和展开 vim 中三个大括号之间的文本,在显示的示例中交替显示:

...

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

...

只是

...

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

...

如果你查看end of the file where you find them,你会经常发现这样的块:

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

这是这些 cmets 与 vim 相关的另一个更明显的指标。

【讨论】:

  • 我现在是折叠的忠实粉丝!
猜你喜欢
  • 1970-01-01
  • 2018-06-16
  • 2012-10-15
  • 1970-01-01
  • 2021-08-21
  • 1970-01-01
  • 2017-06-01
  • 1970-01-01
相关资源
最近更新 更多