mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Expand the examples a little, also not rely on register_globals.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@112821 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
012b14e6c6
commit
25affde9f0
1 changed files with 31 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- splitted from ./en/functions/http.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.setcookie">
|
||||
<refnamediv>
|
||||
|
@ -95,9 +95,13 @@
|
|||
<title><function>setcookie</function> send examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$value = 'something from somewhere';
|
||||
|
||||
setcookie ("TestCookie", $value);
|
||||
setcookie ("TestCookie", $value,time()+3600); /* expire in 1 hour */
|
||||
setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".utoronto.ca", 1);
|
||||
setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".example.com", 1);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@ -110,9 +114,11 @@ setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".utoronto.ca", 1);
|
|||
<title><function>setcookie</function> delete examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// set the expiration date to one hour ago
|
||||
setcookie ("TestCookie", "", time() - 3600);
|
||||
setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".utoronto.ca", 1);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@ -126,8 +132,14 @@ setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".utoronto.ca", 1);
|
|||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
echo $TestCookie;
|
||||
<?php
|
||||
// Print an individual cookie
|
||||
echo $_COOKIE["TestCookie"];
|
||||
echo $HTTP_COOKIE_VARS["TestCookie"];
|
||||
|
||||
// Another way to debug/test is to view all cookies
|
||||
print_r($_COOKIE);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
@ -141,14 +153,27 @@ echo $_COOKIE["TestCookie"];
|
|||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// set the cookies
|
||||
setcookie ("cookie[three]", "cookiethree");
|
||||
setcookie ("cookie[two]", "cookietwo");
|
||||
setcookie ("cookie[one]", "cookieone");
|
||||
if (isset ($cookie)) {
|
||||
while (list ($name, $value) = each ($cookie)) {
|
||||
echo "$name == $value<br>\n";
|
||||
|
||||
// after the page reloads, print them out
|
||||
if (isset($_COOKIE['cookie'])) {
|
||||
foreach ($_COOKIE['cookie'] as $name => $value) {
|
||||
echo "$name : $value <br />\n";
|
||||
}
|
||||
}
|
||||
|
||||
/* which prints
|
||||
|
||||
three : cookiethree
|
||||
two : cookietwo
|
||||
one : cookieone
|
||||
|
||||
*/
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
|
Loading…
Reference in a new issue