mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
145 lines
5.0 KiB
HTML
145 lines
5.0 KiB
HTML
<!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="function.mb-substr" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">mb_substr</h1>
|
||
<p class="verinfo">(PHP 4 >= 4.0.6, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">mb_substr</span> — <span class="dc-title">获取部分字符串</span></p>
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.mb-substr-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>mb_substr</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
|
||
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$start</code></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$length</code><span class="initializer"> = NULL</span></span>
|
||
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$encoding</code><span class="initializer"> = mb_internal_encoding()</span></span>
|
||
]] ) : <span class="type">string</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
根据字符数执行一个多字节安全的 <span class="function"><a href="substr.html" class="function">substr()</a></span> 操作。
|
||
位置是从 <code class="parameter">str</code> 的开始位置进行计数。
|
||
第一个字符的位置是 0。第二个字符的位置是 1,以此类推。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.mb-substr-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">str</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
从该 <span class="type"><a href="language.types.string.html" class="type string">string</a></span> 中提取子字符串。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">start</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
如果 <code class="parameter">start</code> 不是负数,返回的字符串会从 <code class="parameter">str</code> 第 <code class="parameter">start</code> 的位置开始,从 0 开始计数。举个例子,字符串 '<em>abcdef</em>',位置 <em>0</em> 的字符是 '<em>a</em>',位置 <em>2</em> 的字符是
|
||
'<em>c</em>',以此类推。
|
||
</p>
|
||
<p class="para">
|
||
如果 <code class="parameter">start</code> 是负数,返回的字符串是从 <code class="parameter">str</code> 末尾处第 <code class="parameter">start</code> 个字符开始的。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">length</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
<code class="parameter">str</code> 中要使用的最大字符数。如果省略了此参数或者传入了 <em>NULL</em>,则会提取到字符串的尾部。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">encoding</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para"><code class="parameter">encoding</code>
|
||
参数为字符编码。如果省略,则使用内部字符编码。</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.mb-substr-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
<span class="function"><strong>mb_substr()</strong></span> 函数根据 <code class="parameter">start</code> 和 <code class="parameter">length</code> 参数返回 <code class="parameter">str</code> 中指定的部分。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 changelog" id="refsect1-function.mb-substr-changelog">
|
||
<h3 class="title">更新日志</h3>
|
||
<p class="para">
|
||
<table class="doctable informaltable">
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>版本</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td>5.4.8</td>
|
||
<td>
|
||
<code class="parameter">length</code> 传入 <em>NULL</em>,则从 start 提取到字符串的结尾处。
|
||
在之前的版本里,
|
||
<em>NULL</em> 会被当作 <em>0</em> 来处理。
|
||
</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.mb-substr-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="mb_strcut.html" class="function" rel="rdfs-seeAlso">mb_strcut()</a> - 获取字符的一部分</span></li>
|
||
<li class="member"><span class="function"><a href="mb_internal_encoding.html" class="function" rel="rdfs-seeAlso">mb_internal_encoding()</a> - 设置/获取内部字符编码</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
</div></div></div></body></html> |