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

98 lines
4.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>Sets the process title</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.cli-set-process-title" class="refentry">
<div class="refnamediv">
<h1 class="refname">cli_set_process_title</h1>
<p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7)</p><p class="refpurpose"><span class="refname">cli_set_process_title</span> &mdash; <span class="dc-title">Sets the process title</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.cli-set-process-title-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>cli_set_process_title</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$title</code></span>
) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
Sets the process title visible in tools such as <strong class="command">top</strong> and
<strong class="command">ps</strong>. This function is available only in
<a href="features.commandline.html" class="link">CLI</a> mode.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.cli-set-process-title-parameters">
<h3 class="title">参数</h3>
<dl>
<dt>
<code class="parameter">title</code></dt>
<dd>
<p class="para">
The new title.
</p>
</dd>
</dl>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.cli-set-process-title-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 errors" id="refsect1-function.cli-set-process-title-errors">
<h3 class="title">错误/异常</h3>
<p class="para">
An <strong><code>E_WARNING</code></strong> will be generated if the operating system
is unsupported.
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.cli-set-process-title-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-490">
<p><strong>Example #1 <span class="function"><strong>cli_set_process_title()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$title&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"My&nbsp;Amazing&nbsp;PHP&nbsp;Script"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$pid&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getmypid</span><span style="color: #007700">();&nbsp;</span><span style="color: #FF8000">//&nbsp;you&nbsp;can&nbsp;use&nbsp;this&nbsp;to&nbsp;see&nbsp;your&nbsp;process&nbsp;title&nbsp;in&nbsp;ps<br /><br /></span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">cli_set_process_title</span><span style="color: #007700">(</span><span style="color: #0000BB">$title</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Unable&nbsp;to&nbsp;set&nbsp;process&nbsp;title&nbsp;for&nbsp;PID&nbsp;</span><span style="color: #0000BB">$pid</span><span style="color: #DD0000">...\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;exit(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;process&nbsp;title&nbsp;'</span><span style="color: #0000BB">$title</span><span style="color: #DD0000">'&nbsp;for&nbsp;PID&nbsp;</span><span style="color: #0000BB">$pid</span><span style="color: #DD0000">&nbsp;has&nbsp;been&nbsp;set&nbsp;for&nbsp;your&nbsp;process!\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">sleep</span><span style="color: #007700">(</span><span style="color: #0000BB">5</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.cli-set-process-title-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="cli_get_process_title.html" class="function" rel="rdfs-seeAlso">cli_get_process_title()</a> - Returns the current process title</span></li>
<li class="member"><span class="function"><a href="setproctitle.html" class="function" rel="rdfs-seeAlso">setproctitle()</a> - Set the process title</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>