mirror of
https://github.com/php/doc-tr.git
synced 2026-03-24 15:22:23 +01:00
306 lines
8.9 KiB
XML
306 lines
8.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: 8859c8b96cd9e80652813f7bcf561432a5e9f934 Maintainer: nilgun Status: ready -->
|
||
<refentry xml:id="function.stream-notification-callback" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
<refnamediv>
|
||
<refname>stream_notification_callback</refname>
|
||
<refpurpose><literal>notification</literal> bağlam bağımsız değişkeni için bir
|
||
geri çağırım işlevi</refpurpose>
|
||
</refnamediv>
|
||
|
||
<refsect1 role="description"><!-- {{{ -->
|
||
&reftitle.description;
|
||
<methodsynopsis>
|
||
<type>void</type><methodname><replaceable>stream_notification_callback</replaceable></methodname>
|
||
<methodparam><type>int</type><parameter>bildirim_kodu</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>önem</parameter></methodparam>
|
||
<methodparam><type class="union"><type>string</type><type>null</type></type><parameter>ileti</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>ileti_kodu</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>bayt_sayısı</parameter></methodparam>
|
||
<methodparam><type>int</type><parameter>azami_bayt_sayısı</parameter></methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
Bir olay sırasında çağrılmak üzere <literal>notification</literal> <link
|
||
linkend="context.params.notification">bağlam bağımsız değişkeni</link> tarafından
|
||
kullanılan bir geriçağırım işlevi.
|
||
</para>
|
||
<note>
|
||
<para>
|
||
Bu gerçek bir işlev olmayıp, kullanacağınız işlevin bir örneği olarak
|
||
tasarlanmıştır.
|
||
</para>
|
||
</note>
|
||
</refsect1><!-- }}} -->
|
||
|
||
<refsect1 role="parameters"><!-- {{{ -->
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>bildirim_kodu</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
<constant>STREAM_NOTIFY_*</constant> bildirim sabitlerinden biri.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>önem</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
<constant>STREAM_NOTIFY_SEVERITY_*</constant> bildirim sabitlerinden biri.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>ileti</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Olayı açıklayan bir ileti.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>ileti_kodu</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Olay için kullanılabilecek açıklayıcı bir ileti kodu.
|
||
</para>
|
||
<para>
|
||
Bu değerin anlamı kullanılacak sarmalayıcıya bağlıdır.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>bayt_sayısı</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Uygulanabilirse, aktarılacak baytların sayısı.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>azami_bayt_sayısı</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Uygulanabilirse, aktarılacak baytların azami sayısı.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
|
||
</variablelist>
|
||
</para>
|
||
</refsect1><!-- }}} -->
|
||
|
||
<refsect1 role="returnvalues"><!-- {{{ -->
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
&return.void;
|
||
</para>
|
||
</refsect1><!-- }}} -->
|
||
|
||
<refsect1 role="examples"><!-- {{{ -->
|
||
&reftitle.examples;
|
||
<para>
|
||
<example xml:id="stream-notification-callback.example.basic"><!-- {{{ -->
|
||
<title>- <function>stream_notification_callback</function> örneği</title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
function stream_notification_callback($bildirim_kodu, $önem, $ileti,
|
||
$ileti_kodu, $bayt_sayısı, $azami_bayt_sayısı) {
|
||
|
||
switch($bildirim_kodu) {
|
||
case STREAM_NOTIFY_RESOLVE:
|
||
case STREAM_NOTIFY_AUTH_REQUIRED:
|
||
case STREAM_NOTIFY_COMPLETED:
|
||
case STREAM_NOTIFY_FAILURE:
|
||
case STREAM_NOTIFY_AUTH_RESULT:
|
||
var_dump($bildirim_kodu, $önem, $ileti, $ileti_kodu,
|
||
$bayt_sayısı, $azami_bayt_sayısı);
|
||
/* yoksay */
|
||
break;
|
||
|
||
case STREAM_NOTIFY_REDIRECTED:
|
||
echo "Yönlendirildiği yer: ", $ileti;
|
||
break;
|
||
|
||
case STREAM_NOTIFY_CONNECT:
|
||
echo "Bağlandı...";
|
||
break;
|
||
|
||
case STREAM_NOTIFY_FILE_SIZE_IS:
|
||
echo "Alınan dosya boyu: ", $azami_bayt_sayısı;
|
||
break;
|
||
|
||
case STREAM_NOTIFY_MIME_TYPE_IS:
|
||
echo "Bulunan MIME türü: ", $ileti;
|
||
break;
|
||
|
||
case STREAM_NOTIFY_PROGRESS:
|
||
echo "Biraz işlem yapılıp, ", $bayt_sayısı, " bayt indirildi";
|
||
break;
|
||
}
|
||
echo "\n";
|
||
}
|
||
|
||
$ctx = stream_context_create();
|
||
stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));
|
||
|
||
file_get_contents("http://php.net/contact", false, $ctx);
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
&example.outputs.similar;
|
||
<screen>
|
||
<![CDATA[
|
||
Bağlandı...
|
||
Bulunan MIME türü: text/html; charset=utf-8
|
||
Yönlendirildiği yer: http://no.php.net/contact
|
||
Bağlandı...
|
||
Alınan dosya boyu: 0
|
||
Bulunan MIME türü: text/html; charset=utf-8
|
||
Yönlendirildiği yer: http://no.php.net/contact.php
|
||
Bağlandı...
|
||
Alınan dosya boyu: 4589
|
||
Bulunan MIME türü: text/html;charset=utf-8
|
||
Biraz işlem yapılıp, 0 bayt indirildi
|
||
Biraz işlem yapılıp, 0 bayt indirildi
|
||
Biraz işlem yapılıp, 0 bayt indirildi
|
||
Biraz işlem yapılıp, 1440 bayt indirildi
|
||
Biraz işlem yapılıp, 2880 bayt indirildi
|
||
Biraz işlem yapılıp, 4320 bayt indirildi
|
||
Biraz işlem yapılıp, 5760 bayt indirildi
|
||
Biraz işlem yapılıp, 6381 bayt indirildi
|
||
Biraz işlem yapılıp, 7002 bayt indirildi
|
||
]]>
|
||
</screen>
|
||
</example><!-- }}} -->
|
||
</para>
|
||
<para>
|
||
<example xml:id="stream-notification-callback.example.download"><!-- {{{ -->
|
||
<title>- Komut satırı istemcisi için basit bir ilerleme çubuğu</title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
function usage($argv) {
|
||
echo Kullanım:\n";
|
||
printf("\tphp %s <http://example.com/file> <yereldosya>\n", $argv[0]);
|
||
exit(1);
|
||
}
|
||
|
||
function stream_notification_callback($bildirim_kodu, $önem, $ileti,
|
||
$ileti_kodu, $bayt_sayısı, $azami_bayt_sayısı) {
|
||
static $dosyaboyu = null;
|
||
|
||
switch($bildirim_kodu) {
|
||
case STREAM_NOTIFY_RESOLVE:
|
||
case STREAM_NOTIFY_AUTH_REQUIRED:
|
||
case STREAM_NOTIFY_COMPLETED:
|
||
case STREAM_NOTIFY_FAILURE:
|
||
case STREAM_NOTIFY_AUTH_RESULT:
|
||
/* yoksay */
|
||
break;
|
||
|
||
case STREAM_NOTIFY_REDIRECTED:
|
||
echo "Yönlendirildiği yer: ", $ileti, "\n";
|
||
break;
|
||
|
||
case STREAM_NOTIFY_CONNECT:
|
||
echo "Bağlandı...\n";
|
||
break;
|
||
|
||
case STREAM_NOTIFY_FILE_SIZE_IS:
|
||
$dosyaboyu = $azami_bayt_sayısı;
|
||
echo "Dosya uzunluğu: ", $dosyaboyu, "\n";
|
||
break;
|
||
|
||
case STREAM_NOTIFY_MIME_TYPE_IS:
|
||
echo "MIME türü: ", $ileti, "\n";
|
||
break;
|
||
|
||
case STREAM_NOTIFY_PROGRESS:
|
||
if ($bayt_sayısı > 0) {
|
||
if (!isset($dosyaboyu)) {
|
||
printf("\rDosya uzunluğu bilinmiyor... %2d kb alındı..",
|
||
$bayt_sayısı/1024);
|
||
} else {
|
||
$length = (int) (($bayt_sayısı/$dosyaboyu)*100);
|
||
printf("\r[%-100s] %%%d (%2d/%2d kb)", str_repeat("=",
|
||
$length). ">", $length, ($bayt_sayısı/1024), $dosyaboyu/1024);
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
isset($argv[1], $argv[2]) or usage($argv);
|
||
|
||
$ctx = stream_context_create();
|
||
stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));
|
||
|
||
$fp = fopen($argv[1], "r", false, $ctx);
|
||
if (is_resource($fp) && file_put_contents($argv[2], $fp)) {
|
||
echo "\nBitti!\n";
|
||
exit(0);
|
||
}
|
||
|
||
$err = error_get_last();
|
||
echo "\nHataaaa..\n", $err["message"], "\n";
|
||
exit(1);
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
<para>
|
||
Yukarıdaki örneği şu komutla çalıştıralım:
|
||
<literal>php -n fetch.php
|
||
http://no2.php.net/get/php-5-LATEST.tar.bz2/from/this/mirror
|
||
php-latest.tar.bz2</literal>. Çıktı şöyle olacaktır:
|
||
</para>
|
||
<screen>
|
||
<![CDATA[
|
||
Bağlandı...
|
||
MIME türü: text/html; charset=utf-8
|
||
Yönlendirildiği yer: http://no2.php.net/distributions/php-5.2.5.tar.bz2
|
||
Bağlandı...
|
||
Dosya uzunluğu: 7773024
|
||
MIME türü: application/octet-stream
|
||
[===============> ] %40 (3076/7590 kb)
|
||
]]>
|
||
</screen>
|
||
</example>
|
||
</para>
|
||
</refsect1><!-- }}} -->
|
||
|
||
<refsect1 role="seealso"><!-- {{{ -->
|
||
&reftitle.seealso;
|
||
<para>
|
||
<simplelist>
|
||
<member><xref linkend="context.params" /></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
|
||
-->
|
||
|