mirror of
https://github.com/php/doc-zh.git
synced 2026-03-24 15:12:20 +01:00
130 lines
3.2 KiB
XML
Executable File
130 lines
3.2 KiB
XML
Executable File
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 0c9c2dd669fe9395eaa73d487fbd160f9057429a Maintainer: HonestQiao Status: ready -->
|
|
<!-- CREDITS: mowangjuanzi -->
|
|
<refentry xml:id="function.dechex" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>dechex</refname>
|
|
<refpurpose>十进制转换为十六进制</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>dechex</methodname>
|
|
<methodparam><type>int</type><parameter>num</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
返回一字符串,包含有给定
|
|
<parameter>num</parameter>
|
|
参数的十六进制表示。
|
|
</para>
|
|
<para>
|
|
所能转换的最大数值为十进制的
|
|
<constant>PHP_INT_MAX</constant><literal> * 2 + 1</literal> (或
|
|
<literal>-1</literal>):在 32 位平台上是十进制的 <literal>4294967295</literal>,其 <function>dechex</function> 的结果为 <literal>ffffffff</literal>。
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>num</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
要转换的十进制值
|
|
</para>
|
|
<para>
|
|
PHP 的 <type>int</type> 类型是有符号的,但 <function>dechex</function> 处理无符号整数,负正数会以无符号处理。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<parameter>num</parameter> 的16进制表示
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>dechex</function> 示例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
echo dechex(10) . "\n";
|
|
echo dechex(47);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
a
|
|
2f
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>大整数的 <function>dechex</function> 示例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// 下面的输出假设是 32 位平台。
|
|
// 注意输出的所有值一样。
|
|
echo dechex(-1)."\n";
|
|
echo dechex(PHP_INT_MAX * 2 + 1)."\n";
|
|
echo dechex(pow(2, 32) - 1)."\n";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
ffffffff
|
|
ffffffff
|
|
ffffffff
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>hexdec</function></member>
|
|
<member><function>decbin</function></member>
|
|
<member><function>decoct</function></member>
|
|
<member><function>base_convert</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|