svn: /phpdoc/en/trunk/reference/network/functions/ http-response-code.xml
| From: | Thomas Punt | Date: | Sun, 21 Feb 2016 21:10:12 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/network/functions/ http-response-code.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-14031@lists.php.net to get a copy of this message | ||
tpunt Sun, 21 Feb 2016 21:10:12 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=338620
Log:
Resolve doc bug #71618
Bug: https://bugs.php.net/71618 (Open) http_response_code()
can return bool
Changed paths:
U phpdoc/en/trunk/reference/network/functions/http-response-code.xml
Modified: phpdoc/en/trunk/reference/network/functions/http-response-code.xml
===================================================================
--- phpdoc/en/trunk/reference/network/functions/http-response-code.xml 2016-02-21 12:48:31 UTC (rev
338619)
+++ phpdoc/en/trunk/reference/network/functions/http-response-code.xml 2016-02-21 21:10:12 UTC (rev
338620)
@@ -10,14 +10,12 @@
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
- <type>int</type><methodname>http_response_code</methodname>
+ <type>mixed</type><methodname>http_response_code</methodname>
<methodparam
choice="opt"><type>int</type><parameter>response_code</parameter></methodparam>
</methodsynopsis>
<para>
- If you pass no parameters then http_response_code will get the current status code.
- If you pass a parameter it will set the response code.
+ Gets or sets the HTTP response status code.
</para>
-
</refsect1>
<refsect1 role="parameters">
@@ -30,17 +28,6 @@
<para>
The optional <parameter>response_code</parameter> will set the response code.
</para>
- <para>
- <informalexample>
- <programlisting role="php">
-<![CDATA[
-<?php
-http_response_code(404);
-?>
-]]>
- </programlisting>
- </informalexample>
- </para>
</listitem>
</varlistentry>
</variablelist>
@@ -50,30 +37,72 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
- The current response code. By default the return value is int(200).
+ If <parameter>response_code</parameter> is provided, then the previous
+ status code will be returned. If <parameter>response_code</parameter> is not
+ provided, then the current status code will be returned. Both of these
+ values will default to a <literal>200</literal> status code if used in a web
+ server environment.
</para>
+ <para>
+ &false; will be returned if <parameter>response_code</parameter> is not
+ provided and it is not invoked in a web server environment (such as from a
+ CLI application). &true; will be returned if
+ <parameter>response_code</parameter> is provided and it is not invoked in a
+ web server environment (but only when no previous response status has been
+ set).
+ </para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
- <title>Examples using <function>http_response_code</function></title>
+ <title>Using <function>http_response_code</function> in a web server
environment</title>
<programlisting role="php">
<![CDATA[
<?php
+// Get the current response code and set a new one
+var_dump(http_response_code(404));
+
+// Get the new response code
+var_dump(http_response_code());
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+int(200)
+int(404)
+]]>
+ </screen>
+ </example>
+ <example>
+ <title>Using <function>http_response_code</function> in a CLI
environment</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
// Get the current default response code
-var_dump(http_response_code()); // int(200)
+var_dump(http_response_code());
-// Set our response code
-http_response_code(404);
+// Set a response code
+var_dump(http_response_code(201));
-// Get our new response code
-var_dump(http_response_code()); // int(404)
+// Get the new response code
+var_dump(http_response_code());
?>
]]>
</programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+bool(false)
+bool(true)
+int(201)
+]]>
+ </screen>
</example>
</para>
</refsect1>