PageRenderTime 54ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/xml/language/variables.xml

http://phpdoc-zh.googlecode.com/
XML | 948 lines | 801 code | 123 blank | 24 comment | 0 complexity | 6823aed953c11d52c8d6eb856d71dff8 MD5 | raw file
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- $Revision: 324974 $ -->
  3. <!-- EN-Revision: 324522 Maintainer: HonestQiao Status: ready -->
  4. <!-- Reviewed: no Maintainer: HonestQiao -->
  5. <!-- CREDITS: dallas, Gregory, verdana -->
  6. <chapter xml:id="language.variables" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
  7. <title>??</title>
  8. <sect1 xml:id="language.variables.basics">
  9. <title>??</title>
  10. <simpara>
  11. PHP ????????????????????????????????
  12. </simpara>
  13. <para>
  14. ???? PHP
  15. ??????????????????????????????????????????????????????????????????????????'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'?
  16. </para>
  17. <note>
  18. <simpara>
  19. ???????? a-z?A-Z??? ASCII ??? 127 ? 255?0x7f-0xff??
  20. </simpara>
  21. </note>
  22. <note>
  23. <simpara>
  24. <literal>$this</literal> ????????????????
  25. </simpara>
  26. </note>
  27. &tip.userlandnaming;
  28. <para>
  29. ??????????<link linkend="ref.var">????</link>?
  30. </para>
  31. <para>
  32. <informalexample>
  33. <programlisting role="php">
  34. <![CDATA[
  35. <?php
  36. $var = 'Bob';
  37. $Var = 'Joe';
  38. echo "$var, $Var"; // ?? "Bob, Joe"
  39. $4site = 'not yet'; // ???????????
  40. $_4site = 'not yet'; // ????????????
  41. $i??is = 'mansikka'; // ???????????
  42. ?>
  43. ]]>
  44. </programlisting>
  45. </informalexample>
  46. </para>
  47. <para>
  48. ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????<link linkend="language.expressions">???</link>???
  49. </para>
  50. <para>
  51. PHP ????????????????<link linkend="language.references">????</link>???????????????????????? ?? ?????????????????????????????
  52. </para>
  53. <para>
  54. ????????????? &amp;
  55. ??????????????????????????????My name is Bob???
  56. <informalexample>
  57. <programlisting role="php">
  58. <![CDATA[
  59. <?php
  60. $foo = 'Bob'; // ? 'Bob' ?? $foo
  61. $bar = &$foo; // ?? $bar ?? $foo
  62. $bar = "My name is $bar"; // ?? $bar ??
  63. echo $bar;
  64. echo $foo; // $foo ??????
  65. ?>
  66. ]]>
  67. </programlisting>
  68. </informalexample>
  69. </para>
  70. <para>
  71. ???????????????????????????????
  72. <informalexample>
  73. <programlisting role="php">
  74. <![CDATA[
  75. <?php
  76. $foo = 25;
  77. $bar = &$foo; // ?????
  78. $bar = &(24 * 7); // ??; ??????????
  79. function test()
  80. {
  81. return 25;
  82. }
  83. $bar = &test(); // ??
  84. ?>
  85. ]]>
  86. </programlisting>
  87. </informalexample>
  88. </para>
  89. <para>
  90. ??? PHP ?????????????????????????????????????????? - ???????????
  91. &false;????????????????????????????????????????????
  92. </para>
  93. <para>
  94. <example>
  95. <title>??????????</title>
  96. <programlisting role="php">
  97. <![CDATA[
  98. <?php
  99. // Unset AND unreferenced (no use context) variable; outputs NULL
  100. var_dump($unset_var);
  101. // Boolean usage; outputs 'false' (See ternary operators for more on this syntax)
  102. echo($unset_bool ? "true\n" : "false\n");
  103. // String usage; outputs 'string(3) "abc"'
  104. $unset_str .= 'abc';
  105. var_dump($unset_str);
  106. // Integer usage; outputs 'int(25)'
  107. $unset_int += 25; // 0 + 25 => 25
  108. var_dump($unset_int);
  109. // Float/double usage; outputs 'float(1.25)'
  110. $unset_float += 1.25;
  111. var_dump($unset_float);
  112. // Array usage; outputs array(1) { [3]=> string(3) "def" }
  113. $unset_arr[3] = "def"; // array() + array(3 => "def") => array(3 => "def")
  114. var_dump($unset_arr);
  115. // Object usage; creates new stdClass object (see http://www.php.net/manual/en/reserved.classes.php)
  116. // Outputs: object(stdClass)#1 (1) { ["foo"]=> string(3) "bar" }
  117. $unset_obj->foo = 'bar';
  118. var_dump($unset_obj);
  119. ?>
  120. ]]>
  121. </programlisting>
  122. </example>
  123. </para>
  124. <para>
  125. ???????????????????????????????????????????????????
  126. <link linkend="ini.register-globals">register_globals</link> ????????<link
  127. linkend="security.globals">????</link>?????????????<link
  128. linkend="errorfunc.constants.errorlevels.e-notice">E_NOTICE</link>????????????????????????<function>isset</function>
  129. ??????????????????????
  130. </para>
  131. </sect1>
  132. <sect1 xml:id="language.variables.predefined">
  133. <title>?????</title>
  134. <simpara>
  135. PHP ?????????????????????????????????????????????????????????????
  136. PHP ?<link linkend="features.commandline">???</link>?????????????????????????<link
  137. linkend="reserved.variables">?????</link>???
  138. </simpara>
  139. <warning>
  140. <simpara>
  141. PHP 4.2.0 ????????PHP ?? <link
  142. linkend="ini.register-globals">register_globals</link> ?????
  143. <emphasis>off</emphasis>??? PHP ????????? register_globals ???
  144. <emphasis>off</emphasis> ????????????????????????????
  145. <varname>DOCUMENT_ROOT</varname> ????????
  146. <varname>$_SERVER['DOCUMENT_ROOT']</varname> ??
  147. <varname>$DOCUMENT_ROOT</varname>??????
  148. <varname>$_GET['id']</varname> ??? <varname>$id</varname> ? URL
  149. <literal>http://www.example.com/test.php?id=3</literal> ???
  150. id ?????? <varname>$_ENV['HOME']</varname> ???
  151. <varname>$HOME</varname> ?????? HOME ???
  152. </simpara>
  153. <simpara>
  154. ?????????? <link
  155. linkend="ini.register-globals">register_globals</link>
  156. ?????????????<link
  157. linkend="security.globals">?? Register Globals</link>??? PHP
  158. <link xlink:href="&url.php.release4.1.0;">4.1.0</link> ?
  159. <link xlink:href="&url.php.release4.2.0;">4.2.0</link> ??????
  160. </simpara>
  161. <simpara>
  162. ?????? PHP ???????????<link
  163. linkend="language.variables.superglobals">?????</link>?
  164. </simpara>
  165. </warning>
  166. <simpara>
  167. ? PHP 4.1.0 ???PHP ???????????????????????? web
  168. ??????????????????????????????????????????????????????????????????????????autoglobals?????????superglobals???PHP
  169. ????????????????????????????????????????????
  170. PHP ???????????????????????<link
  171. linkend="reserved.variables">?????</link>??????????????????<varname>$HTTP_*_VARS</varname>??????&avail.register-long-arrays;
  172. </simpara>
  173. <note>
  174. <title>????</title>
  175. <para>
  176. ???????????<link linkend="language.variables.variable">????</link>?
  177. </para>
  178. </note>
  179. <note>
  180. <para>
  181. ???????? HTTP_*_VARS
  182. ??????????????????????????????????????
  183. </para>
  184. </note>
  185. <para>
  186. ???? <link linkend="ini.variables-order">variables_order</link>
  187. ??????????????? PHP ??????????
  188. </para>
  189. </sect1>
  190. <sect1 xml:id="language.variables.scope">
  191. <title>????</title>
  192. <simpara>
  193. ???????????????????????????????
  194. PHP ??????????????????????????
  195. include ? require ?????????
  196. </simpara>
  197. <informalexample>
  198. <programlisting role="php">
  199. <![CDATA[
  200. <?php
  201. $a = 1;
  202. include 'b.inc';
  203. ?>
  204. ]]>
  205. </programlisting>
  206. </informalexample>
  207. <simpara>
  208. ???? <varname>$a</varname> ???????
  209. <filename>b.inc</filename> ??????????????????????????????????????????????????????????????
  210. </simpara>
  211. <informalexample>
  212. <programlisting role="php">
  213. <![CDATA[
  214. <?php
  215. $a = 1; /* global scope */
  216. function Test()
  217. {
  218. echo $a; /* reference to local scope variable */
  219. }
  220. Test();
  221. ?>
  222. ]]>
  223. </programlisting>
  224. </informalexample>
  225. <simpara>
  226. ?????????????? echo ??????????????
  227. <varname>$a</varname>????????????????????????
  228. PHP ?????? C ?????????? C
  229. ????????????????????????????????????????????????????????PHP
  230. ?????????????????global?
  231. </simpara>
  232. <sect2 xml:id="language.variables.scope.global">
  233. <title>global ???</title>
  234. <simpara>
  235. ??????? <literal>global</literal> ????
  236. </simpara>
  237. <para>
  238. <example>
  239. <title>?? global</title>
  240. <programlisting role="php">
  241. <![CDATA[
  242. <?php
  243. $a = 1;
  244. $b = 2;
  245. function Sum()
  246. {
  247. global $a, $b;
  248. $b = $a + $b;
  249. }
  250. Sum();
  251. echo $b;
  252. ?>
  253. ]]>
  254. </programlisting>
  255. </example>
  256. </para>
  257. <simpara>
  258. ?????????3????????????
  259. <varname>$a</varname> ? <varname>$b</varname>???????????????????????????????????????????PHP ?????
  260. </simpara>
  261. <simpara>
  262. ?????????????????????? PHP ???
  263. <varname>$GLOBALS</varname> ?????????????
  264. </simpara>
  265. <para>
  266. <example>
  267. <title>?? <varname>$GLOBALS</varname> ?? global</title>
  268. <programlisting role="php">
  269. <![CDATA[
  270. <?php
  271. $a = 1;
  272. $b = 2;
  273. function Sum()
  274. {
  275. $GLOBALS['b'] = $GLOBALS['a'] + $GLOBALS['b'];
  276. }
  277. Sum();
  278. echo $b;
  279. ?>
  280. ]]>
  281. </programlisting>
  282. </example>
  283. </para>
  284. <simpara>
  285. <varname>$GLOBALS</varname>
  286. ????????????????????????????????????<varname>$GLOBALS</varname>
  287. ??????????????? $GLOBALS ???<link
  288. linkend="language.variables.superglobals">?????</link>?????????????????
  289. </simpara>
  290. <para>
  291. <example>
  292. <title>??????????????</title>
  293. <programlisting role="php">
  294. <![CDATA[
  295. <?php
  296. function test_global()
  297. {
  298. // ??????????? "super"?????? 'global' ???????????????????
  299. global $HTTP_POST_VARS;
  300. echo $HTTP_POST_VARS['name'];
  301. // Superglobals ???????????????? 'global' ???Superglobals ?? PHP 4.1.0 ????
  302. echo $_POST['name'];
  303. }
  304. ?>
  305. ]]>
  306. </programlisting>
  307. </example>
  308. </para>
  309. </sect2>
  310. <sect2 xml:id="language.variables.scope.static">
  311. <title>??????</title>
  312. <simpara>
  313. ?????????????<emphasis>????</emphasis>?static
  314. variable??????????????????????????????????????????????
  315. </simpara>
  316. <para>
  317. <example>
  318. <title>???????????</title>
  319. <programlisting role="php">
  320. <![CDATA[
  321. <?php
  322. function Test()
  323. {
  324. $a = 0;
  325. echo $a;
  326. $a++;
  327. }
  328. ?>
  329. ]]>
  330. </programlisting>
  331. </example>
  332. </para>
  333. <simpara>
  334. ???????????????????
  335. <varname>$a</varname> ???? <literal>0</literal> ???
  336. &quot;0&quot;??????? <varname>$a</varname>++
  337. ?????????????????
  338. <varname>$a</varname> ?????????????????????????????
  339. <varname>$a</varname> ???????
  340. </simpara>
  341. <para>
  342. <example>
  343. <title>?????????</title>
  344. <programlisting role="php">
  345. <![CDATA[
  346. <?php
  347. function test()
  348. {
  349. static $a = 0;
  350. echo $a;
  351. $a++;
  352. }
  353. ?>
  354. ]]>
  355. </programlisting>
  356. </example>
  357. </para>
  358. <simpara>
  359. ?????<varname>$a</varname>?????test()?????????? test() ??????
  360. <varname>$a</varname> ??????
  361. </simpara>
  362. <simpara>
  363. ???????????????????????????????????????????????????????????????????????????????????????
  364. 10???????
  365. <varname>$count</varname> ????????
  366. </simpara>
  367. <para>
  368. <example>
  369. <title>?????????</title>
  370. <programlisting role="php">
  371. <![CDATA[
  372. <?php
  373. function test()
  374. {
  375. static $count = 0;
  376. $count++;
  377. echo $count;
  378. if ($count < 10) {
  379. test();
  380. }
  381. $count--;
  382. }
  383. ?>
  384. ]]>
  385. </programlisting>
  386. </example>
  387. </para>
  388. <note>
  389. <para>
  390. ?????????????????????????????????????????
  391. </para>
  392. <para>
  393. <example>
  394. <title>??????</title>
  395. <programlisting role="php">
  396. <![CDATA[
  397. <?php
  398. function foo(){
  399. static $int = 0; // correct
  400. static $int = 1+2; // wrong (as it is an expression)
  401. static $int = sqrt(121); // wrong (as it is an expression too)
  402. $int++;
  403. echo $int;
  404. }
  405. ?>
  406. ]]>
  407. </programlisting>
  408. </example>
  409. </para>
  410. </note>
  411. </sect2>
  412. <sect2 xml:id="language.variables.scope.references">
  413. <title>??????????</title>
  414. <simpara>
  415. ? Zend ?? 1 ?????? PHP4??????
  416. <link linkend="language.variables.scope.static">static</link> ?
  417. <link linkend="language.variables.scope.global">global</link>
  418. ???? <link linkend="language.references">references</link>
  419. ???????????????????
  420. <literal>global</literal>
  421. ????????????????????????????????????????????????????????
  422. </simpara>
  423. <informalexample>
  424. <programlisting role="php">
  425. <![CDATA[
  426. <?php
  427. function test_global_ref() {
  428. global $obj;
  429. $obj = &new stdclass;
  430. }
  431. function test_global_noref() {
  432. global $obj;
  433. $obj = new stdclass;
  434. }
  435. test_global_ref();
  436. var_dump($obj);
  437. test_global_noref();
  438. var_dump($obj);
  439. ?>
  440. ]]>
  441. </programlisting>
  442. </informalexample>
  443. &example.outputs;
  444. <screen>
  445. NULL
  446. object(stdClass)(0) {
  447. }
  448. </screen>
  449. <simpara>
  450. ?????????
  451. <literal>static</literal> ???????????????
  452. </simpara>
  453. <informalexample>
  454. <programlisting role="php">
  455. <![CDATA[
  456. <?php
  457. function &get_instance_ref() {
  458. static $obj;
  459. echo 'Static object: ';
  460. var_dump($obj);
  461. if (!isset($obj)) {
  462. // ????????????
  463. $obj = &new stdclass;
  464. }
  465. $obj->property++;
  466. return $obj;
  467. }
  468. function &get_instance_noref() {
  469. static $obj;
  470. echo 'Static object: ';
  471. var_dump($obj);
  472. if (!isset($obj)) {
  473. // ????????????
  474. $obj = new stdclass;
  475. }
  476. $obj->property++;
  477. return $obj;
  478. }
  479. $obj1 = get_instance_ref();
  480. $still_obj1 = get_instance_ref();
  481. echo "\n";
  482. $obj2 = get_instance_noref();
  483. $still_obj2 = get_instance_noref();
  484. ?>
  485. ]]>
  486. </programlisting>
  487. </informalexample>
  488. &example.outputs;
  489. <screen>
  490. Static object: NULL
  491. Static object: NULL
  492. Static object: NULL
  493. Static object: object(stdClass)(1) {
  494. ["property"]=>
  495. int(1)
  496. }
  497. </screen>
  498. <simpara>
  499. ???????????????????????????
  500. <literal>&amp;get_instance_ref()</literal> ?????????<emphasis>??</emphasis>?
  501. </simpara>
  502. </sect2>
  503. </sect1>
  504. <sect1 xml:id="language.variables.variable">
  505. <title>????</title>
  506. <simpara>
  507. ?????????????????????????????????????????????????????????
  508. </simpara>
  509. <informalexample>
  510. <programlisting role="php">
  511. <![CDATA[
  512. <?php
  513. $a = 'hello';
  514. ?>
  515. ]]>
  516. </programlisting>
  517. </informalexample>
  518. <simpara>
  519. ?????????????????????????????????????
  520. <emphasis>hello</emphasis> ??????????$???????????????????????
  521. </simpara>
  522. <informalexample>
  523. <programlisting role="php">
  524. <![CDATA[
  525. <?php
  526. $$a = 'world';
  527. ?>
  528. ]]>
  529. </programlisting>
  530. </informalexample>
  531. <simpara>
  532. ?????????????<varname>$a</varname> ????hello??
  533. <varname>$hello</varname> ????world??????????
  534. </simpara>
  535. <informalexample>
  536. <programlisting role="php">
  537. <![CDATA[
  538. <?php
  539. echo "$a ${$a}";
  540. ?>
  541. ]]>
  542. </programlisting>
  543. </informalexample>
  544. <simpara>
  545. ??????????????????
  546. </simpara>
  547. <informalexample>
  548. <programlisting role="php">
  549. <![CDATA[
  550. <?php
  551. echo "$a $hello";
  552. ?>
  553. ]]>
  554. </programlisting>
  555. </informalexample>
  556. <simpara>
  557. ???????<computeroutput>hello world</computeroutput>?
  558. </simpara>
  559. <simpara>
  560. ???????????????????????????????
  561. <varname>$$a[1]</varname>
  562. ????????????
  563. <varname>$a[1]</varname>
  564. ????????????
  565. <varname>$$a</varname>
  566. ???????????????? [1]
  567. ????????????????????
  568. <varname>${$a[1]}</varname>????????
  569. <varname>${$a}[1]</varname>?
  570. </simpara>
  571. <warning>
  572. <simpara>
  573. ???? PHP ??????????<link
  574. linkend="language.variables.superglobals">?????</link>?????????
  575. </simpara>
  576. </warning>
  577. </sect1>
  578. <sect1 xml:id="language.variables.external">
  579. <title>?? PHP ?????</title>
  580. <sect2 xml:id="language.variables.external.form">
  581. <title>HTML ???GET ? POST?</title>
  582. <simpara>
  583. ???????? PHP
  584. ??????????????????????????????????
  585. </simpara>
  586. <para>
  587. <example>
  588. <title>????? HTML ??</title>
  589. <programlisting role="html">
  590. <![CDATA[
  591. <form action="foo.php" method="POST">
  592. Name: <input type="text" name="username"><br />
  593. Email: <input type="text" name="email"><br />
  594. <input type="submit" name="submit" value="Submit me!" />
  595. </form>
  596. ]]>
  597. </programlisting>
  598. </example>
  599. </para>
  600. <para>
  601. ?????????????????????? HTML
  602. ??????????
  603. </para>
  604. <para>
  605. <example>
  606. <title>?????? POST HTML ??????</title>
  607. <programlisting role="html">
  608. <![CDATA[
  609. <?php
  610. // ? PHP 4.1.0 ???
  611. echo $_POST['username'];
  612. echo $_REQUEST['username'];
  613. import_request_variables('p', 'p_');
  614. echo $p_username;
  615. // PHP 6??????? PHP 5.0.0 ????????????
  616. // ?? register_long_arrays ?????
  617. echo $HTTP_POST_VARS['username'];
  618. // ?? PHP ?? register_globals = on ???????
  619. // PHP 4.2.0 ????? register_globals = off?
  620. // ?????/???????
  621. echo $username;
  622. ?>
  623. ]]>
  624. </programlisting>
  625. </example>
  626. </para>
  627. <para>
  628. ?? GET ?????????????? GET ??????GET
  629. ????
  630. QUERY_STRING?URL ?????????????????<literal>http://www.example.com/test.php?id=3</literal>
  631. ????? <varname>$_GET['id']</varname>
  632. ??? GET ?????
  633. <link linkend="reserved.variables.request">$_REQUEST</link> ?
  634. <function>import_request_variables</function>?
  635. </para>
  636. <note>
  637. <para>
  638. <link linkend="language.variables.superglobals">?????</link>?
  639. <varname>$_POST</varname> ?? <varname>$_GET</varname> ????
  640. PHP 4.1.0 ????
  641. </para>
  642. </note>
  643. <para>
  644. ?????? PHP 4.2.0 ?? <link
  645. linkend="ini.register-globals">register_globals</link>
  646. ?????
  647. <emphasis>on</emphasis>?PHP
  648. ????????????????????????
  649. <emphasis>off</emphasis>?
  650. </para>
  651. <note>
  652. <para>
  653. <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link>
  654. ???????
  655. Get?Post ? Cookie ????????? (It's "PHP!") ??????
  656. (It\'s \"PHP!\")???????????????
  657. <function>addslashes</function>?<function>stripslashes</function> ?
  658. <link linkend="ini.magic-quotes-sybase">magic_quotes_sybase</link>?
  659. </para>
  660. </note>
  661. <simpara>
  662. PHP ?????????????????<link
  663. linkend="faq.html">??????</link>????????????????????????????????????????? POST ?????????????
  664. </simpara>
  665. <para>
  666. <example>
  667. <title>????????</title>
  668. <programlisting role="php">
  669. <![CDATA[
  670. <?php
  671. if (isset($_POST['action']) && $_POST['action'] == 'submitted') {
  672. echo '<pre>';
  673. print_r($_POST);
  674. echo '<a href="'. $_SERVER['PHP_SELF'] .'">Please try again</a>';
  675. echo '</pre>';
  676. } else {
  677. ?>
  678. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  679. Name: <input type="text" name="personal[name]"><br />
  680. Email: <input type="text" name="personal[email]"><br />
  681. Beer: <br>
  682. <select multiple name="beer[]">
  683. <option value="warthog">Warthog</option>
  684. <option value="guinness">Guinness</option>
  685. <option value="stuttgarter">Stuttgarter Schwabenbr</option>
  686. </select><br />
  687. <input type="hidden" name="action" value="submitted" />
  688. <input type="submit" name="submit" value="submit me!" />
  689. </form>
  690. <?php
  691. }
  692. ?>
  693. ]]>
  694. </programlisting>
  695. </example>
  696. </para>
  697. <sect3 xml:id="language.variables.external.form.submit">
  698. <title>IMAGE SUBMIT ???</title>
  699. <simpara>
  700. ?????????????????????????????????
  701. </simpara>
  702. <informalexample>
  703. <programlisting role="html">
  704. <![CDATA[
  705. <input type="image" src="image.gif" name="sub" />
  706. ]]>
  707. </programlisting>
  708. </informalexample>
  709. <simpara>
  710. ???????????????????????????????????
  711. sub_x ? sub_y???????????????????????????????????????????????????????
  712. sub.x ? sub.y??? PHP ????????????
  713. </simpara>
  714. </sect3>
  715. </sect2>
  716. <sect2 xml:id="language.variables.external.cookies">
  717. <title>HTTP Cookies</title>
  718. <simpara>
  719. PHP ????? <link
  720. xlink:href="&url.rfc;6265">RFC 6265</link>????
  721. HTTP cookies?Cookies
  722. ???????????????????????????????????
  723. <function>setcookie</function>
  724. ???? cookies?Cookies ?
  725. HTTP ???????????
  726. SetCookie ??????????????????????
  727. <function>header</function> ??????????Cookie
  728. ??????? cookie ??????????
  729. <varname>$_COOKIE</varname>?<varname>$HTTP_COOKIE_VARS</varname> ?
  730. <varname>$_REQUEST</varname>?????????
  731. <function>setcookie</function> ?????
  732. </simpara>
  733. <simpara>
  734. ??????????? cookie ???????????????
  735. </simpara>
  736. <informalexample>
  737. <programlisting role="php">
  738. <![CDATA[
  739. <?php
  740. setcookie("MyCookie[foo]", 'Testing 1', time()+3600);
  741. setcookie("MyCookie[bar]", 'Testing 2', time()+3600);
  742. ?>
  743. ]]>
  744. </programlisting>
  745. </informalexample>
  746. <simpara>
  747. ?????????? cookie??? MyCookie
  748. ????????????????????? cookie
  749. ???????????????
  750. <function>serialize</function> ?
  751. <function>explode</function>?
  752. </simpara>
  753. <simpara>
  754. ????????? cookie ??????????
  755. cookie??????????????????????????????????????
  756. </simpara>
  757. <example>
  758. <title>?? <function>setcookie</function> ???</title>
  759. <programlisting role="php">
  760. <![CDATA[
  761. <?php
  762. if (isset($_COOKIE['count'])) {
  763. $count = $_COOKIE['count'] + 1;
  764. } else {
  765. $count = 1;
  766. }
  767. setcookie('count', $count, time()+3600);
  768. setcookie("Cart[$count]", $item, time()+3600);
  769. ?>
  770. ]]>
  771. </programlisting>
  772. </example>
  773. </sect2>
  774. <sect2 xml:id="language.variables.external.dot-in-names">
  775. <title>??????</title>
  776. <para>
  777. ???PHP ?????????????????????????????
  778. PHP ??????????????????
  779. <programlisting role="php">
  780. <![CDATA[
  781. <?php
  782. $varname.ext; /* ????? */
  783. ?>
  784. ]]>
  785. </programlisting>
  786. ?????????????
  787. <varname>$varname</varname>
  788. ?????????????????????????????????????????????????????????'ext'?????????????
  789. </para>
  790. <para>
  791. ????????? PHP
  792. ??????????????????
  793. </para>
  794. </sect2>
  795. <sect2 xml:id="language.variables.determining-type-of">
  796. <title>??????</title>
  797. <para>
  798. ?? PHP ??????????????????????????????????????????????PHP
  799. ???????????????????<function>gettype</function>?<function>is_array</function>?<function>is_float</function>?<function>is_int</function>?<function>is_object</function> ?
  800. <function>is_string</function>???<link
  801. linkend="language.types">??</link>???
  802. </para>
  803. </sect2>
  804. </sect1>
  805. </chapter>
  806. <!-- Keep this comment at the end of the file
  807. Local variables:
  808. mode: sgml
  809. sgml-omittag:t
  810. sgml-shorttag:t
  811. sgml-minimize-attributes:nil
  812. sgml-always-quote-attributes:t
  813. sgml-indent-step:1
  814. sgml-indent-data:t
  815. indent-tabs-mode:nil
  816. sgml-parent-document:nil
  817. sgml-default-dtd-file:"~/.phpdoc/manual.ced"
  818. sgml-exposed-tags:nil
  819. sgml-local-catalogs:nil
  820. sgml-local-ecat-files:nil
  821. End:
  822. vim600: syn=xml fen fdm=syntax fdl=2 si
  823. vim: et tw=78 syn=sgml
  824. vi: ts=1 sw=1
  825. -->