mirror of
https://github.com/php/doc-es.git
synced 2026-03-25 16:02:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@334646 c90b9560-bf6c-de11-be94-00142212c4b1
144 lines
4.0 KiB
XML
144 lines
4.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 8b5940cadeb4f1c8492f4a7f70743a2be807cf39 Maintainer: andresdzphp Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<refentry xml:id="function.headers-sent" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>headers_sent</refname>
|
|
<refpurpose>Comprueba si o donde han enviado cabeceras</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>headers_sent</methodname>
|
|
<methodparam choice="opt"><type>string</type><parameter role="reference">file</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter role="reference">line</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Comprueba si o donde han enviado cabeceras.
|
|
</para>
|
|
<para>
|
|
No se puede agregar más líneas de cabecera con la función <function>header</function>
|
|
una vez que el bloque de cabecera ya ha sido enviado. Con esta función se puede
|
|
evitar recibir mensajes de error relacionados con cabecera HTTP.
|
|
Otra opción es utilizar <link linkend="ref.outcontrol">Output Buffering</link>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>file</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Si los parámetros opcionales <parameter>file</parameter> y
|
|
<parameter>line</parameter> se establecen,
|
|
<function>headers_sent</function> pondrá el nombre del archivo PHP
|
|
y número de línea donde la producción se inició en las variables
|
|
<parameter>file</parameter> y <parameter>line</parameter>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>line</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El número de línea donde inició la salida.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<function>headers_sent</function> retornará &false; Si no se han
|
|
enviado encabezados HTTP o de lo contrario &true;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplos usando <function>headers_sent</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// Si no se han enviado encabezados, enviar uno
|
|
if (!headers_sent()) {
|
|
header('Location: http://www.example.com/');
|
|
exit;
|
|
}
|
|
|
|
// Un ejemplo usando los parámetros opcionales file y line, a partir de PHP 4.3.0
|
|
// Tenga en cuenta que $filename y $linenum se pasan para su posterior uso.
|
|
// No asigne los valores de antemano.
|
|
if (!headers_sent($filename, $linenum)) {
|
|
header('Location: http://www.example.com/');
|
|
exit;
|
|
|
|
// Lo más probable es generar un error aquí.
|
|
} else {
|
|
|
|
echo "Headers already sent in $filename on line $linenum\n" .
|
|
"Cannot redirect, for now please click this <a " .
|
|
"href=\"http://www.example.com\">link</a> instead\n";
|
|
exit;
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.network.header.sapi;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>ob_start</function></member>
|
|
<member><function>trigger_error</function></member>
|
|
<member><function>headers_list</function></member>
|
|
<member>
|
|
<function>header</function> para una discusión más detallada de los asuntos planteados.
|
|
</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
|
|
-->
|