<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/language.types.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'language.types.singleton.php',
    1 => '单例类型',
    2 => '单例类型',
  ),
  'up' => 
  array (
    0 => 'language.types.php',
    1 => '类型',
  ),
  'prev' => 
  array (
    0 => 'language.types.relative-class-types.php',
    1 => '相对类类型',
  ),
  'next' => 
  array (
    0 => 'language.types.iterable.php',
    1 => 'Iterable 可迭代对象',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'language/types/singleton.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="language.types.singleton" class="sect1">
 <h2 class="title">单例类型</h2>

 <p class="para">
  单例类型（singleton type）是只允许单个值的类型。PHP 支持两种单例类型：<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span>（自
  PHP 8.0.0 起支持），<span class="type"><a href="language.types.singleton.php" class="type true">true</a></span>（自 PHP 8.2.0 起支持）。
 </p>

 <div class="warning"><strong class="warning">警告</strong>
  <p class="simpara">
   在 PHP 8.2.0 之前，<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span> 类型只能用作<a href="language.types.type-system.php#language.types.type-system.composite.union" class="link">联合类型</a>的一部分。
  </p>
 </div>

 <blockquote class="note"><p><strong class="note">注意</strong>: 
  <span class="simpara">
   无法定义自定义单例类型。建议改用<a href="language.types.enumerations.php" class="link">枚举</a>。
  </span>
 </p></blockquote>

</div><?php manual_footer($setup); ?>