mirror of
https://github.com/php/doc-pl.git
synced 2026-03-25 15:42:11 +01:00
182 lines
5.0 KiB
XML
182 lines
5.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 099842f34289b4cf932863e1f83d0e9a144d3b06 Maintainer: sobak Status: ready -->
|
|
<!-- $Revision$ -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.printf">
|
|
<refnamediv>
|
|
<refname>printf</refname>
|
|
<refpurpose>Wyświetla sformatowany ciąg znaków</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>printf</methodname>
|
|
<methodparam><type>string</type><parameter>format</parameter></methodparam>
|
|
<methodparam rep="repeat"><type>mixed</type><parameter>values</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
Tworzy wyjście zgodnie z podanym <parameter>format</parameter>em.
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
&strings.parameter.format;
|
|
<varlistentry>
|
|
<term><parameter>values</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Zwraca długość wyświetlonego ciągu znaków.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
&strings.errors.sprintf;
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
&strings.changelog.sprintf;
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>printf</function>: różne przykłady</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$n = 43951789;
|
|
$u = -43951789;
|
|
$c = 65; // ASCII 65 to 'A'
|
|
|
|
// zwróć uwagę na podwójne %%, wyświetli to znak '%'
|
|
printf("%%b = '%b'\n", $n); // reprezentacja binarna
|
|
printf("%%c = '%c'\n", $c); // wyświetl znak ascii, działa tak jak funkcja chr()
|
|
printf("%%d = '%d'\n", $n); // standardowa reprezentacja liczby całkowitej
|
|
printf("%%e = '%e'\n", $n); // notacja naukowa
|
|
printf("%%u = '%u'\n", $n); // reprezentacja dodatniej liczby całkowitej bez znaku
|
|
printf("%%u = '%u'\n", $u); // reprezentacja ujemnej liczby całkowitej bez znaku
|
|
printf("%%f = '%f'\n", $n); // reprezentacja zmiennoprzecinkowa
|
|
printf("%%o = '%o'\n", $n); // reprezentacja ósemkowa
|
|
printf("%%s = '%s'\n", $n); // reprezentacja jako ciąg znaków
|
|
printf("%%x = '%x'\n", $n); // reprezentacja szesnastkowa (małe litery)
|
|
printf("%%X = '%X'\n", $n); // reprezentacja szesnastkowa (duże litery)
|
|
|
|
printf("%%+d = '%+d'\n", $n); // znak (plus/minus) liczby dodatniej
|
|
printf("%%+d = '%+d'\n", $u); // znak (plus/minus) liczby ujemnej
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
%b = '10100111101010011010101101'
|
|
%c = 'A'
|
|
%d = '43951789'
|
|
%e = '4.39518e+7'
|
|
%u = '43951789'
|
|
%u = '4251015507'
|
|
%f = '43951789.000000'
|
|
%o = '247523255'
|
|
%s = '43951789'
|
|
%x = '29ea6ad'
|
|
%X = '29EA6AD'
|
|
%+d = '+43951789'
|
|
%+d = '-43951789'
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
|
|
<example>
|
|
<title><function>printf</function>: znaki formatujące dla ciągów znaków</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$s = 'monkey';
|
|
$t = 'many monkeys';
|
|
|
|
printf("[%s]\n", $s); // standardowe wyjście ciągu znaków
|
|
printf("[%10s]\n", $s); // wyrównanie spacjami do prawej
|
|
printf("[%-10s]\n", $s); // wyrównanie spacjami do lewej
|
|
printf("[%010s]\n", $s); // dopełnianie zerami działa też dla ciągów znaków
|
|
printf("[%'#10s]\n", $s); // użycie własnego znaku dopełniającego: '#'
|
|
printf("[%'#*s]\n", 10, $s); // szerokość dopełnienia podana jako argument
|
|
printf("[%10.9s]\n", $t); // wyrównanie do prawej, ale odetnij resztę po 8 znakach
|
|
printf("[%-10.9s]\n", $t); // wyrównanie do lewej, ale odetnij resztę po 8 znakach
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
[monkey]
|
|
[ monkey]
|
|
[monkey ]
|
|
[0000monkey]
|
|
[####monkey]
|
|
[####monkey]
|
|
[ many monk]
|
|
[many monk ]
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>print</function></member>
|
|
<member><function>sprintf</function></member>
|
|
<member><function>fprintf</function></member>
|
|
<member><function>vprintf</function></member>
|
|
<member><function>vsprintf</function></member>
|
|
<member><function>vfprintf</function></member>
|
|
<member><function>sscanf</function></member>
|
|
<member><function>fscanf</function></member>
|
|
<member><function>number_format</function></member>
|
|
<member><function>date</function></member>
|
|
<member><function>flush</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
|
|
-->
|