uTools-Manuals/docs/php/language.pseudo-types.html
2019-04-08 23:22:26 +08:00

77 lines
2.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>本文档中使用的伪类型与变量</title>
</head>
<body class="docs">
<div id="layout">
<div id="layout-content"><div id="language.pseudo-types" class="sect1">
<h2 class="title">本文档中使用的伪类型与变量</h2>
<p class="para">
伪类型pseudo-types 是 PHP 文档里用于指示参数可以使用的类型和值。
请注意,它们不是 PHP 语言里原生类型。
所以不能把伪类型用于自定义函数里的类型约束typehint
</p>
<div class="sect2" id="language.types.mixed">
<h3 class="title">mixed</h3>
<p class="para">
<em>mixed</em> 说明一个参数可以接受多种不同的(但不一定是所有的)类型。
</p>
<p class="para">
例如 <span class="function"><a href="gettype.html" class="function">gettype()</a></span> 可以接受所有的 PHP 类型,<span class="function"><a href="str_replace.html" class="function">str_replace()</a></span> 可以接受字符串和数组。
</p>
</div>
<div class="sect2" id="language.types.number">
<h3 class="title">number</h3>
<p class="para">
<em>number</em> 说明一个参数可以是 <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> 或者 <span class="type"><a href="language.types.float.html" class="type float">float</a></span>
</p>
</div>
<div class="sect2" id="language.types.callback">
<h3 class="title">callback</h3>
<p class="para">
本文档中在 PHP 5.4 引入 <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> 类型之前使用
<span class="type"><a href="language.pseudo-types.html#language.types.callback" class="type callback">callback</a></span> 伪类型。二者含义完全相同。
</p>
</div>
<div class="sect2" id="language.types.array-object">
<h3 class="title">array|object</h3>
<p class="para">
<em>array|object</em> 意思是参数既可以是 <span class="type"><a href="language.types.array.html" class="type array">array</a></span> 也可以是
<span class="type"><a href="language.types.object.html" class="type object">object</a></span>
</p>
</div>
<div class="sect2" id="language.types.void">
<h3 class="title">void</h3>
<p class="para">
<em>void</em> 作为返回类型意味着函数的返回值是无用的。<em>void</em>
作为参数列表意味着函数不接受任何参数。
</p>
</div>
<div class="sect2" id="language.types.dotdotdot">
<h3 class="title">...</h3>
<p class="para">
在函数原型中,<code class="parameter">$...</code> 表示<em>等等</em>的意思。当一个函数可以接受任意个参数时使用此变量名。
</p>
</div>
</div></div></div></body></html>