home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / phpmanual / phpmanual.exe / php_manual_de.html.htm < prev    next >
Encoding:
Extensible Markup Language  |  2005-01-13  |  8.7 MB  |  567,373 lines

Text Truncated. Only the first 1MB is shown below. Download the file for the complete contents.
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <HTML
  3. ><HEAD
  4. ><TITLE
  5. >PHP Handbuch</TITLE
  6. ><META
  7. NAME="GENERATOR"
  8. CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><META
  9. HTTP-EQUIV="Content-type"
  10. CONTENT="text/html; charset=ISO-8859-1"></HEAD
  11. ><BODY
  12. CLASS="book"
  13. BGCOLOR="#FFFFFF"
  14. TEXT="#000000"
  15. LINK="#0000FF"
  16. VLINK="#840084"
  17. ALINK="#0000FF"
  18. ><DIV
  19. CLASS="BOOK"
  20. ><A
  21. NAME="manual"
  22. ></A
  23. ><DIV
  24. CLASS="TITLEPAGE"
  25. ><H1
  26. CLASS="title"
  27. ><A
  28. NAME="manual"
  29. >PHP Handbuch</A
  30. ></H1
  31. ><DIV
  32. CLASS="author"
  33. >Mehdi Achour</DIV
  34. ><DIV
  35. CLASS="author"
  36. >Friedhelm Betz</DIV
  37. ><DIV
  38. CLASS="author"
  39. >Antony Dovgal</DIV
  40. ><DIV
  41. CLASS="author"
  42. >Nuno Lopes</DIV
  43. ><DIV
  44. CLASS="author"
  45. >Philip Olson</DIV
  46. ><DIV
  47. CLASS="author"
  48. >Georg Richter</DIV
  49. ><DIV
  50. CLASS="author"
  51. >Damien Seguy</DIV
  52. ><DIV
  53. CLASS="author"
  54. >Jakub Vrana</DIV
  55. ><SPAN
  56. CLASS="collab"
  57. ><SPAN
  58. CLASS="collabname"
  59. >      <A
  60. HREF="#contributors"
  61. >And several others</A
  62. >
  63.     </SPAN
  64. ><BR></SPAN
  65. ><H2
  66. CLASS="EDITEDBY"
  67. >Herausgegeben von</H2
  68. ><DIV
  69. CLASS="editor"
  70. >Gabor Hojtsy</DIV
  71. ><SPAN
  72. CLASS="collab"
  73. ><SPAN
  74. CLASS="collabname"
  75. >Bei der ▄bersetzung wirkten mit:</SPAN
  76. ><BR></SPAN
  77. ><SPAN
  78. CLASS="collab"
  79. ><SPAN
  80. CLASS="collabname"
  81. >Sebastian Bergmann</SPAN
  82. ><BR></SPAN
  83. ><SPAN
  84. CLASS="collab"
  85. ><SPAN
  86. CLASS="collabname"
  87. >Friedhelm Betz</SPAN
  88. ><BR></SPAN
  89. ><SPAN
  90. CLASS="collab"
  91. ><SPAN
  92. CLASS="collabname"
  93. >Cornelia Boenigk</SPAN
  94. ><BR></SPAN
  95. ><SPAN
  96. CLASS="collab"
  97. ><SPAN
  98. CLASS="collabname"
  99. >Ali Chahvand</SPAN
  100. ><BR></SPAN
  101. ><SPAN
  102. CLASS="collab"
  103. ><SPAN
  104. CLASS="collabname"
  105. >Wolfgang Drews</SPAN
  106. ><BR></SPAN
  107. ><SPAN
  108. CLASS="collab"
  109. ><SPAN
  110. CLASS="collabname"
  111. >Ralf Ebert</SPAN
  112. ><BR></SPAN
  113. ><SPAN
  114. CLASS="collab"
  115. ><SPAN
  116. CLASS="collabname"
  117. >Thomas Fromm</SPAN
  118. ><BR></SPAN
  119. ><SPAN
  120. CLASS="collab"
  121. ><SPAN
  122. CLASS="collabname"
  123. >Stefan Hanauska</SPAN
  124. ><BR></SPAN
  125. ><SPAN
  126. CLASS="collab"
  127. ><SPAN
  128. CLASS="collabname"
  129. >Johann-Peter Hartmann</SPAN
  130. ><BR></SPAN
  131. ><SPAN
  132. CLASS="collab"
  133. ><SPAN
  134. CLASS="collabname"
  135. >Hartmut Holzgraefe</SPAN
  136. ><BR></SPAN
  137. ><SPAN
  138. CLASS="collab"
  139. ><SPAN
  140. CLASS="collabname"
  141. >Martin Jansen</SPAN
  142. ><BR></SPAN
  143. ><SPAN
  144. CLASS="collab"
  145. ><SPAN
  146. CLASS="collabname"
  147. >Michael Kaiser</SPAN
  148. ><BR></SPAN
  149. ><SPAN
  150. CLASS="collab"
  151. ><SPAN
  152. CLASS="collabname"
  153. >Mark Kronsbein</SPAN
  154. ><BR></SPAN
  155. ><SPAN
  156. CLASS="collab"
  157. ><SPAN
  158. CLASS="collabname"
  159. >Hakan Kⁿcⁿkyilmaz</SPAN
  160. ><BR></SPAN
  161. ><SPAN
  162. CLASS="collab"
  163. ><SPAN
  164. CLASS="collabname"
  165. >Sven Lauer</SPAN
  166. ><BR></SPAN
  167. ><SPAN
  168. CLASS="collab"
  169. ><SPAN
  170. CLASS="collabname"
  171. >Jan Lehnardt</SPAN
  172. ><BR></SPAN
  173. ><SPAN
  174. CLASS="collab"
  175. ><SPAN
  176. CLASS="collabname"
  177. >Sebastian Nohn</SPAN
  178. ><BR></SPAN
  179. ><SPAN
  180. CLASS="collab"
  181. ><SPAN
  182. CLASS="collabname"
  183. >Tobias Orterer</SPAN
  184. ><BR></SPAN
  185. ><SPAN
  186. CLASS="collab"
  187. ><SPAN
  188. CLASS="collabname"
  189. >Catharina Paulsen</SPAN
  190. ><BR></SPAN
  191. ><SPAN
  192. CLASS="collab"
  193. ><SPAN
  194. CLASS="collabname"
  195. >Peter Petermann</SPAN
  196. ><BR></SPAN
  197. ><SPAN
  198. CLASS="collab"
  199. ><SPAN
  200. CLASS="collabname"
  201. >Sebastian-H. Picklum</SPAN
  202. ><BR></SPAN
  203. ><SPAN
  204. CLASS="collab"
  205. ><SPAN
  206. CLASS="collabname"
  207. >Franziskus Domig</SPAN
  208. ><BR></SPAN
  209. ><SPAN
  210. CLASS="collab"
  211. ><SPAN
  212. CLASS="collabname"
  213. >Georg Richter</SPAN
  214. ><BR></SPAN
  215. ><SPAN
  216. CLASS="collab"
  217. ><SPAN
  218. CLASS="collabname"
  219. >Stefan Saasen</SPAN
  220. ><BR></SPAN
  221. ><SPAN
  222. CLASS="collab"
  223. ><SPAN
  224. CLASS="collabname"
  225. >Martin Samesch</SPAN
  226. ><BR></SPAN
  227. ><SPAN
  228. CLASS="collab"
  229. ><SPAN
  230. CLASS="collabname"
  231. >Egon Schmid</SPAN
  232. ><BR></SPAN
  233. ><SPAN
  234. CLASS="collab"
  235. ><SPAN
  236. CLASS="collabname"
  237. >Thomas Sch÷fbeck</SPAN
  238. ><BR></SPAN
  239. ><SPAN
  240. CLASS="collab"
  241. ><SPAN
  242. CLASS="collabname"
  243. >Holger Schranz</SPAN
  244. ><BR></SPAN
  245. ><SPAN
  246. CLASS="collab"
  247. ><SPAN
  248. CLASS="collabname"
  249. >Thomas Schⁿrmann</SPAN
  250. ><BR></SPAN
  251. ><SPAN
  252. CLASS="collab"
  253. ><SPAN
  254. CLASS="collabname"
  255. >Uwe Steinmann</SPAN
  256. ><BR></SPAN
  257. ><SPAN
  258. CLASS="collab"
  259. ><SPAN
  260. CLASS="collabname"
  261. >Christian Ullrich</SPAN
  262. ><BR></SPAN
  263. ><SPAN
  264. CLASS="collab"
  265. ><SPAN
  266. CLASS="collabname"
  267. >Mark Wiesemann</SPAN
  268. ><BR></SPAN
  269. ><P
  270. CLASS="pubdate"
  271. >11-08-2004<BR></P
  272. ><P
  273. CLASS="copyright"
  274. >Copyright © 1997-2004 der PHP-Dokumentationsgruppe</P
  275. ><DIV
  276. CLASS="legalnotice"
  277. ><A
  278. NAME="copyright"
  279. ></A
  280. ><P
  281. ><B
  282. >Copyright</B
  283. ></P
  284. ><P
  285. >     Copyright ⌐ 1997 - 2004 by the PHP Documentation Group. Dieses Material
  286.     darf nur gemΣ▀ den Regeln und Bedingungen der Open Publication Licence
  287.     Version v1.0 oder neuer weiter verbreitet werden. Eine Kopie der
  288.     <A
  289. HREF="#opl.license"
  290. >Open Publication License</A
  291. >
  292.     ist in diesem Handbuch enthalten, die aktuellste Version ist gegenwΣrtig
  293.     immer unter <A
  294. HREF="http://www.opencontent.org/openpub/"
  295. TARGET="_top"
  296. >http://www.opencontent.org/openpub/</A
  297. > verfⁿgbar.
  298.    </P
  299. ><P
  300. >     Die Verbreitung von substantiell modifizierten Versionen dieses Dokuments
  301.     ist ohne die ausdrⁿckliche Erlaubnis des Copyright-Inhabers untersagt.
  302.    </P
  303. ><P
  304. >     Die Verbreitung dieser Arbeit oder abgeleiteter Arbeiten in jeglicher
  305.     Standard-(Papier-) Buchform ist ohne vorherige Erlaubnis durch den
  306.     Copyright-Inhaber verboten.
  307.    </P
  308. ><P
  309. >     Fⁿr den Fall, dass Sie daran interessiert sind, dieses Dokument
  310.     weiter zu verbreiten oder in sonstiger Form zu ver÷ffentlichen, in Teilen
  311.     oder als Ganzes, entweder verΣndert oder unverΣndert und Sie Fragen haben,
  312.     k÷nnen Sie Kontakt zu den Copyright-Inhabern ⁿber
  313.     <A
  314. HREF="mailto:doc-license@lists.php.net"
  315. TARGET="_top"
  316. >doc-license@lists.php.net</A
  317. >.
  318.     aufnehmen. Bitte beachten Sie, dass das Archiv dieser Maillingliste
  319.     ÷ffentlich zugΣnglich ist.
  320.    </P
  321. ><P
  322. >     Das Kapitel 'Extending PHP 4.0' ist ⌐ 2000 by
  323.     Zend Technologies, Ltd. Dieses Material darf nur gemΣ▀ den Regeln und
  324.     Bedingungen der Open Publication Licence Version v1.0 oder neuer, (die
  325.     aktuellste Version ist gegenwΣrtig unter
  326.     <A
  327. HREF="http://www.opencontent.org/openpub/"
  328. TARGET="_top"
  329. >http://www.opencontent.org/openpub/</A
  330. > verfⁿgbar), verbreitet werden.
  331.    </P
  332. ></DIV
  333. ><HR></DIV
  334. ><DIV
  335. CLASS="TOC"
  336. ><DL
  337. ><DT
  338. ><B
  339. >Inhaltsverzeichnis</B
  340. ></DT
  341. ><DT
  342. ><A
  343. HREF="#preface"
  344. >Vorwort</A
  345. ></DT
  346. ><DD
  347. ><DL
  348. ><DT
  349. ><A
  350. HREF="#contributors"
  351. >Autoren und Mitwirkende</A
  352. ></DT
  353. ></DL
  354. ></DD
  355. ><DT
  356. >I. <A
  357. HREF="#getting-started"
  358. >Einfⁿhrung</A
  359. ></DT
  360. ><DD
  361. ><DL
  362. ><DT
  363. >1. <A
  364. HREF="#introduction"
  365. >Einleitung</A
  366. ></DT
  367. ><DT
  368. >2. <A
  369. HREF="#tutorial"
  370. >Kleines Tutorial</A
  371. ></DT
  372. ></DL
  373. ></DD
  374. ><DT
  375. >II. <A
  376. HREF="#install"
  377. >Installation und Konfiguration</A
  378. ></DT
  379. ><DD
  380. ><DL
  381. ><DT
  382. >3. <A
  383. HREF="#install.general"
  384. >General Installation Considerations</A
  385. ></DT
  386. ><DT
  387. >4. <A
  388. HREF="#install.macosx"
  389. >Installation on Mac OS X</A
  390. ></DT
  391. ><DT
  392. >5. <A
  393. HREF="#install.unix"
  394. >Installation on Unix systems</A
  395. ></DT
  396. ><DT
  397. >6. <A
  398. HREF="#install.windows"
  399. >Installation on Windows systems</A
  400. ></DT
  401. ><DT
  402. >7. <A
  403. HREF="#install.problems"
  404. >Problems?</A
  405. ></DT
  406. ><DT
  407. >8. <A
  408. HREF="#configuration"
  409. >Runtime Configuration</A
  410. ></DT
  411. ></DL
  412. ></DD
  413. ><DT
  414. >III. <A
  415. HREF="#langref"
  416. >Sprachreferenz</A
  417. ></DT
  418. ><DD
  419. ><DL
  420. ><DT
  421. >9. <A
  422. HREF="#language.basic-syntax"
  423. >Grundlagen der Syntax</A
  424. ></DT
  425. ><DT
  426. >10. <A
  427. HREF="#language.types"
  428. >Typen</A
  429. ></DT
  430. ><DT
  431. >11. <A
  432. HREF="#language.variables"
  433. >Variablen</A
  434. ></DT
  435. ><DT
  436. >12. <A
  437. HREF="#language.constants"
  438. >Konstanten</A
  439. ></DT
  440. ><DT
  441. >13. <A
  442. HREF="#language.expressions"
  443. >Ausdrⁿcke</A
  444. ></DT
  445. ><DT
  446. >14. <A
  447. HREF="#language.operators"
  448. >Operatoren</A
  449. ></DT
  450. ><DT
  451. >15. <A
  452. HREF="#language.control-structures"
  453. >Kontroll-Strukturen</A
  454. ></DT
  455. ><DT
  456. >16. <A
  457. HREF="#functions"
  458. >Funktionen</A
  459. ></DT
  460. ><DT
  461. >17. <A
  462. HREF="#language.oop"
  463. >Klassen und Objekte</A
  464. ></DT
  465. ><DT
  466. >18. <A
  467. HREF="#language.oop5"
  468. >Classes and Objects (PHP 5)</A
  469. ></DT
  470. ><DT
  471. >19. <A
  472. HREF="#language.references"
  473. >Referenzen in PHP</A
  474. ></DT
  475. ></DL
  476. ></DD
  477. ><DT
  478. >IV. <A
  479. HREF="#security"
  480. >Sicherheit</A
  481. ></DT
  482. ><DD
  483. ><DL
  484. ><DT
  485. >20. <A
  486. HREF="#security.intro"
  487. >Einfⁿhrung</A
  488. ></DT
  489. ><DT
  490. >21. <A
  491. HREF="#security.general"
  492. >Allgemeine ▄berlegungen</A
  493. ></DT
  494. ><DT
  495. >22. <A
  496. HREF="#security.cgi-bin"
  497. >CGI-Version</A
  498. ></DT
  499. ><DT
  500. >23. <A
  501. HREF="#security.apache"
  502. >Apache-Modul</A
  503. ></DT
  504. ><DT
  505. >24. <A
  506. HREF="#security.filesystem"
  507. >Dateisystem - Sicherheit</A
  508. ></DT
  509. ><DT
  510. >25. <A
  511. HREF="#security.database"
  512. >Datenbank - Sicherheit</A
  513. ></DT
  514. ><DT
  515. >26. <A
  516. HREF="#security.errors"
  517. >Fehlerbehandlung</A
  518. ></DT
  519. ><DT
  520. >27. <A
  521. HREF="#security.globals"
  522. >Verwendung von Register Globals</A
  523. ></DT
  524. ><DT
  525. >28. <A
  526. HREF="#security.variables"
  527. >Vom Nutzer ⁿbermittelte Daten</A
  528. ></DT
  529. ><DT
  530. >29. <A
  531. HREF="#security.hiding"
  532. >Verstecken von PHP</A
  533. ></DT
  534. ><DT
  535. >30. <A
  536. HREF="#security.current"
  537. >Aktuell bleiben</A
  538. ></DT
  539. ></DL
  540. ></DD
  541. ><DT
  542. >V. <A
  543. HREF="#features"
  544. >Features</A
  545. ></DT
  546. ><DD
  547. ><DL
  548. ><DT
  549. >31. <A
  550. HREF="#features.http-auth"
  551. >HTTP-Authentifizierung mit PHP</A
  552. ></DT
  553. ><DT
  554. >32. <A
  555. HREF="#features.cookies"
  556. >Cookies</A
  557. ></DT
  558. ><DT
  559. >33. <A
  560. HREF="#features.xforms"
  561. >Dealing with XForms</A
  562. ></DT
  563. ><DT
  564. >34. <A
  565. HREF="#features.file-upload"
  566. >Steuerung von Dateiuploads</A
  567. ></DT
  568. ><DT
  569. >35. <A
  570. HREF="#features.remote-files"
  571. >Zugriff auf entfernte Dateien</A
  572. ></DT
  573. ><DT
  574. >36. <A
  575. HREF="#features.connection-handling"
  576. >Verbindungssteuerung</A
  577. ></DT
  578. ><DT
  579. >37. <A
  580. HREF="#features.persistent-connections"
  581. >Persistente Datenbankverbindungen</A
  582. ></DT
  583. ><DT
  584. >38. <A
  585. HREF="#features.safe-mode"
  586. >Safe Mode</A
  587. ></DT
  588. ><DT
  589. >39. <A
  590. HREF="#features.commandline"
  591. >PHP auf der Kommandozeile</A
  592. ></DT
  593. ></DL
  594. ></DD
  595. ><DT
  596. >VI. <A
  597. HREF="#funcref"
  598. >Funktionsreferenz</A
  599. ></DT
  600. ><DD
  601. ><DL
  602. ><DT
  603. >I. <A
  604. HREF="#ref.apache"
  605. >Apache-spezifische Funktionen</A
  606. ></DT
  607. ><DT
  608. >II. <A
  609. HREF="#ref.array"
  610. >Array Funktionen</A
  611. ></DT
  612. ><DT
  613. >III. <A
  614. HREF="#ref.aspell"
  615. >Aspell Funktionen [veraltet]</A
  616. ></DT
  617. ><DT
  618. >IV. <A
  619. HREF="#ref.bc"
  620. >Mathematische Funktionen mit beliebiger Genauigkeit</A
  621. ></DT
  622. ><DT
  623. >V. <A
  624. HREF="#ref.bzip2"
  625. >Bzip2 Komprimierungsfunktionen</A
  626. ></DT
  627. ><DT
  628. >VI. <A
  629. HREF="#ref.calendar"
  630. >Kalender-Funktionen</A
  631. ></DT
  632. ><DT
  633. >VII. <A
  634. HREF="#ref.ccvs"
  635. >CCVS API Funktionen</A
  636. ></DT
  637. ><DT
  638. >VIII. <A
  639. HREF="#ref.com"
  640. >COM Support Funktionen fⁿr Windows</A
  641. ></DT
  642. ><DT
  643. >IX. <A
  644. HREF="#ref.classobj"
  645. >Klassen- und Objekt-Funktionen</A
  646. ></DT
  647. ><DT
  648. >X. <A
  649. HREF="#ref.cpdf"
  650. >ClibPDF Funktionen</A
  651. ></DT
  652. ><DT
  653. >XI. <A
  654. HREF="#ref.crack"
  655. >Crack Funktionen</A
  656. ></DT
  657. ><DT
  658. >XII. <A
  659. HREF="#ref.curl"
  660. >cURL, Client URL Bibiothek-Funktionen</A
  661. ></DT
  662. ><DT
  663. >XIII. <A
  664. HREF="#ref.cybercash"
  665. >Cybercash Bezahl Funktionen</A
  666. ></DT
  667. ><DT
  668. >XIV. <A
  669. HREF="#ref.cyrus"
  670. >Cyrus IMAP administration Functions</A
  671. ></DT
  672. ><DT
  673. >XV. <A
  674. HREF="#ref.ctype"
  675. >Character type functions</A
  676. ></DT
  677. ><DT
  678. >XVI. <A
  679. HREF="#ref.dba"
  680. >dba Datenbank (dbm-style) Abstraktions-Funktionen</A
  681. ></DT
  682. ><DT
  683. >XVII. <A
  684. HREF="#ref.datetime"
  685. >Datums- und Zeit-Funktionen</A
  686. ></DT
  687. ><DT
  688. >XVIII. <A
  689. HREF="#ref.dbase"
  690. >dBase Funktionen</A
  691. ></DT
  692. ><DT
  693. >XIX. <A
  694. HREF="#ref.dbm"
  695. >DBM Datenbankfunktionen</A
  696. ></DT
  697. ><DT
  698. >XX. <A
  699. HREF="#ref.dbx"
  700. >dbx Funktionen</A
  701. ></DT
  702. ><DT
  703. >XXI. <A
  704. HREF="#ref.dbplus"
  705. >DB++ Functions</A
  706. ></DT
  707. ><DT
  708. >XXII. <A
  709. HREF="#ref.dio"
  710. >Direkte Ein-/Ausgabe Funktionen</A
  711. ></DT
  712. ><DT
  713. >XXIII. <A
  714. HREF="#ref.dir"
  715. >Verzeichnis-Funktionen</A
  716. ></DT
  717. ><DT
  718. >XXIV. <A
  719. HREF="#ref.dom"
  720. >DOM Functions</A
  721. ></DT
  722. ><DT
  723. >XXV. <A
  724. HREF="#ref.domxml"
  725. >DOM XML Funktionen</A
  726. ></DT
  727. ><DT
  728. >XXVI. <A
  729. HREF="#ref.dotnet"
  730. >.NET Funktionen</A
  731. ></DT
  732. ><DT
  733. >XXVII. <A
  734. HREF="#ref.errorfunc"
  735. >Error Handling and Logging Functions</A
  736. ></DT
  737. ><DT
  738. >XXVIII. <A
  739. HREF="#ref.exif"
  740. >Exif Functions</A
  741. ></DT
  742. ><DT
  743. >XXIX. <A
  744. HREF="#ref.fam"
  745. >File Alteration Monitor Functions</A
  746. ></DT
  747. ><DT
  748. >XXX. <A
  749. HREF="#ref.fbsql"
  750. >FrontBase Funktionen</A
  751. ></DT
  752. ><DT
  753. >XXXI. <A
  754. HREF="#ref.filepro"
  755. >filePro Funktionen</A
  756. ></DT
  757. ><DT
  758. >XXXII. <A
  759. HREF="#ref.filesystem"
  760. >Funktionen des Dateisystems</A
  761. ></DT
  762. ><DT
  763. >XXXIII. <A
  764. HREF="#ref.fdf"
  765. >Forms Data Format Funktionen</A
  766. ></DT
  767. ><DT
  768. >XXXIV. <A
  769. HREF="#ref.fribidi"
  770. >FriBiDi Funktionen</A
  771. ></DT
  772. ><DT
  773. >XXXV. <A
  774. HREF="#ref.ftp"
  775. >FTP-Funktionen</A
  776. ></DT
  777. ><DT
  778. >XXXVI. <A
  779. HREF="#ref.funchand"
  780. >Function Handling functions</A
  781. ></DT
  782. ><DT
  783. >XXXVII. <A
  784. HREF="#ref.gettext"
  785. >GNU Gettext</A
  786. ></DT
  787. ><DT
  788. >XXXVIII. <A
  789. HREF="#ref.gmp"
  790. >GMP Functions</A
  791. ></DT
  792. ><DT
  793. >XXXIX. <A
  794. HREF="#ref.http"
  795. >HTTP functions</A
  796. ></DT
  797. ><DT
  798. >XL. <A
  799. HREF="#ref.hw"
  800. >Hyperwave Functions</A
  801. ></DT
  802. ><DT
  803. >XLI. <A
  804. HREF="#ref.hwapi"
  805. >Hyperwave API Functions</A
  806. ></DT
  807. ><DT
  808. >XLII. <A
  809. HREF="#ref.iconv"
  810. >iconv Funktionen</A
  811. ></DT
  812. ><DT
  813. >XLIII. <A
  814. HREF="#ref.image"
  815. >Grafik-Funktionen</A
  816. ></DT
  817. ><DT
  818. >XLIV. <A
  819. HREF="#ref.imap"
  820. >IMAP, POP3 und NNTP Funktionen</A
  821. ></DT
  822. ><DT
  823. >XLV. <A
  824. HREF="#ref.ifx"
  825. >Informix Funktionen</A
  826. ></DT
  827. ><DT
  828. >XLVI. <A
  829. HREF="#ref.ibase"
  830. >InterBase-Funktionen</A
  831. ></DT
  832. ><DT
  833. >XLVII. <A
  834. HREF="#ref.id3"
  835. >ID3 Functions</A
  836. ></DT
  837. ><DT
  838. >XLVIII. <A
  839. HREF="#ref.ingres"
  840. >Ingres II Funktionen</A
  841. ></DT
  842. ><DT
  843. >XLIX. <A
  844. HREF="#ref.ircg"
  845. >IRC Gateway Funktionen</A
  846. ></DT
  847. ><DT
  848. >L. <A
  849. HREF="#ref.java"
  850. >Java</A
  851. ></DT
  852. ><DT
  853. >LI. <A
  854. HREF="#ref.ldap"
  855. >LDAP Funktionen</A
  856. ></DT
  857. ><DT
  858. >LII. <A
  859. HREF="#ref.lzf"
  860. >LZF Functions</A
  861. ></DT
  862. ><DT
  863. >LIII. <A
  864. HREF="#ref.mail"
  865. >Mail-Funktionen</A
  866. ></DT
  867. ><DT
  868. >LIV. <A
  869. HREF="#ref.mailparse"
  870. >mailparse Functions</A
  871. ></DT
  872. ><DT
  873. >LV. <A
  874. HREF="#ref.math"
  875. >Mathematische Funktionen</A
  876. ></DT
  877. ><DT
  878. >LVI. <A
  879. HREF="#ref.mbstring"
  880. >Multibyte String Functions</A
  881. ></DT
  882. ><DT
  883. >LVII. <A
  884. HREF="#ref.mcal"
  885. >MCAL Funktionen</A
  886. ></DT
  887. ><DT
  888. >LVIII. <A
  889. HREF="#ref.mcrypt"
  890. >Mcrypt Encryption Functions</A
  891. ></DT
  892. ><DT
  893. >LIX. <A
  894. HREF="#ref.mcve"
  895. >MCVE Payment Functions</A
  896. ></DT
  897. ><DT
  898. >LX. <A
  899. HREF="#ref.memcache"
  900. >Memcache Functions</A
  901. ></DT
  902. ><DT
  903. >LXI. <A
  904. HREF="#ref.mhash"
  905. >Hash Funktionen</A
  906. ></DT
  907. ><DT
  908. >LXII. <A
  909. HREF="#ref.mime-magic"
  910. >Mimetype Functions</A
  911. ></DT
  912. ><DT
  913. >LXIII. <A
  914. HREF="#ref.mssql"
  915. >Microsoft SQL Server Funktionen</A
  916. ></DT
  917. ><DT
  918. >LXIV. <A
  919. HREF="#ref.ming"
  920. >Ming functions for Flash</A
  921. ></DT
  922. ><DT
  923. >LXV. <A
  924. HREF="#ref.misc"
  925. >Sonstige Funktionen</A
  926. ></DT
  927. ><DT
  928. >LXVI. <A
  929. HREF="#ref.mnogo"
  930. >mnoGoSearch Funktionen</A
  931. ></DT
  932. ><DT
  933. >LXVII. <A
  934. HREF="#ref.msql"
  935. >mSQL Funktionen</A
  936. ></DT
  937. ><DT
  938. >LXVIII. <A
  939. HREF="#ref.mysql"
  940. >MySQL Funktionen</A
  941. ></DT
  942. ><DT
  943. >LXIX. <A
  944. HREF="#ref.mysqli"
  945. >Verbesserte MySQL Erweiterung</A
  946. ></DT
  947. ><DT
  948. >LXX. <A
  949. HREF="#ref.msession"
  950. >Mohawk Software Session Handler Funktionen</A
  951. ></DT
  952. ><DT
  953. >LXXI. <A
  954. HREF="#ref.muscat"
  955. >muscat Functions</A
  956. ></DT
  957. ><DT
  958. >LXXII. <A
  959. HREF="#ref.network"
  960. >Netzwerk Funktionen</A
  961. ></DT
  962. ><DT
  963. >LXXIII. <A
  964. HREF="#ref.ncurses"
  965. >Ncurses Terminal Screen Control Functions</A
  966. ></DT
  967. ><DT
  968. >LXXIV. <A
  969. HREF="#ref.notes"
  970. >Lotus Notes Functions</A
  971. ></DT
  972. ><DT
  973. >LXXV. <A
  974. HREF="#ref.nsapi"
  975. >NSAPI-specific Functions</A
  976. ></DT
  977. ><DT
  978. >LXXVI. <A
  979. HREF="#ref.odbc"
  980. >ODBC Funktionen</A
  981. ></DT
  982. ><DT
  983. >LXXVII. <A
  984. HREF="#ref.objaggregation"
  985. >Object Aggregation/Composition Functions</A
  986. ></DT
  987. ><DT
  988. >LXXVIII. <A
  989. HREF="#ref.oci8"
  990. >Oracle 8 Funktionen</A
  991. ></DT
  992. ><DT
  993. >LXXIX. <A
  994. HREF="#ref.openssl"
  995. >OpenSSL Funktionen</A
  996. ></DT
  997. ><DT
  998. >LXXX. <A
  999. HREF="#ref.oracle"
  1000. >Oracle Funktionen</A
  1001. ></DT
  1002. ><DT
  1003. >LXXXI. <A
  1004. HREF="#ref.ovrimos"
  1005. >Ovrimos SQL Functions</A
  1006. ></DT
  1007. ><DT
  1008. >LXXXII. <A
  1009. HREF="#ref.outcontrol"
  1010. >Funktionen zur Ausgabesteuerung</A
  1011. ></DT
  1012. ><DT
  1013. >LXXXIII. <A
  1014. HREF="#ref.overload"
  1015. >Object property and method call overloading</A
  1016. ></DT
  1017. ><DT
  1018. >LXXXIV. <A
  1019. HREF="#ref.pdf"
  1020. >PDF Funktionen</A
  1021. ></DT
  1022. ><DT
  1023. >LXXXV. <A
  1024. HREF="#ref.pfpro"
  1025. >Verisign Payflow Pro Funktionen</A
  1026. ></DT
  1027. ><DT
  1028. >LXXXVI. <A
  1029. HREF="#ref.info"
  1030. >PHP Optionen & Informationen</A
  1031. ></DT
  1032. ><DT
  1033. >LXXXVII. <A
  1034. HREF="#ref.posix"
  1035. >POSIX Funktionen</A
  1036. ></DT
  1037. ><DT
  1038. >LXXXVIII. <A
  1039. HREF="#ref.pgsql"
  1040. >PostgreSQL Funktionen</A
  1041. ></DT
  1042. ><DT
  1043. >LXXXIX. <A
  1044. HREF="#ref.pcntl"
  1045. >Process Control Functions</A
  1046. ></DT
  1047. ><DT
  1048. >XC. <A
  1049. HREF="#ref.exec"
  1050. >Funktionen zur Programmausfⁿhrung</A
  1051. ></DT
  1052. ><DT
  1053. >XCI. <A
  1054. HREF="#ref.printer"
  1055. >Printer Functions</A
  1056. ></DT
  1057. ><DT
  1058. >XCII. <A
  1059. HREF="#ref.pspell"
  1060. >Pspell Funktionen</A
  1061. ></DT
  1062. ><DT
  1063. >XCIII. <A
  1064. HREF="#ref.readline"
  1065. >GNU Readline</A
  1066. ></DT
  1067. ><DT
  1068. >XCIV. <A
  1069. HREF="#ref.recode"
  1070. >GNU Recode Funktionen</A
  1071. ></DT
  1072. ><DT
  1073. >XCV. <A
  1074. HREF="#ref.pcre"
  1075. >RegulΣre Ausdrⁿcke Funktionen (Perl-kompatibel)</A
  1076. ></DT
  1077. ><DT
  1078. >XCVI. <A
  1079. HREF="#ref.qtdom"
  1080. >qtdom Functions</A
  1081. ></DT
  1082. ><DT
  1083. >XCVII. <A
  1084. HREF="#ref.regex"
  1085. >RegulΣre Ausdrⁿcke Funktionen (POSIX erweitert)</A
  1086. ></DT
  1087. ><DT
  1088. >XCVIII. <A
  1089. HREF="#ref.sem"
  1090. >Semaphor und Shared Memory Funktionen</A
  1091. ></DT
  1092. ><DT
  1093. >XCIX. <A
  1094. HREF="#ref.sesam"
  1095. >SESAM Datenbankfunktionen</A
  1096. ></DT
  1097. ><DT
  1098. >C. <A
  1099. HREF="#ref.session"
  1100. >Session Funktionen</A
  1101. ></DT
  1102. ><DT
  1103. >CI. <A
  1104. HREF="#ref.shmop"
  1105. >Shared Memory Funktionen (Gemeinsamer Speicher)</A
  1106. ></DT
  1107. ><DT
  1108. >CII. <A
  1109. HREF="#ref.simplexml"
  1110. >SimpleXML functions</A
  1111. ></DT
  1112. ><DT
  1113. >CIII. <A
  1114. HREF="#ref.soap"
  1115. >SOAP Functions</A
  1116. ></DT
  1117. ><DT
  1118. >CIV. <A
  1119. HREF="#ref.sqlite"
  1120. >SQLite</A
  1121. ></DT
  1122. ><DT
  1123. >CV. <A
  1124. HREF="#ref.swf"
  1125. >Shockwave Flash Funktionen</A
  1126. ></DT
  1127. ><DT
  1128. >CVI. <A
  1129. HREF="#ref.snmp"
  1130. >SNMP Funktionen</A
  1131. ></DT
  1132. ><DT
  1133. >CVII. <A
  1134. HREF="#ref.sockets"
  1135. >Socket Funktionen</A
  1136. ></DT
  1137. ><DT
  1138. >CVIII. <A
  1139. HREF="#ref.spl"
  1140. >Standard PHP Library (SPL) Functions</A
  1141. ></DT
  1142. ><DT
  1143. >CIX. <A
  1144. HREF="#ref.stream"
  1145. >Stream Functions</A
  1146. ></DT
  1147. ><DT
  1148. >CX. <A
  1149. HREF="#ref.strings"
  1150. >String-Funktionen</A
  1151. ></DT
  1152. ><DT
  1153. >CXI. <A
  1154. HREF="#ref.sybase"
  1155. >Sybase Funktionen</A
  1156. ></DT
  1157. ><DT
  1158. >CXII. <A
  1159. HREF="#ref.tcpwrap"
  1160. >TCP Wrappers Functions</A
  1161. ></DT
  1162. ><DT
  1163. >CXIII. <A
  1164. HREF="#ref.tidy"
  1165. >Tidy Functions</A
  1166. ></DT
  1167. ><DT
  1168. >CXIV. <A
  1169. HREF="#ref.tokenizer"
  1170. >Tokenizer Functions</A
  1171. ></DT
  1172. ><DT
  1173. >CXV. <A
  1174. HREF="#ref.url"
  1175. >URL Funktionen</A
  1176. ></DT
  1177. ><DT
  1178. >CXVI. <A
  1179. HREF="#ref.variables"
  1180. >Variablen-Funktionen</A
  1181. ></DT
  1182. ><DT
  1183. >CXVII. <A
  1184. HREF="#ref.vpopmail"
  1185. >vpopmail Functions</A
  1186. ></DT
  1187. ><DT
  1188. >CXVIII. <A
  1189. HREF="#ref.w32api"
  1190. >W32api Functions</A
  1191. ></DT
  1192. ><DT
  1193. >CXIX. <A
  1194. HREF="#ref.wddx"
  1195. >WDDX Funktionen</A
  1196. ></DT
  1197. ><DT
  1198. >CXX. <A
  1199. HREF="#ref.xml"
  1200. >XML Parser Functions</A
  1201. ></DT
  1202. ><DT
  1203. >CXXI. <A
  1204. HREF="#ref.xmlrpc"
  1205. >XML-RPC Functions</A
  1206. ></DT
  1207. ><DT
  1208. >CXXII. <A
  1209. HREF="#ref.xdiff"
  1210. >xdiff Functions</A
  1211. ></DT
  1212. ><DT
  1213. >CXXIII. <A
  1214. HREF="#ref.xsl"
  1215. >XSL functions</A
  1216. ></DT
  1217. ><DT
  1218. >CXXIV. <A
  1219. HREF="#ref.xslt"
  1220. >XSLT Funktionen</A
  1221. ></DT
  1222. ><DT
  1223. >CXXV. <A
  1224. HREF="#ref.yaz"
  1225. >YAZ Functions</A
  1226. ></DT
  1227. ><DT
  1228. >CXXVI. <A
  1229. HREF="#ref.nis"
  1230. >YP/NIS Funktionen</A
  1231. ></DT
  1232. ><DT
  1233. >CXXVII. <A
  1234. HREF="#ref.zip"
  1235. >ZIP Funktionen (Lesezugriff)</A
  1236. ></DT
  1237. ><DT
  1238. >CXXVIII. <A
  1239. HREF="#ref.zlib"
  1240. >Zlib Komprimierungsfunktionen</A
  1241. ></DT
  1242. ></DL
  1243. ></DD
  1244. ><DT
  1245. >VII. <A
  1246. HREF="#zend"
  1247. >Zend API</A
  1248. ></DT
  1249. ><DD
  1250. ><DL
  1251. ><DT
  1252. >40. <A
  1253. HREF="#zend.overview"
  1254. >Overview</A
  1255. ></DT
  1256. ><DT
  1257. >41. <A
  1258. HREF="#zend.possibilities"
  1259. >Extension Possibilities</A
  1260. ></DT
  1261. ><DT
  1262. >42. <A
  1263. HREF="#zend.layout"
  1264. >Source Layout</A
  1265. ></DT
  1266. ><DT
  1267. >43. <A
  1268. HREF="#zend.build"
  1269. >PHP's Automatic Build System</A
  1270. ></DT
  1271. ><DT
  1272. >44. <A
  1273. HREF="#zend.creating"
  1274. >Creating Extensions</A
  1275. ></DT
  1276. ><DT
  1277. >45. <A
  1278. HREF="#zend.using"
  1279. >Using Extensions</A
  1280. ></DT
  1281. ><DT
  1282. >46. <A
  1283. HREF="#zend.troubleshooting"
  1284. >Troubleshooting</A
  1285. ></DT
  1286. ><DT
  1287. >47. <A
  1288. HREF="#zend.structure"
  1289. >Source Discussion</A
  1290. ></DT
  1291. ><DT
  1292. >48. <A
  1293. HREF="#zend.arguments"
  1294. >Accepting Arguments</A
  1295. ></DT
  1296. ><DT
  1297. >49. <A
  1298. HREF="#zend.variables"
  1299. >Creating Variables</A
  1300. ></DT
  1301. ><DT
  1302. >50. <A
  1303. HREF="#zend.copy-constructor"
  1304. >Duplicating Variable Contents: The Copy Constructor</A
  1305. ></DT
  1306. ><DT
  1307. >51. <A
  1308. HREF="#zend.returning"
  1309. >Returning Values</A
  1310. ></DT
  1311. ><DT
  1312. >52. <A
  1313. HREF="#zend.printing"
  1314. >Printing Information</A
  1315. ></DT
  1316. ><DT
  1317. >53. <A
  1318. HREF="#zend.startup-and-shutdown"
  1319. >Startup and Shutdown Functions</A
  1320. ></DT
  1321. ><DT
  1322. >54. <A
  1323. HREF="#zend.calling-user-functions"
  1324. >Calling User Functions</A
  1325. ></DT
  1326. ><DT
  1327. >55. <A
  1328. HREF="#zend.ini-file-support"
  1329. >Initialization File Support</A
  1330. ></DT
  1331. ><DT
  1332. >56. <A
  1333. HREF="#zend.where-to-go"
  1334. >Where to Go from Here</A
  1335. ></DT
  1336. ><DT
  1337. >57. <A
  1338. HREF="#zend.configuration-macros"
  1339. >Reference: Some Configuration Macros</A
  1340. ></DT
  1341. ><DT
  1342. >58. <A
  1343. HREF="#zend.api-macros"
  1344. >API Macros</A
  1345. ></DT
  1346. ></DL
  1347. ></DD
  1348. ><DT
  1349. >VIII. <A
  1350. HREF="#api"
  1351. >PHP API: Schnittstellen fⁿr Programmierer</A
  1352. ></DT
  1353. ><DD
  1354. ><DL
  1355. ><DT
  1356. >59. <A
  1357. HREF="#streams"
  1358. >Streams API for PHP Extension Authors</A
  1359. ></DT
  1360. ></DL
  1361. ></DD
  1362. ><DT
  1363. >IX. <A
  1364. HREF="#faq"
  1365. >FAQ: Frequently Asked Questions</A
  1366. ></DT
  1367. ><DD
  1368. ><DL
  1369. ><DT
  1370. >60. <A
  1371. HREF="#faq.general"
  1372. >Allgemeine Informationen</A
  1373. ></DT
  1374. ><DT
  1375. >61. <A
  1376. HREF="#faq.mailinglist"
  1377. >Mailing-Listen</A
  1378. ></DT
  1379. ><DT
  1380. >62. <A
  1381. HREF="#faq.obtaining"
  1382. >Obtaining PHP</A
  1383. ></DT
  1384. ><DT
  1385. >63. <A
  1386. HREF="#faq.databases"
  1387. >Database issues</A
  1388. ></DT
  1389. ><DT
  1390. >64. <A
  1391. HREF="#faq.installation"
  1392. >Installation</A
  1393. ></DT
  1394. ><DT
  1395. >65. <A
  1396. HREF="#faq.build"
  1397. >Probleme bei der Compilierung</A
  1398. ></DT
  1399. ><DT
  1400. >66. <A
  1401. HREF="#faq.using"
  1402. >PHP benutzen</A
  1403. ></DT
  1404. ><DT
  1405. >67. <A
  1406. HREF="#faq.html"
  1407. >PHP und HTML</A
  1408. ></DT
  1409. ><DT
  1410. >68. <A
  1411. HREF="#faq.com"
  1412. >PHP and COM</A
  1413. ></DT
  1414. ><DT
  1415. >69. <A
  1416. HREF="#faq.languages"
  1417. >PHP und andere Sprachen</A
  1418. ></DT
  1419. ><DT
  1420. >70. <A
  1421. HREF="#faq.migration"
  1422. >Von PHP 2 auf PHP 3 umsteigen</A
  1423. ></DT
  1424. ><DT
  1425. >71. <A
  1426. HREF="#faq.migration4"
  1427. >Von PHP 3 auf PHP 4 umsteigen</A
  1428. ></DT
  1429. ><DT
  1430. >72. <A
  1431. HREF="#faq.migration5"
  1432. >Migrating from PHP 4 to PHP 5</A
  1433. ></DT
  1434. ><DT
  1435. >73. <A
  1436. HREF="#faq.misc"
  1437. >Verschiedene Fragen</A
  1438. ></DT
  1439. ></DL
  1440. ></DD
  1441. ><DT
  1442. >X. <A
  1443. HREF="#appendixes"
  1444. >Anhang</A
  1445. ></DT
  1446. ><DD
  1447. ><DL
  1448. ><DT
  1449. >A. <A
  1450. HREF="#history"
  1451. >Die Geschichte von PHP und verwandten Projekten</A
  1452. ></DT
  1453. ><DT
  1454. >B. <A
  1455. HREF="#migration5"
  1456. >Migrating from PHP 4 to PHP 5</A
  1457. ></DT
  1458. ><DT
  1459. >C. <A
  1460. HREF="#migration4"
  1461. >Migrating from PHP 3 to PHP 4</A
  1462. ></DT
  1463. ><DT
  1464. >D. <A
  1465. HREF="#migration"
  1466. >Migration von PHP/FI 2.0 zu PHP 3.0</A
  1467. ></DT
  1468. ><DT
  1469. >E. <A
  1470. HREF="#debugger"
  1471. >Der PHP-Debugger</A
  1472. ></DT
  1473. ><DT
  1474. >F. <A
  1475. HREF="#phpdevel"
  1476. >Extending PHP 3</A
  1477. ></DT
  1478. ><DT
  1479. >G. <A
  1480. HREF="#configure"
  1481. >Configure options</A
  1482. ></DT
  1483. ><DT
  1484. >H. <A
  1485. HREF="#ini"
  1486. >Liste der core <TT
  1487. CLASS="filename"
  1488. >php.ini</TT
  1489. > Einstellungen</A
  1490. ></DT
  1491. ><DT
  1492. >I. <A
  1493. HREF="#aliases"
  1494. >Liste der Funktion Aliase</A
  1495. ></DT
  1496. ><DT
  1497. >J. <A
  1498. HREF="#reserved"
  1499. >Reservierte W÷rter in PHP</A
  1500. ></DT
  1501. ><DT
  1502. >K. <A
  1503. HREF="#resource"
  1504. >Liste von Ressourcentypen</A
  1505. ></DT
  1506. ><DT
  1507. >L. <A
  1508. HREF="#wrappers"
  1509. >List of Supported Protocols/Wrappers</A
  1510. ></DT
  1511. ><DT
  1512. >M. <A
  1513. HREF="#filters"
  1514. >List of Available Filters</A
  1515. ></DT
  1516. ><DT
  1517. >N. <A
  1518. HREF="#transports"
  1519. >List of Supported Socket Transports</A
  1520. ></DT
  1521. ><DT
  1522. >O. <A
  1523. HREF="#types.comparisons"
  1524. >PHP type comparison tables</A
  1525. ></DT
  1526. ><DT
  1527. >P. <A
  1528. HREF="#tokens"
  1529. >List of Parser Tokens</A
  1530. ></DT
  1531. ><DT
  1532. >Q. <A
  1533. HREF="#about"
  1534. >▄ber das Handbuch</A
  1535. ></DT
  1536. ><DT
  1537. >R. <A
  1538. HREF="#opl.license"
  1539. >Open Publication License</A
  1540. ></DT
  1541. ><DT
  1542. >S. <A
  1543. HREF="#indexes"
  1544. >Funktions-Index</A
  1545. ></DT
  1546. ><DT
  1547. >T. <A
  1548. HREF="#missing-stuff"
  1549. >Fehlendes</A
  1550. ></DT
  1551. ></DL
  1552. ></DD
  1553. ></DL
  1554. ></DIV
  1555. ><DIV
  1556. CLASS="preface"
  1557. ><HR><H1
  1558. ><A
  1559. NAME="preface"
  1560. >Vorwort</A
  1561. ></H1
  1562. ><BLOCKQUOTE
  1563. CLASS="ABSTRACT"
  1564. ><DIV
  1565. CLASS="abstract"
  1566. ><P
  1567. ></P
  1568. ><A
  1569. NAME="AEN120"
  1570. ></A
  1571. ><P
  1572. >     <ACRONYM
  1573. CLASS="acronym"
  1574. >PHP</ACRONYM
  1575. > ist die Abkⁿrzung fⁿr "PHP: Hypertext
  1576.     Preprocessor", eine weitverbreitete Open Source Skriptsprache speziell
  1577.     fⁿr Webentwicklungen. PHP lΣ▀t sich in HTML einbinden. Die Syntax erinnert
  1578.     an C, Java und Perl und ist einfach zu erlernen. Das Hauptziel dieser Sprache
  1579.     ist es, Webentwicklern die M÷glichkeit zu geben, schnell dynamisch
  1580.     generierte Webseiten zu erzeugen. Aber Sie k÷nnen PHP fⁿr weitaus mehr
  1581.     einsetzen.
  1582.    </P
  1583. ><P
  1584. ></P
  1585. ></DIV
  1586. ></BLOCKQUOTE
  1587. ><P
  1588. >    Dieses Handbuch besteht vorranging aus einer <A
  1589. HREF="#funcref"
  1590. >    Funktionsreferenz</A
  1591. >, enthΣlt aber zusΣtzlich auch eine
  1592.    <A
  1593. HREF="#langref"
  1594. >Sprachreferenz</A
  1595. >, ErlΣuterungen zu den
  1596.    wichtigsten <A
  1597. HREF="#features"
  1598. >Features</A
  1599. > und weitere
  1600.    <A
  1601. HREF="#appendixes"
  1602. >ergΣnzende Informationen</A
  1603. >.
  1604.   </P
  1605. ><P
  1606. >    Sie k÷nnen dieses Handbuch in verschiedenen Formaten unter <A
  1607. HREF="http://www.php.net/download-docs.php"
  1608. TARGET="_top"
  1609. >http://www.php.net/download-docs.php</A
  1610. >
  1611.    herunterladen. Informationen dazu, wie dieses Handbuch erstellt wird
  1612.    finden Sie im Anhang unter dem Kapitel <A
  1613. HREF="#about"
  1614. >    '▄ber dieses Handbuch'</A
  1615. >. Wenn Sie sich fⁿr die
  1616.    <A
  1617. HREF="#history"
  1618. >Geschichte von PHP</A
  1619. > interessieren, lesen
  1620.    Sie den entsprechenden Anhang.
  1621.   </P
  1622. ><DIV
  1623. CLASS="sect1"
  1624. ><HR><H2
  1625. CLASS="sect1"
  1626. ><A
  1627. NAME="contributors"
  1628. >Autoren und Mitwirkende</A
  1629. ></H2
  1630. ><P
  1631. >Wir heben die zur Zeit aktivsten Personen
  1632. auf der Titelseite des Handbuchs hervor, aber es gibt viel mehr Mitwirkende,
  1633. die zurzeit mithelfen oder in der Vergangenheit einen gro▀en Beitrag zu diesem
  1634. Projekt geleistet haben. Ebenfalls gibt es eine Menge von Personen, die hier
  1635. nicht namentlich aufgefⁿhrt sind, die durch ihre User Notes auf den
  1636. Handbuchseiten mithelfen. Die User Notes werden kontinuierlich in unser
  1637. Handbuch integriert und wir schΣtzen diese Unterstⁿtzung au▀erordentlich.
  1638. Alle folgenden Listen sind alphabetisch sortiert.</P
  1639. ><DIV
  1640. CLASS="sect2"
  1641. ><HR><H3
  1642. CLASS="sect2"
  1643. ><A
  1644. NAME="AEN135"
  1645. >Authoren und Editoren</A
  1646. ></H3
  1647. ><P
  1648. >    Obwohl im Augenblick nicht aktiv, haben
  1649. folgende Personen in der Vergangenheit wesentlichen Inhalt zum Handbuch
  1650. beigetragen:
  1651.    Jouni Ahto,              
  1652.    Alexander Aulbach,       
  1653.    Daniel Beckham,          
  1654.    Stig Bakken,             
  1655.    Jesus M. Castagnetto,    
  1656.    Ron Chmara,              
  1657.    John Coggeshall,         
  1658.    Simone Cortesi,          
  1659.    Markus Fischer,          
  1660.    Wez Furlong,             
  1661.    Sara Golemon,            
  1662.    Rui Hirokawa,            
  1663.    Brad House,              
  1664.    Moriyoshi Koizumi,       
  1665.    Rasmus Lerdorf,          
  1666.    Andrew Lindeman,         
  1667.    Stanislav Malyshev,      
  1668.    Rafael Martinez,         
  1669.    Yasuo Ohgaki,            
  1670.    Derick Rethans,          
  1671.    Sander Roobol,           
  1672.    Egon Schmid,             
  1673.    Thomas Schoefbeck,       
  1674.    Sascha Schumann,         
  1675.    Lars Torben Wilson,      
  1676.    Jim Winstead,            
  1677.    Jeroen van Wolffelaar und  
  1678.    Andrei Zmievski.         
  1679.   </P
  1680. ><P
  1681. >    Obwohl im Augenblick nicht aktiv, haben
  1682. folgende Personen in der Vergangenheit durch Ihre Editionsarbeit wesentlich zum
  1683. Handbuch beigetragen:
  1684.    Stig Bakken,                    
  1685.    Hartmut Holzgraefe und  
  1686.    Egon Schmid.                    
  1687.   </P
  1688. ></DIV
  1689. ><DIV
  1690. CLASS="sect2"
  1691. ><HR><H3
  1692. CLASS="sect2"
  1693. ><A
  1694. NAME="AEN139"
  1695. >User Note Betreuer</A
  1696. ></H3
  1697. ><P
  1698. >    Zur Zeit aktive Betreuer:
  1699.    Mehdi Achour,                
  1700.    Friedhelm Betz,              
  1701.    Vincent Gevers,              
  1702.    Aidan Lister,                
  1703.    Nuno Lopes und       
  1704.    Tom Sommer.                  
  1705.   </P
  1706. ><P
  1707. >    Folgende Personen haben in der
  1708. Vergangenheit einiges an Mⁿhe und Zeit zur Betreuung der User Notes investiert:
  1709.    Daniel Beckham,         
  1710.    Victor Boivie,          
  1711.    Jesus M. Castagnetto,   
  1712.    Nicolas Chaillan,       
  1713.    Ron Chmara,             
  1714.    James Cox,              
  1715.    Sara Golemon,           
  1716.    Zak Greant,             
  1717.    Szabolcs Heilig,        
  1718.    Oliver Hinckel,         
  1719.    Hartmut Holzgraefe,     
  1720.    Rasmus Lerdorf,         
  1721.    Andrew Lindeman,        
  1722.    Maxim Maletsky,         
  1723.    James Moore,            
  1724.    Sebastian Picklum,      
  1725.    Derick Rethans,         
  1726.    Sander Roobol,          
  1727.    Damien Seguy,           
  1728.    Jason Sheets,           
  1729.    Jani Taskinen,          
  1730.    Yasuo Ohgaki,           
  1731.    Philip Olson,           
  1732.    Lars Torben Wilson,     
  1733.    Jim Winstead,           
  1734.    Jared Wyles und  
  1735.    Jeroen van Wolffelaar.  
  1736.   </P
  1737. ></DIV
  1738. ></DIV
  1739. ></DIV
  1740. ><DIV
  1741. CLASS="PART"
  1742. ><A
  1743. NAME="getting-started"
  1744. ></A
  1745. ><DIV
  1746. CLASS="TITLEPAGE"
  1747. ><H1
  1748. CLASS="title"
  1749. >I. Einfⁿhrung</H1
  1750. ><DIV
  1751. CLASS="TOC"
  1752. ><DL
  1753. ><DT
  1754. ><B
  1755. >Inhaltsverzeichnis</B
  1756. ></DT
  1757. ><DT
  1758. >1. <A
  1759. HREF="#introduction"
  1760. >Einleitung</A
  1761. ></DT
  1762. ><DT
  1763. >2. <A
  1764. HREF="#tutorial"
  1765. >Kleines Tutorial</A
  1766. ></DT
  1767. ></DL
  1768. ></DIV
  1769. ></DIV
  1770. ><DIV
  1771. CLASS="chapter"
  1772. ><HR><H1
  1773. ><A
  1774. NAME="introduction"
  1775. >Kapitel 1. Einleitung</A
  1776. ></H1
  1777. ><DIV
  1778. CLASS="sect1"
  1779. ><H2
  1780. CLASS="sect1"
  1781. ><A
  1782. NAME="intro-whatis"
  1783. >Was ist PHP?</A
  1784. ></H2
  1785. ><P
  1786. >     <ACRONYM
  1787. CLASS="acronym"
  1788. >PHP</ACRONYM
  1789.     
  1790.     <ACRONYM
  1791. CLASS="acronym"
  1792. >PHP</ACRONYM
  1793. > (Akronym fⁿr "PHP: Hypertext Preprocessor")
  1794.     ist eine weit verbreitete und fⁿr den allgemeinen Gebrauch bestimmte
  1795.     Open Source Skriptsprache, welche speziell fⁿr die Webprogrammierung
  1796.     geeignet ist, und in HTML eingebettet werden kann.
  1797.    </P
  1798. ><P
  1799. >     H÷rt sich einfach an, aber was hei▀t es genau? Ein Beispiel:
  1800.    </P
  1801. ><P
  1802. >     <TABLE
  1803. WIDTH="100%"
  1804. BORDER="0"
  1805. CELLPADDING="0"
  1806. CELLSPACING="0"
  1807. CLASS="EXAMPLE"
  1808. ><TR
  1809. ><TD
  1810. ><DIV
  1811. CLASS="example"
  1812. ><A
  1813. NAME="AEN154"
  1814. ></A
  1815. ><P
  1816. ><B
  1817. >Beispiel 1-1. Ein einleitendes Beispiel</B
  1818. ></P
  1819. ><TABLE
  1820. BORDER="0"
  1821. BGCOLOR="#E0E0E0"
  1822. CELLPADDING="5"
  1823. ><TR
  1824. ><TD
  1825. ><PRE
  1826. CLASS="php"
  1827. ><html>
  1828.     <head>
  1829.         <title>Beispiel</title>
  1830.     </head>
  1831.     <body>
  1832.  
  1833.         <?php 
  1834.         echo "Hallo, ich bin ein PHP-Skript!"; 
  1835.         ?>
  1836.  
  1837.     </body>
  1838. </html></PRE
  1839. ></TD
  1840. ></TR
  1841. ></TABLE
  1842. ></DIV
  1843. ></TD
  1844. ></TR
  1845. ></TABLE
  1846. >
  1847.    </P
  1848. ><P
  1849. >     Beachten Sie den Unterschied zu einem Skript, welches in anderen
  1850.     Sprachen wie Perl oder C geschrieben wurde -- anstatt ein
  1851.     Programm mit vielen Anweisungen zur Ausgabe von HTML zu schreiben,
  1852.     schreibt man einen HTML-Code mit einigen eingebetteten
  1853.     Anweisungen, um etwas auszufⁿhren (z.B. um - wie oben - Text
  1854.     auszugeben). Der PHP-Code steht zwischen speziellen <A
  1855. HREF="#language.basic-syntax.phpmode"
  1856. >Anfangs- und
  1857.     Schlusstags</A
  1858. >, mit denen man in den PHP-Modus und zurⁿck
  1859.     wechseln kann.
  1860.    </P
  1861. ><P
  1862. >     Was PHP von clientseitigen Sprachen wie Javaskript unterscheidet,
  1863.     ist dass der Code auf dem Server ausgefⁿhrt wird. Sollten Sie ein
  1864.     Skript wie das obige auf ihrem Server ausfⁿhren, wⁿrde der Besucher
  1865.     nur das Ergebnis empfangen, ohne die M÷glichkeit herauszufinden,
  1866.     wie der zugrundeliegende Code aussieht. Sie k÷nnen ihren Webserver
  1867.     auch anweisen, alle ihre HTML-Dateien mit PHP zu parsen, denn dann
  1868.     gibt es wirklich nichts, das dem Benutzer sagt, was sie in petto
  1869.     haben.
  1870.    </P
  1871. ><P
  1872. >     Das Beste an der Verwendung von PHP ist, dass es fⁿr Neulinge
  1873.     extrem simpel ist, aber auch einen riesigen Funktionsumfang fⁿr
  1874.     den professionellen Programmierer bietet. Scheuen Sie sich nicht,
  1875.     die lange Liste der PHP-Funktionen zu lesen. Sie k÷nnen einsteigen,
  1876.     und binnen weniger Stunden bereits mit dem Schreiben von einfachen
  1877.     Skripten beginnen.
  1878.    </P
  1879. ><P
  1880. >     Auch wenn die Entwicklung von PHP auf serverseitige Skripte fokussiert
  1881.     ist, k÷nnen Sie mit PHP weitaus mehr anstellen. Lesen Sie mehr im
  1882.     Abschnitt <A
  1883. HREF="#intro-whatcando"
  1884. >Was kann PHP?</A
  1885.    </P
  1886. ></DIV
  1887. ><DIV
  1888. CLASS="sect1"
  1889. ><HR><H2
  1890. CLASS="sect1"
  1891. ><A
  1892. NAME="intro-whatcando"
  1893. >Was kann PHP?</A
  1894. ></H2
  1895. ><P
  1896. >     Alles. PHP ist hauptsΣchlich auf serverseitige Skripte fokussiert,
  1897.     weshalb Sie alles tun k÷nnen, was auch ein anderes CGI Programm
  1898.     kann, wie z.B. Formulardaten sammeln, dynamische Inhalte fⁿr
  1899.     Websites generieren oder Cookies senden und empfangen. Aber PHP
  1900.     kann noch viel mehr.
  1901.    </P
  1902. ><P
  1903. >     Es gibt drei Hauptgebiete, in denen PHP Skripte genutzt werden.
  1904.     <P
  1905. ></P
  1906. ><UL
  1907. ><LI
  1908. ><P
  1909. >        Serverseitige Skripte. Dies ist das traditionelle und auch Hauptfeld
  1910.        von PHP. Sie ben÷tigen dazu drei Dinge. Den PHP Parser (CGI oder
  1911.        Server-Modul), einen Webserver und einen Webbrowser. Sie mⁿssen
  1912.        den Webserver, verbunden mit einer PHP Installation laufen lassen.
  1913.        Sie k÷nnen Sich Ausgabe der PHP Programme ⁿber den Server mit
  1914.        einem Webbrowser ansehen. Fⁿr weitere Informationen lesen Sie
  1915.        bitte im Abschnitt <A
  1916. HREF="#installation"
  1917. >Installation</A
  1918. >
  1919.        weiter.
  1920.       </P
  1921. ></LI
  1922. ><LI
  1923. ><P
  1924. >        Skripte auf der Kommandozeile. Sie k÷nnen auch PHP Skripte
  1925.        schreiben, um sie ohne einen Server oder einen Browser laufen
  1926.        zu lassen. Hierfⁿr ben÷tigen Sie nur den PHP Parser. Diese Art
  1927.        der Verwendung ist fⁿr die regelmΣ▀ig auszufⁿhrende Skripte mittels
  1928.        cron (unter *nix oder Linux) oder dem Task Scheduler (unter Windows).
  1929.        Diese Skripte k÷nnen auch fⁿr einfache Aufgaben zur Verarbeitung von
  1930.        Text verwendet werden. Weitere Informationen dazu finden Sie im
  1931.        Abschnitt <A
  1932. HREF="#features.commandline"
  1933. >Using PHP from the
  1934.        command line</A
  1935. >.
  1936.       </P
  1937. ></LI
  1938. ><LI
  1939. ><P
  1940. >        Schreiben clientseitiger GUI Applikationen. PHP ist wahrscheinlich
  1941.        nicht die allerbeste Sprache um GUI-Applikationen zu schreiben,
  1942.        aber wenn Sie PHP sehr gut kennen und einige weiterfⁿhrende Funktionen
  1943.        in Ihren clientseitigen Applikationen nutzen m÷chten, k÷nnen Sie
  1944.        PHP-GTK nutzen, um derartige Programme zu schreiben. Auf diese Art
  1945.        haben Sie auch die M÷glichkeit, Plattformⁿbergreifende Applikationen
  1946.        zu schreiben. PHP-GTK ist eine Erweiterung von PHP, welche in der
  1947.        Hauptdistribution nicht enthalten ist. Sollten Sie daran interessiert
  1948.        sein, besuchen Sie die <A
  1949. HREF="http://gtk.php.net/"
  1950. TARGET="_top"
  1951. >PHP-GTK
  1952.        Website</A
  1953. >.
  1954.       </P
  1955. ></LI
  1956. ></UL
  1957. >
  1958.    </P
  1959. ><P
  1960. >     PHP kann auf allen gΣngigen Betriebssystemen verwendet werden, inkl.
  1961.     Linux, vielen Unix-Varianten (inkl. HP-UX, Solaris und OpenBSD), 
  1962.     Microsoft Windows, Mac OS X, RISC OS, und wahrscheinlich anderen.
  1963.     PHP unterstⁿtzt auch die meisten der heute gebrΣuchlichen Webserver.
  1964.     Dies umfasst Apache, Microsoft Internet Information Server,
  1965.     Personal Web Server, Netscape und iPlanet Server, Oreilly
  1966.     Website Pro Server, Caudium, Xitami, OmniHTTPd, und viele andere.
  1967.     Fⁿr den Gro▀teil der Server bietet PHP ein eigenes Modul, fⁿr die
  1968.     anderen, welche den CGI Standard unterstⁿtzen, kann PHP als CGI
  1969.     Prozessor arbeiten.
  1970.    </P
  1971. ><P
  1972. >     So haben Sie Freiheit, PHP auf dem Betriebssystem und dem Webserver
  1973.     Ihrer Wahl laufen zu lassen. Weiters k÷nnen Sie je nach Vorliebe
  1974.     prozedural, objektorientiert, oder gemischt programmieren. Auch
  1975.     wenn in der derzeitigen Version von PHP nicht jedes Standard OOP
  1976.     Feature realisiert ist, sind viele Bibliotheken und gro▀e
  1977.     Applikationen (inklusive der PEAR Bibliothek) exklusiv unter
  1978.     Verwendung von OOP Code geschrieben worden.
  1979.    </P
  1980. ><P
  1981. >     Mit PHP sind Sie nicht auf die Ausgabe von HTML beschrΣnkt. Seine
  1982.     FΣhigkeiten umfassen auch das dynamische Generieren von Bildern,
  1983.     PDF Dateien und Flash Animationen (mittels libswf und Ming). Sie
  1984.     k÷nnen auch leicht jede Art von Text, wie XHTML oder irgendeine
  1985.     andere XML Datei ausgeben. PHP kann diese Dateien automatisch
  1986.     generieren und im Dateisystem speichern, anstatt diese nur
  1987.     auszugeben bzw. auszudrucken, und formt auch serverseitigen
  1988.     Zwischenspeicher Ihrer dynamischen Inhalte.
  1989.    </P
  1990. ><P
  1991. >     Vielleicht die gr÷▀te und bemerkenswerteste StΣrke von PHP ist
  1992.     seine Unterstⁿtzung fⁿr eine breite Masse von Datenbanken. Eine
  1993.     datenbankgestⁿtzte Website zu erstellen ist unglaublich
  1994.     einfach. Die folgenden Datenbanken werden zur Zeit unterstⁿtzt:
  1995.     <A
  1996. NAME="AEN181"
  1997. ></A
  1998. ><BLOCKQUOTE
  1999. CLASS="BLOCKQUOTE"
  2000. ><P
  2001. ></P
  2002. ><TABLE
  2003. BORDER="0"
  2004. ><TBODY
  2005. ><TR
  2006. ><TD
  2007. >Adabas D</TD
  2008. ><TD
  2009. >Ingres</TD
  2010. ><TD
  2011. >Oracle (OCI7 und OCI8)</TD
  2012. ></TR
  2013. ><TR
  2014. ><TD
  2015. >dBase</TD
  2016. ><TD
  2017. >InterBase</TD
  2018. ><TD
  2019. >Ovrimos</TD
  2020. ></TR
  2021. ><TR
  2022. ><TD
  2023. >Empress</TD
  2024. ><TD
  2025. >FrontBase</TD
  2026. ><TD
  2027. >PostgreSQL</TD
  2028. ></TR
  2029. ><TR
  2030. ><TD
  2031. >FilePro (nur Lesezugriff)</TD
  2032. ><TD
  2033. >mSQL</TD
  2034. ><TD
  2035. >Solid</TD
  2036. ></TR
  2037. ><TR
  2038. ><TD
  2039. >Hyperwave</TD
  2040. ><TD
  2041. >Direct MS-SQL</TD
  2042. ><TD
  2043. >Sybase</TD
  2044. ></TR
  2045. ><TR
  2046. ><TD
  2047. >IBM DB2</TD
  2048. ><TD
  2049. >MySQL</TD
  2050. ><TD
  2051. >Velocis</TD
  2052. ></TR
  2053. ><TR
  2054. ><TD
  2055. >Informix</TD
  2056. ><TD
  2057. >ODBC</TD
  2058. ><TD
  2059. >Unix dbm</TD
  2060. ></TR
  2061. ></TBODY
  2062. ></TABLE
  2063. ><P
  2064. ></P
  2065. ></BLOCKQUOTE
  2066. >
  2067.     Wir haben auch die Erweiterung DBX zur Datenbankabstraktion, welche
  2068.     Ihnen die transparente Verwendung irgendeiner von dieser Erweiterung
  2069.     unterstⁿtzten Datenbank erlaubt. Weiters unterstⁿtzt PHP ODBC, den 
  2070.     Open Database Connection Standard, mit welchem Sie sich zu jeder
  2071.     anderen diesen Weltstandard unterstⁿtzenden Datenbank verbinden
  2072.     k÷nnen.
  2073.    </P
  2074. ><P
  2075. >     PHP unterstⁿtzt auch die Kommunikation mit anderen Services, welche
  2076.     Protokolle wie LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (auf Windows)
  2077.     und unzΣhlige andere unterstⁿtzen. Sie k÷nnen auch einfache Netzwerk
  2078.     Sockets ÷ffnen, und unter Verwendung irgendeines Protokolls
  2079.     kommunizieren. PHP unterstⁿtzt auch WDDX (Web Distributed Data
  2080.     Exchange) zum Austausch komplexer Daten zwischen Programmiersprachen.
  2081.     Da wir gerade vom Zusammenwirken sprechen: PHP bietet auch
  2082.     Unterstⁿtzung zur Instantiierung von Java Objekten, und deren
  2083.     transparente Verwendung als PHP Objekte. Sie k÷nnen auch unsere
  2084.     CORBA Erweiterung verwenden, um auf entfernte Objekte zuzugreifen.
  2085.    </P
  2086. ><P
  2087. >     PHP verfⁿgt ⁿber Σu▀erst hilfreiche Textverarbeitungsfunktionen, von
  2088.     den regulΣren Ausdrⁿcken (POSIX erweitert oder Perl) bis zum Parsen
  2089.     von XML Dokumenten. Fⁿr den Zugriff und das Parsen von XML Dokumenten
  2090.     unterstⁿtzen wir die Standards SAX und DOM. Sie k÷nnen unsere XSLT
  2091.     Erweiterung verwenden, um XML Dokumente zu transformieren.
  2092.    </P
  2093. ><P
  2094. >     Wenn Sie PHP im Bereich des E-Commerce nutzen, werden Sie Funktionen
  2095.     fⁿr Cybercash Payment, CyberMUT, VeriSign Payflow Pro und CCVS fⁿr 
  2096.     Ihre Onlineprogramme zur Zahlungsabwicklung zu schΣtzen lernen.
  2097.    </P
  2098. ><P
  2099. >     Wir haben viele andere interessante Erweiterungen, wie mnoGoSearch
  2100.     fⁿr Suchmaschinen, die IRC Gateway Funktionen, viele
  2101.     Komprimierungswerkzeuge (gzip, bz2), Kalenderumrechnung,
  2102.     ▄bersetzung...
  2103.    </P
  2104. ><P
  2105. >     Wie Sie sehen k÷nnen, reicht diese Seite nicht aus, um alle M÷glichkeiten
  2106.     und Vorteile von PHP aufzulisten. Lesen Sie im Abschnitt <A
  2107. HREF="#installation"
  2108. >Installation</A
  2109. > weiter, und konsultieren Sie
  2110.     auch die <A
  2111. HREF="#funcref"
  2112. >Funktionsreferenz</A
  2113. > fⁿr weitere
  2114.     ErlΣuterungen der einzelnen hier erwΣhnten Erweiterungen.
  2115.    </P
  2116. ></DIV
  2117. ></DIV
  2118. ><DIV
  2119. CLASS="chapter"
  2120. ><HR><H1
  2121. ><A
  2122. NAME="tutorial"
  2123. >Kapitel 2. Kleines Tutorial</A
  2124. ></H1
  2125. ><P
  2126. >    Auf diesen Seiten m÷chten wir Ihnen die Grundlagen von PHP in einem
  2127.    kleinen Tutorial vorstellen. Dieser Text behandelt nur das Erstellen
  2128.    von dynamischen Web-Seiten, obwohl PHP natⁿrlich nicht nur dafⁿr
  2129.    geeignet ist. Weitere Informationen finden Sie im Abschnitt
  2130.    <A
  2131. HREF="#intro-whatcando"
  2132. >Was kann PHP?</A
  2133. >.
  2134.   </P
  2135. ><P
  2136. >    Mit PHP erweiterte Web-Seiten werden wie normale HTML-Seiten
  2137.    behandelt. Sie k÷nnen sie genauso wie normale HTML-Seiten erstellen
  2138.    und bearbeiten.
  2139.   </P
  2140. ><DIV
  2141. CLASS="sect1"
  2142. ><HR><H2
  2143. CLASS="sect1"
  2144. ><A
  2145. NAME="tutorial.requirements"
  2146. >Was brauche ich?</A
  2147. ></H2
  2148. ><P
  2149. >     In diesem Tutorial gehen wir davon aus, dass auf Ihrem Server
  2150.     die PHP-Unterstⁿtzung aktiviert ist und dass die Dateiendung
  2151.     <TT
  2152. CLASS="filename"
  2153. >.php</TT
  2154. > PHP zugeordnet ist. Auf den meisten
  2155.     Servern ist dies die Standardeinstellung fⁿr PHP-Dateien, aber
  2156.     fragen Sie bitte Ihren Server-Administrator, um sicherzugehen.
  2157.     Wenn Ihr Server PHP unterstⁿtzt, mⁿssen Sie nichts machen.
  2158.     Erstellen Sie einfach Ihre <TT
  2159. CLASS="filename"
  2160. >.php</TT
  2161. >-Dateien
  2162.     und legen Sie diese in Ihr Web-Verzeichnis - der Server wird
  2163.     sie dann fⁿr Sie parsen. Sie mⁿssen nichts kompilieren und
  2164.     auch keine Zusatz-Tools installieren. Stellen Sie sich diese
  2165.     PHP-erweiterten Dateien wie normale HTML-Seiten mit einer
  2166.     ganzen Familie von "magischen" Tags, die Sie verschiedenste
  2167.     Dinge tun lassen, vor.
  2168.    </P
  2169. ><P
  2170. >     Angenommen, Sie m÷chten Bandbreite sparen und lokal entwickeln.
  2171.     In diesem Fall mⁿssen Sie einen Webserver wie z.B.
  2172.     <A
  2173. HREF="#install.apache"
  2174. >Apache</A
  2175. > und natⁿrlich
  2176.     <A
  2177. HREF="http://www.php.net/downloads.php"
  2178. TARGET="_top"
  2179. >PHP</A
  2180. > installieren.
  2181.     Sehr empfehlenswert ist auch die Installation einer Datenbank
  2182.     wie z.B. <A
  2183. HREF="http://dev.mysql.com/doc/"
  2184. TARGET="_top"
  2185. >MySQL</A
  2186. >. Sie
  2187.     k÷nnen diese Programm entweder eins nach dem anderen selbst
  2188.     installieren oder nach einem <A
  2189. HREF="http://www.hotscripts.com/PHP/Software_and_Servers/Installation_Kits/"
  2190. TARGET="_top"
  2191. >vorkonfigurierten Paket</A
  2192. > suchen,
  2193.     dass automatisch alle ben÷tigen Programme mit einigen wenigen
  2194.     Mausklicks installieren kann.
  2195.     Es ist sehr einfach, einen Webserver mit PHP-Support unter
  2196.     jedem Betriebssystem, wie Linux oder Windows, zu installieren.
  2197.     Unter Linux ist <A
  2198. HREF="http://www.rpmfind.net/"
  2199. TARGET="_top"
  2200. >rpmfind</A
  2201. >
  2202.     nⁿtzlich, um RPMs zu finden.
  2203.    </P
  2204. ></DIV
  2205. ><DIV
  2206. CLASS="sect1"
  2207. ><HR><H2
  2208. CLASS="sect1"
  2209. ><A
  2210. NAME="tutorial.firstpage"
  2211. >Ihre erste PHP-erweiterte Seite</A
  2212. ></H2
  2213. ><P
  2214. >     Erstellen Sie eine Datei mit dem Namen <TT
  2215. CLASS="filename"
  2216. >hallo.php</TT
  2217. >
  2218.     und speichern Sie sie im Root-Verzeichnis Ihres Webservers
  2219.     (<VAR
  2220. CLASS="varname"
  2221. >DOCUMENT_ROOT</VAR
  2222. >) mit dem folgenden Inhalt:
  2223.    </P
  2224. ><P
  2225. >     <TABLE
  2226. WIDTH="100%"
  2227. BORDER="0"
  2228. CELLPADDING="0"
  2229. CELLSPACING="0"
  2230. CLASS="EXAMPLE"
  2231. ><TR
  2232. ><TD
  2233. ><DIV
  2234. CLASS="example"
  2235. ><A
  2236. NAME="AEN233"
  2237. ></A
  2238. ><P
  2239. ><B
  2240. >Beispiel 2-1. Unser erstes PHP-Skript: <TT
  2241. CLASS="filename"
  2242. >hallo.php</TT
  2243. ></B
  2244. ></P
  2245. ><TABLE
  2246. BORDER="0"
  2247. BGCOLOR="#E0E0E0"
  2248. CELLPADDING="5"
  2249. ><TR
  2250. ><TD
  2251. ><PRE
  2252. CLASS="php"
  2253. ><html>
  2254.  <head>
  2255.   <title>PHP-Test</title>
  2256.  </head>
  2257.  <body>
  2258.  <?php echo "<p>Hallo Welt</p>"; ?>
  2259.  </body>
  2260. </html></PRE
  2261. ></TD
  2262. ></TR
  2263. ></TABLE
  2264. ><P
  2265.       Benutzen Sie Ihren Browser, um die Datei ⁿber den Webserver-URL
  2266.       aufzurufen. Der URL muss mit "/halle.php" enden. Wenn Sie lokal
  2267.       entwickeln, sieht der URL z.B. so aus:
  2268.       <VAR
  2269. CLASS="literal"
  2270. >http://localhost/hallo.php</VAR
  2271. > oder
  2272.       <VAR
  2273. CLASS="literal"
  2274. >http://127.0.0.1/hallo.php</VAR
  2275. > - andere Adressen
  2276.       sind aber, abhΣngig vom Webserver, auch m÷glich.
  2277.       Sie k÷nnen sich auch die Direktiven
  2278.       <VAR
  2279. CLASS="varname"
  2280. >DocumentRoot</VAR
  2281. > und
  2282.       <VAR
  2283. CLASS="varname"
  2284. >ServerName</VAR
  2285. > in der Konfigurationsdatei Ihres
  2286.       Webservers fⁿr weitere Informationen anschauen (bei Apache
  2287.       lautet der Name dieser Datei <TT
  2288. CLASS="filename"
  2289. >httpd.conf</TT
  2290. >).
  2291.       Wenn Sie alles korrekt installiert haben, wird die Datei von
  2292.       PHP geparst und Sie werden die folgende Ausgabe in Ihrem
  2293.       Browser sehen:
  2294.      </P
  2295. ><P
  2296. >       <TABLE
  2297. BORDER="0"
  2298. BGCOLOR="#E0E0E0"
  2299. CELLPADDING="5"
  2300. ><TR
  2301. ><TD
  2302. ><PRE
  2303. CLASS="html"
  2304. ><html>
  2305.  <head>
  2306.   <title>PHP-Test</title>
  2307.  </head>
  2308.  <body>
  2309.  <p>Hallo Welt</p>
  2310.  </body>
  2311. </html></PRE
  2312. ></TD
  2313. ></TR
  2314. ></TABLE
  2315. >
  2316.      </P
  2317. ></DIV
  2318. ></TD
  2319. ></TR
  2320. ></TABLE
  2321. >
  2322.    </P
  2323. ><P
  2324. >     Beachten Sie, dass dies nicht mit einem CGI-Skript vergleichbar ist.
  2325.     Die Datei muss nicht ausfⁿhrbar oder sonst irgendwie speziell sein.
  2326.     Stellen Sie sich die Datei wie eine normale HTML-Datei vor, die eine
  2327.     spezielle Menge von Tags zur Verfⁿgung stellt, mit denen Sie viele
  2328.     interessante Dinge machen k÷nnen.
  2329.    </P
  2330. ><P
  2331. >     Das Beispiel ist extrem einfach und natⁿrlich brauchen Sie PHP nicht,
  2332.     um eine Seite wie diese zu erstellen. Denn es macht nicht mehr, als
  2333.     <VAR
  2334. CLASS="literal"
  2335. >Hallo Welt</VAR
  2336. > mit der <A
  2337. HREF="#function.echo"
  2338. ><B
  2339. CLASS="function"
  2340. >echo()</B
  2341. ></A
  2342. >-Anweisung
  2343.     von PHP auszugeben.
  2344.    </P
  2345. ><P
  2346. >     Wenn Sie dieses Beispiel ausprobiert haben und Sie aber keine Ausgabe
  2347.     erhalten haben oder zum Download aufgefordert worden sind oder die
  2348.     komplette Datei als Text erhalten haben, dann ist es sehr wahrscheinlich,
  2349.     dass auf Ihrem Server PHP nicht aktiviert ist. Fragen Sie in diesem
  2350.     Fall Ihren Administrator und weisen Sie ihn auf das
  2351.     <A
  2352. HREF="#installation"
  2353. >Installations-Kapitel</A
  2354. > hin.
  2355.     Wenn Sie lokal entwickeln, lesen Sie bitte das Installations-Kapitel,
  2356.     um festzustellen, ob alles richtig konfiguriert wurde.
  2357.     Sollten Ihre Probleme nach Lesen dieses Kapitels immer noch bestehen,
  2358.     z÷gern Sie nicht und nutzen Sie eines der vielen <A
  2359. HREF="http://www.php.net/support.php"
  2360. TARGET="_top"
  2361. >Support</A
  2362. >-Angebote.
  2363.    </P
  2364. ><P
  2365. >     Der wichtigste Punkt im Beispiel ist, Ihnen das spezielle PHP Tag-Format
  2366.     zu zeigen. Im Beispiel wurde <VAR
  2367. CLASS="literal"
  2368. ><?php</VAR
  2369. > verwendet,
  2370.     um den Beginn eines PHP-Tags zu kennzeichnen. Anschlie▀end folgte
  2371.     die PHP-Anweisung. Mit dem schlie▀enden Tag, <VAR
  2372. CLASS="literal"
  2373. >?></VAR
  2374. >,
  2375.     wurde der PHP-Modus wieder verlassen. Sie k÷nnen an jeder Stelle und so
  2376.     oft Sie wollen, in den PHP-Modus wechseln und ihn wieder verlassen. Fⁿr
  2377.     weitere Details lesen Sie bitte den Abschnitt zu den <A
  2378. HREF="#language.basic-syntax"
  2379. >Grundlagen der Syntax</A
  2380. > von PHP.
  2381.    </P
  2382. ><DIV
  2383. CLASS="note"
  2384. ><BLOCKQUOTE
  2385. CLASS="note"
  2386. ><P
  2387. ><B
  2388. >Anmerkung zu Text-Editoren: </B
  2389. >
  2390.      Es gibt eine ganze Reihe von Text-Editoren und Integrated Development
  2391.      Environments (IDEs), mit denen Sie Ihre PHP-Dateien erstellen, bearbeiten
  2392.      und managen k÷nnen. Eine Liste solcher Programme finden Sie hier:
  2393.      <A
  2394. HREF="http://phpeditors.linuxbackup.co.uk/"
  2395. TARGET="_top"
  2396. >PHP Editor's List</A
  2397. >.
  2398.      Wenn Sie einen Editor vorschlagen m÷chten, besuchen Sie bitte die genannte
  2399.      Seite und bitten Sie den Betreiber der Seite, dass er den Editor
  2400.      der Liste hinzufⁿgt.
  2401.      Wir empfehlen Ihnen einen Editor zu benutzen, der Syntax-Highlighting
  2402.      bietet.
  2403.     </P
  2404. ></BLOCKQUOTE
  2405. ></DIV
  2406. ><DIV
  2407. CLASS="note"
  2408. ><BLOCKQUOTE
  2409. CLASS="note"
  2410. ><P
  2411. ><B
  2412. >Anmerkung zu Textverarbeitungen: </B
  2413. >
  2414.      Textverarbeitungen wie StarOffice Writer, Microsoft Word und Abiword sind
  2415.      keine gute Wahl, um PHP-Dateien zu bearbeiten.
  2416.      Wenn Sie eines dieser Programme fⁿr dieses Test-Skript nutzen m÷chten,
  2417.      dann mⁿssen Sie sicherstellen, dass die Datei als "Nur Text"-Datei
  2418.      gespeichert wird, da PHP sonst das Skript nicht lesen und nicht
  2419.      ausfⁿhren kann.
  2420.     </P
  2421. ></BLOCKQUOTE
  2422. ></DIV
  2423. ><DIV
  2424. CLASS="note"
  2425. ><BLOCKQUOTE
  2426. CLASS="note"
  2427. ><P
  2428. ><B
  2429. >Anmerkung zu Notepad, dem Windows-Standard-Editor: </B
  2430. >    
  2431.      Wenn Sie Ihre PHP-Skripte mit Notepad schreiben, mⁿssen Sie sicherstellen,
  2432.      dass Ihre Dateien mit der Endung <TT
  2433. CLASS="filename"
  2434. >.php</TT
  2435. > gespeichert
  2436.      werden. (Notepad fⁿgt die Endung <TT
  2437. CLASS="filename"
  2438. >.txt</TT
  2439. > automatisch
  2440.      an den Dateinamen an, wenn Sie das nicht mit einem der folgenden Schritte
  2441.      verhindern.)
  2442.      Wenn Sie die Datei speichern und einen Namen fⁿr die Datei eingeben sollen,
  2443.      dann setzen Sie den Dateinamen in Anfⁿhrungszeichen (z.B.
  2444.      "<TT
  2445. CLASS="filename"
  2446. >hallo.php</TT
  2447. >").
  2448.      Alternativ k÷nnen Sie auch im "Datei speichern"-Fenster in der Drop-Down-Liste
  2449.      "Dateityp" die Einstellung auf "Alle Dateien" Σndern. Sie k÷nnen dann den
  2450.      Dateinamen ohne Anfⁿhrungszeichen eingeben.
  2451.     </P
  2452. ></BLOCKQUOTE
  2453. ></DIV
  2454. ><P
  2455.     Nachdem Sie jetzt erfolgreich ein einfaches, funktionierendes PHP-Skript
  2456.     geschrieben haben, wird es Zeit, das berⁿhmteste PHP-Skript zu schreiben.
  2457.     Rufen Sie die Funktion <A
  2458. HREF="#function.phpinfo"
  2459. ><B
  2460. CLASS="function"
  2461. >phpinfo()</B
  2462. ></A
  2463. > auf und Sie bekommen
  2464.     viele nⁿtzliche Informationen ⁿber Ihr System und Ihre Installation wie
  2465.     z.B. die verfⁿgbaren <A
  2466. HREF="#language.variables.predefined"
  2467. >vordefinierten Variablen</A
  2468. >,
  2469.     die geladenen PHP-Module und die <A
  2470. HREF="#configuration"
  2471. >Konfigurations</A
  2472. >-Einstellungen. Nehmen Sie
  2473.     sich etwas Zeit und schauen Sie sich diese wichtigen Informationen an.
  2474.    </P
  2475. ></DIV
  2476. ><DIV
  2477. CLASS="sect1"
  2478. ><HR><H2
  2479. CLASS="sect1"
  2480. ><A
  2481. NAME="tutorial.useful"
  2482. >Nⁿtzliches</A
  2483. ></H2
  2484. ><P
  2485. >     Kommen wir nun zu einem etwas nⁿtzlicheren Beispiel. Wir wollen prⁿfen,
  2486.     welchen Browser die Person, die die Seite besucht, benutzt.
  2487.     Um das zu tun, prⁿfen wir den "user agent"-String, den der Browser
  2488.     als Teil seiner HTTP-Anforderung sendet. Diese Information ist in einer
  2489.     <A
  2490. HREF="#language.variables"
  2491. >Variablen</A
  2492. > abgelegt. In PHP
  2493.     beginnen Variablen immer mit einem Dollar-Zeichen. Die Variable, die
  2494.     uns jetzt interessiert, ist <VAR
  2495. CLASS="varname"
  2496. >$_SERVER["HTTP_USER_AGENT"]</VAR
  2497. >.
  2498.    </P
  2499. ><DIV
  2500. CLASS="note"
  2501. ><BLOCKQUOTE
  2502. CLASS="note"
  2503. ><P
  2504. ><B
  2505. >PHP Autoglobals-Anmerkung: </B
  2506. >
  2507.      <A
  2508. HREF="#reserved.variables.server"
  2509. >$_SERVER</A
  2510. > ist eine
  2511.      speziell reservierte PHP-Variable, die alle Informationen ⁿber den
  2512.      Webserver enthΣlt. Diese Variable wird auch als auto- oder superglobal
  2513.      bezeichnet. Mehr Informationen darⁿber Sie auf der Manual-Seite ⁿber
  2514.      <A
  2515. HREF="#language.variables.superglobals"
  2516. >Autoglobals</A
  2517. >.
  2518.      Diese speziellen Variablen wurden in PHP 
  2519.      <A
  2520. HREF="http://www.php.net/release_4_1_0.php"
  2521. TARGET="_top"
  2522. >4.1.0</A
  2523. > eingefⁿhrt.
  2524.      Vorher wurden stattdessen die Σlteren <VAR
  2525. CLASS="varname"
  2526. >$HTTP_*_VARS</VAR
  2527. >-Arrays
  2528.      benutzt, also z.B. <VAR
  2529. CLASS="varname"
  2530. >$HTTP_SERVER_VARS</VAR
  2531. >. Auch wenn diese
  2532.      Variablen nicht mehr genutzt werden sollen - sie existieren weiterhin.
  2533.      (Beachten Sie auch die Seite <A
  2534. HREF="#tutorial.oldcode"
  2535. >Alten Code
  2536.      mit neuen PHP-Versionen benutzen</A
  2537. >.)
  2538.     </P
  2539. ></BLOCKQUOTE
  2540. ></DIV
  2541. ><P
  2542. >     Um die Variable auszugeben, schreiben wir einfach:
  2543.    </P
  2544. ><P
  2545. >     <TABLE
  2546. WIDTH="100%"
  2547. BORDER="0"
  2548. CELLPADDING="0"
  2549. CELLSPACING="0"
  2550. CLASS="EXAMPLE"
  2551. ><TR
  2552. ><TD
  2553. ><DIV
  2554. CLASS="example"
  2555. ><A
  2556. NAME="AEN289"
  2557. ></A
  2558. ><P
  2559. ><B
  2560. >Beispiel 2-2. Variable ausgeben (Array-Element)</B
  2561. ></P
  2562. ><TABLE
  2563. BORDER="0"
  2564. BGCOLOR="#E0E0E0"
  2565. CELLPADDING="5"
  2566. ><TR
  2567. ><TD
  2568. ><PRE
  2569. CLASS="php"
  2570. ><?php echo $_SERVER["HTTP_USER_AGENT"]; ?></PRE
  2571. ></TD
  2572. ></TR
  2573. ></TABLE
  2574. ><P
  2575. >      Die Ausgabe dieses Beispiel k÷nnte so aussehen:
  2576.      <TABLE
  2577. BORDER="0"
  2578. BGCOLOR="#E0E0E0"
  2579. CELLPADDING="5"
  2580. ><TR
  2581. ><TD
  2582. ><PRE
  2583. CLASS="html"
  2584. >Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)</PRE
  2585. ></TD
  2586. ></TR
  2587. ></TABLE
  2588. >
  2589.     </P
  2590. ></DIV
  2591. ></TD
  2592. ></TR
  2593. ></TABLE
  2594. >
  2595.    </P
  2596. ><P
  2597. >     Es gibt viele <A
  2598. HREF="#language.types"
  2599. >Typen</A
  2600. > von
  2601.     Variablen. Im obigen Beispiel haben wir ein <A
  2602. HREF="#language.types.array"
  2603. >Array</A
  2604. >-Element ausgegeben.
  2605.     Arrays k÷nnen sehr nⁿtzlich sein.
  2606.    </P
  2607. ><P
  2608. >     <VAR
  2609. CLASS="varname"
  2610. >$_SERVER</VAR
  2611. > ist nur eine von vielen Variablen, die
  2612.     Ihnen automatisch von PHP zur Verfⁿgung gestellt werden. Eine Liste
  2613.     finden Sie auf der Seite <A
  2614. HREF="#reserved.variables"
  2615. >Reservierte
  2616.     Variablen</A
  2617. > im Manual. Eine vollstΣndige Liste k÷nnen Sie auch
  2618.     bekommen, wenn Sie eine Datei wie die folgende erstellen:
  2619.    </P
  2620. ><P
  2621. >     <TABLE
  2622. WIDTH="100%"
  2623. BORDER="0"
  2624. CELLPADDING="0"
  2625. CELLSPACING="0"
  2626. CLASS="EXAMPLE"
  2627. ><TR
  2628. ><TD
  2629. ><DIV
  2630. CLASS="example"
  2631. ><A
  2632. NAME="AEN301"
  2633. ></A
  2634. ><P
  2635. ><B
  2636. >Beispiel 2-3. Alle vordefinierten Variablen mit <A
  2637. HREF="#function.phpinfo"
  2638. ><B
  2639. CLASS="function"
  2640. >phpinfo()</B
  2641. ></A
  2642. > ausgeben</B
  2643. ></P
  2644. ><TABLE
  2645. BORDER="0"
  2646. BGCOLOR="#E0E0E0"
  2647. CELLPADDING="5"
  2648. ><TR
  2649. ><TD
  2650. ><PRE
  2651. CLASS="php"
  2652. ><?php phpinfo(); ?></PRE
  2653. ></TD
  2654. ></TR
  2655. ></TABLE
  2656. ></DIV
  2657. ></TD
  2658. ></TR
  2659. ></TABLE
  2660. >
  2661.    </P
  2662. ><P
  2663. >     Wenn Sie diese Datei in Ihrem Browser ÷ffnen, sehen Sie eine Seite
  2664.     mit vielen Informationen ⁿber PHP zusammen mit einer Liste aller
  2665.     fⁿr Sie verfⁿgbaren Variablen.
  2666.    </P
  2667. ><P
  2668. >     Sie k÷nnen mehrere PHP-Anweisungen innerhalb eines PHP-Tags
  2669.     platzieren und so kleine Code-Bl÷cke schreiben, die mehr
  2670.     als nur eine Ausgabe mit <A
  2671. HREF="#function.echo"
  2672. ><B
  2673. CLASS="function"
  2674. >echo()</B
  2675. ></A
  2676. > enthalten.
  2677.     Wenn wir zum Beispiel prⁿfen m÷chten, ob es sich beim Browser
  2678.     des Besuchers um den Internet Explorer handelt, k÷nnen wir
  2679.     folgenden Code benutzen:
  2680.    </P
  2681. ><P
  2682. >     <TABLE
  2683. WIDTH="100%"
  2684. BORDER="0"
  2685. CELLPADDING="0"
  2686. CELLSPACING="0"
  2687. CLASS="EXAMPLE"
  2688. ><TR
  2689. ><TD
  2690. ><DIV
  2691. CLASS="example"
  2692. ><A
  2693. NAME="AEN309"
  2694. ></A
  2695. ><P
  2696. ><B
  2697. >Beispiel 2-4. Beispiel, das <A
  2698. HREF="#control-structures"
  2699. >Kontrollstrukturen</A
  2700. > und
  2701.      <A
  2702. HREF="#functions"
  2703. >Funktionen</A
  2704. > benutzt</B
  2705. ></P
  2706. ><TABLE
  2707. BORDER="0"
  2708. BGCOLOR="#E0E0E0"
  2709. CELLPADDING="5"
  2710. ><TR
  2711. ><TD
  2712. ><PRE
  2713. CLASS="php"
  2714. ><?php
  2715. if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) {
  2716.   echo "Sie benutzen Internet Explorer<br />";
  2717. }
  2718. ?></PRE
  2719. ></TD
  2720. ></TR
  2721. ></TABLE
  2722. ><P
  2723. >       Die Ausgabe dieses Skripte k÷nnte so aussehen:
  2724.       <TABLE
  2725. BORDER="0"
  2726. BGCOLOR="#E0E0E0"
  2727. CELLPADDING="5"
  2728. ><TR
  2729. ><TD
  2730. ><PRE
  2731. CLASS="html"
  2732. >Sie benutzen Internet Explorer<br /></PRE
  2733. ></TD
  2734. ></TR
  2735. ></TABLE
  2736. >
  2737.      </P
  2738. ></DIV
  2739. ></TD
  2740. ></TR
  2741. ></TABLE
  2742. >
  2743.    </P
  2744. ><P
  2745. >     Hier haben wir Ihnen eine ganze Reihe von neuen Konzepten vorgestellt.
  2746.     Wir haben hier zuerst eine <A
  2747. HREF="#control-structures.if"
  2748. >if</A
  2749. >-Anweisung.
  2750.     Wenn Sie mit der Grundlagen-Syntax von der Programmiersprache C
  2751.     vertraut sind, sollte Ihnen dies logisch erscheinen. Wenn Sie
  2752.     C oder eine andere Sprache, die die obige Syntax benutzt, nicht
  2753.     gut genug kennen, dann sollten Sie sich ein Buch mit einer
  2754.     PHP-Einfⁿhrung besorgen und die ersten Kapitel lesen. Sie
  2755.     k÷nnen natⁿrlich auch in die <A
  2756. HREF="#langref"
  2757. >Sprachreferenz</A
  2758. > des Manuals schauen.
  2759.     Eine Liste von PHP-Bⁿchern finden Sie unter <A
  2760. HREF="http://www.php.net/books.php"
  2761. TARGET="_top"
  2762. >http://www.php.net/books.php</A
  2763. >.
  2764.    </P
  2765. ><P
  2766. >     Das zweite hier vorgestellte Konzept ist der Aufruf der Funktion
  2767.     <A
  2768. HREF="#function.strstr"
  2769. ><B
  2770. CLASS="function"
  2771. >strstr()</B
  2772. ></A
  2773. >. <VAR
  2774. CLASS="literal"
  2775. >strstr</VAR
  2776. > ist eine
  2777.     in PHP eingebaute Funktion, die nach einem String in einem anderen
  2778.     String sucht. In diesem Fall suchen wir nach <VAR
  2779. CLASS="literal"
  2780. >"MSIE"</VAR
  2781. >
  2782.     in <VAR
  2783. CLASS="varname"
  2784. >$_SERVER["HTTP_USER_AGENT"]</VAR
  2785. >. Wenn der String
  2786.     gefunden wird, gibt die Funktion <TT
  2787. CLASS="constant"
  2788. ><B
  2789. >TRUE</B
  2790. ></TT
  2791. > zurⁿck, wird er nicht gefunden,
  2792.     dann wird <TT
  2793. CLASS="constant"
  2794. ><B
  2795. >FALSE</B
  2796. ></TT
  2797. > zurⁿckgegeben. Wenn <TT
  2798. CLASS="constant"
  2799. ><B
  2800. >TRUE</B
  2801. ></TT
  2802. > zurⁿckgeben wird,
  2803.     wird die <A
  2804. HREF="#control-structures.if"
  2805. >if</A
  2806. >-Anweisung
  2807.     zu <TT
  2808. CLASS="constant"
  2809. ><B
  2810. >TRUE</B
  2811. ></TT
  2812. > ausgewertet und der Code innerhalb der geschweiften Klammern
  2813.     wird ausgefⁿhrt. Wenn aber <TT
  2814. CLASS="constant"
  2815. ><B
  2816. >FALSE</B
  2817. ></TT
  2818. > zurⁿckgegeben wird, wird der
  2819.     Code innerhalb der Klammern nicht ausgefⁿhrt. Probieren Sie weitere
  2820.     Σhnliche Beispiele mit <A
  2821. HREF="#control-structures.if"
  2822. >if</A
  2823. >, 
  2824.     <A
  2825. HREF="#control-structures.else"
  2826. >else</A
  2827. > und anderen
  2828.     Funktionen wie <A
  2829. HREF="#function.strtoupper"
  2830. ><B
  2831. CLASS="function"
  2832. >strtoupper()</B
  2833. ></A
  2834. > oder 
  2835.     <A
  2836. HREF="#function.strlen"
  2837. ><B
  2838. CLASS="function"
  2839. >strlen()</B
  2840. ></A
  2841. >. Jede dieser Manual-Seiten enthΣlt
  2842.     weitere Beispiele.
  2843.    </P
  2844. ><P
  2845. >     Wir k÷nnen jetzt einen Schritt weitergehen und sehen, wie Sie innerhalb
  2846.     eines PHP-Blocks den PHP-Modus verlassen und wieder in ihn hinein
  2847.     gelangen k÷nnen:
  2848.    </P
  2849. ><P
  2850. >     <TABLE
  2851. WIDTH="100%"
  2852. BORDER="0"
  2853. CELLPADDING="0"
  2854. CELLSPACING="0"
  2855. CLASS="EXAMPLE"
  2856. ><TR
  2857. ><TD
  2858. ><DIV
  2859. CLASS="example"
  2860. ><A
  2861. NAME="AEN337"
  2862. ></A
  2863. ><P
  2864. ><B
  2865. >Beispiel 2-5. HTML- und PHP-Modus vermischt</B
  2866. ></P
  2867. ><TABLE
  2868. BORDER="0"
  2869. BGCOLOR="#E0E0E0"
  2870. CELLPADDING="5"
  2871. ><TR
  2872. ><TD
  2873. ><PRE
  2874. CLASS="php"
  2875. ><?php
  2876. if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) {
  2877. ?>
  2878. <h3>strstr muss true zurⁿckgegeben haben</h3>
  2879. <center><b>Sie benutzen Internet Explorer</b></center>
  2880. <?php
  2881. } else {
  2882. ?>
  2883. <h3>strstr muss false zurⁿckgegeben haben</h3>
  2884. <center><b>Sie benutzen nicht Internet Explorer</b></center>
  2885. <?php
  2886. }
  2887. ?></PRE
  2888. ></TD
  2889. ></TR
  2890. ></TABLE
  2891. ><P
  2892. >       Die Ausgabe dieses Skripts k÷nnte so aussehen:
  2893.       <TABLE
  2894. BORDER="0"
  2895. BGCOLOR="#E0E0E0"
  2896. CELLPADDING="5"
  2897. ><TR
  2898. ><TD
  2899. ><PRE
  2900. CLASS="html"
  2901. ><h3>strstr muss true zurⁿckgegeben haben</h3>
  2902. <center><b>Sie benutzen Internet Explorer</b></center></PRE
  2903. ></TD
  2904. ></TR
  2905. ></TABLE
  2906. >
  2907.      </P
  2908. ></DIV
  2909. ></TD
  2910. ></TR
  2911. ></TABLE
  2912. >
  2913.    </P
  2914. ><P
  2915. >     Anstatt die PHP <VAR
  2916. CLASS="literal"
  2917. >echo</VAR
  2918. >-Anweisung fⁿr die Ausgabe zu benutzen,
  2919.     haben wir den PHP-Modus verlassen und normales HTML verwendet. Der wichtige
  2920.     Punkt hierbei ist, dass der logische Ablauf des Skripts dadurch nicht
  2921.     gest÷rt wird. Nur einer der beiden HTML-Bl÷cke wird ausgegeben - abhΣngig
  2922.     davon, ob <A
  2923. HREF="#function.strstr"
  2924. ><B
  2925. CLASS="function"
  2926. >strstr()</B
  2927. ></A
  2928. > <TT
  2929. CLASS="constant"
  2930. ><B
  2931. >TRUE</B
  2932. ></TT
  2933. > oder <TT
  2934. CLASS="constant"
  2935. ><B
  2936. >FALSE</B
  2937. ></TT
  2938. > zurⁿckgibt bzw.
  2939.     ob der String <VAR
  2940. CLASS="literal"
  2941. >MSIE</VAR
  2942. > gefunden wird oder nicht.
  2943.    </P
  2944. ></DIV
  2945. ><DIV
  2946. CLASS="sect1"
  2947. ><HR><H2
  2948. CLASS="sect1"
  2949. ><A
  2950. NAME="tutorial.forms"
  2951. >Formulare verarbeiten</A
  2952. ></H2
  2953. ><P
  2954. >     Eine der mΣchtigsten Funktionen von PHP ist die Art, wie HTML-Formulare
  2955.     verarbeitet werden. Sie sollten wissen, dass jedes Element eines Formulars
  2956.     automatisch in Ihren PHP-Skripts verfⁿgbar ist. Bitte lesen Sie die Seite
  2957.     <A
  2958. HREF="#language.variables.external"
  2959. >Variablen au▀erhalb von PHP</A
  2960. >
  2961.     fⁿr weitere Informationen und Beispiele ⁿber das Benutzen von Formularen
  2962.     mit PHP. Hier ist ein Beispiel-HTML-Formular:
  2963.    </P
  2964. ><P
  2965. >     <TABLE
  2966. WIDTH="100%"
  2967. BORDER="0"
  2968. CELLPADDING="0"
  2969. CELLSPACING="0"
  2970. CLASS="EXAMPLE"
  2971. ><TR
  2972. ><TD
  2973. ><DIV
  2974. CLASS="example"
  2975. ><A
  2976. NAME="AEN353"
  2977. ></A
  2978. ><P
  2979. ><B
  2980. >Beispiel 2-6. Ein einfaches HTML-Formular</B
  2981. ></P
  2982. ><TABLE
  2983. BORDER="0"
  2984. BGCOLOR="#E0E0E0"
  2985. CELLPADDING="5"
  2986. ><TR
  2987. ><TD
  2988. ><PRE
  2989. CLASS="html"
  2990. ><form action="action.php" method="POST">
  2991.  Ihr Name: <input type="text" name="name" />
  2992.  Ihr Alter: <input type="text" name="alter" />
  2993.  <input type="submit">
  2994. </form></PRE
  2995. ></TD
  2996. ></TR
  2997. ></TABLE
  2998. ></DIV
  2999. ></TD
  3000. ></TR
  3001. ></TABLE
  3002. >
  3003.    </P
  3004. ><P
  3005. >     An diesem Formular ist nichts Besonderes. Es ist ein normales
  3006.     HTML-Formular ohne irgendwelche speziellen Tags. Wenn der Benutzer
  3007.     das Formular ausfⁿllt und den Submit-Button anklickt, wird die
  3008.     Seite <TT
  3009. CLASS="filename"
  3010. >action.php</TT
  3011. > aufgerufen. Diese Datei
  3012.     k÷nnte so aussehen:
  3013.    </P
  3014. ><P
  3015. >     <TABLE
  3016. WIDTH="100%"
  3017. BORDER="0"
  3018. CELLPADDING="0"
  3019. CELLSPACING="0"
  3020. CLASS="EXAMPLE"
  3021. ><TR
  3022. ><TD
  3023. ><DIV
  3024. CLASS="example"
  3025. ><A
  3026. NAME="AEN359"
  3027. ></A
  3028. ><P
  3029. ><B
  3030. >Beispiel 2-7. Daten des Formulars ausgeben</B
  3031. ></P
  3032. ><TABLE
  3033. BORDER="0"
  3034. BGCOLOR="#E0E0E0"
  3035. CELLPADDING="5"
  3036. ><TR
  3037. ><TD
  3038. ><PRE
  3039. CLASS="php"
  3040. >Hallo <?php echo $_POST["name"]; ?>.
  3041. Sie sind <?php echo $_POST["alter"]; ?> Jahre alt.</PRE
  3042. ></TD
  3043. ></TR
  3044. ></TABLE
  3045. ><P
  3046. >       Die Ausgabe des Skripts k÷nnte dann so aussehen:
  3047.       <TABLE
  3048. BORDER="0"
  3049. BGCOLOR="#E0E0E0"
  3050. CELLPADDING="5"
  3051. ><TR
  3052. ><TD
  3053. ><PRE
  3054. CLASS="html"
  3055. >Hallo Joe.
  3056. Sie sind 22 Jahre alt.</PRE
  3057. ></TD
  3058. ></TR
  3059. ></TABLE
  3060. >
  3061.      </P
  3062. ></DIV
  3063. ></TD
  3064. ></TR
  3065. ></TABLE
  3066. >
  3067.    </P
  3068. ><P
  3069. >     Es sollte einfach zu verstehen sein, was hier passiert. Die
  3070.     Variablen <VAR
  3071. CLASS="varname"
  3072. >$_POST["name"]</VAR
  3073. > und
  3074.     <VAR
  3075. CLASS="varname"
  3076. >$_POST["alter"]</VAR
  3077. > werden fⁿr Sie automatisch
  3078.     von PHP gesetzt. Weiter oben haben wir das autoglobale Array
  3079.     <VAR
  3080. CLASS="varname"
  3081. >$_SERVER</VAR
  3082. > eingefⁿhrt, jetzt benutzen wir hier
  3083.     das - ebenfalls autoglobale - Array <A
  3084. HREF="#reserved.variables.post"
  3085. >$_POST</A
  3086. >, dass alle
  3087.     POST-Daten enthΣlt. Beachten Sie, dass die im Formular verwendete
  3088.     <SPAN
  3089. CLASS="emphasis"
  3090. ><I
  3091. CLASS="emphasis"
  3092. >Methode</I
  3093. ></SPAN
  3094. > POST ist. HΣtten wir
  3095.     <SPAN
  3096. CLASS="emphasis"
  3097. ><I
  3098. CLASS="emphasis"
  3099. >GET</I
  3100. ></SPAN
  3101. > verwendet, dann wΣren die Daten unseres
  3102.     Formulars stattdessen im autoglobalen Array <A
  3103. HREF="#reserved.variables.get"
  3104. >$_GET</A
  3105. > verfⁿgbar.
  3106.     Sie k÷nnen auch das autoglobale Array <A
  3107. HREF="#reserved.variables.request"
  3108. >$_REQUEST</A
  3109. > benutzen,
  3110.     wenn die Quelle der Daten keine Rolle spielt. Dieses Array enthΣlt
  3111.     die GET-, POST-, COOKIE- und FILE-Daten. Vgl. auch die
  3112.     <A
  3113. HREF="#function.import-request-variables"
  3114. ><B
  3115. CLASS="function"
  3116. >import_request_variables()</B
  3117. ></A
  3118. >-Funktion.
  3119.    </P
  3120. ></DIV
  3121. ><DIV
  3122. CLASS="sect1"
  3123. ><HR><H2
  3124. CLASS="sect1"
  3125. ><A
  3126. NAME="tutorial.oldcode"
  3127. >Alten Code mit neuen PHP-Versionen benutzen</A
  3128. ></H2
  3129. ><P
  3130. >     Dadurch dass PHP eine immer beliebtere Skriptsprache ist, gibt es immer
  3131.     mehr Quellen, die Ihnen Code-Listings zur Verfⁿgung zu stellen.
  3132.     Die PHP-Entwickler haben versucht, den gr÷▀ten Teil der Sprache
  3133.     abwΣrtskompatibel zu halten. Das bedeutet, dass ein Skript, das fⁿr
  3134.     eine Σltere PHP-Version geschrieben wurde, (im Idealfall) ohne
  3135.     ─nderungen auch unter einer neueren PHP-Version lΣuft. In der Praxis
  3136.     sind aber meist einige ─nderungen n÷tig.
  3137.    </P
  3138. ><P
  3139. >     Zwei der wichtigsten aktuellen ─nderungen, die alten Code betreffen, sind:
  3140.     <P
  3141. ></P
  3142. ><UL
  3143. ><LI
  3144. ><P
  3145. >        Die Missbilligung der alten <VAR
  3146. CLASS="varname"
  3147. >$HTTP_*_VARS</VAR
  3148. >-Arrays
  3149.        (die global gemacht werden mussten, wenn man sie innerhalb einer Funktion
  3150.        nutzen wollte). In PHP <A
  3151. HREF="http://www.php.net/release_4_1_0.php"
  3152. TARGET="_top"
  3153. >4.1.0</A
  3154. >
  3155.        wurden die folgenden <A
  3156. HREF="#language.variables.superglobals"
  3157. >autoglobalen
  3158.        Arrays</A
  3159. > eingefⁿhrt: <VAR
  3160. CLASS="varname"
  3161. >$_GET</VAR
  3162. >, <VAR
  3163. CLASS="varname"
  3164. >$_POST</VAR
  3165. >, 
  3166.        <VAR
  3167. CLASS="varname"
  3168. >$_COOKIE</VAR
  3169. >, <VAR
  3170. CLASS="varname"
  3171. >$_SERVER</VAR
  3172. >, 
  3173.        <VAR
  3174. CLASS="varname"
  3175. >$_ENV</VAR
  3176. >, <VAR
  3177. CLASS="varname"
  3178. >$_REQUEST</VAR
  3179. > und 
  3180.        <VAR
  3181. CLASS="varname"
  3182. >$_SESSION</VAR
  3183. >.  Die Σlteren <VAR
  3184. CLASS="varname"
  3185. >$HTTP_*_VARS</VAR
  3186. >-Arrays,
  3187.        wie <VAR
  3188. CLASS="varname"
  3189. >$HTTP_POST_VARS</VAR
  3190. >, existierten bereits seit PHP 3 und sind
  3191.        auch immer noch verfⁿgbar.
  3192.       </P
  3193. ></LI
  3194. ><LI
  3195. ><P
  3196. >        Externe Variablen werden standardmΣ▀ig nicht mehr im globalen Namensraum
  3197.        registriert. Mit anderen Worten, seit PHP
  3198.        <A
  3199. HREF="http://www.php.net/release_4_2_0.php"
  3200. TARGET="_top"
  3201. >4.2.0</A
  3202. > ist <SPAN
  3203. CLASS="emphasis"
  3204. ><I
  3205. CLASS="emphasis"
  3206. >off</I
  3207. ></SPAN
  3208. >
  3209.        die Standard-Einstellung fⁿr die PHP-Direktive 
  3210.        <A
  3211. HREF="#ini.register-globals"
  3212. >register_globals</A
  3213. >.
  3214.        Die empfohlene Methode, auf diese Werte zuzugreifen, ist, die oben genannten
  3215.        autoglobalen Arrays zu verwenden. ─ltere Skripte, Bⁿcher und Tutorials gehen
  3216.        eventuell davon aus, dass diese Einstellung auf <SPAN
  3217. CLASS="emphasis"
  3218. ><I
  3219. CLASS="emphasis"
  3220. >on</I
  3221. ></SPAN
  3222. > steht.
  3223.        WΣre die Einstellung on, wΣre die Variable <VAR
  3224. CLASS="varname"
  3225. >$id</VAR
  3226. > aus der
  3227.        URL <VAR
  3228. CLASS="literal"
  3229. >http://www.example.com/foo.php?id=42</VAR
  3230. > verfⁿgbar.
  3231.        UnabhΣngig davon, ob on oder off, ist immer <VAR
  3232. CLASS="varname"
  3233. >$_GET['id']</VAR
  3234. >
  3235.        verfⁿgbar.
  3236.       </P
  3237. ></LI
  3238. ></UL
  3239. >
  3240.     Fⁿr weitere Details ⁿber diese ─nderungen siehe die Seite ⁿber
  3241.     <A
  3242. HREF="#language.variables.predefined"
  3243. >vordefinierte Variablen</A
  3244. >
  3245.     und die Links dort.
  3246.    </P
  3247. ></DIV
  3248. ><DIV
  3249. CLASS="sect1"
  3250. ><HR><H2
  3251. CLASS="sect1"
  3252. ><A
  3253. NAME="tutorial.whatsnext"
  3254. >Und weiter?</A
  3255. ></H2
  3256. ><P
  3257. >     Mit dem Wissen, das Sie jetzt haben, sollte es Ihnen m÷glich sein,
  3258.     das meiste aus diesem Manual und die vielen Beispiel-Skripte
  3259.     in den Beispiel-Archiven zu verstehen.
  3260.     Sie k÷nnen weitere auf den php.net-Seiten verfⁿgbare Beispiele auf der
  3261.     folgenden Seite finden: <A
  3262. HREF="http://www.php.net/links.php"
  3263. TARGET="_top"
  3264. >http://www.php.net/links.php</A
  3265. >.
  3266.    </P
  3267. ></DIV
  3268. ></DIV
  3269. ></DIV
  3270. ><DIV
  3271. CLASS="PART"
  3272. ><A
  3273. NAME="install"
  3274. ></A
  3275. ><DIV
  3276. CLASS="TITLEPAGE"
  3277. ><H1
  3278. CLASS="title"
  3279. >II. Installation und Konfiguration</H1
  3280. ><DIV
  3281. CLASS="TOC"
  3282. ><DL
  3283. ><DT
  3284. ><B
  3285. >Inhaltsverzeichnis</B
  3286. ></DT
  3287. ><DT
  3288. >3. <A
  3289. HREF="#install.general"
  3290. >General Installation Considerations</A
  3291. ></DT
  3292. ><DT
  3293. >4. <A
  3294. HREF="#install.macosx"
  3295. >Installation on Mac OS X</A
  3296. ></DT
  3297. ><DT
  3298. >5. <A
  3299. HREF="#install.unix"
  3300. >Installation on Unix systems</A
  3301. ></DT
  3302. ><DT
  3303. >6. <A
  3304. HREF="#install.windows"
  3305. >Installation on Windows systems</A
  3306. ></DT
  3307. ><DT
  3308. >7. <A
  3309. HREF="#install.problems"
  3310. >Problems?</A
  3311. ></DT
  3312. ><DT
  3313. >8. <A
  3314. HREF="#configuration"
  3315. >Runtime Configuration</A
  3316. ></DT
  3317. ></DL
  3318. ></DIV
  3319. ></DIV
  3320. ><DIV
  3321. CLASS="chapter"
  3322. ><HR><H1
  3323. ><A
  3324. NAME="install.general"
  3325. >Kapitel 3. General Installation Considerations</A
  3326. ></H1
  3327. ><P
  3328. >     Before starting the installation, first you need to know what do you
  3329.     want to use PHP for. There are three main fields you
  3330.     can use PHP, as described in the
  3331.     <A
  3332. HREF="#intro-whatcando"
  3333. >What can PHP do?</A
  3334. >
  3335.     section:
  3336.     <P
  3337. ></P
  3338. ><UL
  3339. ><LI
  3340. ><P
  3341. >Server-side scripting</P
  3342. ></LI
  3343. ><LI
  3344. ><P
  3345. >Command line scripting</P
  3346. ></LI
  3347. ><LI
  3348. ><P
  3349. >Client-side GUI applications</P
  3350. ></LI
  3351. ></UL
  3352. >
  3353.    </P
  3354. ><P
  3355. >     For the first and most common form, you need three things:
  3356.     PHP itself, a web server and a web browser. You
  3357.     probably already have a web browser, and depending on
  3358.     your operating system setup, you may also have a web
  3359.     server (e.g. Apache on Linux and MacOS X; IIS on Windows).
  3360.     You may also rent webspace at a company. This way, you
  3361.     don't need to set up anything on your own, only write
  3362.     your PHP scripts, upload it to the server you rent, and
  3363.     see the results in your browser. 
  3364.    </P
  3365. ><P
  3366. >     While setting up the server and PHP on your own, you have
  3367.     two choices for the method of connecting PHP to the
  3368.     server. For many servers PHP has a direct module
  3369.     interface (also called SAPI). These servers include
  3370.     Apache, Microsoft Internet Information Server,
  3371.     Netscape and iPlanet servers. Many other servers
  3372.     have support for ISAPI, the Microsoft module
  3373.     interface (OmniHTTPd for example). If PHP has no
  3374.     module support for your web server, you can always
  3375.     use it as a CGI or FastCGI processor. This means you set up
  3376.     your server to use the CGI executable of
  3377.     PHP to process all PHP file requests on the server.
  3378.    </P
  3379. ><P
  3380. >     If you are also interested to use PHP for command line
  3381.     scripting (e.g. write scripts autogenerating some images
  3382.     for you offline, or processing text files depending
  3383.     on some arguments you pass to them), you always need
  3384.     the command line executable. For more information, read
  3385.     the section about <A
  3386. HREF="#features.commandline"
  3387. >writing
  3388.     command line PHP applications</A
  3389. >. In this case,
  3390.     you need no server and no browser.
  3391.    </P
  3392. ><P
  3393. >     With PHP you can also write desktop GUI applications
  3394.     using the PHP-GTK extension. This is a completely
  3395.     different approach than writing web pages, as you
  3396.     do not output any HTML, but manage windows and objects
  3397.     within them. For more information about PHP-GTK, please
  3398.     <A
  3399. HREF="http://gtk.php.net/"
  3400. TARGET="_top"
  3401. >visit the site dedicated to
  3402.     this extension</A
  3403. >. PHP-GTK is not included in the
  3404.     official PHP distribution.
  3405.    </P
  3406. ><P
  3407. >     From now on, this section deals with setting up PHP
  3408.     for web servers on Unix and Windows with server module
  3409.     interfaces and CGI executables. You will also find
  3410.     information on the command line executable in the
  3411.     following sections.
  3412.    </P
  3413. ><P
  3414. >     PHP source code and binary distributions for Windows can be
  3415.     found at
  3416.     <A
  3417. HREF="http://www.php.net/downloads.php"
  3418. TARGET="_top"
  3419. >http://www.php.net/downloads.php</A
  3420. >.
  3421.     We recommend you to choose a
  3422.     <A
  3423. HREF="http://www.php.net/mirrors.php"
  3424. TARGET="_top"
  3425. >mirror</A
  3426. > nearest
  3427.     to you for downloading the distributions.
  3428.    </P
  3429. ></DIV
  3430. ><DIV
  3431. CLASS="chapter"
  3432. ><HR><H1
  3433. ><A
  3434. NAME="install.macosx"
  3435. >Kapitel 4. Installation on Mac OS X</A
  3436. ></H1
  3437. ><P
  3438. >   This section contains notes and hints specific to installing
  3439.   PHP on Mac OS X. There are two slightly different versions of
  3440.   Mac OS X, Client and Server, our manual deals with installing
  3441.   PHP on both systems. Note that PHP is not available for MacOS
  3442.   9 and earlier versions. 
  3443.  </P
  3444. ><DIV
  3445. CLASS="sect1"
  3446. ><HR><H2
  3447. CLASS="sect1"
  3448. ><A
  3449. NAME="install.macosx.packages"
  3450. >Using Packages</A
  3451. ></H2
  3452. ><P
  3453. >    There are a few pre-packaged and pre-compiled versions of PHP for
  3454.    Mac OS X. This can help in setting up a standard
  3455.    configuration, but if you need to have a different set of features
  3456.    (such as a secure server, or a different database driver), you may
  3457.    need to build PHP and/or your web server yourself. If you are unfamiliar
  3458.    with building and compiling your own software, it's worth
  3459.    checking whether somebody has already built a packaged
  3460.    version of PHP with the features you need.
  3461.   </P
  3462. ></DIV
  3463. ><DIV
  3464. CLASS="sect1"
  3465. ><HR><H2
  3466. CLASS="sect1"
  3467. ><A
  3468. NAME="install.macosx.server"
  3469. >Compiling for OS X Server</A
  3470. ></H2
  3471. ><DIV
  3472. CLASS="formalpara"
  3473. ><P
  3474. ><A
  3475. NAME="install.macosx.server.compile"
  3476. ></A
  3477. ><B
  3478. >Mac OS X Server install. </B
  3479. >
  3480.     <P
  3481. ></P
  3482. ><OL
  3483. TYPE="1"
  3484. ><LI
  3485. ><P
  3486. >Get the latest distributions of Apache and PHP.</P
  3487. ></LI
  3488. ><LI
  3489. ><P
  3490. >        Untar them, and run the <B
  3491. CLASS="command"
  3492. >configure</B
  3493. > program on Apache
  3494.        like so.
  3495.        <TABLE
  3496. BORDER="0"
  3497. BGCOLOR="#E0E0E0"
  3498. CELLPADDING="5"
  3499. ><TR
  3500. ><TD
  3501. ><PRE
  3502. CLASS="shell"
  3503. >./configure --exec-prefix=/usr \
  3504. --localstatedir=/var \
  3505. --mandir=/usr/share/man \
  3506. --libexecdir=/System/Library/Apache/Modules \
  3507. --iconsdir=/System/Library/Apache/Icons \
  3508. --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
  3509. --enable-shared=max \
  3510. --enable-module=most \
  3511. --target=apache</PRE
  3512. ></TD
  3513. ></TR
  3514. ></TABLE
  3515. >
  3516.       </P
  3517. ></LI
  3518. ><LI
  3519. ><P
  3520. >        If you want the compiler to do some optimization, you may also want to
  3521.        add this line:
  3522.        <TABLE
  3523. BORDER="0"
  3524. BGCOLOR="#E0E0E0"
  3525. CELLPADDING="5"
  3526. ><TR
  3527. ><TD
  3528. ><PRE
  3529. CLASS="shell"
  3530. >setenv OPTIM=-O2</PRE
  3531. ></TD
  3532. ></TR
  3533. ></TABLE
  3534. >
  3535.       </P
  3536. ></LI
  3537. ><LI
  3538. ><P
  3539. >        Next, go to the PHP 4 source directory and configure it.
  3540.        <TABLE
  3541. BORDER="0"
  3542. BGCOLOR="#E0E0E0"
  3543. CELLPADDING="5"
  3544. ><TR
  3545. ><TD
  3546. ><PRE
  3547. CLASS="shell"
  3548. >./configure --prefix=/usr \
  3549.     --sysconfdir=/etc \
  3550.     --localstatedir=/var \
  3551.     --mandir=/usr/share/man \
  3552.     --with-xml \
  3553.     --with-apache=/src/apache_1.3.12</PRE
  3554. ></TD
  3555. ></TR
  3556. ></TABLE
  3557. >
  3558.        If you have any other additions (MySQL, GD, etc.), be sure to add them
  3559.        here. For the <VAR
  3560. CLASS="option"
  3561. >--with-apache</VAR
  3562. > string, put
  3563.        in the path to your apache source directory, for example
  3564.        <TT
  3565. CLASS="filename"
  3566. >/src/apache_1.3.12</TT
  3567. >.
  3568.       </P
  3569. ></LI
  3570. ><LI
  3571. ><P
  3572. >        Type <B
  3573. CLASS="command"
  3574. >make</B
  3575. > and <B
  3576. CLASS="command"
  3577. >make install</B
  3578. >. This
  3579.        will add a directory to your Apache source directory under
  3580.        <TT
  3581. CLASS="filename"
  3582. >src/modules/php4</TT
  3583. >.
  3584.       </P
  3585. ></LI
  3586. ><LI
  3587. ><P
  3588. >        Now, reconfigure Apache to build in PHP 4.
  3589.        <TABLE
  3590. BORDER="0"
  3591. BGCOLOR="#E0E0E0"
  3592. CELLPADDING="5"
  3593. ><TR
  3594. ><TD
  3595. ><PRE
  3596. CLASS="shell"
  3597. >./configure --exec-prefix=/usr \
  3598. --localstatedir=/var \
  3599. --mandir=/usr/share/man \
  3600. --libexecdir=/System/Library/Apache/Modules \
  3601. --iconsdir=/System/Library/Apache/Icons \
  3602. --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
  3603. --enable-shared=max \
  3604. --enable-module=most \
  3605. --target=apache \
  3606. --activate-module=src/modules/php4/libphp4.a</PRE
  3607. ></TD
  3608. ></TR
  3609. ></TABLE
  3610. >
  3611.        You may get a message telling you that <TT
  3612. CLASS="filename"
  3613. >libmodphp4.a</TT
  3614. > is
  3615.        out of date. If so, go to the <TT
  3616. CLASS="filename"
  3617. >src/modules/php4</TT
  3618. >
  3619.        directory inside your Apache source directory and run this command: 
  3620.        <B
  3621. CLASS="command"
  3622. >ranlib libmodphp4.a</B
  3623. >. Then go back to the root of the
  3624.        Apache source directory and run the above <B
  3625. CLASS="command"
  3626. >configure</B
  3627. >
  3628.        command again. That'll bring the link table up to date. Run
  3629.        <B
  3630. CLASS="command"
  3631. >make</B
  3632. > and <B
  3633. CLASS="command"
  3634. >make install</B
  3635. > again.
  3636.       </P
  3637. ></LI
  3638. ><LI
  3639. ><P
  3640. >        Copy and rename the <TT
  3641. CLASS="filename"
  3642. >php.ini-dist</TT
  3643. > file to your
  3644.        <TT
  3645. CLASS="filename"
  3646. >bin</TT
  3647. > directory from your PHP 4
  3648.        source directory: 
  3649.        <KBD
  3650. CLASS="userinput"
  3651. >cp php.ini-dist /usr/local/bin/php.ini</KBD
  3652. >
  3653.        or (if your don't have a local directory)
  3654.        <KBD
  3655. CLASS="userinput"
  3656. >cp php.ini-dist /usr/bin/php.ini</KBD
  3657. >.
  3658.       </P
  3659. ></LI
  3660. ></OL
  3661. >
  3662.    </P
  3663. ></DIV
  3664. ></DIV
  3665. ><DIV
  3666. CLASS="sect1"
  3667. ><HR><H2
  3668. CLASS="sect1"
  3669. ><A
  3670. NAME="install.macosx.client"
  3671. >Compiling for MacOS X Client</A
  3672. ></H2
  3673. ><P
  3674. >    The following instructions will help you install a PHP module for the Apache
  3675.    web server included in MacOS X. This version includes support for the MySQL
  3676.    and PostgreSQL databases. These instructions are graciously provided by
  3677.    <A
  3678. HREF="http://www.entropy.ch/software/macosx/"
  3679. TARGET="_top"
  3680. >Marc Liyanage</A
  3681. >.
  3682.   </P
  3683. ><DIV
  3684. CLASS="warning"
  3685. ><P
  3686. ></P
  3687. ><TABLE
  3688. CLASS="warning"
  3689. BORDER="1"
  3690. WIDTH="100%"
  3691. ><TR
  3692. ><TD
  3693. ALIGN="CENTER"
  3694. ><B
  3695. >Warnung</B
  3696. ></TD
  3697. ></TR
  3698. ><TR
  3699. ><TD
  3700. ALIGN="LEFT"
  3701. ><P
  3702. >     Be careful when you do this, you could screw up your Apache web server!
  3703.    </P
  3704. ></TD
  3705. ></TR
  3706. ></TABLE
  3707. ></DIV
  3708. ><P
  3709. >    Do this to install:
  3710.    <P
  3711. ></P
  3712. ><OL
  3713. TYPE="1"
  3714. ><LI
  3715. ><P
  3716. >       Open a terminal window.
  3717.      </P
  3718. ></LI
  3719. ><LI
  3720. ><P
  3721. >       Type
  3722.       <KBD
  3723. CLASS="userinput"
  3724. >wget http://www.diax.ch/users/liyanage/software/macosx/libphp4.so.gz</KBD
  3725. >,
  3726.       wait for the download to finish.
  3727.      </P
  3728. ></LI
  3729. ><LI
  3730. ><P
  3731. >       Type <KBD
  3732. CLASS="userinput"
  3733. >gunzip libphp4.so.gz</KBD
  3734. >.
  3735.      </P
  3736. ></LI
  3737. ><LI
  3738. ><P
  3739. >       Type <KBD
  3740. CLASS="userinput"
  3741. >sudo apxs -i -a -n php4 libphp4.so</KBD
  3742. >
  3743.      </P
  3744. ></LI
  3745. ><LI
  3746. ><P
  3747. >       Now type <KBD
  3748. CLASS="userinput"
  3749. >sudo open -a TextEdit /etc/httpd/httpd.conf</KBD
  3750. >.
  3751.       TextEdit will open with the web server configuration file. Locate these 
  3752.       two lines towards the end of the file: (Use the Find command)
  3753.       <TABLE
  3754. BORDER="0"
  3755. BGCOLOR="#E0E0E0"
  3756. CELLPADDING="5"
  3757. ><TR
  3758. ><TD
  3759. ><PRE
  3760. CLASS="apache"
  3761. >#AddType application/x-httpd-php .php 
  3762. #AddType application/x-httpd-php-source .phps</PRE
  3763. ></TD
  3764. ></TR
  3765. ></TABLE
  3766. >
  3767.        Remove the two hash marks (<VAR
  3768. CLASS="literal"
  3769. >#</VAR
  3770. >), then save the file and
  3771.        quit TextEdit.
  3772.       </P
  3773. ></LI
  3774. ><LI
  3775. ><P
  3776. >       Finally, type <KBD
  3777. CLASS="userinput"
  3778. >sudo apachectl graceful</KBD
  3779. > to restart
  3780.       the web server.
  3781.      </P
  3782. ></LI
  3783. ></OL
  3784. >
  3785.   </P
  3786. ><P
  3787. >    PHP should now be up and running. You can test it by dropping a file into 
  3788.    your <TT
  3789. CLASS="filename"
  3790. >Sites</TT
  3791. > folder which is called
  3792.    <TT
  3793. CLASS="filename"
  3794. >test.php</TT
  3795. >. Into that file, write this line:
  3796.    <VAR
  3797. CLASS="literal"
  3798. ><?php phpinfo() ?></VAR
  3799. >.
  3800.   </P
  3801. ><P
  3802. >    Now open up <VAR
  3803. CLASS="literal"
  3804. >127.0.0.1/~your_username/test.php</VAR
  3805. > in your web
  3806.    browser. You should see a status table with information about the PHP module.
  3807.   </P
  3808. ></DIV
  3809. ></DIV
  3810. ><DIV
  3811. CLASS="chapter"
  3812. ><HR><H1
  3813. ><A
  3814. NAME="install.unix"
  3815. >Kapitel 5. Installation on Unix systems</A
  3816. ></H1
  3817. ><P
  3818. >     This section will guide you through the general configuration and
  3819.     installation of PHP on Unix systems. Be sure to investigate any
  3820.     sections specific to your platform or web server before you begin
  3821.     the process.
  3822.    </P
  3823. ><P
  3824. >     As our manual outlines in the <A
  3825. HREF="#install.general"
  3826. >General
  3827.     Installation Considerations</A
  3828. > section, we are mainly dealing with
  3829.     web centric setups of PHP in this section, although we will cover
  3830.     setting up PHP for command line usage as well.
  3831.    </P
  3832. ><P
  3833.     There are several ways to install PHP for the Unix platform, either
  3834.     with a compile and configure process, or through various
  3835.     pre-packaged methods. This documentation is mainly focused around
  3836.     the process of compiling and configuring PHP. Many Unix like systems
  3837.     have some sort of package installation system. This can assist in
  3838.     setting up a standard configuration, but if you need to have a
  3839.     different set of features (such as a secure server, or a different
  3840.     database driver), you may need to build PHP and/or your webserver.
  3841.     If you are unfamiliar with building and compiling your own software,
  3842.     it is worth checking to see whether somebody has already built a
  3843.     packaged version of PHP with the features you need.
  3844.    </P
  3845. ><P
  3846. >     Prerequisite knowledge and software for compiling:
  3847.     <P
  3848. ></P
  3849. ><UL
  3850. ><LI
  3851. ><P
  3852. >        Basic Unix skills (being able to operate "make" and a C
  3853.        compiler)
  3854.       </P
  3855. ></LI
  3856. ><LI
  3857. ><P
  3858. >        An ANSI C compiler
  3859.       </P
  3860. ></LI
  3861. ><LI
  3862. ><P
  3863. >        flex
  3864.       </P
  3865. ></LI
  3866. ><LI
  3867. ><P
  3868. >        bison
  3869.       </P
  3870. ></LI
  3871. ><LI
  3872. ><P
  3873. >        A web server
  3874.       </P
  3875. ></LI
  3876. ><LI
  3877. ><P
  3878. >        Any module specific components (such as gd, pdf libs, etc.)
  3879.       </P
  3880. ></LI
  3881. ></UL
  3882. >
  3883.    </P
  3884. ><P
  3885. >     The initial PHP setup and configuration process is controlled by the
  3886.     use of the commandline options of the <TT
  3887. CLASS="filename"
  3888. >configure</TT
  3889. >
  3890.     script. Our manual documents the different options separately. You will
  3891.     find the <A
  3892. HREF="#configure"
  3893. >core options in the appendix</A
  3894. >,
  3895.     while the different extension specific options are descibed on the
  3896.     reference pages.
  3897.    </P
  3898. ><P
  3899. >     When PHP is configured, you are ready to build the module and/or
  3900.     executables. The command <B
  3901. CLASS="command"
  3902. >make</B
  3903. > should
  3904.     take care of this. If it fails and you can't figure out why, see
  3905.     the <A
  3906. HREF="#install.problems"
  3907. >Problems section</A
  3908. >.
  3909.    </P
  3910. ><DIV
  3911. CLASS="sect1"
  3912. ><HR><H2
  3913. CLASS="sect1"
  3914. ><A
  3915. NAME="install.unix.gentoo"
  3916. >Gentoo installation notes</A
  3917. ></H2
  3918. ><P
  3919. >   This section contains notes and hints specific to installing
  3920.   PHP on <A
  3921. HREF="http://www.gentoo.org/"
  3922. TARGET="_top"
  3923. >Gentoo Linux</A
  3924. >.
  3925.  </P
  3926. ><DIV
  3927. CLASS="sect2"
  3928. ><HR><H3
  3929. CLASS="sect2"
  3930. ><A
  3931. NAME="install.unix.gentoo.portage"
  3932. >Using Portage (emerge)</A
  3933. ></H3
  3934. ><P
  3935. >     While you can just download the PHP source and compile it youself,
  3936.     using Gentoo's packaging system is the simplest and cleanest
  3937.     method of installing PHP. If you are not familiar with building
  3938.     software on Linux, this is the way to go.
  3939.    </P
  3940. ><P
  3941. >     If you have built your Gentoo system so far, you are probably used
  3942.     to Portage already. Installing Apache and PHP is no different than 
  3943.     the other system tools.
  3944.    </P
  3945. ><P
  3946. >     The first decision you need to make is whether you want to install
  3947.     Apache 1.3.x or Apache 2.x. While both can be used with PHP, the 
  3948.     steps given bellow will use Apache 1.3.x. Another thing to consider
  3949.     is whether your local Portage tree is up to date. If you have not
  3950.     updated it recently, you need to run <B
  3951. CLASS="command"
  3952. >emerge sync</B
  3953. >
  3954.     before anything else. This way, you will be using the most recent
  3955.     stable version of Apache and PHP.
  3956.    </P
  3957. ><P
  3958. >     Now that everything is in place, you can use the following example
  3959.     to install Apache and PHP:
  3960.    </P
  3961. ><TABLE
  3962. WIDTH="100%"
  3963. BORDER="0"
  3964. CELLPADDING="0"
  3965. CELLSPACING="0"
  3966. CLASS="EXAMPLE"
  3967. ><TR
  3968. ><TD
  3969. ><DIV
  3970. CLASS="example"
  3971. ><A
  3972. NAME="install.unix.gentoo.portage.example"
  3973. ></A
  3974. ><P
  3975. ><B
  3976. >Beispiel 5-1. Gentoo Install Example with Apache 1.3</B
  3977. ></P
  3978. ><TABLE
  3979. BORDER="0"
  3980. BGCOLOR="#E0E0E0"
  3981. CELLPADDING="5"
  3982. ><TR
  3983. ><TD
  3984. ><PRE
  3985. CLASS="shell"
  3986. ># emerge \<apache-2
  3987. # USE="-*" emerge php mod_php
  3988. # ebuild /var/db/pkg/dev-php/mod_php-<your PHP version>/mod_php-<your PHP version>.ebuild config
  3989. # nano /etc/conf.d/apache
  3990.   Add "-D PHP4" to APACHE_OPTS
  3991.   
  3992. # rc-update add apache default
  3993. # /etc/init.d/apache start</PRE
  3994. ></TD
  3995. ></TR
  3996. ></TABLE
  3997. ></DIV
  3998. ></TD
  3999. ></TR
  4000. ></TABLE
  4001. ><P
  4002. >     You can read more about emerge in the excellent 
  4003.     <A
  4004. HREF="http://www.gentoo.org/doc/en/portage-manual.xml"
  4005. TARGET="_top"
  4006. >Portage Manual</A
  4007. > provided
  4008.     on the Gentoo website.
  4009.    </P
  4010. ><P
  4011. >     If you need to use Apache 2, you can simply use <B
  4012. CLASS="command"
  4013. >emerge apache</B
  4014. >
  4015.     in the last example.
  4016.    </P
  4017. ></DIV
  4018. ><DIV
  4019. CLASS="sect2"
  4020. ><HR><H3
  4021. CLASS="sect2"
  4022. ><A
  4023. NAME="install.unix.gentoo.config"
  4024. >Better control on configuration</A
  4025. ></H3
  4026. ><P
  4027. >     In the last section, PHP was emerged without any activated modules.
  4028.     As of this writing, the only module activated by default with Portage 
  4029.     is XML which is needed by <A
  4030. HREF="http://pear.php.net/"
  4031. TARGET="_top"
  4032. >PEAR</A
  4033. >.
  4034.     This may not be what you want and you will soon discover that you need 
  4035.     more activated modules, like MySQL, gettext, GD, etc.
  4036.    </P
  4037. ><P
  4038. >     When you compile PHP from source yourself, you need to activate modules
  4039.     via the <B
  4040. CLASS="command"
  4041. >configure</B
  4042. > command. With Gentoo, you can simply
  4043.     provide USE flags which will be passed to the configure script automatically.
  4044.     To see which USE flags to use with emerge, you can try:
  4045.    </P
  4046. ><TABLE
  4047. WIDTH="100%"
  4048. BORDER="0"
  4049. CELLPADDING="0"
  4050. CELLSPACING="0"
  4051. CLASS="EXAMPLE"
  4052. ><TR
  4053. ><TD
  4054. ><DIV
  4055. CLASS="example"
  4056. ><A
  4057. NAME="install.unix.gentoo.config.example"
  4058. ></A
  4059. ><P
  4060. ><B
  4061. >Beispiel 5-2. Getting the list of valid USE flags</B
  4062. ></P
  4063. ><TABLE
  4064. BORDER="0"
  4065. BGCOLOR="#E0E0E0"
  4066. CELLPADDING="5"
  4067. ><TR
  4068. ><TD
  4069. ><PRE
  4070. CLASS="shell"
  4071. ># USE="-*" emerge -pv php
  4072.  
  4073. [ebuild  N    ] dev-php/php-4.3.6-r1  -X -berkdb -crypt -curl -debug -doc 
  4074. -fdftk -firebird -flash -freetds -gd -gd-external -gdbm -gmp -hardenedphp 
  4075. -imap -informix -ipv6 -java -jpeg -kerberos -ldap -mcal -memlimit -mssql 
  4076. -mysql -ncurses -nls -oci8 -odbc -pam -pdflib -png -postgres -qt -readline 
  4077. -snmp -spell -ssl -tiff -truetype -xml2 -yaz  3,876 kB</PRE
  4078. ></TD
  4079. ></TR
  4080. ></TABLE
  4081. ></DIV
  4082. ></TD
  4083. ></TR
  4084. ></TABLE
  4085. ><P
  4086. >     As you can see from the last output, PHP considers a lot of USE flags.
  4087.     Look at them closely and choose what you need. If you choose a flag and 
  4088.     you do not have the proper librairies, Portage will compile them for you.
  4089.     It is a good idea to use <B
  4090. CLASS="command"
  4091. >emerge -pv</B
  4092. > again to see what
  4093.     Portage will compile in accordance to your USE flags. As an example,
  4094.     if you do not have X installed and you choose to include X in the USE
  4095.     flags, Portage will compile X prior to PHP, which can take a couple
  4096.     of hours.
  4097.    </P
  4098. ><P
  4099. >     If you choose to compile PHP with MySQL, cURL and GD support, the command
  4100.     will look something like this:
  4101.    </P
  4102. ><TABLE
  4103. WIDTH="100%"
  4104. BORDER="0"
  4105. CELLPADDING="0"
  4106. CELLSPACING="0"
  4107. CLASS="EXAMPLE"
  4108. ><TR
  4109. ><TD
  4110. ><DIV
  4111. CLASS="example"
  4112. ><A
  4113. NAME="install.unix.gentoo.config.example2"
  4114. ></A
  4115. ><P
  4116. ><B
  4117. >Beispiel 5-3. Install PHP with USE flags</B
  4118. ></P
  4119. ><TABLE
  4120. BORDER="0"
  4121. BGCOLOR="#E0E0E0"
  4122. CELLPADDING="5"
  4123. ><TR
  4124. ><TD
  4125. ><PRE
  4126. CLASS="shell"
  4127. ># USE="-* curl mysql gd" emerge php mod_php</PRE
  4128. ></TD
  4129. ></TR
  4130. ></TABLE
  4131. ></DIV
  4132. ></TD
  4133. ></TR
  4134. ></TABLE
  4135. ><P
  4136. >     As in the last example, do not forget to emerge php as well as mod_php.
  4137.     php is responsible for the command line version of PHP as mod_php is
  4138.     for the Apache module version of PHP.
  4139.    </P
  4140. ></DIV
  4141. ><DIV
  4142. CLASS="sect2"
  4143. ><HR><H3
  4144. CLASS="sect2"
  4145. ><A
  4146. NAME="install.unix.gentoo.faq"
  4147. >Common Problems</A
  4148. ></H3
  4149. ><P
  4150. ></P
  4151. ><UL
  4152. ><LI
  4153. ><P
  4154. >      If you see the PHP source instead of the result the script should
  4155.      produce, you have probably forgot to edit <TT
  4156. CLASS="filename"
  4157. >/etc/conf.d/apache</TT
  4158. >.
  4159.      Apache needs to be started with the -D PHP4 flag. To see if the flag is
  4160.      present, you should be able to see it when using 
  4161.      <B
  4162. CLASS="command"
  4163. >ps ax | grep apache</B
  4164. > while Apache is running.
  4165.     </P
  4166. ></LI
  4167. ><LI
  4168. ><P
  4169. >      Due to slotting problems, you might end up with more than one version
  4170.      of PHP installed on your system. If this is the case, you need to unmerge
  4171.      the old versions manually by using
  4172.      <B
  4173. CLASS="command"
  4174. >emerge unmerge mod_php-<old version></B
  4175. >.
  4176.     </P
  4177. ></LI
  4178. ><LI
  4179. ><P
  4180. >      If you cannot emerge PHP because of Java, try putting <B
  4181. CLASS="command"
  4182. >-*</B
  4183. >
  4184.      in front of your USE flags like in the above examples.
  4185.     </P
  4186. ></LI
  4187. ><LI
  4188. ><P
  4189. >      If you are having problems configuring Apache and PHP, you can always
  4190.      search the <A
  4191. HREF="http://forums.gentoo.org/"
  4192. TARGET="_top"
  4193. >Gentoo Forums</A
  4194. >.
  4195.      Try searching with the keywords "Apache PHP".
  4196.     </P
  4197. ></LI
  4198. ></UL
  4199. ></DIV
  4200. ></DIV
  4201. ><DIV
  4202. CLASS="sect1"
  4203. ><HR><H2
  4204. CLASS="sect1"
  4205. ><A
  4206. NAME="install.unix.hpux"
  4207. >HP-UX specific installation notes</A
  4208. ></H2
  4209. ><P
  4210. >     This section contains notes and hints specific to installing PHP
  4211.     on HP-UX systems. (Contributed by paul_mckay at clearwater-it dot co dot
  4212.     uk).
  4213.    </P
  4214. ><DIV
  4215. CLASS="note"
  4216. ><BLOCKQUOTE
  4217. CLASS="note"
  4218. ><P
  4219. ><B
  4220. >Anmerkung: </B
  4221. >
  4222.      These tips were written for PHP 4.0.4 and Apache 1.3.9.
  4223.     </P
  4224. ></BLOCKQUOTE
  4225. ></DIV
  4226. ><P
  4227. >     <P
  4228. ></P
  4229. ><OL
  4230. TYPE="1"
  4231. ><LI
  4232. ><P
  4233. >        You need gzip, download a binary distribution from
  4234.        <TT
  4235. CLASS="filename"
  4236. >http://hpux.connect.org.uk/ftp/hpux/Gnu/gzip-1.2.4a/gzip-1.2.4a-sd-10.20.depot.Z</TT
  4237. >
  4238.        uncompress the file and install using swinstall.
  4239.       </P
  4240. ></LI
  4241. ><LI
  4242. ><P
  4243. >        You need gcc, download a binary distribution from
  4244.        <TT
  4245. CLASS="filename"
  4246. >http://gatekeep.cs.utah.edu/ftp/hpux/Gnu/gcc-2.95.2/gcc-2.95.2-sd-10.20.depot.gz</TT
  4247. >.
  4248.        uncompress this file and install gcc using swinstall.
  4249.       </P
  4250. ></LI
  4251. ><LI
  4252. ><P
  4253. >        You need the GNU binutils, you can download a binary distribution from
  4254.        <TT
  4255. CLASS="filename"
  4256. >http://hpux.connect.org.uk/ftp/hpux/Gnu/binutils-2.9.1/binutils-2.9.1-sd-10.20.depot.gz</TT
  4257. >.
  4258.        uncompress this file and install binutils using swinstall.
  4259.       </P
  4260. ></LI
  4261. ><LI
  4262. ><P
  4263. >        You now need bison, you can download a binary distribution from
  4264.        <TT
  4265. CLASS="filename"
  4266. >http://hpux.connect.org.uk/ftp/hpux/Gnu/bison-1.28/bison-1.28-sd-10.20.depot.gz</TT
  4267. >,
  4268.        install as above.
  4269.       </P
  4270. ></LI
  4271. ><LI
  4272. ><P
  4273. >        You now need flex, you need to download the source from one of the
  4274.        http://www.gnu.org mirrors. It is in the non-gnu directory of the ftp
  4275.        site.  Download the file, <B
  4276. CLASS="command"
  4277. >gunzip</B
  4278. >, then
  4279.        <B
  4280. CLASS="command"
  4281. >tar -xvf</B
  4282. > it. Go into the newly created flex directory
  4283.        and run <B
  4284. CLASS="command"
  4285. >./configure</B
  4286. >, followed by 
  4287.        <B
  4288. CLASS="command"
  4289. >make</B
  4290. >, and then <B
  4291. CLASS="command"
  4292. >make install</B
  4293. >.
  4294.       </P
  4295. ><P
  4296. >        If you have errors here, it's probably because gcc etc. are not in your
  4297.        PATH so add them to your PATH. 
  4298.       </P
  4299. ></LI
  4300. ><LI
  4301. ><P
  4302. >        Download the PHP and apache sources. 
  4303.       </P
  4304. ></LI
  4305. ><LI
  4306. ><P
  4307. >        <B
  4308. CLASS="command"
  4309. >gunzip</B
  4310. > and <B
  4311. CLASS="command"
  4312. >tar -xvf</B
  4313. > them. We
  4314.        need to hack a couple of files so that they can compile OK.
  4315.       </P
  4316. ></LI
  4317. ><LI
  4318. ><P
  4319. >        Firstly the configure file needs to be hacked because it seems to lose
  4320.        track of the fact that you are a hpux machine, there will be a better
  4321.        way of doing this but a cheap and cheerful hack is to put
  4322.        <VAR
  4323. CLASS="literal"
  4324. >lt_target=hpux10.20</VAR
  4325. > on line 47286 of the configure
  4326.        script.
  4327.       </P
  4328. ></LI
  4329. ><LI
  4330. ><P
  4331. >        Next, the Apache GuessOS file needs to be hacked. Under
  4332.        <TT
  4333. CLASS="filename"
  4334. >apache_1.3.9/src/helpers</TT
  4335. > change line 89 from <VAR
  4336. CLASS="literal"
  4337. >echo
  4338.        "hp${HPUXMACH}-hpux${HPUXVER}"; exit 0</VAR
  4339. > to: <VAR
  4340. CLASS="literal"
  4341. >echo
  4342.        "hp${HPUXMACH}-hp-hpux${HPUXVER}"; exit 0</VAR
  4343. >
  4344.       </P
  4345. ></LI
  4346. ><LI
  4347. ><P
  4348. >        You cannot install PHP as a shared object under HP-UX so you must
  4349.        compile it as a static, just follow the instructions at the Apache
  4350.        page. 
  4351.       </P
  4352. ></LI
  4353. ><LI
  4354. ><P
  4355. >        PHP and Apache should have compiled OK, but Apache won't start. you
  4356.        need to create a new user for Apache, e.g. www, or apache. You then
  4357.        change lines 252 and 253 of the <TT
  4358. CLASS="filename"
  4359. >conf/httpd.conf</TT
  4360. > in
  4361.        Apache so that instead of
  4362.       </P
  4363. ><TABLE
  4364. BORDER="0"
  4365. BGCOLOR="#E0E0E0"
  4366. CELLPADDING="5"
  4367. ><TR
  4368. ><TD
  4369. ><PRE
  4370. CLASS="screen"
  4371. >User nobody 
  4372. Group nogroup</PRE
  4373. ></TD
  4374. ></TR
  4375. ></TABLE
  4376. ><P
  4377. >        you have something like 
  4378.       </P
  4379. ><TABLE
  4380. BORDER="0"
  4381. BGCOLOR="#E0E0E0"
  4382. CELLPADDING="5"
  4383. ><TR
  4384. ><TD
  4385. ><PRE
  4386. CLASS="screen"
  4387. >User www 
  4388. Group sys</PRE
  4389. ></TD
  4390. ></TR
  4391. ></TABLE
  4392. ><P
  4393. >        This is because you can't run Apache as nobody under hp-ux. Apache and
  4394.        PHP should then work. 
  4395.       </P
  4396. ></LI
  4397. ></OL
  4398. >
  4399.  </P
  4400. ></DIV
  4401. ><DIV
  4402. CLASS="sect1"
  4403. ><HR><H2
  4404. CLASS="sect1"
  4405. ><A
  4406. NAME="install.unix.openbsd"
  4407. >OpenBSD installation notes</A
  4408. ></H2
  4409. ><P
  4410. >  This section contains notes and hints specific to installing
  4411.  PHP on <A
  4412. HREF="http://www.openbsd.org/"
  4413. TARGET="_top"
  4414. >OpenBSD 3.4</A
  4415. >.
  4416.  </P
  4417. ><DIV
  4418. CLASS="sect2"
  4419. ><HR><H3
  4420. CLASS="sect2"
  4421. ><A
  4422. NAME="install.unix.openbsd.packages"
  4423. >Using Binary Packages</A
  4424. ></H3
  4425. ><P
  4426. >     Using binary packages to install PHP on OpenBSD is the recommended
  4427.     and simplest method.  The core package has been separated from the various
  4428.     modules, and each can be installed and removed independently from the others.
  4429.     The files you need can be found on your OpenBSD CD or on the FTP site.
  4430.    </P
  4431. ><P
  4432. >     The main package you need to install is <TT
  4433. CLASS="filename"
  4434. >php4-core-4.3.3.tgz</TT
  4435. >,
  4436.     which contains the basic engine (plus gettext and iconv).  Next, take a look
  4437.     at the module packages, such as <TT
  4438. CLASS="filename"
  4439. >php4-mysql-4.3.3.tgz</TT
  4440. >
  4441.     or <TT
  4442. CLASS="filename"
  4443. >php4-imap-4.3.3.tgz</TT
  4444. >.  You need to use the <B
  4445. CLASS="command"
  4446. >phpxs</B
  4447. >
  4448.     command to activate and deactivate these modules in your <TT
  4449. CLASS="filename"
  4450. >php.ini</TT
  4451. >.
  4452.    </P
  4453. ><TABLE
  4454. WIDTH="100%"
  4455. BORDER="0"
  4456. CELLPADDING="0"
  4457. CELLSPACING="0"
  4458. CLASS="EXAMPLE"
  4459. ><TR
  4460. ><TD
  4461. ><DIV
  4462. CLASS="example"
  4463. ><A
  4464. NAME="install.unix.openbsd.ports.example"
  4465. ></A
  4466. ><P
  4467. ><B
  4468. >Beispiel 5-4. OpenBSD Package Install Example</B
  4469. ></P
  4470. ><TABLE
  4471. BORDER="0"
  4472. BGCOLOR="#E0E0E0"
  4473. CELLPADDING="5"
  4474. ><TR
  4475. ><TD
  4476. ><PRE
  4477. CLASS="shell"
  4478. ># pkg_add php4-core-4.3.3.tgz
  4479. # /usr/local/sbin/phpxs -s
  4480. # cp /usr/local/share/doc/php4/php.ini-recommended /var/www/conf/php.ini
  4481.   (add in mysql)
  4482. # pkg_add php4-mysql-4.3.3.tgz
  4483. # /usr/local/sbin/phpxs -a mysql
  4484.   (add in imap)
  4485. # pkg_add php4-imap-4.3.3.tgz
  4486. # /usr/local/sbin/phpxs -a imap
  4487.   (remove mysql as a test)
  4488. # pkg_delete php4-mysql-4.3.3
  4489. # /usr/local/sbin/phpxs -r mysql
  4490.   (install the PEAR libraries)
  4491. # pkg_add php4-pear-4.3.3.tgz</PRE
  4492. ></TD
  4493. ></TR
  4494. ></TABLE
  4495. ></DIV
  4496. ></TD
  4497. ></TR
  4498. ></TABLE
  4499. ><P
  4500. >    Read the <A
  4501. HREF="http://www.openbsd.org/cgi-bin/man.cgi?query=packages"
  4502. TARGET="_top"
  4503. >packages(7)</A
  4504. >
  4505.    manual page for more information about binary packages on OpenBSD.
  4506.    </P
  4507. ></DIV
  4508. ><DIV
  4509. CLASS="sect2"
  4510. ><HR><H3
  4511. CLASS="sect2"
  4512. ><A
  4513. NAME="install.unix.openbsd.ports"
  4514. >Using Ports</A
  4515. ></H3
  4516. ><P
  4517. >    You can also compile up PHP from source using the <A
  4518. HREF="http://www.openbsd.org/ports.html"
  4519. TARGET="_top"
  4520. >ports tree</A
  4521. >.
  4522.    However, this is only recommended for users familiar with OpenBSD.  The PHP 4 port
  4523.    is split into two sub-directories: core and extensions.  The
  4524.    extensions directory generates sub-packages for all of the supported
  4525.    PHP modules.  If you find you do not want to create some of these modules,
  4526.    use the <B
  4527. CLASS="command"
  4528. >no_*</B
  4529. > FLAVOR.  For example, to skip building
  4530.    the imap module, set the FLAVOR to <B
  4531. CLASS="command"
  4532. >no_imap</B
  4533. >.
  4534.   </P
  4535. ></DIV
  4536. ><DIV
  4537. CLASS="sect2"
  4538. ><HR><H3
  4539. CLASS="sect2"
  4540. ><A
  4541. NAME="install.unix.openbsd.faq"
  4542. >Common Problems</A
  4543. ></H3
  4544. ><P
  4545. ></P
  4546. ><UL
  4547. ><LI
  4548. ><P
  4549. >The default install of Apache runs inside a
  4550.     <A
  4551. HREF="http://www.openbsd.org/cgi-bin/man.cgi?query=chroot"
  4552. TARGET="_top"
  4553. >chroot(2) jail</A
  4554. >, which will restrict PHP scripts to
  4555.     accessing files under <TT
  4556. CLASS="filename"
  4557. >/var/www</TT
  4558. >.  You will therefore need to create a
  4559.     <TT
  4560. CLASS="filename"
  4561. >/var/www/tmp</TT
  4562. > directory for PHP session files to be stored, or use an
  4563.     alternative session backend.  In addition, database sockets need to be placed inside the
  4564.     jail or listen on the <TT
  4565. CLASS="filename"
  4566. >localhost</TT
  4567. > interface.  If you use network functions,
  4568.     some files from <TT
  4569. CLASS="filename"
  4570. >/etc</TT
  4571. > such as <TT
  4572. CLASS="filename"
  4573. >/etc/resolv.conf</TT
  4574. > and
  4575.     <TT
  4576. CLASS="filename"
  4577. >/etc/services</TT
  4578. > will need to be moved into <TT
  4579. CLASS="filename"
  4580. >/var/www/etc</TT
  4581. >.
  4582.     The OpenBSD PEAR package automatically installs into the correct chroot directories, so 
  4583.     no special modification is needed there.  More information on the OpenBSD Apache is available
  4584.     in the <A
  4585. HREF="http://www.openbsd.org/faq/faq10.html#httpdchroot"
  4586. TARGET="_top"
  4587. >OpenBSD FAQ</A
  4588. >.
  4589.     </P
  4590. ></LI
  4591. ><LI
  4592. ><P
  4593. >     The OpenBSD 3.4 package for the <A
  4594. HREF="http://www.boutell.com/gd/"
  4595. TARGET="_top"
  4596. >gd</A
  4597. > extension requires
  4598.     XFree86 to be installed.  If you do not wish to use some of the font features that
  4599.     require X11, install the <TT
  4600. CLASS="filename"
  4601. >php4-gd-4.3.3-no_x11.tgz</TT
  4602. > package instead.
  4603.     </P
  4604. ></LI
  4605. ></UL
  4606. ></DIV
  4607. ><DIV
  4608. CLASS="sect2"
  4609. ><HR><H3
  4610. CLASS="sect2"
  4611. ><A
  4612. NAME="install.unix.openbsd.older"
  4613. >Older Releases</A
  4614. ></H3
  4615. ><P
  4616. >    Older releases of OpenBSD used the FLAVORS system to compile up
  4617.    a statically linked PHP.  Since it is hard to generate binary packages using
  4618.    this method, it is now deprecated.  You can still use the old stable
  4619.    ports trees if you wish, but they are unsupported by the OpenBSD team.
  4620.    If you have any comments about this, the current maintainer for the port
  4621.    is Anil Madhavapeddy (avsm at openbsd dot org).
  4622.   </P
  4623. ></DIV
  4624. ></DIV
  4625. ><DIV
  4626. CLASS="sect1"
  4627. ><HR><H2
  4628. CLASS="sect1"
  4629. ><A
  4630. NAME="install.unix.solaris"
  4631. >Solaris specific installation tips</A
  4632. ></H2
  4633. ><P
  4634. >   This section contains notes and hints specific to installing
  4635.   PHP on Solaris systems.
  4636.  </P
  4637. ><DIV
  4638. CLASS="sect2"
  4639. ><HR><H3
  4640. CLASS="sect2"
  4641. ><A
  4642. NAME="install.unix.solaris.required"
  4643. >Required software</A
  4644. ></H3
  4645. ><P
  4646. >    Solaris installs often lack C compilers and their related tools.
  4647.    Read <A
  4648. HREF="#faq.installation.needgnu"
  4649. >this FAQ</A
  4650.    for information on why using GNU versions for some of these
  4651.    tools is necessary.  The required software is as follows:
  4652.    <P
  4653. ></P
  4654. ><UL
  4655. ><LI
  4656. ><P
  4657. >       gcc (recommended, other C compilers may work)
  4658.      </P
  4659. ></LI
  4660. ><LI
  4661. ><P
  4662. >       make
  4663.      </P
  4664. ></LI
  4665. ><LI
  4666. ><P
  4667. >       flex
  4668.      </P
  4669. ></LI
  4670. ><LI
  4671. ><P
  4672. >       bison
  4673.      </P
  4674. ></LI
  4675. ><LI
  4676. ><P
  4677. >       m4
  4678.      </P
  4679. ></LI
  4680. ><LI
  4681. ><P
  4682. >       autoconf
  4683.      </P
  4684. ></LI
  4685. ><LI
  4686. ><P
  4687. >       automake
  4688.      </P
  4689. ></LI
  4690. ><LI
  4691. ><P
  4692. >       perl
  4693.      </P
  4694. ></LI
  4695. ><LI
  4696. ><P
  4697. >       gzip
  4698.      </P
  4699. ></LI
  4700. ><LI
  4701. ><P
  4702. >       tar
  4703.      </P
  4704. ></LI
  4705. ><LI
  4706. ><P
  4707. >       GNU sed
  4708.      </P
  4709. ></LI
  4710. ></UL
  4711. >
  4712.     In addition, you will need to install (and possibly compile) any
  4713.     additional software specific to your configuration, such as Oracle
  4714.     or MySQL.
  4715.   </P
  4716. ></DIV
  4717. ><DIV
  4718. CLASS="sect2"
  4719. ><HR><H3
  4720. CLASS="sect2"
  4721. ><A
  4722. NAME="install.unix.solaris.packages"
  4723. >Using Packages</A
  4724. ></H3
  4725. ><P
  4726. >    You can simplify the Solaris install process by using pkgadd to
  4727.    install most of your needed components. 
  4728.   </P
  4729. ></DIV
  4730. ></DIV
  4731. ><DIV
  4732. CLASS="sect1"
  4733. ><HR><H2
  4734. CLASS="sect1"
  4735. ><A
  4736. NAME="install.unix.apache"
  4737. >Apache 1.3.x on Unix systems</A
  4738. ></H2
  4739. ><P
  4740. >      This section contains notes and hints specific to Apache installs
  4741.      of PHP on Unix platforms. We also have <A
  4742. HREF="#install.unix.apache2"
  4743. >instructions and notes for Apache 2
  4744.      on a separate page</A
  4745. >.
  4746.     </P
  4747. ><P
  4748. >      You can select arguments to add to the
  4749.      <B
  4750. CLASS="command"
  4751. >configure</B
  4752. > on line 10 below from the <A
  4753. HREF="#configure"
  4754. >list of core configure options</A
  4755. > and
  4756.      from extension specific options described at the respective
  4757.      places in the manual. The version numbers have been omitted here, to
  4758.      ensure the instructions are not incorrect. You will need to replace
  4759.      the 'xxx' here with the correct values from your files.
  4760.     </P
  4761. ><TABLE
  4762. WIDTH="100%"
  4763. BORDER="0"
  4764. CELLPADDING="0"
  4765. CELLSPACING="0"
  4766. CLASS="EXAMPLE"
  4767. ><TR
  4768. ><TD
  4769. ><DIV
  4770. CLASS="example"
  4771. ><A
  4772. NAME="install.unix.apache.example"
  4773. ></A
  4774. ><P
  4775. ><B
  4776. >Beispiel 5-5. 
  4777.       Installation Instructions (Apache Shared Module Version) for PHP
  4778.      </B
  4779. ></P
  4780. ><TABLE
  4781. BORDER="0"
  4782. BGCOLOR="#E0E0E0"
  4783. CELLPADDING="5"
  4784. ><TR
  4785. ><TD
  4786. ><PRE
  4787. CLASS="screen"
  4788. >1.  gunzip apache_xxx.tar.gz
  4789. 2.  tar -xvf apache_xxx.tar
  4790. 3.  gunzip php-xxx.tar.gz
  4791. 4.  tar -xvf php-xxx.tar
  4792. 5.  cd apache_xxx
  4793. 6.  ./configure --prefix=/www --enable-module=so
  4794. 7.  make
  4795. 8.  make install
  4796. 9.  cd ../php-xxx
  4797.  
  4798. 10. Now, configure your PHP.  This is where you customize your PHP
  4799.     with various options, like which extensions will be enabled.  Do a
  4800.     ./configure --help for a list of available options.  In our example
  4801.     we'll do a simple configure with Apache 1 and MySQL support.  Your
  4802.     path to apxs may differ from our example.
  4803.  
  4804.       ./configure --with-mysql --with-apxs=/www/bin/apxs
  4805.  
  4806. 11. make
  4807. 12. make install
  4808.  
  4809.     If you decide to change your configure options after installation,
  4810.     you only need to repeat the last three steps. You only need to 
  4811.     restart apache for the new module to take effect. A recompile of
  4812.     Apache is not needed.
  4813.   
  4814.     Note that unless told otherwise, 'make install' will also install PEAR,
  4815.     various PHP tools such as phpize, install the PHP CLI, and more.
  4816.  
  4817. 13. Setup your php.ini file:
  4818.  
  4819.       cp php.ini-dist /usr/local/lib/php.ini
  4820.  
  4821.     You may edit your .ini file to set PHP options.  If you prefer your
  4822.     php.ini in another location, use --with-config-file-path=/some/path in
  4823.     step 10. 
  4824.     
  4825.     If you instead choose php.ini-recommended, be certain to read the list
  4826.     of changes within, as they affect how PHP behaves.
  4827.  
  4828. 14. Edit your httpd.conf to load the PHP module.  The path on the right hand
  4829.     side of the LoadModule statement must point to the path of the PHP
  4830.     module on your system.  The make install from above may have already
  4831.     added this for you, but be sure to check.
  4832.         
  4833.     For PHP 4:
  4834.             
  4835.       LoadModule php4_module libexec/libphp4.so
  4836.  
  4837.     For PHP 5:
  4838.                       
  4839.       LoadModule php5_module libexec/libphp5.so
  4840.       
  4841. 15. And in the AddModule section of httpd.conf, somewhere under the
  4842.     ClearModuleList, add this:
  4843.     
  4844.     For PHP 4:
  4845.     
  4846.       AddModule mod_php4.c
  4847.       
  4848.     For PHP 5:
  4849.     
  4850.       AddModule mod_php5.c
  4851.  
  4852. 16. Tell Apache to parse certain extensions as PHP.  For example,
  4853.     let's have Apache parse the .php extension as PHP.  You could
  4854.     have any extension(s) parse as PHP by simply adding more, with
  4855.     each separated by a space.  We'll add .phtml to demonstrate.
  4856.  
  4857.       AddType application/x-httpd-php .php .phtml
  4858.  
  4859.     It's also common to setup the .phps extension to show highlighted PHP
  4860.     source, this can be done with:
  4861.     
  4862.       AddType application/x-httpd-php-source .phps
  4863.  
  4864. 17. Use your normal procedure for starting the Apache server. (You must
  4865.     stop and restart the server, not just cause the server to reload by
  4866.     using a HUP or USR1 signal.)</PRE
  4867. ></TD
  4868. ></TR
  4869. ></TABLE
  4870. ></DIV
  4871. ></TD
  4872. ></TR
  4873. ></TABLE
  4874. ><P
  4875. >       Depending on your Apache install and Unix variant, there are many
  4876.       possible ways to stop and restart the server. Below are some typical
  4877.       lines used in restarting the server, for different apache/unix
  4878.       installations. You should replace <VAR
  4879. CLASS="literal"
  4880. >/path/to/</VAR
  4881. > with
  4882.       the path to these applications on your systems.
  4883.      </P
  4884. ><P
  4885. >       <TABLE
  4886. WIDTH="100%"
  4887. BORDER="0"
  4888. CELLPADDING="0"
  4889. CELLSPACING="0"
  4890. CLASS="EXAMPLE"
  4891. ><TR
  4892. ><TD
  4893. ><DIV
  4894. CLASS="example"
  4895. ><A
  4896. NAME="AEN726"
  4897. ></A
  4898. ><P
  4899. ><B
  4900. >Beispiel 5-6. Example commands for restarting Apache</B
  4901. ></P
  4902. ><TABLE
  4903. BORDER="0"
  4904. BGCOLOR="#E0E0E0"
  4905. CELLPADDING="5"
  4906. ><TR
  4907. ><TD
  4908. ><PRE
  4909. CLASS="shell"
  4910. >1. Several Linux and SysV variants:
  4911. /etc/rc.d/init.d/httpd restart
  4912.  
  4913. 2. Using apachectl scripts:
  4914. /path/to/apachectl stop
  4915. /path/to/apachectl start
  4916.  
  4917. 3. httpdctl and httpsdctl (Using OpenSSL), similar to apachectl:
  4918. /path/to/httpsdctl stop
  4919. /path/to/httpsdctl start
  4920.  
  4921. 4. Using mod_ssl, or another SSL server, you may want to manually
  4922. stop and start:
  4923. /path/to/apachectl stop
  4924. /path/to/apachectl startssl</PRE
  4925. ></TD
  4926. ></TR
  4927. ></TABLE
  4928. ></DIV
  4929. ></TD
  4930. ></TR
  4931. ></TABLE
  4932. >
  4933.      </P
  4934. ><P
  4935. >       The locations of the apachectl and http(s)dctl binaries often
  4936.       vary. If your system has <VAR
  4937. CLASS="literal"
  4938. >locate</VAR
  4939. > or
  4940.       <VAR
  4941. CLASS="literal"
  4942. >whereis</VAR
  4943. > or <VAR
  4944. CLASS="literal"
  4945. >which</VAR
  4946. > commands,
  4947.       these can assist you in finding your server control programs.
  4948.      </P
  4949. ><P
  4950. >       Different examples of compiling PHP for apache are as follows:
  4951.       <DIV
  4952. CLASS="informalexample"
  4953. ><P
  4954. ></P
  4955. ><A
  4956. NAME="AEN734"
  4957. ></A
  4958. ><TABLE
  4959. BORDER="0"
  4960. BGCOLOR="#E0E0E0"
  4961. CELLPADDING="5"
  4962. ><TR
  4963. ><TD
  4964. ><PRE
  4965. CLASS="shell"
  4966. >./configure --with-apxs --with-pgsql</PRE
  4967. ></TD
  4968. ></TR
  4969. ></TABLE
  4970. ><P
  4971. ></P
  4972. ></DIV
  4973. >
  4974.      </P
  4975. ><P
  4976. >       This will create a <TT
  4977. CLASS="filename"
  4978. >libphp4.so</TT
  4979. > shared
  4980.       library that is loaded into Apache using a LoadModule line in
  4981.       Apache's <TT
  4982. CLASS="filename"
  4983. >httpd.conf</TT
  4984. > file. The PostgreSQL
  4985.       support is embedded into this <TT
  4986. CLASS="filename"
  4987. >libphp4.so</TT
  4988. >
  4989.       library.
  4990.      </P
  4991. ><P
  4992. >       <DIV
  4993. CLASS="informalexample"
  4994. ><P
  4995. ></P
  4996. ><A
  4997. NAME="AEN741"
  4998. ></A
  4999. ><TABLE
  5000. BORDER="0"
  5001. BGCOLOR="#E0E0E0"
  5002. CELLPADDING="5"
  5003. ><TR
  5004. ><TD
  5005. ><PRE
  5006. CLASS="shell"
  5007. >./configure --with-apxs --with-pgsql=shared</PRE
  5008. ></TD
  5009. ></TR
  5010. ></TABLE
  5011. ><P
  5012. ></P
  5013. ></DIV
  5014. >
  5015.      </P
  5016. ><P
  5017. >       This will create a <TT
  5018. CLASS="filename"
  5019. >libphp4.so</TT
  5020. > shared
  5021.       library for Apache, but it will also create a
  5022.       <TT
  5023. CLASS="filename"
  5024. >pgsql.so</TT
  5025. > shared library that is loaded into
  5026.       PHP either by using the extension directive in
  5027.       <TT
  5028. CLASS="filename"
  5029. >php.ini</TT
  5030. > file or by loading it explicitly in
  5031.       a script using the <A
  5032. HREF="#function.dl"
  5033. ><B
  5034. CLASS="function"
  5035. >dl()</B
  5036. ></A
  5037. > function.
  5038.      </P
  5039. ><P
  5040. >       <DIV
  5041. CLASS="informalexample"
  5042. ><P
  5043. ></P
  5044. ><A
  5045. NAME="AEN749"
  5046. ></A
  5047. ><TABLE
  5048. BORDER="0"
  5049. BGCOLOR="#E0E0E0"
  5050. CELLPADDING="5"
  5051. ><TR
  5052. ><TD
  5053. ><PRE
  5054. CLASS="shell"
  5055. >./configure --with-apache=/path/to/apache_source --with-pgsql</PRE
  5056. ></TD
  5057. ></TR
  5058. ></TABLE
  5059. ><P
  5060. ></P
  5061. ></DIV
  5062. >
  5063.      </P
  5064. ><P
  5065. >       This will create a <TT
  5066. CLASS="filename"
  5067. >libmodphp4.a</TT
  5068. > library, a
  5069.       <TT
  5070. CLASS="filename"
  5071. >mod_php4.c</TT
  5072. > and some accompanying files and
  5073.       copy this into the <VAR
  5074. CLASS="literal"
  5075. >src/modules/php4</VAR
  5076. > directory
  5077.       in the Apache source tree. Then you compile Apache using
  5078.       <VAR
  5079. CLASS="literal"
  5080. >--activate-module=src/modules/php4/libphp4.a</VAR
  5081. >
  5082.       and the Apache build system will create
  5083.       <TT
  5084. CLASS="filename"
  5085. >libphp4.a</TT
  5086. > and link it statically into the
  5087.       <TT
  5088. CLASS="filename"
  5089. >httpd</TT
  5090. > binary. The PostgreSQL support is
  5091.       included directly into this <TT
  5092. CLASS="filename"
  5093. >httpd</TT
  5094. > binary,
  5095.       so the final result here is a single <TT
  5096. CLASS="filename"
  5097. >httpd</TT
  5098. >
  5099.       binary that includes all of Apache and all of PHP.
  5100.      </P
  5101. ><P
  5102. >       <DIV
  5103. CLASS="informalexample"
  5104. ><P
  5105. ></P
  5106. ><A
  5107. NAME="AEN761"
  5108. ></A
  5109. ><TABLE
  5110. BORDER="0"
  5111. BGCOLOR="#E0E0E0"
  5112. CELLPADDING="5"
  5113. ><TR
  5114. ><TD
  5115. ><PRE
  5116. CLASS="shell"
  5117. >./configure --with-apache=/path/to/apache_source --with-pgsql=shared</PRE
  5118. ></TD
  5119. ></TR
  5120. ></TABLE
  5121. ><P
  5122. ></P
  5123. ></DIV
  5124. >
  5125.      </P
  5126. ><P
  5127. >       Same as before, except instead of including PostgreSQL support
  5128.       directly into the final <TT
  5129. CLASS="filename"
  5130. >httpd</TT
  5131. > you will get
  5132.       a <TT
  5133. CLASS="filename"
  5134. >pgsql.so</TT
  5135. > shared library that you can load
  5136.       into PHP from either the <TT
  5137. CLASS="filename"
  5138. >php.ini</TT
  5139. > file or
  5140.       directly using <A
  5141. HREF="#function.dl"
  5142. ><B
  5143. CLASS="function"
  5144. >dl()</B
  5145. ></A
  5146. >.
  5147.      </P
  5148. ><P
  5149. >       When choosing to build PHP in different ways, you should consider
  5150.       the advantages and drawbacks of each method. Building as a shared
  5151.       object will mean that you can compile apache separately, and don't
  5152.       have to recompile everything as you add to, or change, PHP.
  5153.       Building PHP into apache (static method) means that PHP will
  5154.       load and run faster. For more information, see the Apache
  5155.       <A
  5156. HREF="http://httpd.apache.org/docs/dso.html"
  5157. TARGET="_top"
  5158. >webpage on DSO support</A
  5159. >.
  5160.      </P
  5161. ><DIV
  5162. CLASS="note"
  5163. ><BLOCKQUOTE
  5164. CLASS="note"
  5165. ><P
  5166. ><B
  5167. >Anmerkung: </B
  5168. >
  5169.       Apache's default <TT
  5170. CLASS="filename"
  5171. >httpd.conf</TT
  5172. > currently ships with a section that looks
  5173.       like this:
  5174.       <DIV
  5175. CLASS="informalexample"
  5176. ><P
  5177. ></P
  5178. ><A
  5179. NAME="AEN773"
  5180. ></A
  5181. ><TABLE
  5182. BORDER="0"
  5183. BGCOLOR="#E0E0E0"
  5184. CELLPADDING="5"
  5185. ><TR
  5186. ><TD
  5187. ><PRE
  5188. CLASS="apache-conf"
  5189. >User nobody
  5190. Group "#-1"</PRE
  5191. ></TD
  5192. ></TR
  5193. ></TABLE
  5194. ><P
  5195. ></P
  5196. ></DIV
  5197. >
  5198.       Unless you change that to "Group nogroup" or something like that ("Group daemon" is
  5199.       also very common) PHP will not be able to open files.
  5200.      </P
  5201. ></BLOCKQUOTE
  5202. ></DIV
  5203. ><DIV
  5204. CLASS="note"
  5205. ><BLOCKQUOTE
  5206. CLASS="note"
  5207. ><P
  5208. ><B
  5209. >Anmerkung: </B
  5210. >
  5211.       Make sure you specify the installed version of apxs when using
  5212.       <VAR
  5213. CLASS="option"
  5214. >--with-apxs=/path/to/apxs</VAR
  5215. >.
  5216.       You must NOT use the apxs version that is in the apache sources but the one
  5217.       that is actually installed on your system.
  5218.      </P
  5219. ></BLOCKQUOTE
  5220. ></DIV
  5221. ></DIV
  5222. ><DIV
  5223. CLASS="sect1"
  5224. ><HR><H2
  5225. CLASS="sect1"
  5226. ><A
  5227. NAME="install.unix.apache2"
  5228. >Apache 2.0 on Unix systems</A
  5229. ></H2
  5230. ><P
  5231. >      This section contains notes and hints specific to Apache 2.0 installs
  5232.      of PHP on Unix systems.
  5233.     </P
  5234. ><DIV
  5235. CLASS="warning"
  5236. ><P
  5237. ></P
  5238. ><TABLE
  5239. CLASS="warning"
  5240. BORDER="1"
  5241. WIDTH="100%"
  5242. ><TR
  5243. ><TD
  5244. ALIGN="CENTER"
  5245. ><B
  5246. >Warnung</B
  5247. ></TD
  5248. ></TR
  5249. ><TR
  5250. ><TD
  5251. ALIGN="LEFT"
  5252. ><P
  5253. >Verwenden Sie Apache 2.0.x und PHP
  5254. weder unter Unix noch Windows in einer Produktivumgebung. Fⁿr weitere
  5255. Informationen und Grⁿnde lesen Sie bitte diesen
  5256. <A
  5257. HREF="#faq.installation.apache2"
  5258. >FAQ Eintrag.</A
  5259. ></P
  5260. ></TD
  5261. ></TR
  5262. ></TABLE
  5263. ></DIV
  5264. ><P
  5265. >      You are highly encouraged to take a look at the
  5266.      <A
  5267. HREF="http://httpd.apache.org/docs-2.0/"
  5268. TARGET="_top"
  5269. >Apache Documentation</A
  5270. > to get
  5271.      a basic understanding of the Apache 2.0 Server.
  5272.     </P
  5273. ><DIV
  5274. CLASS="note"
  5275. ><BLOCKQUOTE
  5276. CLASS="note"
  5277. ><P
  5278. ><B
  5279. >PHP and Apache 2.0.x compatibility notes: </B
  5280. >
  5281.       The following versions of PHP are known to work with the most recent
  5282.       version of Apache 2.0.x:
  5283.       <P
  5284. ></P
  5285. ><UL
  5286. COMPACT="COMPACT"
  5287. ><LI
  5288. ><SPAN
  5289. >          PHP 4.3.0 or later available at
  5290.          <A
  5291. HREF="http://www.php.net/downloads.php"
  5292. TARGET="_top"
  5293. >http://www.php.net/downloads.php</A
  5294. >.
  5295.         </SPAN
  5296. ></LI
  5297. ><LI
  5298. ><SPAN
  5299. >          the latest stable development version.
  5300.          Get the source code <A
  5301. HREF="http://snaps.php.net/php4-latest.tar.gz"
  5302. TARGET="_top"
  5303. >          http://snaps.php.net/php4-latest.tar.gz</A
  5304. > or download binaries
  5305.          for Windows <A
  5306. HREF="http://snaps.php.net/win32/php4-win32-latest.zip"
  5307. TARGET="_top"
  5308. >          http://snaps.php.net/win32/php4-win32-latest.zip</A
  5309. >.
  5310.         </SPAN
  5311. ></LI
  5312. ><LI
  5313. ><SPAN
  5314. >          a prerelease version downloadable from
  5315.          <A
  5316. HREF="http://qa.php.net/"
  5317. TARGET="_top"
  5318. >http://qa.php.net/</A
  5319. >.
  5320.         </SPAN
  5321. ></LI
  5322. ><LI
  5323. ><SPAN
  5324. >          you have always the option to obtain PHP through
  5325.          <A
  5326. HREF="http://www.php.net/anoncvs.php"
  5327. TARGET="_top"
  5328. >anonymous CVS</A
  5329. >.
  5330.         </SPAN
  5331. ></LI
  5332. ></UL
  5333. >
  5334.       These versions of PHP are compatible to Apache 2.0.40 and later.
  5335.      </P
  5336. ><P
  5337. >       Apache 2.0 <VAR
  5338. CLASS="literal"
  5339. >SAPI</VAR
  5340. >-support started with PHP 4.2.0.
  5341.       PHP 4.2.3 works with Apache 2.0.39, don't use any other version of Apache with
  5342.       PHP 4.2.3. However, the recommended setup is to use PHP 4.3.0 or later with
  5343.       the most recent version of Apache2.
  5344.      </P
  5345. ><P
  5346. >       All mentioned versions of PHP will work still with
  5347.       Apache 1.3.x.
  5348.      </P
  5349. ></BLOCKQUOTE
  5350. ></DIV
  5351. ><P
  5352. >      Download the most recent version of <A
  5353. HREF="http://www.apache.org/"
  5354. TARGET="_top"
  5355. >      Apache 2.0</A
  5356. > and a fitting PHP version from the above mentioned places.
  5357.      This quick guide covers only the basics to get started with Apache 2.0
  5358.      and PHP. For more information read the
  5359.      <A
  5360. HREF="http://httpd.apache.org/docs-2.0/"
  5361. TARGET="_top"
  5362. >Apache Documentation</A
  5363. >.
  5364.      The version numbers have been omitted here, to ensure the
  5365.      instructions are not incorrect. You will need to replace the
  5366.      'NN' here with the correct values from your files.
  5367.     </P
  5368. ><TABLE
  5369. WIDTH="100%"
  5370. BORDER="0"
  5371. CELLPADDING="0"
  5372. CELLSPACING="0"
  5373. CLASS="EXAMPLE"
  5374. ><TR
  5375. ><TD
  5376. ><DIV
  5377. CLASS="example"
  5378. ><A
  5379. NAME="AEN809"
  5380. ></A
  5381. ><P
  5382. ><B
  5383. >Beispiel 5-7. 
  5384.       Installation Instructions (Apache 2 Shared Module Version)
  5385.      </B
  5386. ></P
  5387. ><TABLE
  5388. BORDER="0"
  5389. BGCOLOR="#E0E0E0"
  5390. CELLPADDING="5"
  5391. ><TR
  5392. ><TD
  5393. ><PRE
  5394. CLASS="screen"
  5395. >1.  gzip -d httpd-2_0_NN.tar.gz
  5396. 2.  tar xvf httpd-2_0_NN.tar
  5397. 3.  gunzip php-NN.tar.gz
  5398. 4.  tar -xvf php-NN.tar
  5399. 5.  cd httpd-2_0_NN
  5400. 6.  ./configure --enable-so
  5401. 7.  make
  5402. 8.  make install
  5403.  
  5404.     Now you have Apache 2.0.NN available under /usr/local/apache2,
  5405.     configured with loadable module support and the standard MPM prefork.
  5406.     To test the installation use your normal procedure for starting
  5407.     the Apache server, e.g.:
  5408.     /usr/local/apache2/bin/apachectl start
  5409.     and stop the server to go on with the configuration for PHP:
  5410.     /usr/local/apache2/bin/apachectl stop.
  5411.  
  5412. 9.  cd ../php-NN
  5413.  
  5414. 10. Now, configure your PHP.  This is where you customize your PHP
  5415.     with various options, like which extensions will be enabled.  Do a
  5416.     ./configure --help for a list of available options.  In our example
  5417.     we'll do a simple configure with Apache 2 and MySQL support.  Your
  5418.     path to apxs may differ, in fact, the binary may even be named apxs2 on
  5419.     your system. 
  5420.     
  5421.       ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
  5422.  
  5423. 11. make
  5424. 12. make install
  5425.  
  5426.     If you decide to change your configure options after installation,
  5427.     you only need to repeat the last three steps. You only need to
  5428.     restart apache for the new module to take effect. A recompile of
  5429.     Apache is not needed.
  5430.                 
  5431.     Note that unless told otherwise, 'make install' will also install PEAR,
  5432.     various PHP tools such as phpize, install the PHP CLI, and more.
  5433.     
  5434. 13. Setup your php.ini 
  5435.     
  5436.     cp php.ini-dist /usr/local/lib/php.ini
  5437.           
  5438.     You may edit your .ini file to set PHP options.  If you prefer having
  5439.     php.ini in another location, use --with-config-file-path=/some/path in
  5440.     step 10.
  5441.     
  5442.     If you instead choose php.ini-recommended, be certain to read the list
  5443.     of changes within, as they affect how PHP behaves.
  5444.  
  5445. 14. Edit your httpd.conf to load the PHP module.  The path on the right hand
  5446.     side of the LoadModule statement must point to the path of the PHP
  5447.     module on your system.  The make install from above may have already
  5448.     added this for you, but be sure to check.
  5449.  
  5450.     For PHP 4:
  5451.   
  5452.       LoadModule php4_module libexec/libphp4.so
  5453.       
  5454.     For PHP 5:
  5455.     
  5456.       LoadModule php5_module libexec/libphp5.so
  5457.  
  5458. 15. Tell Apache to parse certain extensions as PHP.  For example,
  5459.     let's have Apache parse the .php extension as PHP.  You could
  5460.     have any extension(s) parse as PHP by simply adding more, with
  5461.     each separated by a space.  We'll add .phtml to demonstrate.
  5462.             
  5463.       AddType application/x-httpd-php .php .phtml
  5464.                   
  5465.     It's also common to setup the .phps extension to show highlighted PHP
  5466.     source, this can be done with:
  5467.     
  5468.       AddType application/x-httpd-php-source .phps
  5469.  
  5470. 16. Use your normal procedure for starting the Apache server, e.g.:
  5471.    
  5472.       /usr/local/apache2/bin/apachectl start</PRE
  5473. ></TD
  5474. ></TR
  5475. ></TABLE
  5476. ></DIV
  5477. ></TD
  5478. ></TR
  5479. ></TABLE
  5480. ><P
  5481. >      Following the steps above you will have a running Apache 2.0 with
  5482.      support for PHP as <VAR
  5483. CLASS="literal"
  5484. >SAPI</VAR
  5485. > module.
  5486.      Of course there are many more configuration options available for both,
  5487.      Apache and PHP. For more information use
  5488.      <B
  5489. CLASS="command"
  5490. >./configure --help</B
  5491. > in the corresponding source
  5492.      tree. In case you wish to build a multithreaded version of Apache 2.0
  5493.      you must overwrite the standard MPM-Module <TT
  5494. CLASS="filename"
  5495. >prefork</TT
  5496. >
  5497.      either with <TT
  5498. CLASS="filename"
  5499. >worker</TT
  5500. > or <TT
  5501. CLASS="filename"
  5502. >perchild</TT
  5503. >.
  5504.      To do so append to your configure line in step 6 above either the option
  5505.      <VAR
  5506. CLASS="option"
  5507. >--with-mpm=worker</VAR
  5508. > or
  5509.      <VAR
  5510. CLASS="option"
  5511. >--with-mpm=perchild</VAR
  5512. >. Take care about
  5513.      the consequences and understand what you are doing. For more information
  5514.      read the Apache documentation about the <A
  5515. HREF="http://httpd.apache.org/docs-2.0/mpm.html"
  5516. TARGET="_top"
  5517. >      MPM-Modules</A
  5518. >.
  5519.     </P
  5520. ><DIV
  5521. CLASS="note"
  5522. ><BLOCKQUOTE
  5523. CLASS="note"
  5524. ><P
  5525. ><B
  5526. >Anmerkung: </B
  5527. >
  5528.       To build a multithreaded version of Apache your system must support threads.
  5529.       This also implies to build PHP with experimental
  5530.       Zend Thread Safety (ZTS). Therefore not all extensions might be available.
  5531.       The recommended setup is to build Apache with the standard
  5532.       <TT
  5533. CLASS="filename"
  5534. >prefork</TT
  5535. > MPM-Module.
  5536.      </P
  5537. ></BLOCKQUOTE
  5538. ></DIV
  5539. ></DIV
  5540. ><DIV
  5541. CLASS="sect1"
  5542. ><HR><H2
  5543. CLASS="sect1"
  5544. ><A
  5545. NAME="install.unix.caudium"
  5546. >Caudium</A
  5547. ></H2
  5548. ><P
  5549. >     PHP 4 can be built as a Pike module for the
  5550.     <A
  5551. HREF="http://caudium.net/"
  5552. TARGET="_top"
  5553. >Caudium webserver</A
  5554. >.
  5555.     Note that this is not supported with PHP 3. Follow the simple
  5556.     instructions below to install PHP 4 for Caudium.
  5557.    </P
  5558. ><TABLE
  5559. WIDTH="100%"
  5560. BORDER="0"
  5561. CELLPADDING="0"
  5562. CELLSPACING="0"
  5563. CLASS="EXAMPLE"
  5564. ><TR
  5565. ><TD
  5566. ><DIV
  5567. CLASS="example"
  5568. ><A
  5569. NAME="install.unix.caudium.instructions"
  5570. ></A
  5571. ><P
  5572. ><B
  5573. >Beispiel 5-8. Caudium Installation Instructions</B
  5574. ></P
  5575. ><TABLE
  5576. BORDER="0"
  5577. BGCOLOR="#E0E0E0"
  5578. CELLPADDING="5"
  5579. ><TR
  5580. ><TD
  5581. ><PRE
  5582. CLASS="screen"
  5583. >1.  Make sure you have Caudium installed prior to attempting to
  5584.     install PHP 4. For PHP 4 to work correctly, you will need Pike
  5585.     7.0.268 or newer. For the sake of this example we assume that
  5586.     Caudium is installed in /opt/caudium/server/.
  5587. 2.  Change directory to php-x.y.z (where x.y.z is the version number).
  5588. 3.  ./configure --with-caudium=/opt/caudium/server
  5589. 4.  make
  5590. 5.  make install
  5591. 6.  Restart Caudium if it's currently running.
  5592. 7.  Log into the graphical configuration interface and go to the
  5593.     virtual server where you want to add PHP 4 support.
  5594. 8.  Click Add Module and locate and then add the PHP 4 Script Support module.
  5595. 9.  If the documentation says that the 'PHP 4 interpreter isn't
  5596.     available', make sure that you restarted the server. If you did
  5597.     check /opt/caudium/logs/debug/default.1 for any errors related to
  5598.     <filename>PHP4.so</filename>. Also make sure that 
  5599.     <filename>caudium/server/lib/[pike-version]/PHP4.so</filename>
  5600.     is present.
  5601. 10. Configure the PHP Script Support module if needed.</PRE
  5602. ></TD
  5603. ></TR
  5604. ></TABLE
  5605. ></DIV
  5606. ></TD
  5607. ></TR
  5608. ></TABLE
  5609. ><P
  5610. >     You can of course compile your Caudium module with support for the
  5611.     various extensions available in PHP 4. See the reference pages
  5612.     for extension specific configure options.
  5613.    </P
  5614. ><DIV
  5615. CLASS="note"
  5616. ><BLOCKQUOTE
  5617. CLASS="note"
  5618. ><P
  5619. ><B
  5620. >Anmerkung: </B
  5621. >
  5622.      When compiling PHP 4 with MySQL support you must make sure that
  5623.      the normal MySQL client code is used. Otherwise there might be
  5624.      conflicts if your Pike already has MySQL support. You do this by
  5625.      specifying a MySQL install directory the 
  5626.      <VAR
  5627. CLASS="option"
  5628. >--with-mysql</VAR
  5629. > option.
  5630.     </P
  5631. ></BLOCKQUOTE
  5632. ></DIV
  5633. ></DIV
  5634. ><DIV
  5635. CLASS="sect1"
  5636. ><HR><H2
  5637. CLASS="sect1"
  5638. ><A
  5639. NAME="install.unix.fhttpd"
  5640. >fhttpd related notes</A
  5641. ></H2
  5642. ><P
  5643. >     To build PHP as an fhttpd module, answer "yes" to "Build as an
  5644.     fhttpd module?" (the <A
  5645. HREF="#configure.with-fhttpd"
  5646. >     --with-fhttpd</A
  5647. >=<VAR
  5648. CLASS="replaceable"
  5649. >DIR</VAR
  5650. >
  5651.     option to configure) and specify the fhttpd source base
  5652.     directory.  The default directory is <TT
  5653. CLASS="filename"
  5654. >/usr/local/src/fhttpd</TT
  5655. >. If you are
  5656.     running fhttpd, building PHP as a module will give better
  5657.     performance, more control and remote execution capability.
  5658.    </P
  5659. ><DIV
  5660. CLASS="note"
  5661. ><BLOCKQUOTE
  5662. CLASS="note"
  5663. ><P
  5664. ><B
  5665. >Anmerkung: </B
  5666. >
  5667.      Support for fhttpd is no longer available as of PHP 4.3.0.
  5668.     </P
  5669. ></BLOCKQUOTE
  5670. ></DIV
  5671. ></DIV
  5672. ><DIV
  5673. CLASS="sect1"
  5674. ><HR><H2
  5675. CLASS="sect1"
  5676. ><A
  5677. NAME="install.unix.sun"
  5678. >Sun, iPlanet and Netscape servers on Sun Solaris</A
  5679. ></H2
  5680. ><P
  5681. >      This section contains notes and hints specific to Sun Java System Web Server,
  5682.      Sun ONE Web Server, iPlanet and Netscape server installs of PHP on Sun Solaris.
  5683.     </P
  5684. ><P
  5685. >      From PHP 4.3.3 on you can use PHP scripts with the
  5686.      <A
  5687. HREF="#ref.nsapi"
  5688. >NSAPI module</A
  5689. > to 
  5690.      <A
  5691. HREF="#install.unix.sun.specialpages"
  5692. >generate custom directory
  5693.      listings and error pages</A
  5694. >. Additional functions for Apache
  5695.      compatibility are also available. For support in current webservers read
  5696.      the <A
  5697. HREF="#install.unix.sun.notes"
  5698. >note about subrequests</A
  5699. >.
  5700.     </P
  5701. ><P
  5702. >      You can find more information about setting up PHP for the Netscape
  5703.      Enterprise Server (NES) here:
  5704.      <A
  5705. HREF="http://benoit.noss.free.fr/php/install-php4.html"
  5706. TARGET="_top"
  5707. >http://benoit.noss.free.fr/php/install-php4.html</A
  5708. >
  5709.     </P
  5710. ><P
  5711. >      To build PHP with Sun JSWS/Sun ONE WS/iPlanet/Netscape webservers,
  5712.      enter the proper install directory for the
  5713.      <A
  5714. HREF="#configure.with-nsapi"
  5715. >--with-nsapi=[DIR]</A
  5716. >
  5717.      option. The default directory is usually
  5718.      <TT
  5719. CLASS="filename"
  5720. >/opt/netscape/suitespot/</TT
  5721. >.
  5722.      Please also read <TT
  5723. CLASS="filename"
  5724. >/php-xxx-version/sapi/nsapi/nsapi-readme.txt</TT
  5725. >.
  5726.     </P
  5727. ><P
  5728. >      <P
  5729. ></P
  5730. ><OL
  5731. TYPE="1"
  5732. ><LI
  5733. ><P
  5734. >         Install the following packages from <A
  5735. HREF="http://www.sunfreeware.com/"
  5736. TARGET="_top"
  5737. >         http://www.sunfreeware.com/</A
  5738. > or another download site:
  5739.         <P
  5740. ></P
  5741. ><TABLE
  5742. BORDER="0"
  5743. ><TBODY
  5744. ><TR
  5745. ><TD
  5746. ><TT
  5747. CLASS="filename"
  5748. >autoconf-2.13</TT
  5749. ></TD
  5750. ></TR
  5751. ><TR
  5752. ><TD
  5753. ><TT
  5754. CLASS="filename"
  5755. >automake-1.4</TT
  5756. ></TD
  5757. ></TR
  5758. ><TR
  5759. ><TD
  5760. ><TT
  5761. CLASS="filename"
  5762. >bison-1_25-sol26-sparc-local</TT
  5763. ></TD
  5764. ></TR
  5765. ><TR
  5766. ><TD
  5767. ><TT
  5768. CLASS="filename"
  5769. >flex-2_5_4a-sol26-sparc-local</TT
  5770. ></TD
  5771. ></TR
  5772. ><TR
  5773. ><TD
  5774. ><TT
  5775. CLASS="filename"
  5776. >gcc-2_95_2-sol26-sparc-local</TT
  5777. ></TD
  5778. ></TR
  5779. ><TR
  5780. ><TD
  5781. ><TT
  5782. CLASS="filename"
  5783. >gzip-1.2.4-sol26-sparc-local</TT
  5784. ></TD
  5785. ></TR
  5786. ><TR
  5787. ><TD
  5788. ><TT
  5789. CLASS="filename"
  5790. >m4-1_4-sol26-sparc-local</TT
  5791. ></TD
  5792. ></TR
  5793. ><TR
  5794. ><TD
  5795. ><TT
  5796. CLASS="filename"
  5797. >make-3_76_1-sol26-sparc-local</TT
  5798. ></TD
  5799. ></TR
  5800. ><TR
  5801. ><TD
  5802. >           <TT
  5803. CLASS="filename"
  5804. >mysql-3.23.24-beta</TT
  5805. > (if you want mysql support)
  5806.          </TD
  5807. ></TR
  5808. ><TR
  5809. ><TD
  5810. ><TT
  5811. CLASS="filename"
  5812. >perl-5_005_03-sol26-sparc-local</TT
  5813. ></TD
  5814. ></TR
  5815. ><TR
  5816. ><TD
  5817. ><TT
  5818. CLASS="filename"
  5819. >tar-1.13</TT
  5820. > (GNU tar)</TD
  5821. ></TR
  5822. ></TBODY
  5823. ></TABLE
  5824. ><P
  5825. ></P
  5826. >
  5827.        </P
  5828. ></LI
  5829. ><LI
  5830. ><P
  5831. >         Make sure your path includes the proper directories
  5832.         <VAR
  5833. CLASS="literal"
  5834. >PATH=.:/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin</VAR
  5835. >
  5836.         and make it available to your system <KBD
  5837. CLASS="userinput"
  5838. >export PATH</KBD
  5839. >.
  5840.        </P
  5841. ></LI
  5842. ><LI
  5843. ><P
  5844. >         <KBD
  5845. CLASS="userinput"
  5846. >gunzip php-x.x.x.tar.gz</KBD
  5847. > (if you have a .gz dist,
  5848.         otherwise go to 4).
  5849.        </P
  5850. ></LI
  5851. ><LI
  5852. ><P
  5853. >         <KBD
  5854. CLASS="userinput"
  5855. >tar xvf php-x.x.x.tar</KBD
  5856. >
  5857.        </P
  5858. ></LI
  5859. ><LI
  5860. ><P
  5861. >         Change to your extracted PHP directory:
  5862.         <KBD
  5863. CLASS="userinput"
  5864. >cd ../php-x.x.x </KBD
  5865. >
  5866.        </P
  5867. ></LI
  5868. ><LI
  5869. ><P
  5870. >         For the following step, make sure
  5871.         <TT
  5872. CLASS="filename"
  5873. >/opt/netscape/suitespot/</TT
  5874. > is
  5875.         where your netscape server is installed. Otherwise, change to the
  5876.         correct path and run:
  5877.         <TABLE
  5878. BORDER="0"
  5879. BGCOLOR="#E0E0E0"
  5880. CELLPADDING="5"
  5881. ><TR
  5882. ><TD
  5883. ><PRE
  5884. CLASS="shell"
  5885. >./configure --with-mysql=/usr/local/mysql \
  5886. --with-nsapi=/opt/netscape/suitespot/ \
  5887. --enable-libgcc</PRE
  5888. ></TD
  5889. ></TR
  5890. ></TABLE
  5891. >
  5892.        </P
  5893. ></LI
  5894. ><LI
  5895. ><P
  5896. >         Run <B
  5897. CLASS="command"
  5898. >make</B
  5899. > followed by <B
  5900. CLASS="command"
  5901. >make install</B
  5902. >.
  5903.        </P
  5904. ></LI
  5905. ></OL
  5906. >
  5907.     </P
  5908. ><P
  5909. >      After performing the base install and reading the appropriate readme file,
  5910.      you may need to perform some additional configuration steps.
  5911.     </P
  5912. ><DIV
  5913. CLASS="formalpara"
  5914. ><P
  5915. ><B
  5916. >Configuration Instructions for Sun/iPlanet/Netscape. </B
  5917. >
  5918.       Firstly you may need to add some paths to the <VAR
  5919. CLASS="varname"
  5920. >LD_LIBRARY_PATH</VAR
  5921. >
  5922.       environment for the server to find all the shared libs. This can best done
  5923.       in the start script for your webserver. The start script is often located
  5924.       in: <TT
  5925. CLASS="filename"
  5926. >/path/to/server/https-servername/start</TT
  5927. >.
  5928.       You may also need to edit the configuration files that are
  5929.       located in: <TT
  5930. CLASS="filename"
  5931. >/path/to/server/https-servername/config/</TT
  5932. >.
  5933.       <P
  5934. ></P
  5935. ><OL
  5936. TYPE="1"
  5937. ><LI
  5938. ><P
  5939. >          Add the following line to <TT
  5940. CLASS="filename"
  5941. >mime.types</TT
  5942. > (you can do
  5943.          that by the administration server):
  5944.          <TABLE
  5945. BORDER="0"
  5946. BGCOLOR="#E0E0E0"
  5947. CELLPADDING="5"
  5948. ><TR
  5949. ><TD
  5950. ><PRE
  5951. CLASS="screen"
  5952. >type=magnus-internal/x-httpd-php exts=php</PRE
  5953. ></TD
  5954. ></TR
  5955. ></TABLE
  5956. >
  5957.         </P
  5958. ></LI
  5959. ><LI
  5960. ><P
  5961. >          Edit <TT
  5962. CLASS="filename"
  5963. >magnus.conf</TT
  5964. > (for servers >= 6) or
  5965.          <TT
  5966. CLASS="filename"
  5967. >obj.conf</TT
  5968. > (for servers < 6) and add the following,
  5969.          shlib will vary depending on your system, it will be something like
  5970.          <TT
  5971. CLASS="filename"
  5972. >/opt/netscape/suitespot/bin/libphp4.so</TT
  5973. >. You should
  5974.          place the following lines after <VAR
  5975. CLASS="literal"
  5976. >mime types init</VAR
  5977. >.
  5978.          <TABLE
  5979. BORDER="0"
  5980. BGCOLOR="#E0E0E0"
  5981. CELLPADDING="5"
  5982. ><TR
  5983. ><TD
  5984. ><PRE
  5985. CLASS="programlisting"
  5986. >Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="/opt/netscape/suitespot/bin/libphp4.so"
  5987. Init fn="php4_init" LateInit="yes" errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"]</PRE
  5988. ></TD
  5989. ></TR
  5990. ></TABLE
  5991. >
  5992.          (PHP >= 4.3.3) The <VAR
  5993. CLASS="literal"
  5994. >php_ini</VAR
  5995. > parameter is
  5996.          optional but with it you can place your <TT
  5997. CLASS="filename"
  5998. >php.ini</TT
  5999. > in your
  6000.          webserver config directory.
  6001.         </P
  6002. ></LI
  6003. ><LI
  6004. ><P
  6005. >          Configure the default object in <TT
  6006. CLASS="filename"
  6007. >obj.conf</TT
  6008. >
  6009.          (for virtual server classes [version 6.0+] in
  6010.          their <TT
  6011. CLASS="filename"
  6012. >vserver.obj.conf</TT
  6013. >):
  6014.          <TABLE
  6015. BORDER="0"
  6016. BGCOLOR="#E0E0E0"
  6017. CELLPADDING="5"
  6018. ><TR
  6019. ><TD
  6020. ><PRE
  6021. CLASS="programlisting"
  6022. ><Object name="default">
  6023. .
  6024. .
  6025. .
  6026. .#NOTE this next line should happen after all 'ObjectType' and before all 'AddLog' lines
  6027. Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inikey=value ...]
  6028. .
  6029. .
  6030. </Object></PRE
  6031. ></TD
  6032. ></TR
  6033. ></TABLE
  6034. >
  6035.          (PHP >= 4.3.3) As additional parameters you can add some special
  6036.          <TT
  6037. CLASS="filename"
  6038. >php.ini</TT
  6039. >-values, for example you can set a
  6040.          <VAR
  6041. CLASS="literal"
  6042. >docroot="/path/to/docroot"</VAR
  6043. > specific
  6044.          to the context <VAR
  6045. CLASS="literal"
  6046. >php4_execute</VAR
  6047. > is called. For boolean
  6048.          ini-keys please use 0/1 as value, not
  6049.          <VAR
  6050. CLASS="literal"
  6051. >"On","Off",...</VAR
  6052. >
  6053.          (this will not work correctly), e.g.
  6054.          <VAR
  6055. CLASS="literal"
  6056. >zlib.output_compression=1</VAR
  6057. > instead of
  6058.          <VAR
  6059. CLASS="literal"
  6060. >zlib.output_compression="On"</VAR
  6061. >
  6062.         </P
  6063. ></LI
  6064. ><LI
  6065. ><P
  6066. >          This is only needed if you want to configure a directory that only consists of
  6067.          PHP scripts (same like a <TT
  6068. CLASS="filename"
  6069. >cgi-bin</TT
  6070. > directory):
  6071.          <TABLE
  6072. BORDER="0"
  6073. BGCOLOR="#E0E0E0"
  6074. CELLPADDING="5"
  6075. ><TR
  6076. ><TD
  6077. ><PRE
  6078. CLASS="programlisting"
  6079. ><Object name="x-httpd-php">
  6080. ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
  6081. Service fn=php4_execute [inikey=value inikey=value ...]
  6082. </Object></PRE
  6083. ></TD
  6084. ></TR
  6085. ></TABLE
  6086. >
  6087.          After that you can configure a directory in the Administration server and assign it
  6088.          the style <VAR
  6089. CLASS="literal"
  6090. >x-httpd-php</VAR
  6091. >. All files in it will get executed as PHP.
  6092.          This is nice to hide PHP usage by renaming files to <TT
  6093. CLASS="filename"
  6094. >.html</TT
  6095. >.
  6096.         </P
  6097. ></LI
  6098. ><LI
  6099. ><P
  6100. >          Setup of authentication: PHP authentication cannot be used with any
  6101.          other authentication. ALL AUTHENTICATION IS PASSED TO YOUR PHP SCRIPT.
  6102.          To configure PHP Authentication for the entire server, add the
  6103.          following line to your default object:
  6104.          <TABLE
  6105. BORDER="0"
  6106. BGCOLOR="#E0E0E0"
  6107. CELLPADDING="5"
  6108. ><TR
  6109. ><TD
  6110. ><PRE
  6111. CLASS="programlisting"
  6112. ><Object name="default">
  6113. AuthTrans fn=php4_auth_trans
  6114. .
  6115. .
  6116. .
  6117. </Object></PRE
  6118. ></TD
  6119. ></TR
  6120. ></TABLE
  6121. >
  6122.         </P
  6123. ></LI
  6124. ><LI
  6125. ><P
  6126. >          To use PHP Authentication on a single directory, add the following:
  6127.          <TABLE
  6128. BORDER="0"
  6129. BGCOLOR="#E0E0E0"
  6130. CELLPADDING="5"
  6131. ><TR
  6132. ><TD
  6133. ><PRE
  6134. CLASS="programlisting"
  6135. ><Object ppath="d:\path\to\authenticated\dir\*">
  6136. AuthTrans fn=php4_auth_trans
  6137. </Object></PRE
  6138. ></TD
  6139. ></TR
  6140. ></TABLE
  6141. >
  6142.         </P
  6143. ></LI
  6144. ></OL
  6145. >
  6146.      </P
  6147. ></DIV
  6148. ><DIV
  6149. CLASS="note"
  6150. ><BLOCKQUOTE
  6151. CLASS="note"
  6152. ><P
  6153. ><B
  6154. >Anmerkung: </B
  6155. >
  6156.       The stacksize that PHP uses depends on the configuration of the webserver. If you get
  6157.       crashes with very large PHP scripts, it is recommended to raise it with the Admin Server
  6158.       (in the section "MAGNUS EDITOR").
  6159.      </P
  6160. ></BLOCKQUOTE
  6161. ></DIV
  6162. ><DIV
  6163. CLASS="sect2"
  6164. ><HR><H3
  6165. CLASS="sect2"
  6166. ><A
  6167. NAME="install.unix.sun.phpini"
  6168. >CGI environment and recommended modifications in php.ini</A
  6169. ></H3
  6170. ><P
  6171. >      Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
  6172.      WS/iPlanet/Netscape is a multithreaded web server. Because of that all
  6173.      requests are running in the same process space (the space of the webserver
  6174.      itself) and this space has only one environment. If you want to get CGI
  6175.      variables like <VAR
  6176. CLASS="literal"
  6177. >PATH_INFO</VAR
  6178. >, <VAR
  6179. CLASS="literal"
  6180. >HTTP_HOST</VAR
  6181. >
  6182.      etc. it is not the correct way to try this in the old PHP 3.x way with
  6183.      <A
  6184. HREF="#function.getenv"
  6185. ><B
  6186. CLASS="function"
  6187. >getenv()</B
  6188. ></A
  6189. > or a similar way (register globals to
  6190.      environment, <VAR
  6191. CLASS="literal"
  6192. >$_ENV</VAR
  6193. >). You would only get the environment
  6194.      of the running webserver without any valid CGI variables!
  6195.     </P
  6196. ><DIV
  6197. CLASS="note"
  6198. ><BLOCKQUOTE
  6199. CLASS="note"
  6200. ><P
  6201. ><B
  6202. >Anmerkung: </B
  6203. >
  6204.       Why are there (invalid) CGI variables in the environment?
  6205.      </P
  6206. ><P
  6207. >       Answer: This is because you started the webserver process from the admin server
  6208.       which runs the startup script of the webserver, you wanted to start, as a CGI script
  6209.       (a CGI script inside of the admin server!). This is why the environment of
  6210.       the started webserver has some CGI environment variables in it. You can test
  6211.       this by starting the webserver not from the administration server. Use
  6212.       the command line as root user and start it manually - you will see
  6213.       there are no CGI-like environment variables.
  6214.      </P
  6215. ></BLOCKQUOTE
  6216. ></DIV
  6217. ><P
  6218. >      Simply change your scripts to get CGI variables in the correct way for
  6219.      PHP 4.x by using the superglobal <VAR
  6220. CLASS="literal"
  6221. >$_SERVER</VAR
  6222. >. If you have
  6223.      older scripts which use <VAR
  6224. CLASS="literal"
  6225. >$HTTP_HOST</VAR
  6226. >, etc., you should turn
  6227.      on <VAR
  6228. CLASS="literal"
  6229. >register_globals</VAR
  6230. > in <TT
  6231. CLASS="filename"
  6232. >php.ini</TT
  6233. > and change the variable
  6234.      order too (important: remove <VAR
  6235. CLASS="literal"
  6236. >"E"</VAR
  6237. > from it,
  6238.      because you do not need the environment here):
  6239.      <TABLE
  6240. BORDER="0"
  6241. BGCOLOR="#E0E0E0"
  6242. CELLPADDING="5"
  6243. ><TR
  6244. ><TD
  6245. ><PRE
  6246. CLASS="programlisting"
  6247. >variables_order = "GPCS"
  6248. register_globals = On</PRE
  6249. ></TD
  6250. ></TR
  6251. ></TABLE
  6252. >
  6253.     </P
  6254. ></DIV
  6255. ><DIV
  6256. CLASS="sect2"
  6257. ><HR><H3
  6258. CLASS="sect2"
  6259. ><A
  6260. NAME="install.unix.sun.specialpages"
  6261. >Special use for error pages or self-made directory listings (PHP >= 4.3.3)</A
  6262. ></H3
  6263. ><P
  6264. >      You can use PHP to generate the error pages for <VAR
  6265. CLASS="literal"
  6266. >"404 Not Found"</VAR
  6267. >
  6268.      or similar. Add the following line to the object in <TT
  6269. CLASS="filename"
  6270. >obj.conf</TT
  6271. > for
  6272.      every error page you want to overwrite:
  6273.      <TABLE
  6274. BORDER="0"
  6275. BGCOLOR="#E0E0E0"
  6276. CELLPADDING="5"
  6277. ><TR
  6278. ><TD
  6279. ><PRE
  6280. CLASS="programlisting"
  6281. >Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...]</PRE
  6282. ></TD
  6283. ></TR
  6284. ></TABLE
  6285. >
  6286.      where <VAR
  6287. CLASS="literal"
  6288. >XXX</VAR
  6289. > is the HTTP error code. Please delete
  6290.      any other <VAR
  6291. CLASS="literal"
  6292. >Error</VAR
  6293. > directives which could interfere with yours.
  6294.      If you want to place a page for all errors that could exist, leave
  6295.      the <VAR
  6296. CLASS="literal"
  6297. >code</VAR
  6298. > parameter out. Your script can get the HTTP status code
  6299.      with <VAR
  6300. CLASS="literal"
  6301. >$_SERVER['ERROR_TYPE']</VAR
  6302. >.
  6303.     </P
  6304. ><P
  6305. >      Another possibility is to generate self-made directory listings.
  6306.      Just create a PHP script which displays a directory listing and
  6307.      replace the corresponding default Service line for
  6308.      <VAR
  6309. CLASS="literal"
  6310. >type="magnus-internal/directory"</VAR
  6311. >
  6312.      in <TT
  6313. CLASS="filename"
  6314. >obj.conf</TT
  6315. > with the following:
  6316.      <TABLE
  6317. BORDER="0"
  6318. BGCOLOR="#E0E0E0"
  6319. CELLPADDING="5"
  6320. ><TR
  6321. ><TD
  6322. ><PRE
  6323. CLASS="programlisting"
  6324. >Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...]</PRE
  6325. ></TD
  6326. ></TR
  6327. ></TABLE
  6328. >
  6329.      For both error and directory listing pages the original URI and
  6330.      translated URI are in the variables <VAR
  6331. CLASS="literal"
  6332. >$_SERVER['PATH_INFO']</VAR
  6333. > and
  6334.      <VAR
  6335. CLASS="literal"
  6336. >$_SERVER['PATH_TRANSLATED']</VAR
  6337. >.
  6338.     </P
  6339. ></DIV
  6340. ><DIV
  6341. CLASS="sect2"
  6342. ><HR><H3
  6343. CLASS="sect2"
  6344. ><A
  6345. NAME="install.unix.sun.notes"
  6346. >Note about <A
  6347. HREF="#function.nsapi-virtual"
  6348. ><B
  6349. CLASS="function"
  6350. >nsapi_virtual()</B
  6351. ></A
  6352. > and subrequests (PHP >= 4.3.3)</A
  6353. ></H3
  6354. ><P
  6355. >      The NSAPI module now supports the <A
  6356. HREF="#function.nsapi-virtual"
  6357. ><B
  6358. CLASS="function"
  6359. >nsapi_virtual()</B
  6360. ></A
  6361. > function
  6362.      (alias: <A
  6363. HREF="#function.virtual"
  6364. ><B
  6365. CLASS="function"
  6366. >virtual()</B
  6367. ></A
  6368. >)
  6369.      to make subrequests on the webserver and insert the result in the webpage.
  6370.      This function uses some undocumented features from the NSAPI library.
  6371.      On Unix the module automatically looks for the needed functions and uses
  6372.      them if available. If not, <A
  6373. HREF="#function.nsapi-virtual"
  6374. ><B
  6375. CLASS="function"
  6376. >nsapi_virtual()</B
  6377. ></A
  6378. > is disabled.
  6379.     </P
  6380. ><DIV
  6381. CLASS="note"
  6382. ><BLOCKQUOTE
  6383. CLASS="note"
  6384. ><P
  6385. ><B
  6386. >Anmerkung: </B
  6387. >
  6388.       But be warned: Support for <A
  6389. HREF="#function.nsapi-virtual"
  6390. ><B
  6391. CLASS="function"
  6392. >nsapi_virtual()</B
  6393. ></A
  6394. > is EXPERIMENTAL!!!
  6395.      </P
  6396. ></BLOCKQUOTE
  6397. ></DIV
  6398. ></DIV
  6399. ></DIV
  6400. ><DIV
  6401. CLASS="sect1"
  6402. ><HR><H2
  6403. CLASS="sect1"
  6404. ><A
  6405. NAME="install.unix.commandline"
  6406. >CGI and commandline setups</A
  6407. ></H2
  6408. ><P
  6409. >     The default is to build PHP as a CGI program.  This creates a
  6410.     commandline interpreter, which can be used for CGI processing, or
  6411.     for non-web-related PHP scripting.  If you are running a web
  6412.     server PHP has module support for, you should generally go for
  6413.     that solution for performance reasons.  However, the CGI version
  6414.     enables users to run different PHP-enabled pages under
  6415.     different user-ids.
  6416.    </P
  6417. ><DIV
  6418. CLASS="warning"
  6419. ><P
  6420. ></P
  6421. ><TABLE
  6422. CLASS="warning"
  6423. BORDER="1"
  6424. WIDTH="100%"
  6425. ><TR
  6426. ><TD
  6427. ALIGN="CENTER"
  6428. ><B
  6429. >Warnung</B
  6430. ></TD
  6431. ></TR
  6432. ><TR
  6433. ><TD
  6434. ALIGN="LEFT"
  6435. ><P
  6436. >By using the CGI setup, your server
  6437. is open to several possible attacks. Please read our
  6438. <A
  6439. HREF="#security.cgi-bin"
  6440. >CGI security section</A
  6441. > to learn how to
  6442. defend yourself from those attacks.</P
  6443. ></TD
  6444. ></TR
  6445. ></TABLE
  6446. ></DIV
  6447. ><P
  6448. >     As of PHP 4.3.0, some important additions have happened to PHP.  A new
  6449.     SAPI named CLI also exists and it has the same name as the CGI binary.
  6450.     What is installed at <VAR
  6451. CLASS="literal"
  6452. >{PREFIX}/bin/php</VAR
  6453. > depends on your
  6454.     configure line and this is described in detail in the manual section
  6455.     named <A
  6456. HREF="#features.commandline"
  6457. >Using PHP from the command
  6458.     line</A
  6459. >. For further details please read that section of the manual.
  6460.    </P
  6461. ><DIV
  6462. CLASS="sect2"
  6463. ><HR><H3
  6464. CLASS="sect2"
  6465. ><A
  6466. NAME="install.unix.commandline.testing"
  6467. >Testing</A
  6468. ></H3
  6469. ><P
  6470. >      If you have built PHP as a CGI program, you may test your build
  6471.      by typing <B
  6472. CLASS="command"
  6473. >make test</B
  6474. >.  It is always a good idea
  6475.      to test your build.  This way you may catch a problem with PHP on
  6476.      your platform early instead of having to struggle with it later.
  6477.     </P
  6478. ></DIV
  6479. ><DIV
  6480. CLASS="sect2"
  6481. ><HR><H3
  6482. CLASS="sect2"
  6483. ><A
  6484. NAME="install.unix.commandline.benchmarking"
  6485. >Benchmarking</A
  6486. ></H3
  6487. ><P
  6488. >      If you have built PHP 3 as a CGI program, you may benchmark your
  6489.      build by typing <B
  6490. CLASS="command"
  6491. >make bench</B
  6492. >. Note that if 
  6493.      <A
  6494. HREF="#ini.safe-mode"
  6495. >Safe Mode</A
  6496. > is on by default, the benchmark may not be able to finish if
  6497.      it takes longer then the 30 seconds allowed. This is because the
  6498.      <A
  6499. HREF="#function.set-time-limit"
  6500. ><B
  6501. CLASS="function"
  6502. >set_time_limit()</B
  6503. ></A
  6504. > can not be used in 
  6505.      <A
  6506. HREF="#ini.safe-mode"
  6507. >Safe Mode</A
  6508. >. Use the <A
  6509. HREF="#ini.max-execution-time"
  6510. >max_execution_time</A
  6511. >
  6512.      configuration setting to control this time for your own
  6513.      scripts. <B
  6514. CLASS="command"
  6515. >make bench</B
  6516. > ignores the <A
  6517. HREF="#configuration.file"
  6518. >configuration file</A
  6519. >.
  6520.     </P
  6521. ><DIV
  6522. CLASS="note"
  6523. ><BLOCKQUOTE
  6524. CLASS="note"
  6525. ><P
  6526. ><B
  6527. >Anmerkung: </B
  6528. >
  6529.         <B
  6530. CLASS="command"
  6531. >make bench</B
  6532. > is only available for PHP 3.
  6533.      </P
  6534. ></BLOCKQUOTE
  6535. ></DIV
  6536. ></DIV
  6537. ><DIV
  6538. CLASS="sect2"
  6539. ><HR><H3
  6540. CLASS="sect2"
  6541. ><A
  6542. NAME="install.unix.commandline.using-variables"
  6543. >Using Variables</A
  6544. ></H3
  6545. ><P
  6546. >       Some <A
  6547. HREF="#reserved.variables.server"
  6548. >server supplied
  6549.       environment variables</A
  6550. > are not defined in the 
  6551.       current <A
  6552. HREF="http://hoohoo.ncsa.uiuc.edu/cgi/env.html"
  6553. TARGET="_top"
  6554. >CGI/1.1 specification</A
  6555. >.
  6556.       Only the following variables are defined there: <VAR
  6557. CLASS="varname"
  6558. >AUTH_TYPE</VAR
  6559. >, 
  6560.       <VAR
  6561. CLASS="varname"
  6562. >CONTENT_LENGTH</VAR
  6563. >, <VAR
  6564. CLASS="varname"
  6565. >CONTENT_TYPE</VAR
  6566. >,
  6567.       <VAR
  6568. CLASS="varname"
  6569. >GATEWAY_INTERFACE</VAR
  6570. >, <VAR
  6571. CLASS="varname"
  6572. >PATH_INFO</VAR
  6573. >, 
  6574.       <VAR
  6575. CLASS="varname"
  6576. >PATH_TRANSLATED</VAR
  6577. >, <VAR
  6578. CLASS="varname"
  6579. >QUERY_STRING</VAR
  6580. >,
  6581.       <VAR
  6582. CLASS="varname"
  6583. >REMOTE_ADDR</VAR
  6584. >, <VAR
  6585. CLASS="varname"
  6586. >REMOTE_HOST</VAR
  6587. >, 
  6588.       <VAR
  6589. CLASS="varname"
  6590. >REMOTE_IDENT</VAR
  6591. >, <VAR
  6592. CLASS="varname"
  6593. >REMOTE_USER</VAR
  6594. >,
  6595.       <VAR
  6596. CLASS="varname"
  6597. >REQUEST_METHOD</VAR
  6598. >, <VAR
  6599. CLASS="varname"
  6600. >SCRIPT_NAME</VAR
  6601. >, 
  6602.       <VAR
  6603. CLASS="varname"
  6604. >SERVER_NAME</VAR
  6605. >, <VAR
  6606. CLASS="varname"
  6607. >SERVER_PORT</VAR
  6608. >,
  6609.       <VAR
  6610. CLASS="varname"
  6611. >SERVER_PROTOCOL</VAR
  6612. >, and <VAR
  6613. CLASS="varname"
  6614. >SERVER_SOFTWARE</VAR
  6615. >.
  6616.       Everything else should be treated as 'vendor extensions'.
  6617.     </P
  6618. ></DIV
  6619. ></DIV
  6620. ></DIV
  6621. ><DIV
  6622. CLASS="chapter"
  6623. ><HR><H1
  6624. ><A
  6625. NAME="install.windows"
  6626. >Kapitel 6. Installation on Windows systems</A
  6627. ></H1
  6628. ><P
  6629. >     This section applies to Windows 98/Me and Windows NT/2000/XP/2003. PHP 
  6630.     will not work on 16 bit platforms such as Windows 3.1 and sometimes 
  6631.     we refer to the supported Windows platforms as Win32. Windows 95
  6632.     is no longer supported as of PHP 4.3.0.
  6633.    </P
  6634. ><P
  6635. >     There are two main ways to install PHP for Windows: either
  6636.     <A
  6637. HREF="#install.windows.manual"
  6638. >manually</A
  6639. >
  6640.     or by using the <A
  6641. HREF="#install.windows.installer"
  6642. >installer</A
  6643. >.
  6644.    </P
  6645. ><P
  6646. >     If you have Microsoft Visual Studio, you can also 
  6647.     <A
  6648. HREF="#install.windows.build"
  6649. >build</A
  6650. >
  6651.     PHP from the original source code.
  6652.    </P
  6653. ><P
  6654. >     Once you have PHP installed on your Windows system, you may also
  6655.     want to <A
  6656. HREF="#install.windows.extensions"
  6657. >load various extensions</A
  6658. >
  6659.     for added functionality.
  6660.    </P
  6661. ><DIV
  6662. CLASS="warning"
  6663. ><P
  6664. ></P
  6665. ><TABLE
  6666. CLASS="warning"
  6667. BORDER="1"
  6668. WIDTH="100%"
  6669. ><TR
  6670. ><TD
  6671. ALIGN="CENTER"
  6672. ><B
  6673. >Warnung</B
  6674. ></TD
  6675. ></TR
  6676. ><TR
  6677. ><TD
  6678. ALIGN="LEFT"
  6679. ><P
  6680. >      There are several all-in-one installers over the Internet, but none of
  6681.      those are endorsed by PHP.net, as we believe that the manual installation
  6682.      is the best choice to have your system secure and optimised.
  6683.     </P
  6684. ></TD
  6685. ></TR
  6686. ></TABLE
  6687. ></DIV
  6688. ><DIV
  6689. CLASS="sect1"
  6690. ><HR><H2
  6691. CLASS="sect1"
  6692. ><A
  6693. NAME="install.windows.installer"
  6694. >Windows Installer</A
  6695. ></H2
  6696. ><P
  6697. >      The Windows PHP installer is available from the downloads page at
  6698.      <A
  6699. HREF="http://www.php.net/downloads.php"
  6700. TARGET="_top"
  6701. >http://www.php.net/downloads.php</A
  6702. >. This
  6703.      installs the <SPAN
  6704. CLASS="emphasis"
  6705. ><I
  6706. CLASS="emphasis"
  6707. >CGI version</I
  6708. ></SPAN
  6709. > of PHP and for IIS, PWS,
  6710.      and Xitami, it configures the web server as well.  The installer does not 
  6711.      include any extra external PHP extensions (php_*.dll) as you'll only find 
  6712.      those in the Windows Zip Package and <ACRONYM
  6713. CLASS="acronym"
  6714. >PECL</ACRONYM
  6715. > downloads.
  6716.     </P
  6717. ><DIV
  6718. CLASS="note"
  6719. ><BLOCKQUOTE
  6720. CLASS="note"
  6721. ><P
  6722. ><B
  6723. >Anmerkung: </B
  6724. >
  6725.       While the Windows installer is an easy way to make PHP work, it is 
  6726.       restricted in many aspects as, for example, the automatic setup of 
  6727.       extensions is not supported.  Use of the installer isn't the preferred 
  6728.       method for installing PHP.
  6729.      </P
  6730. ></BLOCKQUOTE
  6731. ></DIV
  6732. ><P
  6733. >      First, install your selected <ACRONYM
  6734. CLASS="acronym"
  6735. >HTTP</ACRONYM
  6736. > (web) server on your 
  6737.      system, and make sure that it works.
  6738.     </P
  6739. ><P
  6740. >      Run the executable installer and follow the instructions provided by the
  6741.      installation wizard. Two types of installation are supported - standard,
  6742.      which provides sensible defaults for all the settings it can, and advanced,
  6743.      which asks questions as it goes along.
  6744.     </P
  6745. ><P
  6746. >      The installation wizard gathers enough information to set up the <TT
  6747. CLASS="filename"
  6748. >php.ini</TT
  6749. >
  6750.      file, and configure certain web servers to use PHP.  With IIS or PWS on 
  6751.      a NT Workstation, a list of all the nodes on the server with script map 
  6752.      settings is displayed, and you can choose those nodes to which you wish 
  6753.      to add the PHP script mappings.  One of the web servers the PHP installer 
  6754.      does not configure for is Apache, so you'll need to configure it
  6755.      manually.
  6756.     </P
  6757. ><P
  6758. >      Once the installation has completed, the installer will inform you if you
  6759.      need to restart your system, restart the server, or just start using PHP.
  6760.     </P
  6761. ><DIV
  6762. CLASS="warning"
  6763. ><P
  6764. ></P
  6765. ><TABLE
  6766. CLASS="warning"
  6767. BORDER="1"
  6768. WIDTH="100%"
  6769. ><TR
  6770. ><TD
  6771. ALIGN="CENTER"
  6772. ><B
  6773. >Warnung</B
  6774. ></TD
  6775. ></TR
  6776. ><TR
  6777. ><TD
  6778. ALIGN="LEFT"
  6779. ><P
  6780. >       Be aware, that this setup of PHP is not secure. If you would like to have
  6781.       a secure PHP setup, you'd better go on the manual way, and set every
  6782.       option carefully. This automatically working setup gives you an instantly
  6783.       working PHP installation, but it is not meant to be used on online servers.
  6784.      </P
  6785. ></TD
  6786. ></TR
  6787. ></TABLE
  6788. ></DIV
  6789. ></DIV
  6790. ><DIV
  6791. CLASS="sect1"
  6792. ><HR><H2
  6793. CLASS="sect1"
  6794. ><A
  6795. NAME="install.windows.manual"
  6796. >Manual Installation Steps</A
  6797. ></H2
  6798. ><P
  6799. >      This install guide will help you manually install and configure PHP with
  6800.      a web server on Microsoft Windows.  To get started you'll need to download 
  6801.      the zip binary distribution from the downloads page at
  6802.      <A
  6803. HREF="http://www.php.net/downloads.php"
  6804. TARGET="_top"
  6805. >http://www.php.net/downloads.php</A
  6806. >.
  6807.     </P
  6808. ><P
  6809. >      Although there are many all-in-one installation kits, and we also 
  6810.      distribute a PHP installer for Microsoft Windows, we recommend you take 
  6811.      the time to setup PHP yourself as this will provide you with a better 
  6812.      understanding of the system, and enables you to install PHP extensions 
  6813.      easily when needed.
  6814.     </P
  6815. ><DIV
  6816. CLASS="note"
  6817. ><BLOCKQUOTE
  6818. CLASS="note"
  6819. ><A
  6820. NAME="install.windows.manual.upgrade"
  6821. ></A
  6822. ><P
  6823. ><B
  6824. >Upgrading from a previous PHP version: </B
  6825. >
  6826.       Previous editions of the manual suggest moving various ini and 
  6827.       <ACRONYM
  6828. CLASS="acronym"
  6829. >DLL</ACRONYM
  6830. > files into your SYSTEM (i.e. 
  6831.       <TT
  6832. CLASS="filename"
  6833. >C:\WINDOWS</TT
  6834. >) folder and while this 
  6835.       simplifies the installation procedure it makes upgrading difficult.  We 
  6836.       advise you remove all of these files (like <TT
  6837. CLASS="filename"
  6838. >php.ini</TT
  6839. > and PHP related
  6840.       DLLs from the Windows SYSTEM folder) before moving on with a new 
  6841.       PHP installation.  Be sure to backup these files as you might break the
  6842.       entire system.  The old <TT
  6843. CLASS="filename"
  6844. >php.ini</TT
  6845. > might be useful in setting up the new
  6846.       PHP as well.  And as you'll soon learn, the preferred method for 
  6847.       installing PHP is to keep all PHP related files in one directory and
  6848.       have this directory available to your systems PATH.
  6849.      </P
  6850. ></BLOCKQUOTE
  6851. ></DIV
  6852. ><DIV
  6853. CLASS="note"
  6854. ><BLOCKQUOTE
  6855. CLASS="note"
  6856. ><P
  6857. ><B
  6858. >MDAC requirements: </B
  6859. >
  6860.       If you use Microsoft <SPAN
  6861. CLASS="emphasis"
  6862. ><I
  6863. CLASS="emphasis"
  6864. >Windows 98/NT4</I
  6865. ></SPAN
  6866. > download the
  6867.       latest version of the Microsoft Data Access Components (MDAC) for your
  6868.       platform. MDAC is available at <A
  6869. HREF="http://msdn.microsoft.com/data/"
  6870. TARGET="_top"
  6871. >http://msdn.microsoft.com/data/</A
  6872. >.
  6873.       This requirement exists because <A
  6874. HREF="#ref.uodbc"
  6875. >ODBC</A
  6876. > is
  6877.       built into the distributed Windows binaries.
  6878.      </P
  6879. ></BLOCKQUOTE
  6880. ></DIV
  6881. ><P
  6882. >      The following steps should be completed on all installations before any
  6883.      server specific instructions are performed:
  6884.     </P
  6885. ><P
  6886. >      Extract the distribution file into a directory of your choice. If you
  6887.      are installing PHP 4, extract to <TT
  6888. CLASS="filename"
  6889. >C:\</TT
  6890. >, as the zip file expands to a
  6891.      foldername like <TT
  6892. CLASS="filename"
  6893. >php-4.3.7-Win32</TT
  6894. >. If you are
  6895.      installing PHP 5, extract to <TT
  6896. CLASS="filename"
  6897. >C:\php</TT
  6898. > as the zip file doesn't expand as in
  6899.      PHP 4. You may choose a different location but do not have spaces in the
  6900.      path (like <TT
  6901. CLASS="filename"
  6902. >C:\Program Files\PHP</TT
  6903. >)
  6904.      as some web servers will crash if you do.
  6905.     </P
  6906. ><P
  6907. >      The directory structure extracted from the zip is different for PHP 
  6908.      versions 4 and 5 and look like as follows:
  6909.     </P
  6910. ><TABLE
  6911. WIDTH="100%"
  6912. BORDER="0"
  6913. CELLPADDING="0"
  6914. CELLSPACING="0"
  6915. CLASS="EXAMPLE"
  6916. ><TR
  6917. ><TD
  6918. ><DIV
  6919. CLASS="example"
  6920. ><A
  6921. NAME="AEN1095"
  6922. ></A
  6923. ><P
  6924. ><B
  6925. >Beispiel 6-1. PHP 4 package structure</B
  6926. ></P
  6927. ><TABLE
  6928. BORDER="0"
  6929. BGCOLOR="#E0E0E0"
  6930. CELLPADDING="5"
  6931. ><TR
  6932. ><TD
  6933. ><PRE
  6934. CLASS="programlisting"
  6935. >c:\php
  6936.    |
  6937.    +--cli
  6938.    |  |
  6939.    |  |-php.exe           -- CLI executable - ONLY for commandline scripting
  6940.    |
  6941.    +--dlls                -- support DLLs required by some extensions
  6942.    |  |
  6943.    |  |-expat.dll
  6944.    |  |
  6945.    |  |-fdftk.dll
  6946.    |  |
  6947.    |  |-...
  6948.    |
  6949.    +--extensions          -- extension DLLs for PHP
  6950.    |  |
  6951.    |  |-php_bz2.dll
  6952.    |  |
  6953.    |  |-php_cpdf.dll
  6954.    |  |
  6955.    |  |-..
  6956.    |
  6957.    +--mibs                -- support files for SNMP
  6958.    |
  6959.    +--openssl             -- support files for Openssl
  6960.    |
  6961.    +--pdf-related         -- support files for PDF
  6962.    |
  6963.    +--sapi                -- SAPI (server module support) DLLs
  6964.    |  |
  6965.    |  |-php4activescript.dll
  6966.    |  |
  6967.    |  |-php4apache.dll
  6968.    |  |
  6969.    |  |-php4apache2.dll
  6970.    |  |
  6971.    |  |-..
  6972.    |
  6973.    +--PEAR                -- initial copy of PEAR
  6974.    |
  6975.    |
  6976.    |-go-pear.bat          -- PEAR setup script
  6977.    |
  6978.    |-..
  6979.    |
  6980.    |-php.exe              -- CGI executable
  6981.    |
  6982.    |-..
  6983.    |
  6984.    |-php.ini-dist         -- default php.ini settings
  6985.    |
  6986.    |-php.ini-recommended  -- recommended php.ini settings
  6987.    | 
  6988.    |-php4ts.dll           -- core PHP DLL
  6989.    | 
  6990.    |-...</PRE
  6991. ></TD
  6992. ></TR
  6993. ></TABLE
  6994. ></DIV
  6995. ></TD
  6996. ></TR
  6997. ></TABLE
  6998. ><P
  6999. >     Or:
  7000.     </P
  7001. ><TABLE
  7002. WIDTH="100%"
  7003. BORDER="0"
  7004. CELLPADDING="0"
  7005. CELLSPACING="0"
  7006. CLASS="EXAMPLE"
  7007. ><TR
  7008. ><TD
  7009. ><DIV
  7010. CLASS="example"
  7011. ><A
  7012. NAME="AEN1099"
  7013. ></A
  7014. ><P
  7015. ><B
  7016. >Beispiel 6-2. PHP 5 package structure</B
  7017. ></P
  7018. ><TABLE
  7019. BORDER="0"
  7020. BGCOLOR="#E0E0E0"
  7021. CELLPADDING="5"
  7022. ><TR
  7023. ><TD
  7024. ><PRE
  7025. CLASS="programlisting"
  7026. >c:\php
  7027.    |
  7028.    +--dev
  7029.    |  |
  7030.    |  |-php5ts.lib
  7031.    |
  7032.    +--ext                 -- extension DLLs for PHP
  7033.    |  |
  7034.    |  |-php_bz2.dll
  7035.    |  |
  7036.    |  |-php_cpdf.dll
  7037.    |  |
  7038.    |  |-..
  7039.    |
  7040.    +--extras
  7041.    |  |
  7042.    |  +--mibs             -- support files for SNMP
  7043.    |  |
  7044.    |  +--openssl          -- support files for Openssl
  7045.    |  |
  7046.    |  +--pdf-related      -- support files for PDF
  7047.    |  |
  7048.    |  |-mime.magic
  7049.    |
  7050.    +--pear                -- initial copy of PEAR
  7051.    |
  7052.    |
  7053.    |-go-pear.bat          -- PEAR setup script
  7054.    |
  7055.    |-fdftk.dll
  7056.    |
  7057.    |-..
  7058.    |
  7059.    |-php-cgi.exe          -- CGI executable
  7060.    |
  7061.    |-php-win.exe          -- executes scripts without an opened command prompt
  7062.    |
  7063.    |-php.exe              -- CLI executable - ONLY for command line scripting
  7064.    |
  7065.    |-..
  7066.    |
  7067.    |-php.ini-dist         -- default php.ini settings
  7068.    |
  7069.    |-php.ini-recommended  -- recommended php.ini settings
  7070.    | 
  7071.    |-php5activescript.dll
  7072.    |
  7073.    |-php5apache.dll
  7074.    |
  7075.    |-php5apache2.dll
  7076.    |
  7077.    |-..
  7078.    |
  7079.    |-php5ts.dll           -- core PHP DLL
  7080.    | 
  7081.    |-...</PRE
  7082. ></TD
  7083. ></TR
  7084. ></TABLE
  7085. ></DIV
  7086. ></TD
  7087. ></TR
  7088. ></TABLE
  7089. ><P
  7090. >      Notice the differences and similarities.  Both PHP 4 and PHP 5 have a 
  7091.      <ACRONYM
  7092. CLASS="acronym"
  7093. >CGI</ACRONYM
  7094. > executable, a <ACRONYM
  7095. CLASS="acronym"
  7096. >CLI</ACRONYM
  7097. > executable,
  7098.      and server modules, but they are located in different folders and/or have
  7099.      different names.  While PHP 4 packages have the server modules in the 
  7100.      <TT
  7101. CLASS="filename"
  7102. >sapi</TT
  7103. > folder, PHP 5 
  7104.      distributions have no such directory and instead they're in the PHP
  7105.      folder root. The supporting DLLs for the PHP 5 extensions are also not
  7106.      in a seperate directory.
  7107.     </P
  7108. ><DIV
  7109. CLASS="note"
  7110. ><BLOCKQUOTE
  7111. CLASS="note"
  7112. ><P
  7113. ><B
  7114. >Anmerkung: </B
  7115. >
  7116.       In PHP 4, you should move all files located in the <TT
  7117. CLASS="filename"
  7118. >dll</TT
  7119. > and <TT
  7120. CLASS="filename"
  7121. >sapi</TT
  7122. > folders to the main folder (e.g.
  7123.       <TT
  7124. CLASS="filename"
  7125. >C:\php</TT
  7126. >).
  7127.      </P
  7128. ></BLOCKQUOTE
  7129. ></DIV
  7130. ><P
  7131. >      Here is a list of server modules shipped with PHP 4 and PHP 5:
  7132.      <P
  7133. ></P
  7134. ><UL
  7135. ><LI
  7136. ><P
  7137. >        <TT
  7138. CLASS="filename"
  7139. >sapi/php4activescript.dll (php5activescript.dll)</TT
  7140. >
  7141.        - <A
  7142. HREF="#install.windows.activescript"
  7143. >ActiveScript
  7144.         engine</A
  7145. >, allowing you to embed PHP in your Windows
  7146.        applications.
  7147.       </P
  7148. ></LI
  7149. ><LI
  7150. ><P
  7151. >        <TT
  7152. CLASS="filename"
  7153. >sapi/php4apache.dll (php5apache.dll)</TT
  7154. > - Apache 1.3.x module.
  7155.       </P
  7156. ></LI
  7157. ><LI
  7158. ><P
  7159. >        <TT
  7160. CLASS="filename"
  7161. >sapi/php4apache2.dll (php5apache2.dll)</TT
  7162. > - Apache 2.0.x module.
  7163.       </P
  7164. ></LI
  7165. ><LI
  7166. ><P
  7167. >        <TT
  7168. CLASS="filename"
  7169. >sapi/php4isapi.dll (php5isapi.dll)</TT
  7170. > - ISAPI Module
  7171.        for ISAPI compliant web servers like IIS 4.0/PWS 4.0 or newer.
  7172.       </P
  7173. ></LI
  7174. ><LI
  7175. ><P
  7176. >        <TT
  7177. CLASS="filename"
  7178. >sapi/php4nsapi.dll (php5nsapi.dll)</TT
  7179. > - Sun/iPlanet/Netscape
  7180.        server module.
  7181.       </P
  7182. ></LI
  7183. ><LI
  7184. ><P
  7185. >        <TT
  7186. CLASS="filename"
  7187. >sapi/php4pi3web.dll (no equivalent in PHP 5)</TT
  7188. > - Pi3Web server module.
  7189.       </P
  7190. ></LI
  7191. ></UL
  7192. >
  7193.     </P
  7194. ><P
  7195. >      Server modules provide significantly better performance and additional 
  7196.      functionality compared to the CGI binary. The CLI version is designed to
  7197.      let you use PHP for command line scripting. More information about CLI is
  7198.      available in the chapter about <A
  7199. HREF="#features.commandline"
  7200. >using
  7201.      PHP from the command line</A
  7202. >.
  7203.     </P
  7204. ><DIV
  7205. CLASS="warning"
  7206. ><P
  7207. ></P
  7208. ><TABLE
  7209. CLASS="warning"
  7210. BORDER="1"
  7211. WIDTH="100%"
  7212. ><TR
  7213. ><TD
  7214. ALIGN="CENTER"
  7215. ><B
  7216. >Warnung</B
  7217. ></TD
  7218. ></TR
  7219. ><TR
  7220. ><TD
  7221. ALIGN="LEFT"
  7222. ><P
  7223. >       The SAPI modules have been significantly improved as of the 4.1 release,
  7224.       however, in older systems you may encounter server errors or other
  7225.       server modules failing, such as ASP.
  7226.      </P
  7227. ></TD
  7228. ></TR
  7229. ></TABLE
  7230. ></DIV
  7231. ><P
  7232. >      The CGI and CLI binaries, and the web server modules all require the
  7233.      <TT
  7234. CLASS="filename"
  7235. >php4ts.dll</TT
  7236. > (<TT
  7237. CLASS="filename"
  7238. >php5ts.dll</TT
  7239. >) file to
  7240.      be available to them. You have to make sure that this file can be found
  7241.      by your PHP installation. The search order for this DLL is as follows:
  7242.      <P
  7243. ></P
  7244. ><UL
  7245. ><LI
  7246. ><P
  7247. >         The same directory from where <TT
  7248. CLASS="filename"
  7249. >php.exe</TT
  7250. > is called,
  7251.         or in case you use a SAPI module, the web server's directory (e.g.
  7252.         <TT
  7253. CLASS="filename"
  7254. >C:\Program Files\Apache Group\Apache2\bin</TT
  7255. >).
  7256.        </P
  7257. ></LI
  7258. ><LI
  7259. ><P
  7260. >         Any directory in your Windows <VAR
  7261. CLASS="varname"
  7262. >PATH</VAR
  7263. > environment
  7264.         variable.
  7265.        </P
  7266. ></LI
  7267. ></UL
  7268. >
  7269.     </P
  7270. ><P
  7271. >      To make <TT
  7272. CLASS="filename"
  7273. >php4ts.dll</TT
  7274. > / <TT
  7275. CLASS="filename"
  7276. >php5ts.dll</TT
  7277. >
  7278.      available you have three options: copy the file to the Windows system
  7279.      directory, copy the file to the web server's directory, or add your PHP
  7280.      directory, <TT
  7281. CLASS="filename"
  7282. >C:\php</TT
  7283. > to the
  7284.      <VAR
  7285. CLASS="varname"
  7286. >PATH</VAR
  7287. >. For better maintenance, we advise you to follow
  7288.      the last option, add <TT
  7289. CLASS="filename"
  7290. >C:\php</TT
  7291. > to the
  7292.      <VAR
  7293. CLASS="varname"
  7294. >PATH</VAR
  7295. >, because it will be simpler to upgrade PHP in the
  7296.      future. Read more about how to add your PHP directory to
  7297.      <VAR
  7298. CLASS="varname"
  7299. >PATH</VAR
  7300. > in the <A
  7301. HREF="#faq.installation.addtopath"
  7302. >corresponding FAQ entry</A
  7303. >.
  7304.     </P
  7305. ><P
  7306. >      The next step is to set up a valid configuration file for PHP, <TT
  7307. CLASS="filename"
  7308. >php.ini</TT
  7309. >.
  7310.      There are two ini files distributed in the zip file,
  7311.      <TT
  7312. CLASS="filename"
  7313. >php.ini-dist</TT
  7314. > and
  7315.      <TT
  7316. CLASS="filename"
  7317. >php.ini-recommended</TT
  7318. >. We advise you to use
  7319.      <TT
  7320. CLASS="filename"
  7321. >php.ini-recommended</TT
  7322. >, because we optimized the
  7323.      default settings in this file for performance, and security. Read this
  7324.      well documented file carefully because it has changes from
  7325.      <TT
  7326. CLASS="filename"
  7327. >php.ini-dist</TT
  7328. > that will drastically affect your 
  7329.      setup.  Some examples are <A
  7330. HREF="#ini.display-errors"
  7331. >      display_errors</A
  7332. > being <VAR
  7333. CLASS="literal"
  7334. >off</VAR
  7335. > and 
  7336.      <A
  7337. HREF="#ini.magic-quotes-gpc"
  7338. >magic_quotes_gpc</A
  7339. > being
  7340.      <VAR
  7341. CLASS="literal"
  7342. >off</VAR
  7343. >.  In addition to reading these, study the <A
  7344. HREF="#configuration.file"
  7345. >ini settings</A
  7346. > and set every element
  7347.      manually yourself. If you would like to achieve the best security, then
  7348.      this is the way for you, although PHP works fine with these default ini
  7349.      files. Copy your chosen ini-file to a directory that PHP is able to find
  7350.      and rename it to <TT
  7351. CLASS="filename"
  7352. >php.ini</TT
  7353. >. PHP searches for <TT
  7354. CLASS="filename"
  7355. >php.ini</TT
  7356. > in the following
  7357.      locations (in order):
  7358.      <P
  7359. ></P
  7360. ><UL
  7361. ><LI
  7362. ><P
  7363. >         PHPIniDir directive (Apache 2 module only)
  7364.        </P
  7365. ></LI
  7366. ><LI
  7367. ><P
  7368. >         <VAR
  7369. CLASS="literal"
  7370. >HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath</VAR
  7371. >
  7372.        </P
  7373. ></LI
  7374. ><LI
  7375. ><P
  7376. >         The <VAR
  7377. CLASS="varname"
  7378. >PHPRC</VAR
  7379. > environment variable
  7380.        </P
  7381. ></LI
  7382. ><LI
  7383. ><P
  7384. >         Directory of PHP (for CLI), or the web server's directory (for 
  7385.         SAPI modules)
  7386.        </P
  7387. ></LI
  7388. ><LI
  7389. ><P
  7390. >         Windows directory (<TT
  7391. CLASS="filename"
  7392. >C:\windows</TT
  7393. >
  7394.         or <TT
  7395. CLASS="filename"
  7396. >C:\winnt</TT
  7397. >)
  7398.        </P
  7399. ></LI
  7400. ></UL
  7401.     </P
  7402. ><P
  7403. >      If you are running Apache 2, the simpler option is to use the PHPIniDir
  7404.      directive (read the <A
  7405. HREF="#install.windows.apache2"
  7406. >installation
  7407.      on Apache 2</A
  7408. > page), otherwise your best option is to set the
  7409.      <VAR
  7410. CLASS="varname"
  7411. >PHPRC</VAR
  7412. > environment variable. This process is explained
  7413.      in the following <A
  7414. HREF="#faq.installation.phprc"
  7415. >FAQ entry</A
  7416. >.
  7417.     </P
  7418. ><DIV
  7419. CLASS="note"
  7420. ><BLOCKQUOTE
  7421. CLASS="note"
  7422. ><P
  7423. ><B
  7424. >Anmerkung: </B
  7425. >
  7426.       If you're using NTFS on Windows NT, 2000, XP or 2003, make sure that the
  7427.       user running the web server has read permissions to your <TT
  7428. CLASS="filename"
  7429. >php.ini</TT
  7430. > (e.g.
  7431.       make it readable by Everyone).
  7432.      </P
  7433. ></BLOCKQUOTE
  7434. ></DIV
  7435. ><P
  7436. >      The following steps are optional:
  7437.      <P
  7438. ></P
  7439. ><UL
  7440. ><LI
  7441. ><P
  7442. >         Edit your new <TT
  7443. CLASS="filename"
  7444. >php.ini</TT
  7445. > file.       
  7446.         If you plan to use <A
  7447. HREF="#install.windows.omnihttpd"
  7448. >OmniHTTPd</A
  7449. >,
  7450.         do not follow the next step. Set the
  7451.         <A
  7452. HREF="#ini.doc-root"
  7453. >doc_root</A
  7454. > to point to your 
  7455.         web servers document_root. For example:
  7456.         <DIV
  7457. CLASS="informalexample"
  7458. ><P
  7459. ></P
  7460. ><A
  7461. NAME="AEN1198"
  7462. ></A
  7463. ><TABLE
  7464. BORDER="0"
  7465. BGCOLOR="#E0E0E0"
  7466. CELLPADDING="5"
  7467. ><TR
  7468. ><TD
  7469. ><PRE
  7470. CLASS="ini"
  7471. >doc_root = c:\inetpub       // for IIS/PWS
  7472.  
  7473. doc_root = c:\apache\htdocs // for Apache</PRE
  7474. ></TD
  7475. ></TR
  7476. ></TABLE
  7477. ><P
  7478. ></P
  7479. ></DIV
  7480. >
  7481.        </P
  7482. ></LI
  7483. ><LI
  7484. ><P
  7485. >         Choose the extensions you would like to load when PHP starts. See
  7486.         the section about
  7487.         <A
  7488. HREF="#install.windows.extensions"
  7489. >Windows extensions</A
  7490. >,
  7491.         about how to set up one, and what is already built in. Note that on
  7492.         a new installation it is advisable to first get PHP working and tested
  7493.         without any extensions before enabling them in <TT
  7494. CLASS="filename"
  7495. >php.ini</TT
  7496. >.
  7497.        </P
  7498. ></LI
  7499. ><LI
  7500. ><P
  7501. >         On PWS and IIS, you can set the
  7502.         <A
  7503. HREF="#ini.browscap"
  7504. >browscap</A
  7505. > configuration setting
  7506.         to point to:
  7507.         <TT
  7508. CLASS="filename"
  7509. >c:\windows\system\inetsrv\browscap.ini</TT
  7510. > on
  7511.         Windows 9x/Me,
  7512.         <TT
  7513. CLASS="filename"
  7514. >c:\winnt\system32\inetsrv\browscap.ini</TT
  7515. > on
  7516.         NT/2000, and
  7517.         <TT
  7518. CLASS="filename"
  7519. >c:\windows\system32\inetsrv\browscap.ini</TT
  7520. >
  7521.         on XP.  For an up-to-date <TT
  7522. CLASS="filename"
  7523. >browscap.ini</TT
  7524. >, read the
  7525.         following <A
  7526. HREF="#faq.obtaining.browscap"
  7527. >FAQ</A
  7528. >.
  7529.        </P
  7530. ></LI
  7531. ></UL
  7532. >
  7533.     </P
  7534. ><P
  7535. >      PHP is now setup on your system.  The next step is to choose a web
  7536.      server, and enable it to run PHP.  Choose a webserver from the table of 
  7537.      contents.
  7538.     </P
  7539. ></DIV
  7540. ><DIV
  7541. CLASS="sect1"
  7542. ><HR><H2
  7543. CLASS="sect1"
  7544. ><A
  7545. NAME="install.windows.activescript"
  7546. >ActiveScript</A
  7547. ></H2
  7548. ><P
  7549. >      This section contains notes specific to the ActiveScript installation.
  7550.     </P
  7551. ><P
  7552. >      ActiveScript is a windows only SAPI that enables you to use PHP script in
  7553.      any ActiveScript compliant host, like Windows Script Host, ASP/ASP.NET,
  7554.      Windows Script Components or Microsoft Scriptlet control.
  7555.     </P
  7556. ><P
  7557. >      As of PHP 5.0.1, ActiveScript has been moved to the <A
  7558. HREF="http://pecl.php.net"
  7559. TARGET="_top"
  7560. >PECL</A
  7561. > repository. You may download this <ACRONYM
  7562. CLASS="acronym"
  7563. >PECL</ACRONYM
  7564. >
  7565. extensions <ACRONYM
  7566. CLASS="acronym"
  7567. >DLL</ACRONYM
  7568. > from the <A
  7569. HREF="http://www.php.net/downloads.php"
  7570. TARGET="_top"
  7571. > PHP Downloads</A
  7572. > page or at <A
  7573. HREF="http://snaps.php.net/"
  7574. TARGET="_top"
  7575. > http://snaps.php.net/</A
  7576. >.
  7577.     </P
  7578. ><DIV
  7579. CLASS="note"
  7580. ><BLOCKQUOTE
  7581. CLASS="note"
  7582. ><P
  7583. ><B
  7584. >Anmerkung: </B
  7585. >
  7586.       You should read the <A
  7587. HREF="#install.windows.manual"
  7588. >manual
  7589.        installation steps</A
  7590. > first!
  7591.      </P
  7592. ></BLOCKQUOTE
  7593. ></DIV
  7594. ><P
  7595. >      After installing PHP, you should download the ActiveScript DLL
  7596.      (<TT
  7597. CLASS="filename"
  7598. >php5activescript.dll</TT
  7599. >) and place it in the main PHP
  7600.      folder (e.g. <TT
  7601. CLASS="filename"
  7602. >C:\php</TT
  7603. >).
  7604.     </P
  7605. ><P
  7606. >      After having all the files needed, you must register the DLL on your
  7607.      system. To achieve this, open a Command Prompt window (located in the
  7608.      Start Menu). Then go to your PHP directory by typing something like
  7609.      <VAR
  7610. CLASS="literal"
  7611. >cd C:\php</VAR
  7612. >. To register the DLL just type
  7613.      <VAR
  7614. CLASS="literal"
  7615. >regsvr32 php5activescript.dll</VAR
  7616. >.
  7617.     </P
  7618. ><P
  7619. >      To test if ActiveScript is working, create a new file, named
  7620.      <VAR
  7621. CLASS="literal"
  7622. >test.wsf</VAR
  7623. > (the extension is very important) and type:
  7624.      <TABLE
  7625. BORDER="0"
  7626. BGCOLOR="#E0E0E0"
  7627. CELLPADDING="5"
  7628. ><TR
  7629. ><TD
  7630. ><PRE
  7631. CLASS="programlisting"
  7632. ><job id="test">
  7633.  
  7634.  <script language="PHPScript">
  7635.   $WScript->Echo("Hello World!");
  7636.  </script>
  7637.  
  7638. </job></PRE
  7639. ></TD
  7640. ></TR
  7641. ></TABLE
  7642. >
  7643.      Save and double-click on the file. If you receive a little window saying
  7644.      "Hello World!" you're done.
  7645.     </P
  7646. ><DIV
  7647. CLASS="note"
  7648. ><BLOCKQUOTE
  7649. CLASS="note"
  7650. ><P
  7651. ><B
  7652. >Anmerkung: </B
  7653. >
  7654.       ActiveScript doesn't use the default <TT
  7655. CLASS="filename"
  7656. >php.ini</TT
  7657. > file. Instead, it will
  7658.       look only in the same directory as the .exe that caused it to load. You
  7659.       should create <TT
  7660. CLASS="filename"
  7661. >php-activescript.ini</TT
  7662. > and place it in
  7663.       that folder, if you wish to load extensions, etc.
  7664.      </P
  7665. ></BLOCKQUOTE
  7666. ></DIV
  7667. ></DIV
  7668. ><DIV
  7669. CLASS="sect1"
  7670. ><HR><H2
  7671. CLASS="sect1"
  7672. ><A
  7673. NAME="install.windows.iis"
  7674. >Microsoft IIS / PWS</A
  7675. ></H2
  7676. ><P
  7677. >     This section contains notes and hints specific to IIS (Microsoft
  7678.     Internet Information Server). We have included installation
  7679.     instructions for <A
  7680. HREF="#install.windows.iis.iis3"
  7681. >PWS/IIS 3</A
  7682. >,
  7683.     <A
  7684. HREF="#install.windows.iis.pws4"
  7685. >PWS 4 or newer</A
  7686. > and
  7687.     <A
  7688. HREF="#install.windows.iis.iis4"
  7689. >IIS 4 or newer</A
  7690. > versions.
  7691.    </P
  7692. ><DIV
  7693. CLASS="note"
  7694. ><BLOCKQUOTE
  7695. CLASS="note"
  7696. ><P
  7697. ><B
  7698. >Important for CGI users: </B
  7699. >
  7700.      Read the <A
  7701. HREF="#faq.installation.forceredirect"
  7702. >faq
  7703.      on cgi.force_redirect</A
  7704. > for important details.  This
  7705.      directive needs to be set to <VAR
  7706. CLASS="literal"
  7707. >0</VAR
  7708. >.
  7709.     </P
  7710. ></BLOCKQUOTE
  7711. ></DIV
  7712. ><DIV
  7713. CLASS="warning"
  7714. ><P
  7715. ></P
  7716. ><TABLE
  7717. CLASS="warning"
  7718. BORDER="1"
  7719. WIDTH="100%"
  7720. ><TR
  7721. ><TD
  7722. ALIGN="CENTER"
  7723. ><B
  7724. >Warnung</B
  7725. ></TD
  7726. ></TR
  7727. ><TR
  7728. ><TD
  7729. ALIGN="LEFT"
  7730. ><P
  7731. >By using the CGI setup, your server
  7732. is open to several possible attacks. Please read our
  7733. <A
  7734. HREF="#security.cgi-bin"
  7735. >CGI security section</A
  7736. > to learn how to
  7737. defend yourself from those attacks.</P
  7738. ></TD
  7739. ></TR
  7740. ></TABLE
  7741. ></DIV
  7742. ><DIV
  7743. CLASS="sect2"
  7744. ><HR><H3
  7745. CLASS="sect2"
  7746. ><A
  7747. NAME="install.windows.iis.iis3"
  7748. >Windows and PWS/IIS 3</A
  7749. ></H3
  7750. ><P
  7751. >      The recommended method for configuring these servers is to use
  7752.      the REG file included with the distribution
  7753.      (<TT
  7754. CLASS="filename"
  7755. >pws-php4cgi.reg</TT
  7756. > in the SAPI folder for PHP 4, or
  7757.      <TT
  7758. CLASS="filename"
  7759. >pws-php5cgi.reg</TT
  7760. > in the main folder for PHP 5).
  7761.      You may want to edit this file and make sure
  7762.      the extensions and PHP install directories match your
  7763.      configuration. Or you can follow the steps below to do it
  7764.      manually.
  7765.     </P
  7766. ><DIV
  7767. CLASS="warning"
  7768. ><P
  7769. ></P
  7770. ><TABLE
  7771. CLASS="warning"
  7772. BORDER="1"
  7773. WIDTH="100%"
  7774. ><TR
  7775. ><TD
  7776. ALIGN="CENTER"
  7777. ><B
  7778. >Warnung</B
  7779. ></TD
  7780. ></TR
  7781. ><TR
  7782. ><TD
  7783. ALIGN="LEFT"
  7784. ><P
  7785. >       These steps involve working directly with the Windows
  7786.       registry. One error here can leave your system in an unstable
  7787.       state. We highly recommend that you back up your registry
  7788.       first. The PHP Development team will not be held responsible if
  7789.       you damage your registry.
  7790.      </P
  7791. ></TD
  7792. ></TR
  7793. ></TABLE
  7794. ></DIV
  7795. ><P
  7796. >      <P
  7797. ></P
  7798. ><UL
  7799. ><LI
  7800. ><P
  7801. >         Run Regedit.
  7802.        </P
  7803. ></LI
  7804. ><LI
  7805. ><P
  7806. >         Navigate to: <VAR
  7807. CLASS="literal"
  7808. >HKEY_LOCAL_MACHINE /System
  7809.          /CurrentControlSet /Services /W3Svc /Parameters
  7810.          /ScriptMap</VAR
  7811. >.
  7812.        </P
  7813. ></LI
  7814. ><LI
  7815. ><P
  7816. >         On the edit menu select: <VAR
  7817. CLASS="literal"
  7818. >New->String Value</VAR
  7819. >.
  7820.        </P
  7821. ></LI
  7822. ><LI
  7823. ><P
  7824. >         Type in the extension you wish to use for your php
  7825.         scripts. For example <VAR
  7826. CLASS="literal"
  7827. >.php</VAR
  7828. >
  7829.        </P
  7830. ></LI
  7831. ><LI
  7832. ><P
  7833. >         Double click on the new string value and enter the path to
  7834.         <TT
  7835. CLASS="filename"
  7836. >php.exe</TT
  7837. > in the value data field. ex:
  7838.         <TT
  7839. CLASS="filename"
  7840. >C:\php\php.exe</TT
  7841. > for PHP 4, or
  7842.         <TT
  7843. CLASS="filename"
  7844. >C:\php\php-cgi.exe</TT
  7845. > for PHP 5.
  7846.        </P
  7847. ></LI
  7848. ><LI
  7849. ><P
  7850. >         Repeat these steps for each extension you wish to associate
  7851.         with PHP scripts.
  7852.        </P
  7853. ></LI
  7854. ></UL
  7855. >
  7856.     </P
  7857. ><P
  7858. >      The following steps do not affect the web server installation
  7859.      and only apply if you want your PHP scripts to be executed when
  7860.      they are run from the command line (ex. run
  7861.      <TT
  7862. CLASS="filename"
  7863. >C:\myscripts\test.php</TT
  7864. >) or by double clicking
  7865.      on them in a directory viewer window. You may wish to skip these
  7866.      steps as you might prefer the PHP files to load into a text
  7867.      editor when you double click on them.
  7868.     </P
  7869. ><P
  7870. >      <P
  7871. ></P
  7872. ><UL
  7873. ><LI
  7874. ><P
  7875. >         Navigate to: <VAR
  7876. CLASS="literal"
  7877. >HKEY_CLASSES_ROOT</VAR
  7878. >
  7879.        </P
  7880. ></LI
  7881. ><LI
  7882. ><P
  7883. >         On the edit menu select: <VAR
  7884. CLASS="literal"
  7885. >New->Key</VAR
  7886. >.
  7887.        </P
  7888. ></LI
  7889. ><LI
  7890. ><P
  7891. >         Name the key to the extension you setup in the previous
  7892.         section. ex: <VAR
  7893. CLASS="literal"
  7894. >.php</VAR
  7895. >
  7896.        </P
  7897. ></LI
  7898. ><LI
  7899. ><P
  7900. >         Highlight the new key and in the right side pane, double click 
  7901.         the "default value" and enter <VAR
  7902. CLASS="literal"
  7903. >phpfile</VAR
  7904. >.
  7905.        </P
  7906. ></LI
  7907. ><LI
  7908. ><P
  7909. >         Repeat the last step for each extension you set up in the
  7910.         previous section.
  7911.        </P
  7912. ></LI
  7913. ><LI
  7914. ><P
  7915. >         Now create another <VAR
  7916. CLASS="literal"
  7917. >New->Key</VAR
  7918. > under
  7919.         <VAR
  7920. CLASS="literal"
  7921. >HKEY_CLASSES_ROOT</VAR
  7922. > and name it
  7923.         <VAR
  7924. CLASS="literal"
  7925. >phpfile</VAR
  7926. >.
  7927.        </P
  7928. ></LI
  7929. ><LI
  7930. ><P
  7931. >         Highlight the new key <VAR
  7932. CLASS="literal"
  7933. >phpfile</VAR
  7934. > and in the
  7935.         right side pane, double click the "default value" and enter
  7936.         <VAR
  7937. CLASS="literal"
  7938. >PHP Script</VAR
  7939. >.
  7940.        </P
  7941. ></LI
  7942. ><LI
  7943. ><P
  7944. >         Right click on the <VAR
  7945. CLASS="literal"
  7946. >phpfile</VAR
  7947. > key and select
  7948.         <VAR
  7949. CLASS="literal"
  7950. >New->Key</VAR
  7951. >, name it <VAR
  7952. CLASS="literal"
  7953. >Shell</VAR
  7954. >.
  7955.        </P
  7956. ></LI
  7957. ><LI
  7958. ><P
  7959. >         Right click on the <VAR
  7960. CLASS="literal"
  7961. >Shell</VAR
  7962. > key and select
  7963.         <VAR
  7964. CLASS="literal"
  7965. >New->Key</VAR
  7966. >, name it <VAR
  7967. CLASS="literal"
  7968. >open</VAR
  7969. >.
  7970.        </P
  7971. ></LI
  7972. ><LI
  7973. ><P
  7974. >         Right click on the <VAR
  7975. CLASS="literal"
  7976. >open</VAR
  7977. > key and select
  7978.         <VAR
  7979. CLASS="literal"
  7980. >New->Key</VAR
  7981. >, name it
  7982.         <VAR
  7983. CLASS="literal"
  7984. >command</VAR
  7985. >. 
  7986.        </P
  7987. ></LI
  7988. ><LI
  7989. ><P
  7990. >         Highlight the new key <VAR
  7991. CLASS="literal"
  7992. >command</VAR
  7993. > and in the
  7994.         right side pane, double click the "default value" and enter
  7995.         the path to <TT
  7996. CLASS="filename"
  7997. >php.exe</TT
  7998. >. ex:
  7999.         <VAR
  8000. CLASS="literal"
  8001. >c:\php\php.exe -q %1</VAR
  8002. >. (don't forget the
  8003.         <VAR
  8004. CLASS="literal"
  8005. >%1</VAR
  8006. >). 
  8007.        </P
  8008. ></LI
  8009. ><LI
  8010. ><P
  8011. >         Exit Regedit.
  8012.        </P
  8013. ></LI
  8014. ><LI
  8015. ><P
  8016. >         If using PWS on Windows, reboot to reload the registry.
  8017.        </P
  8018. ></LI
  8019. ></UL
  8020. >
  8021.     </P
  8022. ><P
  8023. >      PWS and IIS 3 users now have a fully operational system. IIS 3
  8024.      users can use a nifty <A
  8025. HREF="http://www.genusa.com/iis/iiscfg.html"
  8026. TARGET="_top"
  8027. >tool</A
  8028. >
  8029.      from Steven Genusa to configure their script maps.
  8030.     </P
  8031. ></DIV
  8032. ><DIV
  8033. CLASS="sect2"
  8034. ><HR><H3
  8035. CLASS="sect2"
  8036. ><A
  8037. NAME="install.windows.iis.pws4"
  8038. >Windows and PWS 4 or newer</A
  8039. ></H3
  8040. ><P
  8041. >      When installing PHP on Windows with PWS 4 or newer version,
  8042.      you have two options. One to set up the PHP CGI binary,
  8043.      the other is to use the ISAPI module DLL.
  8044.     </P
  8045. ><P
  8046. >      If you choose the CGI binary, do the following:
  8047.      <P
  8048. ></P
  8049. ><UL
  8050. ><LI
  8051. ><P
  8052. >         Edit the enclosed <TT
  8053. CLASS="filename"
  8054. >pws-php4cgi.reg</TT
  8055. > /
  8056.         <TT
  8057. CLASS="filename"
  8058. >pws-php5cgi.reg</TT
  8059. > file (look into the SAPI folder
  8060.         for PHP 4, or in the main folder for PHP 5) to reflect the location of
  8061.         your <TT
  8062. CLASS="filename"
  8063. >php.exe</TT
  8064. > / <TT
  8065. CLASS="filename"
  8066. >php-cgi.exe</TT
  8067. >.
  8068.         Backslashes should be escaped, for example:
  8069.         <VAR
  8070. CLASS="literal"
  8071. >[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters\Script
  8072.          Map] ".php"="C:\\php\\php.exe"</VAR
  8073. > (change to
  8074.         <VAR
  8075. CLASS="literal"
  8076. >C:\\php\\php-cgi.exe</VAR
  8077. > if you are using PHP 5)
  8078.         Now merge this registery file into your system; you may do 
  8079.         this by double-clicking it.
  8080.        </P
  8081. ></LI
  8082. ><LI
  8083. ><P
  8084. >         In the PWS Manager, right click on a given directory you want
  8085.         to add PHP support to, and select Properties. Check the 'Execute'
  8086.         checkbox, and confirm.
  8087.        </P
  8088. ></LI
  8089. ></UL
  8090. >
  8091.     </P
  8092. ><P
  8093. >      If you choose the ISAPI module, do the following:
  8094.      <P
  8095. ></P
  8096. ><UL
  8097. ><LI
  8098. ><P
  8099. >         Edit the enclosed <TT
  8100. CLASS="filename"
  8101. >pws-php4isapi.reg</TT
  8102. > /
  8103.         <TT
  8104. CLASS="filename"
  8105. >pws-php5isapi.reg</TT
  8106. > file (look into the SAPI folder
  8107.         for PHP 4, or in the main folder for PHP 5) to reflect the location of
  8108.         your <TT
  8109. CLASS="filename"
  8110. >php4isapi.dll</TT
  8111. > /
  8112.         <TT
  8113. CLASS="filename"
  8114. >php5isapi.dll</TT
  8115. >. Backslashes should be escaped, for example:
  8116.         <VAR
  8117. CLASS="literal"
  8118. >[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters\Script
  8119.          Map] ".php"="C:\\php\\sapi\\php4isapi.dll"</VAR
  8120. > (or
  8121.         <VAR
  8122. CLASS="literal"
  8123. >C:\\php\\php5isapi.dll</VAR
  8124. > for PHP 5)
  8125.         Now merge this registery file into your system; you may do 
  8126.         this by double-clicking it.
  8127.        </P
  8128. ></LI
  8129. ><LI
  8130. ><P
  8131. >         In the PWS Manager, right click on a given directory you want to
  8132.         add PHP support to, and select Properties. Check the 'Execute'
  8133.         checkbox, and confirm. 
  8134.        </P
  8135. ></LI
  8136. ></UL
  8137. >
  8138.     </P
  8139. ></DIV
  8140. ><DIV
  8141. CLASS="sect2"
  8142. ><HR><H3
  8143. CLASS="sect2"
  8144. ><A
  8145. NAME="install.windows.iis.iis4"
  8146. >Windows NT/2000/XP and IIS 4 or newer</A
  8147. ></H3
  8148. ><P
  8149. >      To install PHP on an NT/2000/XP Server running IIS 4 or newer,
  8150.      follow these instructions. You have two options to set up
  8151.      PHP, using the CGI binary (<TT
  8152. CLASS="filename"
  8153. >php.exe</TT
  8154. > in PHP 4, or
  8155.      <TT
  8156. CLASS="filename"
  8157. >php-cgi.exe</TT
  8158. > in PHP 5) or with the ISAPI module.
  8159.     </P
  8160. ><P
  8161. >      In either case, you need to start the Microsoft Management
  8162.      Console (may appear as 'Internet Services Manager', either
  8163.      in your Windows NT 4.0 Option Pack branch or the Control
  8164.      Panel=>Administrative Tools under Windows 2000/XP). Then 
  8165.      right click on your Web server node (this will most probably
  8166.      appear as 'Default Web Server'), and select 'Properties'.
  8167.     </P
  8168. ><P
  8169. >      If you want to use the CGI binary, do the following:
  8170.      <P
  8171. ></P
  8172. ><UL
  8173. ><LI
  8174. ><P
  8175. >         Under 'Home Directory', 'Virtual Directory', or
  8176.         'Directory', click on the 'Configuration' button,
  8177.         and then enter the App Mappings tab.
  8178.        </P
  8179. ></LI
  8180. ><LI
  8181. ><P
  8182. >         Click Add, and in the Executable box, type:
  8183.         <VAR
  8184. CLASS="literal"
  8185. >C:\php\php.exe</VAR
  8186. > for PHP 4 or
  8187.         <VAR
  8188. CLASS="literal"
  8189. >C:\php\php-cgi.exe</VAR
  8190. > for PHP 5 (assuming
  8191.         that you have unziped PHP in <TT
  8192. CLASS="filename"
  8193. >c:\php\</TT
  8194. >).
  8195.         </P
  8196. ></LI
  8197. ><LI
  8198. ><P
  8199. >         In the Extension box, type the file name extension you want
  8200.         associated with PHP scripts. Leave 'Method exclusions'
  8201.         blank, and check the 'Script engine' checkbox. You may also
  8202.         like to check the 'check that file exists' box - for a small
  8203.         performance penalty, IIS (or PWS) will check that the script
  8204.         file exists and sort out authentication before firing up PHP.
  8205.         This means that you will get sensible 404 style error messages
  8206.         instead of CGI errors complaining that PHP did not output any data.
  8207.        </P
  8208. ><P
  8209. >         You must start over from the previous step for each
  8210.         extension you want associated with PHP scripts.
  8211.         <VAR
  8212. CLASS="literal"
  8213. >.php</VAR
  8214. > and <VAR
  8215. CLASS="literal"
  8216. >.phtml</VAR
  8217. >
  8218.         are common, although <VAR
  8219. CLASS="literal"
  8220. >.php3</VAR
  8221. > may be
  8222.         required for legacy applications.
  8223.        </P
  8224. ></LI
  8225. ><LI
  8226. ><P
  8227. >         Set up the appropriate security. (This is done in Internet
  8228.         Service Manager), and if your NT Server uses NTFS file system,
  8229.         add execute rights for I_USR_ to the directory that contains
  8230.         <TT
  8231. CLASS="filename"
  8232. >php.exe</TT
  8233. > / <TT
  8234. CLASS="filename"
  8235. >php-cgi.exe</TT
  8236. >.
  8237.        </P
  8238. ></LI
  8239. ></UL
  8240. >
  8241.     </P
  8242. ><P
  8243. >      To use the ISAPI module, do the following:
  8244.      <P
  8245. ></P
  8246. ><UL
  8247. ><LI
  8248. ><P
  8249. >         If you don't want to perform HTTP Authentication using PHP,
  8250.         you can (and should) skip this step. Under ISAPI Filters,
  8251.         add a new ISAPI filter. Use PHP as the filter name, and
  8252.         supply a path to the <TT
  8253. CLASS="filename"
  8254. >php4isapi.dll</TT
  8255. > /
  8256.         <TT
  8257. CLASS="filename"
  8258. >php5isapi.dll</TT
  8259. >.
  8260.        </P
  8261. ></LI
  8262. ><LI
  8263. ><P
  8264. >         Under 'Home Directory', click on the 'Configuration' button.
  8265.         Add a new entry to the Application Mappings. Use the path
  8266.         to the <TT
  8267. CLASS="filename"
  8268. >php4isapi.dll</TT
  8269. > /
  8270.         <TT
  8271. CLASS="filename"
  8272. >php5isapi.dll</TT
  8273. > as the Executable, supply
  8274.         <VAR
  8275. CLASS="literal"
  8276. >.php</VAR
  8277. > as the extension, leave 'Method exclusions'
  8278.         blank, and check the 'Script engine' checkbox.
  8279.        </P
  8280. ></LI
  8281. ><LI
  8282. ><P
  8283. >         Stop IIS completely (NET STOP iisadmin)
  8284.        </P
  8285. ></LI
  8286. ><LI
  8287. ><P
  8288. >         Start IIS again (NET START w3svc)
  8289.        </P
  8290. ></LI
  8291. ></UL
  8292. >
  8293.     </P
  8294. ></DIV
  8295. ></DIV
  8296. ><DIV
  8297. CLASS="sect1"
  8298. ><HR><H2
  8299. CLASS="sect1"
  8300. ><A
  8301. NAME="install.windows.apache1"
  8302. >Apache 1.3.x on Microsft Windows</A
  8303. ></H2
  8304. ><P
  8305. >      This section contains notes and hints specific to Apache 1.3.x installs
  8306.      of PHP on Microsoft Windows systems. We also
  8307.      have <A
  8308. HREF="#install.windows.apache2"
  8309. >instructions and notes
  8310.      for Apache 2 on a separate page</A
  8311. >.
  8312.     </P
  8313. ><DIV
  8314. CLASS="note"
  8315. ><BLOCKQUOTE
  8316. CLASS="note"
  8317. ><P
  8318. ><B
  8319. >Anmerkung: </B
  8320. >
  8321.       You should read the <A
  8322. HREF="#install.windows.manual"
  8323. >manual
  8324.        installation steps</A
  8325. > first!
  8326.      </P
  8327. ></BLOCKQUOTE
  8328. ></DIV
  8329. ><P
  8330. >      There are two ways to set up PHP to work with Apache 1.3.x
  8331.      on Windows. One is to use the CGI binary (<TT
  8332. CLASS="filename"
  8333. >php.exe</TT
  8334. >
  8335.      for PHP 4 and <TT
  8336. CLASS="filename"
  8337. >php-cgi.exe</TT
  8338. > for PHP 5),
  8339.      the other is to use the Apache module DLL. In either case
  8340.      you need to edit your <TT
  8341. CLASS="filename"
  8342. >httpd.conf</TT
  8343. > to configure Apache to
  8344.      work with PHP, and then restart the server.
  8345.     </P
  8346. ><P
  8347. >      It is worth noting here that now the SAPI module has been 
  8348.      made more stable under Windows, we recommend it's use above
  8349.      the CGI binary, since it is more transparent and secure.
  8350.     </P
  8351. ><P
  8352. >      Although there can be a few variations of configuring PHP
  8353.      under Apache, these are simple enough to be used by the
  8354.      newcomer. Please consult the Apache Documentation for further
  8355.      configuration directives.
  8356.     </P
  8357. ><P
  8358. >      After changing the configuration file, remember to restart the server, for
  8359.      example, <B
  8360. CLASS="command"
  8361. >NET STOP APACHE</B
  8362. > followed by
  8363.      <B
  8364. CLASS="command"
  8365. >NET START APACHE</B
  8366. >, if you run Apache as a Windows
  8367.      Service, or use your regular shortcuts.
  8368.     </P
  8369. ><DIV
  8370. CLASS="note"
  8371. ><BLOCKQUOTE
  8372. CLASS="note"
  8373. ><P
  8374. ><B
  8375. >Anmerkung: </B
  8376. >Beachten Sie bitte, dass Sie bei
  8377. Pfadangaben in der Apachekonfigurationsdatei unter Windows alle Backslashes,
  8378. wie z.B. <TT
  8379. CLASS="filename"
  8380. >c:\directory\file.ext</TT
  8381. >, in SchrΣgstriche umwandeln
  8382. mⁿssen: <TT
  8383. CLASS="filename"
  8384. >c:/directory/file.ext</TT
  8385. >.</P
  8386. ></BLOCKQUOTE
  8387. ></DIV
  8388. ><DIV
  8389. CLASS="sect2"
  8390. ><HR><H3
  8391. CLASS="sect2"
  8392. ><A
  8393. NAME="install.windows.apache1.cgi"
  8394. >Installing as a CGI binary</A
  8395. ></H3
  8396. ><P
  8397. >       If you unziped the PHP package to <TT
  8398. CLASS="filename"
  8399. >C:\php\</TT
  8400. > as described
  8401.       in the <A
  8402. HREF="#install.windows.manual"
  8403. >Manual
  8404.       Installation Steps</A
  8405. > section, you need to insert
  8406.       these lines to your Apache configuration file to set
  8407.       up the CGI binary:
  8408.       <TABLE
  8409. WIDTH="100%"
  8410. BORDER="0"
  8411. CELLPADDING="0"
  8412. CELLSPACING="0"
  8413. CLASS="EXAMPLE"
  8414. ><TR
  8415. ><TD
  8416. ><DIV
  8417. CLASS="example"
  8418. ><A
  8419. NAME="AEN1426"
  8420. ></A
  8421. ><P
  8422. ><B
  8423. >Beispiel 6-3. PHP and Apache 1.3.x as CGI</B
  8424. ></P
  8425. ><TABLE
  8426. BORDER="0"
  8427. BGCOLOR="#E0E0E0"
  8428. CELLPADDING="5"
  8429. ><TR
  8430. ><TD
  8431. ><PRE
  8432. CLASS="apache-conf"
  8433. >ScriptAlias /php/ "c:/php/"
  8434. AddType application/x-httpd-php .php
  8435.  
  8436. # For PHP 4
  8437. Action application/x-httpd-php "/php/php.exe"
  8438.  
  8439. # For PHP 5
  8440. Action application/x-httpd-php "/php/php-cgi.exe"
  8441.  
  8442. # specify the directory where php.ini is
  8443. SetEnv PHPRC C:/php</PRE
  8444. ></TD
  8445. ></TR
  8446. ></TABLE
  8447. ></DIV
  8448. ></TD
  8449. ></TR
  8450. ></TABLE
  8451. >
  8452.       Note that the second line in the list above can be found
  8453.       in the actual versions of <TT
  8454. CLASS="filename"
  8455. >httpd.conf</TT
  8456. >, but it is commented out. Remember
  8457.       also to substitute the <TT
  8458. CLASS="filename"
  8459. >c:/php/</TT
  8460. > for your actual path to
  8461.       PHP.
  8462.      </P
  8463. ><DIV
  8464. CLASS="warning"
  8465. ><P
  8466. ></P
  8467. ><TABLE
  8468. CLASS="warning"
  8469. BORDER="1"
  8470. WIDTH="100%"
  8471. ><TR
  8472. ><TD
  8473. ALIGN="CENTER"
  8474. ><B
  8475. >Warnung</B
  8476. ></TD
  8477. ></TR
  8478. ><TR
  8479. ><TD
  8480. ALIGN="LEFT"
  8481. ><P
  8482. >By using the CGI setup, your server
  8483. is open to several possible attacks. Please read our
  8484. <A
  8485. HREF="#security.cgi-bin"
  8486. >CGI security section</A
  8487. > to learn how to
  8488. defend yourself from those attacks.</P
  8489. ></TD
  8490. ></TR
  8491. ></TABLE
  8492. ></DIV
  8493. ><P
  8494. >       If you would like to present PHP source files syntax highlighted, there
  8495.       is no such convinient option as with the module version of PHP.
  8496.       If you chose to configure Apache to use PHP as a CGI binary, you
  8497.       will need to use the <A
  8498. HREF="#function.show-source"
  8499. ><B
  8500. CLASS="function"
  8501. >show_source()</B
  8502. ></A
  8503. > function. To
  8504.       do this simply create a PHP script file and add this code: 
  8505.       <VAR
  8506. CLASS="literal"
  8507. ><?php show_source("original_php_script.php"); ?></VAR
  8508. >. 
  8509.       Substitute <TT
  8510. CLASS="filename"
  8511. >original_php_script.php</TT
  8512. > with 
  8513.       the name of the file you wish to show the source of. 
  8514.      </P
  8515. ></DIV
  8516. ><DIV
  8517. CLASS="sect2"
  8518. ><HR><H3
  8519. CLASS="sect2"
  8520. ><A
  8521. NAME="install.windows.apache1.module"
  8522. >Installing as an Apache module</A
  8523. ></H3
  8524. ><P
  8525. >       You should add the following lines to your Apache <TT
  8526. CLASS="filename"
  8527. >httpd.conf</TT
  8528. > file:
  8529.      </P
  8530. ><P
  8531. >       <TABLE
  8532. WIDTH="100%"
  8533. BORDER="0"
  8534. CELLPADDING="0"
  8535. CELLSPACING="0"
  8536. CLASS="EXAMPLE"
  8537. ><TR
  8538. ><TD
  8539. ><DIV
  8540. CLASS="example"
  8541. ><A
  8542. NAME="AEN1443"
  8543. ></A
  8544. ><P
  8545. ><B
  8546. >Beispiel 6-4. PHP as an Apache 1.3.x module</B
  8547. ></P
  8548. ><TABLE
  8549. BORDER="0"
  8550. BGCOLOR="#E0E0E0"
  8551. CELLPADDING="5"
  8552. ><TR
  8553. ><TD
  8554. ><PRE
  8555. CLASS="apache-conf"
  8556. >AddType application/x-httpd-php .php
  8557.  
  8558. # For PHP 4
  8559. LoadModule php4_module "c:/php/sapi/php4apache.dll"
  8560.  
  8561. # For PHP 5
  8562. LoadModule php5_module "c:/php/php5apache.dll"
  8563.  
  8564. # specify the directory where php.ini is
  8565. SetEnv PHPRC C:/php</PRE
  8566. ></TD
  8567. ></TR
  8568. ></TABLE
  8569. ></DIV
  8570. ></TD
  8571. ></TR
  8572. ></TABLE
  8573. >
  8574.      </P
  8575. ><P
  8576. >       You may find after using the Windows installer for Apache that you need
  8577.       to define the <VAR
  8578. CLASS="literal"
  8579. >AddModule</VAR
  8580. > directive for
  8581.       <TT
  8582. CLASS="filename"
  8583. >mod_php4.c</TT
  8584. >. This is especially important if the
  8585.       <VAR
  8586. CLASS="literal"
  8587. >ClearModuleList</VAR
  8588. > directive is defined, which you will
  8589.       find by scrolling down a few lines. You will see a list of
  8590.       <VAR
  8591. CLASS="literal"
  8592. >AddModule</VAR
  8593. > entries, add the following line
  8594.       <SPAN
  8595. CLASS="emphasis"
  8596. ><I
  8597. CLASS="emphasis"
  8598. >at the end</I
  8599. ></SPAN
  8600. > of the list: <VAR
  8601. CLASS="literal"
  8602. >AddModule
  8603.        mod_php4.c</VAR
  8604. >.  For PHP 5, instead use <VAR
  8605. CLASS="literal"
  8606. >AddModule
  8607.        mod_php5.c</VAR
  8608. >
  8609.       </P
  8610. ><P
  8611. >       If you would like to use the source code highlighting feature, you need
  8612.       to add the following line to your <TT
  8613. CLASS="filename"
  8614. >httpd.conf</TT
  8615. >:
  8616.       <VAR
  8617. CLASS="literal"
  8618. >AddType application/x-httpd-php-source .phps</VAR
  8619. >.
  8620.       This should be inserted at the same place where you inserted
  8621.       <VAR
  8622. CLASS="literal"
  8623. >AddType application/x-httpd-php .php</VAR
  8624. > above). With
  8625.       this setup, all files served with the <VAR
  8626. CLASS="literal"
  8627. >.phps</VAR
  8628. > extension
  8629.       will be syntax highlighted for the browser.
  8630.      </P
  8631. ></DIV
  8632. ></DIV
  8633. ><DIV
  8634. CLASS="sect1"
  8635. ><HR><H2
  8636. CLASS="sect1"
  8637. ><A
  8638. NAME="install.windows.apache2"
  8639. >Apache 2.0.x on Microsoft Windows</A
  8640. ></H2
  8641. ><P
  8642. >      This section contains notes and hints specific to Apache 2.0.x installs
  8643.      of PHP on Microsoft Windows systems. We also
  8644.      have <A
  8645. HREF="#install.windows.apache1"
  8646. >instructions and notes
  8647.      for Apache 1.3.x users on a separate page</A
  8648. >.
  8649.     </P
  8650. ><DIV
  8651. CLASS="note"
  8652. ><BLOCKQUOTE
  8653. CLASS="note"
  8654. ><P
  8655. ><B
  8656. >Anmerkung: </B
  8657. >
  8658.       You should read the <A
  8659. HREF="#install.windows.manual"
  8660. >manual
  8661.        installation steps</A
  8662. > first!
  8663.      </P
  8664. ></BLOCKQUOTE
  8665. ></DIV
  8666. ><DIV
  8667. CLASS="warning"
  8668. ><P
  8669. ></P
  8670. ><TABLE
  8671. CLASS="warning"
  8672. BORDER="1"
  8673. WIDTH="100%"
  8674. ><TR
  8675. ><TD
  8676. ALIGN="CENTER"
  8677. ><B
  8678. >Warnung</B
  8679. ></TD
  8680. ></TR
  8681. ><TR
  8682. ><TD
  8683. ALIGN="LEFT"
  8684. ><P
  8685. >Verwenden Sie Apache 2.0.x und PHP
  8686. weder unter Unix noch Windows in einer Produktivumgebung. Fⁿr weitere
  8687. Informationen und Grⁿnde lesen Sie bitte diesen
  8688. <A
  8689. HREF="#faq.installation.apache2"
  8690. >FAQ Eintrag.</A
  8691. ></P
  8692. ></TD
  8693. ></TR
  8694. ></TABLE
  8695. ></DIV
  8696. ><P
  8697. >      You are highly encouraged to take a look at the
  8698.      <A
  8699. HREF="http://httpd.apache.org/docs-2.0/"
  8700. TARGET="_top"
  8701. >Apache Documentation</A
  8702. > to get
  8703.      a basic understanding of the Apache 2.0.x Server. Also consider to
  8704.      read the <A
  8705. HREF="http://httpd.apache.org/docs-2.0/platform/windows.html"
  8706. TARGET="_top"
  8707. >Windows specific
  8708.      notes</A
  8709. > for Apache 2.0.x before reading on here.
  8710.     </P
  8711. ><DIV
  8712. CLASS="note"
  8713. ><BLOCKQUOTE
  8714. CLASS="note"
  8715. ><P
  8716. ><B
  8717. >PHP and Apache 2.0.x compatibility notes: </B
  8718. >
  8719.       The following versions of PHP are known to work with the most recent
  8720.       version of Apache 2.0.x:
  8721.       <P
  8722. ></P
  8723. ><UL
  8724. COMPACT="COMPACT"
  8725. ><LI
  8726. ><SPAN
  8727. >          PHP 4.3.0 or later available at
  8728.          <A
  8729. HREF="http://www.php.net/downloads.php"
  8730. TARGET="_top"
  8731. >http://www.php.net/downloads.php</A
  8732. >.
  8733.         </SPAN
  8734. ></LI
  8735. ><LI
  8736. ><SPAN
  8737. >          the latest stable development version.
  8738.          Get the source code <A
  8739. HREF="http://snaps.php.net/php4-latest.tar.gz"
  8740. TARGET="_top"
  8741. >          http://snaps.php.net/php4-latest.tar.gz</A
  8742. > or download binaries
  8743.          for Windows <A
  8744. HREF="http://snaps.php.net/win32/php4-win32-latest.zip"
  8745. TARGET="_top"
  8746. >          http://snaps.php.net/win32/php4-win32-latest.zip</A
  8747. >.
  8748.         </SPAN
  8749. ></LI
  8750. ><LI
  8751. ><SPAN
  8752. >          a prerelease version downloadable from
  8753.          <A
  8754. HREF="http://qa.php.net/"
  8755. TARGET="_top"
  8756. >http://qa.php.net/</A
  8757. >.
  8758.         </SPAN
  8759. ></LI
  8760. ><LI
  8761. ><SPAN
  8762. >          you have always the option to obtain PHP through
  8763.          <A
  8764. HREF="http://www.php.net/anoncvs.php"
  8765. TARGET="_top"
  8766. >anonymous CVS</A
  8767. >.
  8768.         </SPAN
  8769. ></LI
  8770. ></UL
  8771. >
  8772.       These versions of PHP are compatible to Apache 2.0.40 and later.
  8773.      </P
  8774. ><P
  8775. >       Apache 2.0 <VAR
  8776. CLASS="literal"
  8777. >SAPI</VAR
  8778. >-support started with PHP 4.2.0.
  8779.       PHP 4.2.3 works with Apache 2.0.39, don't use any other version of Apache with
  8780.       PHP 4.2.3. However, the recommended setup is to use PHP 4.3.0 or later with
  8781.       the most recent version of Apache2.
  8782.      </P
  8783. ><P
  8784. >       All mentioned versions of PHP will work still with
  8785.       Apache 1.3.x.
  8786.      </P
  8787. ></BLOCKQUOTE
  8788. ></DIV
  8789. ><DIV
  8790. CLASS="warning"
  8791. ><P
  8792. ></P
  8793. ><TABLE
  8794. CLASS="warning"
  8795. BORDER="1"
  8796. WIDTH="100%"
  8797. ><TR
  8798. ><TD
  8799. ALIGN="CENTER"
  8800. ><B
  8801. >Warnung</B
  8802. ></TD
  8803. ></TR
  8804. ><TR
  8805. ><TD
  8806. ALIGN="LEFT"
  8807. ><P
  8808. >       Apache 2.0.x is designed to run on Windows NT 4.0, Windows 2000 or
  8809.       Windows XP. At this time, support for Windows 9x is incomplete.
  8810.       Apache 2.0.x is not expected to work on those platforms at this time.
  8811.      </P
  8812. ></TD
  8813. ></TR
  8814. ></TABLE
  8815. ></DIV
  8816. ><P
  8817. >      Download the most recent version of <A
  8818. HREF="http://www.apache.org/"
  8819. TARGET="_top"
  8820. >      Apache 2.0.x</A
  8821. > and a fitting PHP version.
  8822.      Follow the <A
  8823. HREF="#install.windows.manual"
  8824. >Manual Installation
  8825.      Steps</A
  8826. > and come back to go on with the integration of PHP and Apache.
  8827.     </P
  8828. ><P
  8829. >      There are two ways to set up PHP to work with Apache 2.0.x on Windows.
  8830.      One is to use the CGI binary the other is to use the Apache module DLL.
  8831.      In either case you need to edit your <TT
  8832. CLASS="filename"
  8833. >httpd.conf</TT
  8834. > to configure Apache
  8835.      to work with PHP and then restart the server.
  8836.     </P
  8837. ><DIV
  8838. CLASS="note"
  8839. ><BLOCKQUOTE
  8840. CLASS="note"
  8841. ><P
  8842. ><B
  8843. >Anmerkung: </B
  8844. >Beachten Sie bitte, dass Sie bei
  8845. Pfadangaben in der Apachekonfigurationsdatei unter Windows alle Backslashes,
  8846. wie z.B. <TT
  8847. CLASS="filename"
  8848. >c:\directory\file.ext</TT
  8849. >, in SchrΣgstriche umwandeln
  8850. mⁿssen: <TT
  8851. CLASS="filename"
  8852. >c:/directory/file.ext</TT
  8853. >.</P
  8854. ></BLOCKQUOTE
  8855. ></DIV
  8856. ><DIV
  8857. CLASS="sect2"
  8858. ><HR><H3
  8859. CLASS="sect2"
  8860. ><A
  8861. NAME="install.windows.apache2.cgi"
  8862. >Installing as a CGI binary</A
  8863. ></H3
  8864. ><P
  8865. >       You need to insert these three lines to your Apache <TT
  8866. CLASS="filename"
  8867. >httpd.conf</TT
  8868. >
  8869.       configuration file to set up the CGI binary:
  8870.       <TABLE
  8871. WIDTH="100%"
  8872. BORDER="0"
  8873. CELLPADDING="0"
  8874. CELLSPACING="0"
  8875. CLASS="EXAMPLE"
  8876. ><TR
  8877. ><TD
  8878. ><DIV
  8879. CLASS="example"
  8880. ><A
  8881. NAME="AEN1507"
  8882. ></A
  8883. ><P
  8884. ><B
  8885. >Beispiel 6-5. PHP and Apache 2.0 as CGI</B
  8886. ></P
  8887. ><TABLE
  8888. BORDER="0"
  8889. BGCOLOR="#E0E0E0"
  8890. CELLPADDING="5"
  8891. ><TR
  8892. ><TD
  8893. ><PRE
  8894. CLASS="apache-conf"
  8895. >ScriptAlias /php/ "c:/php/"
  8896. AddType application/x-httpd-php .php
  8897.  
  8898. # For PHP 4
  8899. Action application/x-httpd-php "/php/php.exe"
  8900.  
  8901. # For PHP 5
  8902. Action application/x-httpd-php "/php/php-cgi.exe"</PRE
  8903. ></TD
  8904. ></TR
  8905. ></TABLE
  8906. ></DIV
  8907. ></TD
  8908. ></TR
  8909. ></TABLE
  8910. >
  8911.      </P
  8912. ><DIV
  8913. CLASS="warning"
  8914. ><P
  8915. ></P
  8916. ><TABLE
  8917. CLASS="warning"
  8918. BORDER="1"
  8919. WIDTH="100%"
  8920. ><TR
  8921. ><TD
  8922. ALIGN="CENTER"
  8923. ><B
  8924. >Warnung</B
  8925. ></TD
  8926. ></TR
  8927. ><TR
  8928. ><TD
  8929. ALIGN="LEFT"
  8930. ><P
  8931. >By using the CGI setup, your server
  8932. is open to several possible attacks. Please read our
  8933. <A
  8934. HREF="#security.cgi-bin"
  8935. >CGI security section</A
  8936. > to learn how to
  8937. defend yourself from those attacks.</P
  8938. ></TD
  8939. ></TR
  8940. ></TABLE
  8941. ></DIV
  8942. ></DIV
  8943. ><DIV
  8944. CLASS="sect2"
  8945. ><HR><H3
  8946. CLASS="sect2"
  8947. ><A
  8948. NAME="install.windows.apache2.module"
  8949. >Installing as an Apache module</A
  8950. ></H3
  8951. ><P
  8952. >       You need to insert these two lines to your
  8953.       Apache <TT
  8954. CLASS="filename"
  8955. >httpd.conf</TT
  8956. > configuration file to set up the
  8957.       PHP module for Apache 2.0:
  8958.       <TABLE
  8959. WIDTH="100%"
  8960. BORDER="0"
  8961. CELLPADDING="0"
  8962. CELLSPACING="0"
  8963. CLASS="EXAMPLE"
  8964. ><TR
  8965. ><TD
  8966. ><DIV
  8967. CLASS="example"
  8968. ><A
  8969. NAME="AEN1517"
  8970. ></A
  8971. ><P
  8972. ><B
  8973. >Beispiel 6-6. PHP and Apache 2.0 as Module</B
  8974. ></P
  8975. ><TABLE
  8976. BORDER="0"
  8977. BGCOLOR="#E0E0E0"
  8978. CELLPADDING="5"
  8979. ><TR
  8980. ><TD
  8981. ><PRE
  8982. CLASS="apache-conf"
  8983. ># For PHP 4 do something like this:
  8984. LoadModule php4_module "c:/php/sapi/php4apache2.dll"
  8985. AddType application/x-httpd-php .php
  8986.  
  8987. # For PHP 5 do something like this:
  8988. LoadModule php5_module "c:/php/php5apache2.dll"
  8989. AddType application/x-httpd-php .php
  8990.  
  8991. # configure the path to php.ini
  8992. PHPIniDir "C:/php"</PRE
  8993. ></TD
  8994. ></TR
  8995. ></TABLE
  8996. ></DIV
  8997. ></TD
  8998. ></TR
  8999. ></TABLE
  9000. >
  9001.      </P
  9002. ><DIV
  9003. CLASS="note"
  9004. ><BLOCKQUOTE
  9005. CLASS="note"
  9006. ><P
  9007. ><B
  9008. >Anmerkung: </B
  9009. >
  9010.        Remember to substitute the <TT
  9011. CLASS="filename"
  9012. >c:/php/</TT
  9013. > for your actual
  9014.        path to PHP in the above examples. Take care to use
  9015.        either <TT
  9016. CLASS="filename"
  9017. >php4apache2.dll</TT
  9018. > or 
  9019.        <TT
  9020. CLASS="filename"
  9021. >php5apache2.dll</TT
  9022. > in your LoadModule directive and
  9023.        <SPAN
  9024. CLASS="emphasis"
  9025. ><I
  9026. CLASS="emphasis"
  9027. >not</I
  9028. ></SPAN
  9029. > <TT
  9030. CLASS="filename"
  9031. >php4apache.dll</TT
  9032. > or 
  9033.        <TT
  9034. CLASS="filename"
  9035. >php5apache.dll</TT
  9036. > as the latter ones are designed to
  9037.        run with <A
  9038. HREF="#install.windows.apache1"
  9039. >Apache 1.3.x</A
  9040. >.
  9041.       </P
  9042. ></BLOCKQUOTE
  9043. ></DIV
  9044. ><DIV
  9045. CLASS="warning"
  9046. ><P
  9047. ></P
  9048. ><TABLE
  9049. CLASS="warning"
  9050. BORDER="1"
  9051. WIDTH="100%"
  9052. ><TR
  9053. ><TD
  9054. ALIGN="CENTER"
  9055. ><B
  9056. >Warnung</B
  9057. ></TD
  9058. ></TR
  9059. ><TR
  9060. ><TD
  9061. ALIGN="LEFT"
  9062. ><P
  9063. >        Don't mix up your installation with DLL files from
  9064.        <SPAN
  9065. CLASS="emphasis"
  9066. ><I
  9067. CLASS="emphasis"
  9068. >different PHP versions</I
  9069. ></SPAN
  9070. >. You have the only choice
  9071.        to use the DLL's and extensions that ship with your downloaded PHP version.
  9072.       </P
  9073. ></TD
  9074. ></TR
  9075. ></TABLE
  9076. ></DIV
  9077. ></DIV
  9078. ></DIV
  9079. ><DIV
  9080. CLASS="sect1"
  9081. ><HR><H2
  9082. CLASS="sect1"
  9083. ><A
  9084. NAME="install.windows.sun"
  9085. >Sun, iPlanet and Netscape servers on Microsoft Windows</A
  9086. ></H2
  9087. ><P
  9088. >     This section contains notes and hints specific to Sun Java System Web Server,
  9089.     Sun ONE Web Server, iPlanet and Netscape server installs of PHP on Windows.
  9090.    </P
  9091. ><P
  9092. >     From PHP 4.3.3 on you can use PHP scripts with the
  9093.     <A
  9094. HREF="#ref.nsapi"
  9095. >NSAPI module</A
  9096. > to 
  9097.     <A
  9098. HREF="#install.windows.sun.specialpages"
  9099. >generate custom
  9100.     directory listings and error pages</A
  9101. >. Additional functions for
  9102.     Apache compatibility are also available. For support in current webservers
  9103.     read the <A
  9104. HREF="#install.windows.sun.notes"
  9105. >note about
  9106.     subrequests</A
  9107. >.
  9108.    </P
  9109. ><DIV
  9110. CLASS="sect2"
  9111. ><HR><H3
  9112. CLASS="sect2"
  9113. ><A
  9114. NAME="install.windows.sun.cgi"
  9115. >CGI setup on Sun, iPlanet and Netscape servers</A
  9116. ></H3
  9117. ><P
  9118. >      To install PHP as a CGI handler, do the following:
  9119.     </P
  9120. ><P
  9121. ></P
  9122. ><UL
  9123. ><LI
  9124. ><P
  9125. >        Copy <TT
  9126. CLASS="filename"
  9127. >php4ts.dll</TT
  9128. > to your systemroot
  9129.        (the directory where you installed Windows)
  9130.       </P
  9131. ></LI
  9132. ><LI
  9133. ><P
  9134. >        Make a file association from the command line.
  9135.        Type the following two lines:
  9136.        <TABLE
  9137. BORDER="0"
  9138. BGCOLOR="#E0E0E0"
  9139. CELLPADDING="5"
  9140. ><TR
  9141. ><TD
  9142. ><PRE
  9143. CLASS="shell"
  9144. >assoc .php=PHPScript
  9145. ftype PHPScript=c:\php\php.exe %1 %*</PRE
  9146. ></TD
  9147. ></TR
  9148. ></TABLE
  9149. >
  9150.       </P
  9151. ></LI
  9152. ><LI
  9153. ><P
  9154. >        In the Netscape Enterprise Administration Server create
  9155.        a dummy shellcgi directory and remove it just after (this
  9156.        step creates 5 important lines in obj.conf and allow the
  9157.        web server to handle shellcgi scripts).
  9158.       </P
  9159. ></LI
  9160. ><LI
  9161. ><P
  9162. >        In the Netscape Enterprise Administration Server create
  9163.        a new mime type (Category: type,
  9164.        Content-Type: magnus-internal/shellcgi, File Suffix:php).
  9165.       </P
  9166. ></LI
  9167. ><LI
  9168. ><P
  9169. >        Do it for each web server instance you want PHP to run
  9170.       </P
  9171. ></LI
  9172. ></UL
  9173. ><P
  9174. >      More details about setting up
  9175.      PHP as a CGI executable can be found here:
  9176.      <A
  9177. HREF="http://benoit.noss.free.fr/php/install-php.html"
  9178. TARGET="_top"
  9179. >http://benoit.noss.free.fr/php/install-php.html</A
  9180. >
  9181.     </P
  9182. ></DIV
  9183. ><DIV
  9184. CLASS="sect2"
  9185. ><HR><H3
  9186. CLASS="sect2"
  9187. ><A
  9188. NAME="install.windows.sun.nsapi"
  9189. >NSAPI setup on Sun, iPlanet and Netscape servers</A
  9190. ></H3
  9191. ><P
  9192. >      To install PHP with NSAPI, do the following:
  9193.     </P
  9194. ><P
  9195. ></P
  9196. ><UL
  9197. ><LI
  9198. ><P
  9199. >        Copy <TT
  9200. CLASS="filename"
  9201. >php4ts.dll</TT
  9202. > to your systemroot
  9203.        (the directory where you installed Windows)
  9204.       </P
  9205. ></LI
  9206. ><LI
  9207. ><P
  9208. >        Make a file association from the command line.
  9209.        Type the following two lines:
  9210.        <TABLE
  9211. BORDER="0"
  9212. BGCOLOR="#E0E0E0"
  9213. CELLPADDING="5"
  9214. ><TR
  9215. ><TD
  9216. ><PRE
  9217. CLASS="shell"
  9218. >assoc .php=PHPScript
  9219. ftype PHPScript=c:\php\php.exe %1 %*</PRE
  9220. ></TD
  9221. ></TR
  9222. ></TABLE
  9223. >
  9224.       </P
  9225. ></LI
  9226. ><LI
  9227. ><P
  9228. >        In the Netscape Enterprise Administration Server create
  9229.        a new mime type (Category: type,
  9230.        Content-Type: magnus-internal/x-httpd-php, File Suffix: php).
  9231.       </P
  9232. ></LI
  9233. ><LI
  9234. ><P
  9235. >         Edit <TT
  9236. CLASS="filename"
  9237. >magnus.conf</TT
  9238. > (for servers >= 6) or
  9239.         <TT
  9240. CLASS="filename"
  9241. >obj.conf</TT
  9242. > (for servers < 6) and add the following:
  9243.         You should
  9244.         place the lines after <VAR
  9245. CLASS="literal"
  9246. >mime types init</VAR
  9247. >.
  9248.        <TABLE
  9249. BORDER="0"
  9250. BGCOLOR="#E0E0E0"
  9251. CELLPADDING="5"
  9252. ><TR
  9253. ><TD
  9254. ><PRE
  9255. CLASS="programlisting"
  9256. >Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:/php/sapi/php4nsapi.dll"
  9257. Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!" [php_ini="c:/path/to/php.ini"]</PRE
  9258. ></TD
  9259. ></TR
  9260. ></TABLE
  9261. >
  9262.        (PHP >= 4.3.3) The <VAR
  9263. CLASS="literal"
  9264. >php_ini</VAR
  9265. > parameter is
  9266.        optional but with it you can place your
  9267.        <TT
  9268. CLASS="filename"
  9269. >php.ini</TT
  9270. > in your webserver config directory.
  9271.       </P
  9272. ></LI
  9273. ><LI
  9274. ><P
  9275. >        Configure the default object in <TT
  9276. CLASS="filename"
  9277. >obj.conf</TT
  9278. >
  9279.        (for virtual server classes [Sun Web Server 6.0+] in
  9280.        their <TT
  9281. CLASS="filename"
  9282. >vserver.obj.conf</TT
  9283. >):
  9284.        In the <VAR
  9285. CLASS="literal"
  9286. ><Object name="default"></VAR
  9287. >
  9288.        section, place this line necessarily after all 'ObjectType'
  9289.        and before all 'AddLog' lines:
  9290.        <TABLE
  9291. BORDER="0"
  9292. BGCOLOR="#E0E0E0"
  9293. CELLPADDING="5"
  9294. ><TR
  9295. ><TD
  9296. ><PRE
  9297. CLASS="programlisting"
  9298. >Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inikey=value ...]</PRE
  9299. ></TD
  9300. ></TR
  9301. ></TABLE
  9302. >
  9303.        (PHP >= 4.3.3) As additional parameters you can add some special
  9304.        <TT
  9305. CLASS="filename"
  9306. >php.ini</TT
  9307. >-values, for example you
  9308.        can set a <VAR
  9309. CLASS="literal"
  9310. >docroot="/path/to/docroot"</VAR
  9311. >
  9312.        specific to the context <VAR
  9313. CLASS="literal"
  9314. >php4_execute</VAR
  9315. >
  9316.        is called. For boolean ini-keys please use 0/1 as value,
  9317.        not <VAR
  9318. CLASS="literal"
  9319. >"On","Off",...</VAR
  9320. >
  9321.        (this will not work correctly), e.g.
  9322.        <VAR
  9323. CLASS="literal"
  9324. >zlib.output_compression=1</VAR
  9325. > instead of
  9326.        <VAR
  9327. CLASS="literal"
  9328. >zlib.output_compression="On"</VAR
  9329. >
  9330.       </P
  9331. ></LI
  9332. ><LI
  9333. ><P
  9334. >        This is only needed if you want to configure a directory that only consists of
  9335.        PHP scripts (same like a cgi-bin directory):
  9336.        <TABLE
  9337. BORDER="0"
  9338. BGCOLOR="#E0E0E0"
  9339. CELLPADDING="5"
  9340. ><TR
  9341. ><TD
  9342. ><PRE
  9343. CLASS="programlisting"
  9344. ><Object name="x-httpd-php">
  9345. ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
  9346. Service fn=php4_execute [inikey=value inikey=value ...]
  9347. </Object></PRE
  9348. ></TD
  9349. ></TR
  9350. ></TABLE
  9351. >
  9352.        After that you can configure a directory in the Administration server and assign it
  9353.        the style <VAR
  9354. CLASS="literal"
  9355. >x-httpd-php</VAR
  9356. >. All files in it will get executed as PHP.
  9357.        This is nice to hide PHP usage by renaming files to <TT
  9358. CLASS="filename"
  9359. >.html</TT
  9360. >.
  9361.       </P
  9362. ></LI
  9363. ><LI
  9364. ><P
  9365. >        Restart your web service and apply changes
  9366.       </P
  9367. ></LI
  9368. ><LI
  9369. ><P
  9370. >        Do it for each web server instance you want PHP to run
  9371.       </P
  9372. ></LI
  9373. ></UL
  9374. ><DIV
  9375. CLASS="note"
  9376. ><BLOCKQUOTE
  9377. CLASS="note"
  9378. ><P
  9379. ><B
  9380. >Anmerkung: </B
  9381. >
  9382.       More details about setting up
  9383.       PHP as an NSAPI filter can be found here:
  9384.       <A
  9385. HREF="http://benoit.noss.free.fr/php/install-php4.html"
  9386. TARGET="_top"
  9387. >http://benoit.noss.free.fr/php/install-php4.html</A
  9388. >
  9389.      </P
  9390. ></BLOCKQUOTE
  9391. ></DIV
  9392. ><DIV
  9393. CLASS="note"
  9394. ><BLOCKQUOTE
  9395. CLASS="note"
  9396. ><P
  9397. ><B
  9398. >Anmerkung: </B
  9399. >
  9400.       The stacksize that PHP uses depends on the configuration of the webserver. If you get
  9401.       crashes with very large PHP scripts, it is recommended to raise it with the Admin Server
  9402.       (in the section "MAGNUS EDITOR").
  9403.      </P
  9404. ></BLOCKQUOTE
  9405. ></DIV
  9406. ></DIV
  9407. ><DIV
  9408. CLASS="sect2"
  9409. ><HR><H3
  9410. CLASS="sect2"
  9411. ><A
  9412. NAME="install.windows.sun.phpini"
  9413. >CGI environment and recommended modifications in php.ini</A
  9414. ></H3
  9415. ><P
  9416. >      Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
  9417.      WS/iPlanet/Netscape is a multithreaded web server. Because of that all
  9418.      requests are running in the same process space (the space of the webserver
  9419.      itself) and this space has only one environment. If you want to get CGI
  9420.      variables like <VAR
  9421. CLASS="literal"
  9422. >PATH_INFO</VAR
  9423. >, <VAR
  9424. CLASS="literal"
  9425. >HTTP_HOST</VAR
  9426. >
  9427.      etc. it is not the correct way to try this in the old PHP 3.x way with
  9428.      <A
  9429. HREF="#function.getenv"
  9430. ><B
  9431. CLASS="function"
  9432. >getenv()</B
  9433. ></A
  9434. > or a similar way (register globals to
  9435.      environment, <VAR
  9436. CLASS="literal"
  9437. >$_ENV</VAR
  9438. >). You would only get the environment
  9439.      of the running webserver without any valid CGI variables!
  9440.     </P
  9441. ><DIV
  9442. CLASS="note"
  9443. ><BLOCKQUOTE
  9444. CLASS="note"
  9445. ><P
  9446. ><B
  9447. >Anmerkung: </B
  9448. >
  9449.       Why are there (invalid) CGI variables in the environment?
  9450.      </P
  9451. ><P
  9452. >       Answer: This is because you started the webserver process from the admin server
  9453.       which runs the startup script of the webserver, you wanted to start, as a CGI script
  9454.       (a CGI script inside of the admin server!). This is why the environment of
  9455.       the started webserver has some CGI environment variables in it. You can test
  9456.       this by starting the webserver not from the administration server. Use
  9457.       the command line as root user and start it manually - you will see
  9458.       there are no CGI-like environment variables.
  9459.      </P
  9460. ></BLOCKQUOTE
  9461. ></DIV
  9462. ><P
  9463. >      Simply change your scripts to get CGI variables in the correct way for
  9464.      PHP 4.x by using the superglobal <VAR
  9465. CLASS="literal"
  9466. >$_SERVER</VAR
  9467. >. If you have
  9468.      older scripts which use <VAR
  9469. CLASS="literal"
  9470. >$HTTP_HOST</VAR
  9471. >, etc., you should turn
  9472.      on <VAR
  9473. CLASS="literal"
  9474. >register_globals</VAR
  9475. > in <TT
  9476. CLASS="filename"
  9477. >php.ini</TT
  9478. > and change the variable
  9479.      order too (important: remove <VAR
  9480. CLASS="literal"
  9481. >"E"</VAR
  9482. > from it,
  9483.      because you do not need the environment here):
  9484.      <TABLE
  9485. BORDER="0"
  9486. BGCOLOR="#E0E0E0"
  9487. CELLPADDING="5"
  9488. ><TR
  9489. ><TD
  9490. ><PRE
  9491. CLASS="programlisting"
  9492. >variables_order = "GPCS"
  9493. register_globals = On</PRE
  9494. ></TD
  9495. ></TR
  9496. ></TABLE
  9497. >
  9498.     </P
  9499. ></DIV
  9500. ><DIV
  9501. CLASS="sect2"
  9502. ><HR><H3
  9503. CLASS="sect2"
  9504. ><A
  9505. NAME="install.windows.sun.specialpages"
  9506. >Special use for error pages or self-made directory listings (PHP >= 4.3.3)</A
  9507. ></H3
  9508. ><P
  9509. >      You can use PHP to generate the error pages for <VAR
  9510. CLASS="literal"
  9511. >"404 Not Found"</VAR
  9512. >
  9513.      or similar. Add the following line to the object in <TT
  9514. CLASS="filename"
  9515. >obj.conf</TT
  9516. > for
  9517.      every error page you want to overwrite:
  9518.      <TABLE
  9519. BORDER="0"
  9520. BGCOLOR="#E0E0E0"
  9521. CELLPADDING="5"
  9522. ><TR
  9523. ><TD
  9524. ><PRE
  9525. CLASS="programlisting"
  9526. >Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...]</PRE
  9527. ></TD
  9528. ></TR
  9529. ></TABLE
  9530. >
  9531.      where <VAR
  9532. CLASS="literal"
  9533. >XXX</VAR
  9534. > is the HTTP error code. Please delete
  9535.      any other <VAR
  9536. CLASS="literal"
  9537. >Error</VAR
  9538. > directives which could interfere with yours.
  9539.      If you want to place a page for all errors that could exist, leave
  9540.      the <VAR
  9541. CLASS="literal"
  9542. >code</VAR
  9543. > parameter out. Your script can get the HTTP status code
  9544.      with <VAR
  9545. CLASS="literal"
  9546. >$_SERVER['ERROR_TYPE']</VAR
  9547. >.
  9548.     </P
  9549. ><P
  9550. >      Another possibility is to generate self-made directory listings.
  9551.      Just create a PHP script which displays a directory listing and
  9552.      replace the corresponding default Service line for
  9553.      <VAR
  9554. CLASS="literal"
  9555. >type="magnus-internal/directory"</VAR
  9556. >
  9557.      in <TT
  9558. CLASS="filename"
  9559. >obj.conf</TT
  9560. > with the following:
  9561.      <TABLE
  9562. BORDER="0"
  9563. BGCOLOR="#E0E0E0"
  9564. CELLPADDING="5"
  9565. ><TR
  9566. ><TD
  9567. ><PRE
  9568. CLASS="programlisting"
  9569. >Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...]</PRE
  9570. ></TD
  9571. ></TR
  9572. ></TABLE
  9573. >
  9574.      For both error and directory listing pages the original URI and
  9575.      translated URI are in the variables <VAR
  9576. CLASS="literal"
  9577. >$_SERVER['PATH_INFO']</VAR
  9578. > and
  9579.      <VAR
  9580. CLASS="literal"
  9581. >$_SERVER['PATH_TRANSLATED']</VAR
  9582. >.
  9583.     </P
  9584. ></DIV
  9585. ><DIV
  9586. CLASS="sect2"
  9587. ><HR><H3
  9588. CLASS="sect2"
  9589. ><A
  9590. NAME="install.windows.sun.notes"
  9591. >Note about <A
  9592. HREF="#function.nsapi-virtual"
  9593. ><B
  9594. CLASS="function"
  9595. >nsapi_virtual()</B
  9596. ></A
  9597. > and subrequests (PHP >= 4.3.3)</A
  9598. ></H3
  9599. ><P
  9600. >      The NSAPI module now supports the <A
  9601. HREF="#function.nsapi-virtual"
  9602. ><B
  9603. CLASS="function"
  9604. >nsapi_virtual()</B
  9605. ></A
  9606. > function
  9607.      (alias: <A
  9608. HREF="#function.virtual"
  9609. ><B
  9610. CLASS="function"
  9611. >virtual()</B
  9612. ></A
  9613. >)
  9614.      to make subrequests on the webserver and insert the result in the webpage.
  9615.      The problem is, that this function uses some undocumented features from
  9616.      the NSAPI library.
  9617.     </P
  9618. ><P
  9619. >      Under Unix this is not a problem, because the module automatically looks
  9620.      for the needed functions and uses them if available.
  9621.      If not, <A
  9622. HREF="#function.nsapi-virtual"
  9623. ><B
  9624. CLASS="function"
  9625. >nsapi_virtual()</B
  9626. ></A
  9627. > is disabled.
  9628.     </P
  9629. ><P
  9630. >      Under Windows limitations in the DLL handling need the use of a automatic
  9631.      detection of the most recent <TT
  9632. CLASS="filename"
  9633. >ns-httpdXX.dll</TT
  9634. > file.
  9635.      This is tested for servers till version 6.1. If a newer version of the
  9636.      Sun server is used, the detection fails and <A
  9637. HREF="#function.nsapi-virtual"
  9638. ><B
  9639. CLASS="function"
  9640. >nsapi_virtual()</B
  9641. ></A
  9642. >
  9643.      is disabled.
  9644.     </P
  9645. ><P
  9646. >      If this is the case, try the following:
  9647.      Add the following parameter to <VAR
  9648. CLASS="literal"
  9649. >php4_init</VAR
  9650. > in
  9651.      <TT
  9652. CLASS="filename"
  9653. >magnus.conf</TT
  9654. >/<TT
  9655. CLASS="filename"
  9656. >obj.conf</TT
  9657. >:
  9658.      <TABLE
  9659. BORDER="0"
  9660. BGCOLOR="#E0E0E0"
  9661. CELLPADDING="5"
  9662. ><TR
  9663. ><TD
  9664. ><PRE
  9665. CLASS="programlisting"
  9666. >Init fn=php4_init ... server_lib="ns-httpdXX.dll"</PRE
  9667. ></TD
  9668. ></TR
  9669. ></TABLE
  9670. >
  9671.      where <VAR
  9672. CLASS="literal"
  9673. >XX</VAR
  9674. > is the correct DLL version number.
  9675.      To get it, look in the server-root for the correct DLL name. The
  9676.      DLL with the biggest filesize is the right one.
  9677.     </P
  9678. ><P
  9679. >      You can check the status by using the <A
  9680. HREF="#function.phpinfo"
  9681. ><B
  9682. CLASS="function"
  9683. >phpinfo()</B
  9684. ></A
  9685. > function.
  9686.     </P
  9687. ><DIV
  9688. CLASS="note"
  9689. ><BLOCKQUOTE
  9690. CLASS="note"
  9691. ><P
  9692. ><B
  9693. >Anmerkung: </B
  9694. >
  9695.       But be warned: Support for <A
  9696. HREF="#function.nsapi-virtual"
  9697. ><B
  9698. CLASS="function"
  9699. >nsapi_virtual()</B
  9700. ></A
  9701. > is EXPERIMENTAL!!!
  9702.      </P
  9703. ></BLOCKQUOTE
  9704. ></DIV
  9705. ></DIV
  9706. ></DIV
  9707. ><DIV
  9708. CLASS="sect1"
  9709. ><HR><H2
  9710. CLASS="sect1"
  9711. ><A
  9712. NAME="install.windows.omnihttpd"
  9713. >OmniHTTPd Server</A
  9714. ></H2
  9715. ><P
  9716. >     This section contains notes and hints specific to
  9717.     <A
  9718. HREF="http://www.omnicron.ca/"
  9719. TARGET="_top"
  9720. >OmniHTTPd</A
  9721. > on Windows.
  9722.    </P
  9723. ><DIV
  9724. CLASS="note"
  9725. ><BLOCKQUOTE
  9726. CLASS="note"
  9727. ><P
  9728. ><B
  9729. >Anmerkung: </B
  9730. >
  9731.      You should read the <A
  9732. HREF="#install.windows.manual"
  9733. >manual
  9734.      installation steps</A
  9735. > first!
  9736.     </P
  9737. ></BLOCKQUOTE
  9738. ></DIV
  9739. ><DIV
  9740. CLASS="warning"
  9741. ><P
  9742. ></P
  9743. ><TABLE
  9744. CLASS="warning"
  9745. BORDER="1"
  9746. WIDTH="100%"
  9747. ><TR
  9748. ><TD
  9749. ALIGN="CENTER"
  9750. ><B
  9751. >Warnung</B
  9752. ></TD
  9753. ></TR
  9754. ><TR
  9755. ><TD
  9756. ALIGN="LEFT"
  9757. ><P
  9758. >By using the CGI setup, your server
  9759. is open to several possible attacks. Please read our
  9760. <A
  9761. HREF="#security.cgi-bin"
  9762. >CGI security section</A
  9763. > to learn how to
  9764. defend yourself from those attacks.</P
  9765. ></TD
  9766. ></TR
  9767. ></TABLE
  9768. ></DIV
  9769. ><P
  9770. >     You need to complete the following steps to make PHP
  9771.     work with OmniHTTPd. This is a CGI executable setup.
  9772.     SAPI is supported by OmniHTTPd, but some tests have shown
  9773.     that it is not so stable to use PHP as an ISAPI module.
  9774.    </P
  9775. ><DIV
  9776. CLASS="note"
  9777. ><BLOCKQUOTE
  9778. CLASS="note"
  9779. ><P
  9780. ><B
  9781. >Important for CGI users: </B
  9782. >
  9783.      Read the <A
  9784. HREF="#faq.installation.forceredirect"
  9785. >faq
  9786.      on cgi.force_redirect</A
  9787. > for important details.  This
  9788.      directive needs to be set to <VAR
  9789. CLASS="literal"
  9790. >0</VAR
  9791. >.
  9792.     </P
  9793. ></BLOCKQUOTE
  9794. ></DIV
  9795. ><P
  9796. >     <P
  9797. ></P
  9798. ><OL
  9799. TYPE="1"
  9800. ><LI
  9801. ><P
  9802. >        Install OmniHTTPd server.
  9803.       </P
  9804. ></LI
  9805. ><LI
  9806. ><P
  9807. >        Right click on the blue OmniHTTPd icon in the system
  9808.        tray and select <VAR
  9809. CLASS="literal"
  9810. >Properties</VAR
  9811. >
  9812.       </P
  9813. ></LI
  9814. ><LI
  9815. ><P
  9816. >        Click on <VAR
  9817. CLASS="literal"
  9818. >Web Server Global Settings</VAR
  9819. >
  9820.       </P
  9821. ></LI
  9822. ><LI
  9823. ><P
  9824. >        On the 'External' tab, enter: <VAR
  9825. CLASS="literal"
  9826. >virtual = .php
  9827.         | actual = c:\php\php.exe</VAR
  9828. > (use
  9829.        <TT
  9830. CLASS="filename"
  9831. >php-cgi.exe</TT
  9832. > if installing PHP 5), and use the Add
  9833.        button.
  9834.       </P
  9835. ></LI
  9836. ><LI
  9837. ><P
  9838. >        On the <VAR
  9839. CLASS="literal"
  9840. >Mime</VAR
  9841. > tab, enter:
  9842.        <VAR
  9843. CLASS="literal"
  9844. >virtual = wwwserver/stdcgi | actual = .php</VAR
  9845. >,
  9846.        and use the Add button.
  9847.       </P
  9848. ></LI
  9849. ><LI
  9850. ><P
  9851. >        Click <VAR
  9852. CLASS="literal"
  9853. >OK</VAR
  9854. >
  9855.       </P
  9856. ></LI
  9857. ></OL
  9858. >
  9859.    </P
  9860. ><P
  9861. >     Repeat steps 2 - 6 for each extension you want to associate with PHP.
  9862.    </P
  9863. ><DIV
  9864. CLASS="note"
  9865. ><BLOCKQUOTE
  9866. CLASS="note"
  9867. ><P
  9868. ><B
  9869. >Anmerkung: </B
  9870. >
  9871.      Some OmniHTTPd packages come with built in PHP support.
  9872.      You can choose at setup time to do a custom setup, and
  9873.      uncheck the PHP component. We recommend you to use the latest
  9874.      PHP binaries. Some OmniHTTPd servers come with PHP 4 beta
  9875.      distributions, so you should choose not to set up
  9876.      the built in support, but install your own. If the server
  9877.      is already on your machine, use the Replace button in Step
  9878.      4 and 5 to set the new, correct information.
  9879.     </P
  9880. ></BLOCKQUOTE
  9881. ></DIV
  9882. ></DIV
  9883. ><DIV
  9884. CLASS="sect1"
  9885. ><HR><H2
  9886. CLASS="sect1"
  9887. ><A
  9888. NAME="install.windows.sambar"
  9889. >Sambar Server on Microsoft Windows</A
  9890. ></H2
  9891. ><P
  9892. >      This section contains notes and hints specific to the
  9893.      <A
  9894. HREF="http://www.sambar.com/"
  9895. TARGET="_top"
  9896. >Sambar Server</A
  9897. > for Windows.
  9898.     </P
  9899. ><DIV
  9900. CLASS="note"
  9901. ><BLOCKQUOTE
  9902. CLASS="note"
  9903. ><P
  9904. ><B
  9905. >Anmerkung: </B
  9906. >
  9907.       You should read the <A
  9908. HREF="#install.windows.manual"
  9909. >manual
  9910.        installation steps</A
  9911. > first!
  9912.      </P
  9913. ></BLOCKQUOTE
  9914. ></DIV
  9915. ><P
  9916. >      This list describes how to set up the ISAPI module to
  9917.      work with the Sambar server on Windows.
  9918.     </P
  9919. ><P
  9920. >      <P
  9921. ></P
  9922. ><UL
  9923. ><LI
  9924. ><P
  9925. >         Find the file called <TT
  9926. CLASS="filename"
  9927. >mappings.ini</TT
  9928. > (in the config
  9929.         directory) in the Sambar install directory.
  9930.        </P
  9931. ></LI
  9932. ><LI
  9933. ><P
  9934. >         Open <TT
  9935. CLASS="filename"
  9936. >mappings.ini</TT
  9937. > and add the following line
  9938.         under <VAR
  9939. CLASS="literal"
  9940. >[ISAPI]</VAR
  9941. >:
  9942.       <TABLE
  9943. WIDTH="100%"
  9944. BORDER="0"
  9945. CELLPADDING="0"
  9946. CELLSPACING="0"
  9947. CLASS="EXAMPLE"
  9948. ><TR
  9949. ><TD
  9950. ><DIV
  9951. CLASS="example"
  9952. ><A
  9953. NAME="AEN1715"
  9954. ></A
  9955. ><P
  9956. ><B
  9957. >Beispiel 6-7. ISAPI configuration of Sambar</B
  9958. ></P
  9959. ><TABLE
  9960. BORDER="0"
  9961. BGCOLOR="#E0E0E0"
  9962. CELLPADDING="5"
  9963. ><TR
  9964. ><TD
  9965. ><PRE
  9966. CLASS="programlisting"
  9967. >#for PHP 4
  9968. *.php = c:\php\php4isapi.dll
  9969.  
  9970. #for PHP 5
  9971. *.php = c:\php\php5isapi.dll</PRE
  9972. ></TD
  9973. ></TR
  9974. ></TABLE
  9975. ></DIV
  9976. ></TD
  9977. ></TR
  9978. ></TABLE
  9979. >
  9980.         (This line assumes that PHP was installed in
  9981.         <TT
  9982. CLASS="filename"
  9983. >c:\php</TT
  9984. >.)
  9985.        </P
  9986. ></LI
  9987. ><LI
  9988. ><P
  9989. >         Now restart the Sambar server for the changes to take effect.
  9990.        </P
  9991. ></LI
  9992. ></UL
  9993. >
  9994.     </P
  9995. ></DIV
  9996. ><DIV
  9997. CLASS="sect1"
  9998. ><HR><H2
  9999. CLASS="sect1"
  10000. ><A
  10001. NAME="install.windows.xitami"
  10002. >Xitami on Microsoft Windows</A
  10003. ></H2
  10004. ><P
  10005. >      This section contains notes and hints specific to
  10006.      <A
  10007. HREF="http://www.xitami.com/"
  10008. TARGET="_top"
  10009. >Xitami</A
  10010. > on Windows.
  10011.     </P
  10012. ><DIV
  10013. CLASS="note"
  10014. ><BLOCKQUOTE
  10015. CLASS="note"
  10016. ><P
  10017. ><B
  10018. >Anmerkung: </B
  10019. >
  10020.       You should read the <A
  10021. HREF="#install.windows.manual"
  10022. >manual
  10023.        installation steps</A
  10024. > first!
  10025.      </P
  10026. ></BLOCKQUOTE
  10027. ></DIV
  10028. ><P
  10029. >      This list describes how to set up the PHP CGI binary
  10030.      to work with Xitami on Windows.
  10031.     </P
  10032. ><DIV
  10033. CLASS="note"
  10034. ><BLOCKQUOTE
  10035. CLASS="note"
  10036. ><P
  10037. ><B
  10038. >Important for CGI users: </B
  10039. >
  10040.       Read the <A
  10041. HREF="#faq.installation.forceredirect"
  10042. >faq
  10043.       on cgi.force_redirect</A
  10044. > for important details.  This
  10045.       directive needs to be set to <VAR
  10046. CLASS="literal"
  10047. >0</VAR
  10048. >.
  10049.       If you want to use <VAR
  10050. CLASS="literal"
  10051. >$_SERVER['PHP_SELF']</VAR
  10052. > you have to
  10053.       enable the <A
  10054. HREF="#ini.cgi.fix-pathinfo"
  10055. >cgi.fix_pathinfo</A
  10056. >
  10057.       directive.
  10058.      </P
  10059. ></BLOCKQUOTE
  10060. ></DIV
  10061. ><DIV
  10062. CLASS="warning"
  10063. ><P
  10064. ></P
  10065. ><TABLE
  10066. CLASS="warning"
  10067. BORDER="1"
  10068. WIDTH="100%"
  10069. ><TR
  10070. ><TD
  10071. ALIGN="CENTER"
  10072. ><B
  10073. >Warnung</B
  10074. ></TD
  10075. ></TR
  10076. ><TR
  10077. ><TD
  10078. ALIGN="LEFT"
  10079. ><P
  10080. >By using the CGI setup, your server
  10081. is open to several possible attacks. Please read our
  10082. <A
  10083. HREF="#security.cgi-bin"
  10084. >CGI security section</A
  10085. > to learn how to
  10086. defend yourself from those attacks.</P
  10087. ></TD
  10088. ></TR
  10089. ></TABLE
  10090. ></DIV
  10091. ><P
  10092. >      <P
  10093. ></P
  10094. ><UL
  10095. ><LI
  10096. ><P
  10097. >         Make sure the webserver is running, and point
  10098.         your browser to xitamis admin console
  10099.         (usually <VAR
  10100. CLASS="literal"
  10101. >http://127.0.0.1/admin</VAR
  10102. >),
  10103.         and click on Configuration.
  10104.        </P
  10105. ></LI
  10106. ><LI
  10107. ><P
  10108. >         Navigate to the Filters, and put the
  10109.         extension which PHP should parse (i.e. .php)
  10110.         into the field File extensions (.xxx).
  10111.        </P
  10112. ></LI
  10113. ><LI
  10114. ><P
  10115. >         In Filter command or script put the path and name
  10116.         of your PHP CGI executable i.e. <TT
  10117. CLASS="filename"
  10118. >C:\php\php.exe</TT
  10119. >
  10120.         for PHP 4, or <TT
  10121. CLASS="filename"
  10122. >C:\php\php-cgi.exe</TT
  10123. > for PHP 5.
  10124.        </P
  10125. ></LI
  10126. ><LI
  10127. ><P
  10128. >         Press the 'Save' icon.
  10129.        </P
  10130. ></LI
  10131. ><LI
  10132. ><P
  10133. >         Restart the server to reflect changes.
  10134.        </P
  10135. ></LI
  10136. ></UL
  10137. >
  10138.     </P
  10139. ></DIV
  10140. ><DIV
  10141. CLASS="sect1"
  10142. ><HR><H2
  10143. CLASS="sect1"
  10144. ><A
  10145. NAME="install.windows.build"
  10146. >Building from source</A
  10147. ></H2
  10148. ><P
  10149. >      Before getting started, it is worthwhile answering the question:
  10150.      "Why is building on Windows so hard?" Two reasons come to mind:
  10151.     </P
  10152. ><P
  10153. ></P
  10154. ><OL
  10155. TYPE="1"
  10156. ><LI
  10157. ><P
  10158. >        Windows does not (yet) enjoy a large community of developers
  10159.        who are willing to freely share their source. As a direct
  10160.        result, the necessary investment in infrastructure required
  10161.        to support such development hasn't been made. By and large,
  10162.        what is available has been made possible by the porting of
  10163.        necessary utilities from Unix. Don't be surprised if some of
  10164.        this heritage shows through from time to time.
  10165.       </P
  10166. ></LI
  10167. ><LI
  10168. ><P
  10169. >        Pretty much all of the instructions that follow are of the
  10170.        "set and forget" variety. So sit back and try follow the
  10171.        instructions below as faithfully as you can.
  10172.       </P
  10173. ></LI
  10174. ></OL
  10175. ><DIV
  10176. CLASS="sect2"
  10177. ><HR><H3
  10178. CLASS="sect2"
  10179. ><A
  10180. NAME="install.windows.build.requirement"
  10181. >Anforderungen</A
  10182. ></H3
  10183. ><P
  10184. >       To compile and build PHP you need a Microsoft
  10185.       Development Environment. Microsoft Visual C++ 6.0 is recommended.
  10186.       To extract the downloaded files you need a extraction utility
  10187.       (e.g.: Winzip). If you don't already have an unzip utility, you
  10188.       can get a free version from <A
  10189. HREF="http://www.info-zip.org/pub/infozip/"
  10190. TARGET="_top"
  10191. >InfoZip</A
  10192. >.
  10193.      </P
  10194. ><P
  10195. >       Before you get started, you have to download...
  10196.      </P
  10197. ><P
  10198. ></P
  10199. ><UL
  10200. ><LI
  10201. ><P
  10202. >         ..the win32 buildtools from the PHP site
  10203.         at <A
  10204. HREF="http://www.php.net/extra/win32build.zip"
  10205. TARGET="_top"
  10206. >http://www.php.net/extra/win32build.zip</A
  10207. >.
  10208.        </P
  10209. ></LI
  10210. ><LI
  10211. ><P
  10212. >         ..the source code for the DNS name resolver used by PHP from
  10213.         <A
  10214. HREF="http://www.php.net/extra/bindlib_w32.zip"
  10215. TARGET="_top"
  10216. >         http://www.php.net/extra/bindlib_w32.zip</A
  10217. >. This is a replacement for the 
  10218.         <TT
  10219. CLASS="filename"
  10220. >resolv.lib</TT
  10221. > library included in <TT
  10222. CLASS="filename"
  10223. >         win32build.zip</TT
  10224. >.
  10225.        </P
  10226. ></LI
  10227. ><LI
  10228. ><P
  10229. >         If you plan to compile PHP as a Apache
  10230.         module you will also need the <A
  10231. HREF="http://www.apache.org/dist/httpd/"
  10232. TARGET="_top"
  10233. >Apache
  10234.         sources</A
  10235. >.
  10236.        </P
  10237. ></LI
  10238. ></UL
  10239. ><P
  10240. >       Finally, you are going to need the source to PHP itself. You can get
  10241.       the latest development version using <A
  10242. HREF="http://www.php.net/anoncvs.php"
  10243. TARGET="_top"
  10244. >       anonymous CVS</A
  10245. >, a <A
  10246. HREF="http://snaps.php.net/"
  10247. TARGET="_top"
  10248. >       snapshot</A
  10249. > or the most recent released <A
  10250. HREF="http://www.php.net/downloads.php"
  10251. TARGET="_top"
  10252. >       source</A
  10253. > tarball.
  10254.      </P
  10255. ></DIV
  10256. ><DIV
  10257. CLASS="sect2"
  10258. ><HR><H3
  10259. CLASS="sect2"
  10260. ><A
  10261. NAME="install.windows.build.install"
  10262. >Putting it all together</A
  10263. ></H3
  10264. ><P
  10265. >       After downloading the required packages you have to extract them in a
  10266.       proper place.
  10267.       <P
  10268. ></P
  10269. ><UL
  10270. ><LI
  10271. ><P
  10272. >          Create a working directory where all files end up after extracting, e.g:
  10273.          <TT
  10274. CLASS="filename"
  10275. >C:\work</TT
  10276. >.
  10277.         </P
  10278. ></LI
  10279. ><LI
  10280. ><P
  10281. >          Create the directory <TT
  10282. CLASS="filename"
  10283. >win32build</TT
  10284. > under your
  10285.          working directory (<TT
  10286. CLASS="filename"
  10287. >C:\work</TT
  10288. >) and unzip <TT
  10289. CLASS="filename"
  10290. >          win32build.zip</TT
  10291. > into it.
  10292.         </P
  10293. ></LI
  10294. ><LI
  10295. ><P
  10296. >          Create the directory <TT
  10297. CLASS="filename"
  10298. >bindlib_w32</TT
  10299. > under your
  10300.          working directory (<TT
  10301. CLASS="filename"
  10302. >C:\work</TT
  10303. >) and unzip <TT
  10304. CLASS="filename"
  10305. >          bindlib_w32.zip</TT
  10306. > into it.
  10307.         </P
  10308. ></LI
  10309. ><LI
  10310. ><P
  10311. >          Extract the downloaded PHP source code into your working directory
  10312.          (<TT
  10313. CLASS="filename"
  10314. >C:\work</TT
  10315. >).
  10316.         </P
  10317. ></LI
  10318. ></UL
  10319. >
  10320.       Following this steps your directory structure looks like this:
  10321.       <DIV
  10322. CLASS="informalexample"
  10323. ><P
  10324. ></P
  10325. ><A
  10326. NAME="AEN1803"
  10327. ></A
  10328. ><TABLE
  10329. BORDER="0"
  10330. BGCOLOR="#E0E0E0"
  10331. CELLPADDING="5"
  10332. ><TR
  10333. ><TD
  10334. ><PRE
  10335. CLASS="programlisting"
  10336. >+--c:\work
  10337. |  |
  10338. |  +--bindlib_w32
  10339. |  |  |
  10340. |  |  +--arpa
  10341. |  |  |
  10342. |  |  +--conf
  10343. |  |  |
  10344. |  |  +--...
  10345. |  |
  10346. |  +--php-4.x.x
  10347. |  |  |
  10348. |  |  +--build
  10349. |  |  |
  10350. |  |  +--...
  10351. |  |  |
  10352. |  |  +--win32
  10353. |  |  |
  10354. |  |  +--...
  10355. |  |
  10356. |  +--win32build
  10357. |  |  |
  10358. |  |  +--bin
  10359. |  |  |
  10360. |  |  +--include
  10361. |  |  |
  10362. |  |  +--lib</PRE
  10363. ></TD
  10364. ></TR
  10365. ></TABLE
  10366. ><P
  10367. ></P
  10368. ></DIV
  10369. >
  10370.       Create the directories <TT
  10371. CLASS="filename"
  10372. >c:\usr\local\lib</TT
  10373. >. Copy
  10374.       <TT
  10375. CLASS="filename"
  10376. >bison.simple</TT
  10377. > from <TT
  10378. CLASS="filename"
  10379. >c:\work\win32build\bin
  10380.       </TT
  10381. > to <TT
  10382. CLASS="filename"
  10383. >c:\usr\local\lib</TT
  10384. >.
  10385.      </P
  10386. ><DIV
  10387. CLASS="note"
  10388. ><BLOCKQUOTE
  10389. CLASS="note"
  10390. ><P
  10391. ><B
  10392. >Anmerkung: </B
  10393. >
  10394.        <A
  10395. HREF="http://www.cygwin.com/"
  10396. TARGET="_top"
  10397. >Cygwin</A
  10398. > users may omit the last
  10399.        step. A properly installed Cygwin environment provides the mandatory
  10400.        files <TT
  10401. CLASS="filename"
  10402. >bison.simple</TT
  10403. > and
  10404.        <TT
  10405. CLASS="filename"
  10406. >bison.exe</TT
  10407. >.
  10408.       </P
  10409. ></BLOCKQUOTE
  10410. ></DIV
  10411. ></DIV
  10412. ><DIV
  10413. CLASS="sect2"
  10414. ><HR><H3
  10415. CLASS="sect2"
  10416. ><A
  10417. NAME="install.windows.build.configure"
  10418. >Configure MVC ++</A
  10419. ></H3
  10420. ><P
  10421. >        The next step is to configure MVC ++ to prepare for compiling.
  10422.        Launch Microsoft Visual C++, and from the menu select
  10423.        Tools => Options. In the dialog, select the
  10424.        directories tab. Sequentially change the dropdown
  10425.        to Executables, Includes, and Library files. Your entries should look
  10426.        like this:
  10427.        <P
  10428. ></P
  10429. ><UL
  10430. ><LI
  10431. ><P
  10432. >           Executable files: <TT
  10433. CLASS="filename"
  10434. >c:\work\win32build\bin</TT
  10435. >,
  10436.           Cygwin users: <TT
  10437. CLASS="filename"
  10438. >cygwin\bin</TT
  10439. >
  10440.          </P
  10441. ></LI
  10442. ><LI
  10443. ><P
  10444. >           Include files: <TT
  10445. CLASS="filename"
  10446. >c:\work\win32build\include</TT
  10447. >
  10448.          </P
  10449. ></LI
  10450. ><LI
  10451. ><P
  10452. >           Library files: <TT
  10453. CLASS="filename"
  10454. >c:\work\win32build\lib</TT
  10455. >
  10456.          </P
  10457. ></LI
  10458. ></UL
  10459. >
  10460.       </P
  10461. ></DIV
  10462. ><DIV
  10463. CLASS="sect2"
  10464. ><HR><H3
  10465. CLASS="sect2"
  10466. ><A
  10467. NAME="install.windows.build.resolvlib"
  10468. >Build resolv.lib</A
  10469. ></H3
  10470. ><P
  10471. >        You must build the <TT
  10472. CLASS="filename"
  10473. >resolv.lib</TT
  10474. > library.
  10475.        Decide whether you want to have debug symbols available
  10476.        (bindlib - Win32 Debug) or not (bindlib - Win32 Release).
  10477.        Build the appropriate configuration: 
  10478.        <P
  10479. ></P
  10480. ><UL
  10481. ><LI
  10482. ><P
  10483. >           For GUI users, launch VC++, and then select File => Open
  10484.           Workspace, navigate to <TT
  10485. CLASS="filename"
  10486. >c:\work\bindlib_w32</TT
  10487. > and
  10488.           select <TT
  10489. CLASS="filename"
  10490. >bindlib.dsw</TT
  10491. >. Then select Build=>Set
  10492.           Active Configuration and select the desired configuration.
  10493.           Finally select Build=>Rebuild All.
  10494.          </P
  10495. ></LI
  10496. ><LI
  10497. ><P
  10498. >           For command line users, make sure that you either have the C++
  10499.           environment variables registered, or have run
  10500.           <B
  10501. CLASS="command"
  10502. >vcvars.bat</B
  10503. >, and then execute one of the following
  10504.           commands:
  10505.          </P
  10506. ><P
  10507. ></P
  10508. ><UL
  10509. ><LI
  10510. ><P
  10511. >             <KBD
  10512. CLASS="userinput"
  10513. >msdev bindlib.dsp /MAKE "bindlib - Win32 Debug"</KBD
  10514. >
  10515.            </P
  10516. ></LI
  10517. ><LI
  10518. ><P
  10519. >             <KBD
  10520. CLASS="userinput"
  10521. >msdev bindlib.dsp /MAKE "bindlib - Win32 Release"</KBD
  10522. >
  10523.            </P
  10524. ></LI
  10525. ></UL
  10526. ></LI
  10527. ></UL
  10528. >
  10529.        At this point, you should have a usable <TT
  10530. CLASS="filename"
  10531. >resolv.lib</TT
  10532. >
  10533.        in either your <TT
  10534. CLASS="filename"
  10535. >c:\work\bindlib_w32\Debug</TT
  10536. > or
  10537.        <TT
  10538. CLASS="filename"
  10539. >Release</TT
  10540. > subdirectories. Copy this file into your
  10541.        <TT
  10542. CLASS="filename"
  10543. >c:\work\win32build\lib</TT
  10544. > directory over the file
  10545.        by the same name found in there.
  10546.       </P
  10547. ></DIV
  10548. ><DIV
  10549. CLASS="sect2"
  10550. ><HR><H3
  10551. CLASS="sect2"
  10552. ><A
  10553. NAME="install.windows.build.compile"
  10554. >Compiling</A
  10555. ></H3
  10556. ><P
  10557. >       The best way to get started is to build the CGI version.
  10558.      </P
  10559. ><P
  10560. ></P
  10561. ><UL
  10562. ><LI
  10563. ><P
  10564. >         For GUI users, launch VC++, and then select File => Open
  10565.         Workspace and select <TT
  10566. CLASS="filename"
  10567. >c:\work\php-4.x.x\win32\php4ts.dsw
  10568.         </TT
  10569. >. Then select Build=>Set Active
  10570.         Configuration and select the desired configuration, either
  10571.         <VAR
  10572. CLASS="literal"
  10573. >php4ts - Win32 Debug_TS</VAR
  10574. > or
  10575.         <VAR
  10576. CLASS="literal"
  10577. >php4ts - Win32 Release_TS</VAR
  10578. >. Finally select
  10579.         Build=>Rebuild All.
  10580.        </P
  10581. ></LI
  10582. ><LI
  10583. ><P
  10584. >         For command line users, make sure that you either have
  10585.         the C++ environment variables registered, or have run
  10586.         <B
  10587. CLASS="command"
  10588. >vcvars.bat</B
  10589. >, and then execute one of the
  10590.         following commands from the <TT
  10591. CLASS="filename"
  10592. >c:\work\php-4.x.x\win32
  10593.         </TT
  10594. > directory:
  10595.        </P
  10596. ><P
  10597. ></P
  10598. ><UL
  10599. ><LI
  10600. ><P
  10601. >           <KBD
  10602. CLASS="userinput"
  10603. >msdev php4ts.dsp /MAKE "php4ts - Win32 Debug_TS"</KBD
  10604. >
  10605.          </P
  10606. ></LI
  10607. ><LI
  10608. ><P
  10609. >           <KBD
  10610. CLASS="userinput"
  10611. >msdev php4ts.dsp /MAKE "php4ts - Win32 Release_TS"</KBD
  10612. >
  10613.          </P
  10614. ></LI
  10615. ><LI
  10616. ><P
  10617. >           At this point, you should have a usable <TT
  10618. CLASS="filename"
  10619. >php.exe</TT
  10620. >
  10621.           in either your <TT
  10622. CLASS="filename"
  10623. >c:\work\php-4.x.x.\Debug_TS</TT
  10624. > or
  10625.           <TT
  10626. CLASS="filename"
  10627. >Release_TS</TT
  10628. > subdirectories.
  10629.          </P
  10630. ></LI
  10631. ></UL
  10632. ></LI
  10633. ></UL
  10634. ><P
  10635. >       It is possible to do minor customization to the build process by editing
  10636.       the <TT
  10637. CLASS="filename"
  10638. >main/config.win32.h</TT
  10639. > file. For example you can
  10640.       change the default location of <TT
  10641. CLASS="filename"
  10642. >php.ini</TT
  10643. >, the built-in extensions, and the
  10644.       default location for your extensions.
  10645.      </P
  10646. ><P
  10647. >       Next you may want to build the CLI version which is designed to use
  10648.       <A
  10649. HREF="#features.commandline"
  10650. >PHP from the command line</A
  10651. >.
  10652.       The steps are the same as for building the CGI version, except you have
  10653.       to select the <VAR
  10654. CLASS="literal"
  10655. >php4ts_cli - Win32 Debug_TS</VAR
  10656. > or
  10657.       <VAR
  10658. CLASS="literal"
  10659. >php4ts_cli - Win32 Release_TS</VAR
  10660. > project file. After a
  10661.       successful compiling run you will find the <TT
  10662. CLASS="filename"
  10663. >php.exe</TT
  10664. >
  10665.       in either the directory <TT
  10666. CLASS="filename"
  10667. >Release_TS\cli\</TT
  10668. > or
  10669.       <TT
  10670. CLASS="filename"
  10671. >Debug_TS\cli\</TT
  10672. >.
  10673.      </P
  10674. ><DIV
  10675. CLASS="note"
  10676. ><BLOCKQUOTE
  10677. CLASS="note"
  10678. ><P
  10679. ><B
  10680. >Anmerkung: </B
  10681. >
  10682.        If you want to use PEAR and the comfortable command line installer,
  10683.        the CLI-SAPI is mandatory. For more information about PEAR and the
  10684.        installer read the documentation at the <A
  10685. HREF="http://pear.php.net/manual/"
  10686. TARGET="_top"
  10687. >        PEAR</A
  10688. > website.
  10689.       </P
  10690. ></BLOCKQUOTE
  10691. ></DIV
  10692. ><P
  10693. >       In order to build the SAPI module (<TT
  10694. CLASS="filename"
  10695. >php4isapi.dll</TT
  10696. >)
  10697.       for integrating PHP with Microsoft IIS, set your active configuration to
  10698.       <TT
  10699. CLASS="filename"
  10700. >php4isapi-whatever-config</TT
  10701. > and build the desired dll.
  10702.      </P
  10703. ></DIV
  10704. ></DIV
  10705. ><DIV
  10706. CLASS="sect1"
  10707. ><HR><H2
  10708. CLASS="sect1"
  10709. ><A
  10710. NAME="install.windows.extensions"
  10711. >Installation of extensions on Windows</A
  10712. ></H2
  10713. ><P
  10714. >      After installing PHP and a webserver on Windows, you will probably want to
  10715.      install some extensions for added functionality. You can choose which
  10716.      extensions you would like to load when PHP starts by modifying your
  10717.      <TT
  10718. CLASS="filename"
  10719. >php.ini</TT
  10720. >. You can also load a module dynamically in your script using
  10721.      <A
  10722. HREF="#function.dl"
  10723. ><B
  10724. CLASS="function"
  10725. >dl()</B
  10726. ></A
  10727. >.
  10728.     </P
  10729. ><P
  10730. >      The DLLs for PHP extensions are prefixed with <VAR
  10731. CLASS="literal"
  10732. >php_</VAR
  10733. >.
  10734.     </P
  10735. ><DIV
  10736. CLASS="note"
  10737. ><BLOCKQUOTE
  10738. CLASS="note"
  10739. ><P
  10740. ><B
  10741. >Anmerkung: </B
  10742. >
  10743.       In PHP 4.3.1 BCMath, Calendar, COM, Ctype, FTP, MySQL, ODBC, Overload,
  10744.       PCRE, Session, Tokenizer, WDDX, XML and Zlib support is
  10745.       <SPAN
  10746. CLASS="emphasis"
  10747. ><I
  10748. CLASS="emphasis"
  10749. >built in</I
  10750. ></SPAN
  10751. >. You don't need to load any additional
  10752.       extensions in order to use these functions. See your distributions
  10753.       <TT
  10754. CLASS="filename"
  10755. >README.txt</TT
  10756. > or <TT
  10757. CLASS="filename"
  10758. >install.txt</TT
  10759. >
  10760.       or <A
  10761. HREF="#install.windows.extensions.overview"
  10762. >this table</A
  10763. >
  10764.       for a list of built in modules.
  10765.      </P
  10766. ></BLOCKQUOTE
  10767. ></DIV
  10768. ><P
  10769. >      The default location PHP searches for extensions is
  10770.      <TT
  10771. CLASS="filename"
  10772. >c:\php4\extensions</TT
  10773. > in PHP 4 and
  10774.      <TT
  10775. CLASS="filename"
  10776. >c:\php5</TT
  10777. > in PHP 5. To change this
  10778.      setting to reflect your setup of PHP edit your <TT
  10779. CLASS="filename"
  10780. >php.ini</TT
  10781. > file:
  10782.      <P
  10783. ></P
  10784. ><UL
  10785. ><LI
  10786. ><P
  10787. >         You will need to change the
  10788.         <A
  10789. HREF="#ini.extension-dir"
  10790. >extension_dir</A
  10791. > setting to
  10792.         point to the directory where your extensions lives, or where you have
  10793.         placed your <TT
  10794. CLASS="filename"
  10795. >php_*.dll</TT
  10796. > files. Please do not
  10797.         forget the last backslash. For example:
  10798.         <DIV
  10799. CLASS="informalexample"
  10800. ><P
  10801. ></P
  10802. ><A
  10803. NAME="AEN1914"
  10804. ></A
  10805. ><TABLE
  10806. BORDER="0"
  10807. BGCOLOR="#E0E0E0"
  10808. CELLPADDING="5"
  10809. ><TR
  10810. ><TD
  10811. ><PRE
  10812. CLASS="ini"
  10813. >extension_dir = c:/php/extensions/</PRE
  10814. ></TD
  10815. ></TR
  10816. ></TABLE
  10817. ><P
  10818. ></P
  10819. ></DIV
  10820. >
  10821.        </P
  10822. ></LI
  10823. ><LI
  10824. ><P
  10825. >        Enable the extension(s) in <TT
  10826. CLASS="filename"
  10827. >php.ini</TT
  10828. > you want to use by uncommenting the
  10829.        <VAR
  10830. CLASS="literal"
  10831. >extension=php_*.dll</VAR
  10832. > lines in <TT
  10833. CLASS="filename"
  10834. >php.ini</TT
  10835. >. This is done
  10836.        by deleting the leading ; form the extension you want to load. 
  10837.        <TABLE
  10838. WIDTH="100%"
  10839. BORDER="0"
  10840. CELLPADDING="0"
  10841. CELLSPACING="0"
  10842. CLASS="EXAMPLE"
  10843. ><TR
  10844. ><TD
  10845. ><DIV
  10846. CLASS="example"
  10847. ><A
  10848. NAME="AEN1921"
  10849. ></A
  10850. ><P
  10851. ><B
  10852. >Beispiel 6-8. Enable <A
  10853. HREF="#ref.bzip2"
  10854. >Bzip2</A
  10855. > extension for PHP-Windows</B
  10856. ></P
  10857. ><TABLE
  10858. BORDER="0"
  10859. BGCOLOR="#E0E0E0"
  10860. CELLPADDING="5"
  10861. ><TR
  10862. ><TD
  10863. ><PRE
  10864. CLASS="ini"
  10865. >// change the following line from ...
  10866. ;extension=php_bz2.dll
  10867.  
  10868. // ... to
  10869. extension=php_bz2.dll</PRE
  10870. ></TD
  10871. ></TR
  10872. ></TABLE
  10873. ></DIV
  10874. ></TD
  10875. ></TR
  10876. ></TABLE
  10877. >      
  10878.        </P
  10879. ></LI
  10880. ><LI
  10881. ><P
  10882. >         Some of the extensions need extra DLLs to work. Couple of them can be
  10883.         found in the distribution package, in the
  10884.         <TT
  10885. CLASS="filename"
  10886. >C:\php\dlls\</TT
  10887. > folder in PHP 4 or
  10888.         in the main folder in PHP 5, but some, for example Oracle
  10889.         (<TT
  10890. CLASS="filename"
  10891. >php_oci8.dll</TT
  10892. >) require DLLs which are not bundled
  10893.         with the distribution package. If you are installing PHP 4, copy the
  10894.         bundled DLLs from <TT
  10895. CLASS="filename"
  10896. >C:\php\dlls</TT
  10897. >
  10898.         folder to the main <TT
  10899. CLASS="filename"
  10900. >C:\php</TT
  10901. >
  10902.         folder. Don't forget to include <TT
  10903. CLASS="filename"
  10904. >C:\php</TT
  10905. > in the system
  10906.         <VAR
  10907. CLASS="varname"
  10908. >PATH</VAR
  10909. > (this process is explained in a separate <A
  10910. HREF="#faq.installation.addtopath"
  10911. >FAQ entry</A
  10912. >).
  10913.        </P
  10914. ></LI
  10915. ></UL
  10916. >
  10917.    <DIV
  10918. CLASS="note"
  10919. ><BLOCKQUOTE
  10920. CLASS="note"
  10921. ><P
  10922. ><B
  10923. >Anmerkung: </B
  10924. >
  10925.      If you are running a server module version of PHP
  10926.      remember to restart your webserver to reflect your changes to <TT
  10927. CLASS="filename"
  10928. >php.ini</TT
  10929. >.
  10930.     </P
  10931. ></BLOCKQUOTE
  10932. ></DIV
  10933. >
  10934.    </P
  10935. ><P
  10936. >     The following table describes some of the extensions available and required
  10937.     additional dlls.   
  10938.     <DIV
  10939. CLASS="table"
  10940. ><A
  10941. NAME="install.windows.extensions.overview"
  10942. ></A
  10943. ><P
  10944. ><B
  10945. >Tabelle 6-1. PHP Extensions</B
  10946. ></P
  10947. ><TABLE
  10948. BORDER="1"
  10949. CLASS="CALSTABLE"
  10950. ><COL><COL><COL><THEAD
  10951. ><TR
  10952. ><TH
  10953. >Extension</TH
  10954. ><TH
  10955. >Description</TH
  10956. ><TH
  10957. >Notes</TH
  10958. ></TR
  10959. ></THEAD
  10960. ><TBODY
  10961. ><TR
  10962. ><TD
  10963. >php_bz2.dll</TD
  10964. ><TD
  10965. ><A
  10966. HREF="#ref.bzip2"
  10967. >bzip2</A
  10968. > compression functions</TD
  10969. ><TD
  10970. >None</TD
  10971. ></TR
  10972. ><TR
  10973. ><TD
  10974. >php_calendar.dll</TD
  10975. ><TD
  10976. ><A
  10977. HREF="#ref.calendar"
  10978. >Calendar</A
  10979. > conversion functions</TD
  10980. ><TD
  10981. >Built in since PHP 4.0.3</TD
  10982. ></TR
  10983. ><TR
  10984. ><TD
  10985. >php_cpdf.dll</TD
  10986. ><TD
  10987. ><A
  10988. HREF="#ref.cpdf"
  10989. >ClibPDF</A
  10990. > functions</TD
  10991. ><TD
  10992. >None</TD
  10993. ></TR
  10994. ><TR
  10995. ><TD
  10996. >php_crack.dll</TD
  10997. ><TD
  10998. ><A
  10999. HREF="#ref.crack"
  11000. >Crack</A
  11001. > functions</TD
  11002. ><TD
  11003. >None</TD
  11004. ></TR
  11005. ><TR
  11006. ><TD
  11007. >php_ctype.dll</TD
  11008. ><TD
  11009. ><A
  11010. HREF="#ref.ctype"
  11011. >ctype</A
  11012. > family functions</TD
  11013. ><TD
  11014. >Built in since PHP 4.3.0</TD
  11015. ></TR
  11016. ><TR
  11017. ><TD
  11018. >php_curl.dll</TD
  11019. ><TD
  11020. ><A
  11021. HREF="#ref.curl"
  11022. >CURL</A
  11023. >, Client URL library functions</TD
  11024. ><TD
  11025. >Requires: <TT
  11026. CLASS="filename"
  11027. >libeay32.dll</TT
  11028. >, 
  11029.    <TT
  11030. CLASS="filename"
  11031. >ssleay32.dll</TT
  11032. > (bundled)</TD
  11033. ></TR
  11034. ><TR
  11035. ><TD
  11036. >php_cybercash.dll</TD
  11037. ><TD
  11038. ><A
  11039. HREF="#ref.cybercash"
  11040. >Cybercash</A
  11041. > payment functions</TD
  11042. ><TD
  11043. >PHP <= 4.2.0</TD
  11044. ></TR
  11045. ><TR
  11046. ><TD
  11047. >php_db.dll</TD
  11048. ><TD
  11049. ><A
  11050. HREF="#ref.dbm"
  11051. >DBM</A
  11052. > functions</TD
  11053. ><TD
  11054. >Deprecated. Use DBA instead (<TT
  11055. CLASS="filename"
  11056. >php_dba.dll</TT
  11057. >)</TD
  11058. ></TR
  11059. ><TR
  11060. ><TD
  11061. >php_dba.dll</TD
  11062. ><TD
  11063. ><A
  11064. HREF="#ref.dba"
  11065. >DBA</A
  11066. >: DataBase (dbm-style) 
  11067.    Abstraction layer functions</TD
  11068. ><TD
  11069. >None</TD
  11070. ></TR
  11071. ><TR
  11072. ><TD
  11073. >php_dbase.dll</TD
  11074. ><TD
  11075. ><A
  11076. HREF="#ref.dbase"
  11077. >dBase</A
  11078. > functions</TD
  11079. ><TD
  11080. >None</TD
  11081. ></TR
  11082. ><TR
  11083. ><TD
  11084. >php_dbx.dll</TD
  11085. ><TD
  11086. ><A
  11087. HREF="#ref.dbx"
  11088. >dbx</A
  11089. > functions</TD
  11090. ><TD
  11091. > </TD
  11092. ></TR
  11093. ><TR
  11094. ><TD
  11095. >php_domxml.dll</TD
  11096. ><TD
  11097. ><A
  11098. HREF="#ref.domxml"
  11099. >DOM XML</A
  11100. > functions</TD
  11101. ><TD
  11102. >     PHP <= 4.2.0 requires: <TT
  11103. CLASS="filename"
  11104. >libxml2.dll</TT
  11105. > (bundled)
  11106.     PHP >= 4.3.0 requires: <TT
  11107. CLASS="filename"
  11108. >iconv.dll</TT
  11109. > (bundled)
  11110.    </TD
  11111. ></TR
  11112. ><TR
  11113. ><TD
  11114. >php_dotnet.dll</TD
  11115. ><TD
  11116. ><A
  11117. HREF="#ref.dotnet"
  11118. >.NET</A
  11119. > functions</TD
  11120. ><TD
  11121. >PHP <= 4.1.1</TD
  11122. ></TR
  11123. ><TR
  11124. ><TD
  11125. >php_exif.dll</TD
  11126. ><TD
  11127. ><A
  11128. HREF="#function.read-exif-data"
  11129. >Read EXIF</A
  11130. > headers from JPEG</TD
  11131. ><TD
  11132. >None</TD
  11133. ></TR
  11134. ><TR
  11135. ><TD
  11136. >php_fbsql.dll</TD
  11137. ><TD
  11138. ><A
  11139. HREF="#ref.fbsql"
  11140. >FrontBase</A
  11141. > functions</TD
  11142. ><TD
  11143. >PHP <= 4.2.0</TD
  11144. ></TR
  11145. ><TR
  11146. ><TD
  11147. >php_fdf.dll</TD
  11148. ><TD
  11149. ><A
  11150. HREF="#ref.fdf"
  11151. >FDF</A
  11152. >: Forms Data Format functions.</TD
  11153. ><TD
  11154. >Requires: <TT
  11155. CLASS="filename"
  11156. >fdftk.dll</TT
  11157. > (bundled)</TD
  11158. ></TR
  11159. ><TR
  11160. ><TD
  11161. >php_filepro.dll</TD
  11162. ><TD
  11163. ><A
  11164. HREF="#ref.filepro"
  11165. >filePro</A
  11166. > functions</TD
  11167. ><TD
  11168. >Read-only access</TD
  11169. ></TR
  11170. ><TR
  11171. ><TD
  11172. >php_ftp.dll</TD
  11173. ><TD
  11174. ><A
  11175. HREF="#ref.ftp"
  11176. >FTP</A
  11177. > functions</TD
  11178. ><TD
  11179. >Built-in since PHP 4.0.3</TD
  11180. ></TR
  11181. ><TR
  11182. ><TD
  11183. >php_gd.dll</TD
  11184. ><TD
  11185. ><A
  11186. HREF="#ref.image"
  11187. >GD</A
  11188. > library image functions</TD
  11189. ><TD
  11190. >     Removed in PHP 4.3.2.  Also note that truecolor functions are not
  11191.     available in GD1, instead, use <TT
  11192. CLASS="filename"
  11193. >php_gd2.dll</TT
  11194. >.
  11195.    </TD
  11196. ></TR
  11197. ><TR
  11198. ><TD
  11199. >php_gd2.dll</TD
  11200. ><TD
  11201. ><A
  11202. HREF="#ref.image"
  11203. >GD</A
  11204. > library image functions</TD
  11205. ><TD
  11206. >GD2</TD
  11207. ></TR
  11208. ><TR
  11209. ><TD
  11210. >php_gettext.dll</TD
  11211. ><TD
  11212. ><A
  11213. HREF="#ref.gettext"
  11214. >Gettext</A
  11215. > functions</TD
  11216. ><TD
  11217. >     PHP <= 4.2.0 requires <TT
  11218. CLASS="filename"
  11219. >gnu_gettext.dll</TT
  11220. > (bundled), 
  11221.     PHP >= 4.2.3 requires <TT
  11222. CLASS="filename"
  11223. >libintl-1.dll</TT
  11224. >,
  11225.     <TT
  11226. CLASS="filename"
  11227. >iconv.dll</TT
  11228. > (bundled).
  11229.    </TD
  11230. ></TR
  11231. ><TR
  11232. ><TD
  11233. >php_hyperwave.dll</TD
  11234. ><TD
  11235. ><A
  11236. HREF="#ref.hw"
  11237. >HyperWave</A
  11238. > functions</TD
  11239. ><TD
  11240. >None</TD
  11241. ></TR
  11242. ><TR
  11243. ><TD
  11244. >php_iconv.dll</TD
  11245. ><TD
  11246. ><A
  11247. HREF="#ref.iconv"
  11248. >ICONV</A
  11249. > characterset conversion</TD
  11250. ><TD
  11251. >Requires: <TT
  11252. CLASS="filename"
  11253. >iconv-1.3.dll</TT
  11254. > (bundled), 
  11255.    PHP >=4.2.1 <TT
  11256. CLASS="filename"
  11257. >iconv.dll</TT
  11258. ></TD
  11259. ></TR
  11260. ><TR
  11261. ><TD
  11262. >php_ifx.dll</TD
  11263. ><TD
  11264. ><A
  11265. HREF="#ref.ifx"
  11266. >Informix</A
  11267. > functions</TD
  11268. ><TD
  11269. >Requires: Informix libraries</TD
  11270. ></TR
  11271. ><TR
  11272. ><TD
  11273. >php_iisfunc.dll</TD
  11274. ><TD
  11275. >IIS management functions</TD
  11276. ><TD
  11277. >None</TD
  11278. ></TR
  11279. ><TR
  11280. ><TD
  11281. >php_imap.dll</TD
  11282. ><TD
  11283. ><A
  11284. HREF="#ref.imap"
  11285. >IMAP</A
  11286. > POP3 and NNTP functions</TD
  11287. ><TD
  11288. >None</TD
  11289. ></TR
  11290. ><TR
  11291. ><TD
  11292. >php_ingres.dll</TD
  11293. ><TD
  11294. ><A
  11295. HREF="#ref.ingres"
  11296. >Ingres II</A
  11297. > functions</TD
  11298. ><TD
  11299. >Requires: Ingres II libraries</TD
  11300. ></TR
  11301. ><TR
  11302. ><TD
  11303. >php_interbase.dll</TD
  11304. ><TD
  11305. ><A
  11306. HREF="#ref.ibase"
  11307. >InterBase</A
  11308. > functions</TD
  11309. ><TD
  11310. >Requires: <TT
  11311. CLASS="filename"
  11312. >gds32.dll</TT
  11313. > (bundled)</TD
  11314. ></TR
  11315. ><TR
  11316. ><TD
  11317. >php_java.dll</TD
  11318. ><TD
  11319. ><A
  11320. HREF="#ref.java"
  11321. >Java</A
  11322. > functions</TD
  11323. ><TD
  11324. >PHP <= 4.0.6 requires: <TT
  11325. CLASS="filename"
  11326. >jvm.dll</TT
  11327. > (bundled)</TD
  11328. ></TR
  11329. ><TR
  11330. ><TD
  11331. >php_ldap.dll</TD
  11332. ><TD
  11333. ><A
  11334. HREF="#ref.ldap"
  11335. >LDAP</A
  11336. > functions</TD
  11337. ><TD
  11338. >     PHP <= 4.2.0 requires <TT
  11339. CLASS="filename"
  11340. >libsasl.dll</TT
  11341. > (bundled), 
  11342.     PHP >= 4.3.0 requires <TT
  11343. CLASS="filename"
  11344. >libeay32.dll</TT
  11345. >, 
  11346.     <TT
  11347. CLASS="filename"
  11348. >ssleay32.dll</TT
  11349. > (bundled)
  11350.    </TD
  11351. ></TR
  11352. ><TR
  11353. ><TD
  11354. >php_mbstring.dll</TD
  11355. ><TD
  11356. ><A
  11357. HREF="#ref.mbstring"
  11358. >Multi-Byte String</A
  11359. > functions</TD
  11360. ><TD
  11361. >None</TD
  11362. ></TR
  11363. ><TR
  11364. ><TD
  11365. >php_mcrypt.dll</TD
  11366. ><TD
  11367. ><A
  11368. HREF="#ref.mcrypt"
  11369. >Mcrypt Encryption</A
  11370. > functions</TD
  11371. ><TD
  11372. >Requires: <TT
  11373. CLASS="filename"
  11374. >libmcrypt.dll</TT
  11375. ></TD
  11376. ></TR
  11377. ><TR
  11378. ><TD
  11379. >php_mhash.dll</TD
  11380. ><TD
  11381. ><A
  11382. HREF="#ref.mhash"
  11383. >Mhash</A
  11384. > functions</TD
  11385. ><TD
  11386. >PHP >= 4.3.0 requires: <TT
  11387. CLASS="filename"
  11388. >libmhash.dll</TT
  11389. > (bundled)</TD
  11390. ></TR
  11391. ><TR
  11392. ><TD
  11393. >php_mime_magic.dll</TD
  11394. ><TD
  11395. ><A
  11396. HREF="#ref.mime-magic"
  11397. >Mimetype</A
  11398. > functions</TD
  11399. ><TD
  11400. >Requires: <TT
  11401. CLASS="filename"
  11402. >magic.mime</TT
  11403. > (bundled)</TD
  11404. ></TR
  11405. ><TR
  11406. ><TD
  11407. >php_ming.dll</TD
  11408. ><TD
  11409. ><A
  11410. HREF="#ref.ming"
  11411. >Ming</A
  11412. > functions for Flash</TD
  11413. ><TD
  11414. >None</TD
  11415. ></TR
  11416. ><TR
  11417. ><TD
  11418. >php_msql.dll</TD
  11419. ><TD
  11420. ><A
  11421. HREF="#ref.msql"
  11422. >mSQL</A
  11423. > functions</TD
  11424. ><TD
  11425. >Requires: <TT
  11426. CLASS="filename"
  11427. >msql.dll</TT
  11428. > (bundled)</TD
  11429. ></TR
  11430. ><TR
  11431. ><TD
  11432. >php_mssql.dll</TD
  11433. ><TD
  11434. ><A
  11435. HREF="#ref.mssql"
  11436. >MSSQL</A
  11437. > functions</TD
  11438. ><TD
  11439. >Requires: <TT
  11440. CLASS="filename"
  11441. >ntwdblib.dll</TT
  11442. > (bundled)</TD
  11443. ></TR
  11444. ><TR
  11445. ><TD
  11446. >php_mysql.dll</TD
  11447. ><TD
  11448. ><A
  11449. HREF="#ref.mysql"
  11450. >MySQL</A
  11451. > functions</TD
  11452. ><TD
  11453. >PHP >= 5.0.0, requires <TT
  11454. CLASS="filename"
  11455. >libmysql.dll</TT
  11456. >
  11457.     (bundled)</TD
  11458. ></TR
  11459. ><TR
  11460. ><TD
  11461. >php_mysqli.dll</TD
  11462. ><TD
  11463. ><A
  11464. HREF="#ref.mysqli"
  11465. >MySQLi</A
  11466. > functions</TD
  11467. ><TD
  11468. >PHP >= 5.0.0, requires <TT
  11469. CLASS="filename"
  11470. >libmysqli.dll</TT
  11471. >
  11472.     (bundled)</TD
  11473. ></TR
  11474. ><TR
  11475. ><TD
  11476. >php_oci8.dll</TD
  11477. ><TD
  11478. ><A
  11479. HREF="#ref.oci8"
  11480. >Oracle 8</A
  11481. > functions</TD
  11482. ><TD
  11483. >Requires: Oracle 8.1+ client libraries</TD
  11484. ></TR
  11485. ><TR
  11486. ><TD
  11487. >php_openssl.dll</TD
  11488. ><TD
  11489. ><A
  11490. HREF="#ref.openssl"
  11491. >OpenSSL</A
  11492. > functions</TD
  11493. ><TD
  11494. >Requires: <TT
  11495. CLASS="filename"
  11496. >libeay32.dll</TT
  11497. > (bundled)</TD
  11498. ></TR
  11499. ><TR
  11500. ><TD
  11501. >php_oracle.dll</TD
  11502. ><TD
  11503. ><A
  11504. HREF="#ref.oracle"
  11505. >Oracle</A
  11506. > functions</TD
  11507. ><TD
  11508. >Requires: Oracle 7 client libraries</TD
  11509. ></TR
  11510. ><TR
  11511. ><TD
  11512. >php_overload.dll</TD
  11513. ><TD
  11514. ><A
  11515. HREF="#ref.overload"
  11516. >Object overloading</A
  11517. > functions</TD
  11518. ><TD
  11519. >Built in since PHP 4.3.0</TD
  11520. ></TR
  11521. ><TR
  11522. ><TD
  11523. >php_pdf.dll</TD
  11524. ><TD
  11525. ><A
  11526. HREF="#ref.pdf"
  11527. >PDF</A
  11528. > functions</TD
  11529. ><TD
  11530. >None</TD
  11531. ></TR
  11532. ><TR
  11533. ><TD
  11534. >php_pgsql.dll</TD
  11535. ><TD
  11536. ><A
  11537. HREF="#ref.pgsql"
  11538. >PostgreSQL</A
  11539. > functions</TD
  11540. ><TD
  11541. >None</TD
  11542. ></TR
  11543. ><TR
  11544. ><TD
  11545. >php_printer.dll</TD
  11546. ><TD
  11547. ><A
  11548. HREF="#ref.printer"
  11549. >Printer</A
  11550. > functions</TD
  11551. ><TD
  11552. >None</TD
  11553. ></TR
  11554. ><TR
  11555. ><TD
  11556. >php_shmop.dll</TD
  11557. ><TD
  11558. ><A
  11559. HREF="#ref.shmop"
  11560. >Shared Memory</A
  11561. > functions</TD
  11562. ><TD
  11563. >None</TD
  11564. ></TR
  11565. ><TR
  11566. ><TD
  11567. >php_snmp.dll</TD
  11568. ><TD
  11569. ><A
  11570. HREF="#ref.snmp"
  11571. >SNMP</A
  11572. > get and walk functions</TD
  11573. ><TD
  11574. >NT only!</TD
  11575. ></TR
  11576. ><TR
  11577. ><TD
  11578. >php_soap.dll</TD
  11579. ><TD
  11580. ><A
  11581. HREF="#ref.soap"
  11582. >SOAP</A
  11583. > functions</TD
  11584. ><TD
  11585. >PHP >= 5.0.0</TD
  11586. ></TR
  11587. ><TR
  11588. ><TD
  11589. >php_sockets.dll</TD
  11590. ><TD
  11591. ><A
  11592. HREF="#ref.sockets"
  11593. >Socket</A
  11594. > functions</TD
  11595. ><TD
  11596. >None</TD
  11597. ></TR
  11598. ><TR
  11599. ><TD
  11600. >php_sybase_ct.dll</TD
  11601. ><TD
  11602. ><A
  11603. HREF="#ref.sybase"
  11604. >Sybase</A
  11605. > functions</TD
  11606. ><TD
  11607. >Requires: Sybase client libraries</TD
  11608. ></TR
  11609. ><TR
  11610. ><TD
  11611. >php_tidy.dll</TD
  11612. ><TD
  11613. ><A
  11614. HREF="#ref.tidy"
  11615. >Tidy</A
  11616. > functions</TD
  11617. ><TD
  11618. >PHP >= 5.0.0</TD
  11619. ></TR
  11620. ><TR
  11621. ><TD
  11622. >php_tokenizer.dll</TD
  11623. ><TD
  11624. ><A
  11625. HREF="#ref.tokenizer"
  11626. >Tokenizer</A
  11627. > functions</TD
  11628. ><TD
  11629. >Built in since PHP 4.3.0</TD
  11630. ></TR
  11631. ><TR
  11632. ><TD
  11633. >php_w32api.dll</TD
  11634. ><TD
  11635. ><A
  11636. HREF="#ref.w32api"
  11637. >W32api</A
  11638. > functions</TD
  11639. ><TD
  11640. >None</TD
  11641. ></TR
  11642. ><TR
  11643. ><TD
  11644. >php_xmlrpc.dll</TD
  11645. ><TD
  11646. ><A
  11647. HREF="#ref.xmlrpc"
  11648. >XML-RPC</A
  11649. > functions</TD
  11650. ><TD
  11651. >PHP >= 4.2.1 requires: <TT
  11652. CLASS="filename"
  11653. >iconv.dll</TT
  11654. > (bundled)</TD
  11655. ></TR
  11656. ><TR
  11657. ><TD
  11658. >php_xslt.dll</TD
  11659. ><TD
  11660. ><A
  11661. HREF="#ref.xslt"
  11662. >XSLT</A
  11663. > functions</TD
  11664. ><TD
  11665. >     PHP <= 4.2.0 requires <TT
  11666. CLASS="filename"
  11667. >sablot.dll</TT
  11668. >,
  11669.     <TT
  11670. CLASS="filename"
  11671. >expat.dll</TT
  11672. > (bundled). PHP >= 4.2.1 requires
  11673.     <TT
  11674. CLASS="filename"
  11675. >sablot.dll</TT
  11676. >, <TT
  11677. CLASS="filename"
  11678. >expat.dll</TT
  11679. >,
  11680.     <TT
  11681. CLASS="filename"
  11682. >iconv.dll</TT
  11683. > (bundled).
  11684.    </TD
  11685. ></TR
  11686. ><TR
  11687. ><TD
  11688. >php_yaz.dll</TD
  11689. ><TD
  11690. ><A
  11691. HREF="#ref.yaz"
  11692. >YAZ</A
  11693. > functions</TD
  11694. ><TD
  11695. >Requires: <TT
  11696. CLASS="filename"
  11697. >yaz.dll</TT
  11698. > (bundled)</TD
  11699. ></TR
  11700. ><TR
  11701. ><TD
  11702. >php_zip.dll</TD
  11703. ><TD
  11704. ><A
  11705. HREF="#ref.zip"
  11706. >Zip File</A
  11707. > functions</TD
  11708. ><TD
  11709. >Read only access</TD
  11710. ></TR
  11711. ><TR
  11712. ><TD
  11713. >php_zlib.dll</TD
  11714. ><TD
  11715. ><A
  11716. HREF="#ref.zlib"
  11717. >ZLib</A
  11718. > compression functions</TD
  11719. ><TD
  11720. >Built in since PHP 4.3.0</TD
  11721. ></TR
  11722. ></TBODY
  11723. ></TABLE
  11724. ></DIV
  11725. >
  11726.     </P
  11727. ></DIV
  11728. ></DIV
  11729. ><DIV
  11730. CLASS="chapter"
  11731. ><HR><H1
  11732. ><A
  11733. NAME="install.problems"
  11734. >Kapitel 7. Problems?</A
  11735. ></H1
  11736. ><DIV
  11737. CLASS="sect1"
  11738. ><H2
  11739. CLASS="sect1"
  11740. ><A
  11741. NAME="install.problems.faq"
  11742. >Read the FAQ</A
  11743. ></H2
  11744. ><P
  11745. >      Some problems are more common than others. The most
  11746.      common ones are listed in the <A
  11747. HREF="#faq"
  11748. >PHP
  11749.      FAQ</A
  11750. >, part of this manual.
  11751.     </P
  11752. ></DIV
  11753. ><DIV
  11754. CLASS="sect1"
  11755. ><HR><H2
  11756. CLASS="sect1"
  11757. ><A
  11758. NAME="install.problems.support"
  11759. >Other problems</A
  11760. ></H2
  11761. ><P
  11762. >      If you are still stuck, someone on the PHP installation mailing list may be
  11763.      able to help you. You should check out the archive first, in case
  11764.      someone already answered someone else who had the same problem as
  11765.      you. The archives are available from the support page on <A
  11766. HREF="http://www.php.net/support.php"
  11767. TARGET="_top"
  11768. >http://www.php.net/support.php</A
  11769. >. To subscribe to the PHP installation
  11770.      mailing list, send an empty mail to <A
  11771. HREF="mailto:php-install-subscribe@lists.php.net"
  11772. TARGET="_top"
  11773. >php-install-subscribe@lists.php.net</A
  11774. >.
  11775.      The mailing list address is <A
  11776. HREF="mailto:php-install@lists.php.net"
  11777. TARGET="_top"
  11778. >php-install@lists.php.net</A
  11779. >.
  11780.     </P
  11781. ><P
  11782. >      If you want to get help on the mailing list, please try to be
  11783.      precise and give the necessary details about your environment
  11784.      (which operating system, what PHP version, what web server, if
  11785.      you are running PHP as CGI or a server module, <A
  11786. HREF="#ini.safe-mode"
  11787. >Safe Mode</A
  11788. >, etc...), and
  11789.      preferably enough code to make others able to reproduce and test
  11790.      your problem.
  11791.     </P
  11792. ></DIV
  11793. ><DIV
  11794. CLASS="sect1"
  11795. ><HR><H2
  11796. CLASS="sect1"
  11797. ><A
  11798. NAME="install.problems.bugs"
  11799. >Bug reports</A
  11800. ></H2
  11801. ><P
  11802. >      If you think you have found a bug in PHP, please report it.  The
  11803.      PHP developers probably don't know about it, and unless you
  11804.      report it, chances are it won't be fixed. You can report bugs
  11805.      using the bug-tracking system at <A
  11806. HREF="http://bugs.php.net/"
  11807. TARGET="_top"
  11808. >http://bugs.php.net/</A
  11809. >. Please do not
  11810.      send bug reports in mailing list or personal letters. The
  11811.      bug system is also suitable to submit feature requests.
  11812.     </P
  11813. ><P
  11814. >      Read the <A
  11815. HREF="http://bugs.php.net/how-to-report.php"
  11816. TARGET="_top"
  11817. >How to report a bug</A
  11818.      document before submitting any bug reports!
  11819.     </P
  11820. ></DIV
  11821. ></DIV
  11822. ><DIV
  11823. CLASS="chapter"
  11824. ><HR><H1
  11825. ><A
  11826. NAME="configuration"
  11827. >Kapitel 8. Runtime Configuration</A
  11828. ></H1
  11829. ><DIV
  11830. CLASS="sect1"
  11831. ><H2
  11832. CLASS="sect1"
  11833. ><A
  11834. NAME="configuration.file"
  11835. >The configuration file</A
  11836. ></H2
  11837. ><P
  11838. >     The configuration file (called <TT
  11839. CLASS="filename"
  11840. >php3.ini</TT
  11841. > in
  11842.     PHP 3, and simply <TT
  11843. CLASS="filename"
  11844. >php.ini</TT
  11845. > as of PHP 4)
  11846.     is read when PHP starts up. For the server module versions of PHP,
  11847.     this happens only once when the web server is started. For the
  11848.     <ACRONYM
  11849. CLASS="acronym"
  11850. >CGI</ACRONYM
  11851. > and <ACRONYM
  11852. CLASS="acronym"
  11853. >CLI</ACRONYM
  11854. > version, it happens on
  11855.     every invocation.
  11856.    </P
  11857. ><P
  11858. >     The default location of <TT
  11859. CLASS="filename"
  11860. >php.ini</TT
  11861. > is a compile time option (see the <A
  11862. HREF="#faq.installation.phpini"
  11863. >FAQ</A
  11864. > entry), but can be changed
  11865.     for the <ACRONYM
  11866. CLASS="acronym"
  11867. >CGI</ACRONYM
  11868. > and <ACRONYM
  11869. CLASS="acronym"
  11870. >CLI</ACRONYM
  11871. > version with the
  11872.     <VAR
  11873. CLASS="literal"
  11874. >-c</VAR
  11875. > command line switch, see the chapter about using
  11876.     PHP from the <A
  11877. HREF="#features.commandline"
  11878. >command line</A
  11879. >. You can also use the
  11880.     environment variable <VAR
  11881. CLASS="varname"
  11882. >PHPRC</VAR
  11883. > for an additional path to
  11884.     search for a <TT
  11885. CLASS="filename"
  11886. >php.ini</TT
  11887. > file.
  11888.    </P
  11889. ><P
  11890. >     If <TT
  11891. CLASS="filename"
  11892. >php-SAPI.ini</TT
  11893. > exists (where SAPI is used SAPI, so the
  11894.     filename is e.g. <TT
  11895. CLASS="filename"
  11896. >php-cli.ini</TT
  11897. > or
  11898.     <TT
  11899. CLASS="filename"
  11900. >php-apache.ini</TT
  11901. >), it's used instead of <TT
  11902. CLASS="filename"
  11903. >php.ini</TT
  11904. >.
  11905.    </P
  11906. ><DIV
  11907. CLASS="note"
  11908. ><BLOCKQUOTE
  11909. CLASS="note"
  11910. ><P
  11911. ><B
  11912. >Anmerkung: </B
  11913. >
  11914.      The Apache web server changes the directory to root at startup causing
  11915.      PHP to attempt to read <TT
  11916. CLASS="filename"
  11917. >php.ini</TT
  11918. > from the root filesystem if it exists.
  11919.     </P
  11920. ></BLOCKQUOTE
  11921. ></DIV
  11922. ><P
  11923. >     The <TT
  11924. CLASS="filename"
  11925. >php.ini</TT
  11926. > directives handled by extensions are documented respectively
  11927.     on the pages of the extensions themselfs. The <A
  11928. HREF="#ini"
  11929. >list of
  11930.     the core directives</A
  11931. > is available in the appendix. Probably not all
  11932.     the PHP directives are documented in the manual though. For a completel list
  11933.     of directives available in your PHP version, please read your well commented
  11934.     <TT
  11935. CLASS="filename"
  11936. >php.ini</TT
  11937. > file. Alternatively, you may find the
  11938.     <A
  11939. HREF="http://cvs.php.net/co.php/php-src/php.ini-dist"
  11940. TARGET="_top"
  11941. >the latest <TT
  11942. CLASS="filename"
  11943. >php.ini</TT
  11944. ></A
  11945. > from CVS
  11946.     helpful too.
  11947.    </P
  11948. ><P
  11949. >     <TABLE
  11950. WIDTH="100%"
  11951. BORDER="0"
  11952. CELLPADDING="0"
  11953. CELLSPACING="0"
  11954. CLASS="EXAMPLE"
  11955. ><TR
  11956. ><TD
  11957. ><DIV
  11958. CLASS="example"
  11959. ><A
  11960. NAME="AEN2326"
  11961. ></A
  11962. ><P
  11963. ><B
  11964. >Beispiel 8-1. <TT
  11965. CLASS="filename"
  11966. >php.ini</TT
  11967. > example</B
  11968. ></P
  11969. ><TABLE
  11970. BORDER="0"
  11971. BGCOLOR="#E0E0E0"
  11972. CELLPADDING="5"
  11973. ><TR
  11974. ><TD
  11975. ><PRE
  11976. CLASS="ini"
  11977. >; any text on a line after an unquoted semicolon (;) is ignored
  11978. [php] ; section markers (text within square brackets) are also ignored
  11979. ; Boolean values can be set to either:
  11980. ;    true, on, yes
  11981. ; or false, off, no, none
  11982. register_globals = off
  11983. track_errors = yes
  11984.  
  11985. ; you can enclose strings in double-quotes
  11986. include_path = ".:/usr/local/lib/php"
  11987.  
  11988. ; backslashes are treated the same as any other character
  11989. include_path = ".;c:\php\lib"</PRE
  11990. ></TD
  11991. ></TR
  11992. ></TABLE
  11993. ></DIV
  11994. ></TD
  11995. ></TR
  11996. ></TABLE
  11997. >
  11998.    </P
  11999. ></DIV
  12000. ><DIV
  12001. CLASS="sect1"
  12002. ><HR><H2
  12003. CLASS="sect1"
  12004. ><A
  12005. NAME="configuration.changes"
  12006. >How to change configuration settings</A
  12007. ></H2
  12008. ><DIV
  12009. CLASS="sect2"
  12010. ><H3
  12011. CLASS="sect2"
  12012. ><A
  12013. NAME="configuration.changes.apache"
  12014. >Running PHP as an Apache module</A
  12015. ></H3
  12016. ><P
  12017. >      When using PHP as an Apache module, you can also change the
  12018.      configuration settings using directives in Apache configuration
  12019.      files (e.g. <TT
  12020. CLASS="filename"
  12021. >httpd.conf</TT
  12022. >) and <TT
  12023. CLASS="filename"
  12024. >.htaccess</TT
  12025. > files. You will need
  12026.      "AllowOverride Options" or "AllowOverride All" privileges to do so.
  12027.     </P
  12028. ><P
  12029. >      With PHP 4 and PHP 5, there are several Apache directives that allow you
  12030.      to change the PHP configuration from within the Apache configuration
  12031.      files.  For a listing of which directives are 
  12032.      <TT
  12033. CLASS="constant"
  12034. ><B
  12035. >PHP_INI_ALL</B
  12036. ></TT
  12037. >, <TT
  12038. CLASS="constant"
  12039. ><B
  12040. >PHP_INI_PERDIR</B
  12041. ></TT
  12042. >, 
  12043.      or <TT
  12044. CLASS="constant"
  12045. ><B
  12046. >PHP_INI_SYSTEM</B
  12047. ></TT
  12048. >, have a look at the table
  12049.      found within the <A
  12050. HREF="#function.ini-set"
  12051. ><B
  12052. CLASS="function"
  12053. >ini_set()</B
  12054. ></A
  12055. > documentation.
  12056.     </P
  12057. ><DIV
  12058. CLASS="note"
  12059. ><BLOCKQUOTE
  12060. CLASS="note"
  12061. ><P
  12062. ><B
  12063. >Anmerkung: </B
  12064. >
  12065.       With PHP 3, there are Apache directives that correspond to each
  12066.       configuration setting in the <TT
  12067. CLASS="filename"
  12068. >php3.ini</TT
  12069. > name,
  12070.       except the name is prefixed by "php3_".
  12071.      </P
  12072. ></BLOCKQUOTE
  12073. ></DIV
  12074. ><P
  12075. >      <P
  12076. ></P
  12077. ><DIV
  12078. CLASS="variablelist"
  12079. ><DL
  12080. ><DT
  12081. ><SPAN
  12082. CLASS="systemitem"
  12083. >php_value</SPAN
  12084. >
  12085.         <VAR
  12086. CLASS="parameter"
  12087. >name</VAR
  12088. >
  12089.         <VAR
  12090. CLASS="parameter"
  12091. >value</VAR
  12092. ></DT
  12093. ><DD
  12094. ><P
  12095. >          Sets the value of the specified directive.
  12096.          Can be used only with <TT
  12097. CLASS="constant"
  12098. ><B
  12099. >PHP_INI_ALL</B
  12100. ></TT
  12101. > and <TT
  12102. CLASS="constant"
  12103. ><B
  12104. >PHP_INI_PERDIR</B
  12105. ></TT
  12106. > type directives.
  12107.          To clear a previously set value use <VAR
  12108. CLASS="literal"
  12109. >none</VAR
  12110. > as the value.
  12111.         </P
  12112. ><DIV
  12113. CLASS="note"
  12114. ><BLOCKQUOTE
  12115. CLASS="note"
  12116. ><P
  12117. ><B
  12118. >Anmerkung: </B
  12119. >
  12120.           Don't use <SPAN
  12121. CLASS="systemitem"
  12122. >php_value</SPAN
  12123. > to set boolean values.
  12124.           <SPAN
  12125. CLASS="systemitem"
  12126. >php_flag</SPAN
  12127. > (see below) should be used instead.
  12128.          </P
  12129. ></BLOCKQUOTE
  12130. ></DIV
  12131. ></DD
  12132. ><DT
  12133. ><SPAN
  12134. CLASS="systemitem"
  12135. >php_flag</SPAN
  12136. >
  12137.         <VAR
  12138. CLASS="parameter"
  12139. >name</VAR
  12140. >
  12141.         <VAR
  12142. CLASS="parameter"
  12143. >on|off</VAR
  12144. ></DT
  12145. ><DD
  12146. ><P
  12147. >          Used to set a boolean configuration directive.
  12148.          Can be used only with <TT
  12149. CLASS="constant"
  12150. ><B
  12151. >PHP_INI_ALL</B
  12152. ></TT
  12153. > and
  12154.          <TT
  12155. CLASS="constant"
  12156. ><B
  12157. >PHP_INI_PERDIR</B
  12158. ></TT
  12159. > type directives.
  12160.         </P
  12161. ></DD
  12162. ><DT
  12163. ><SPAN
  12164. CLASS="systemitem"
  12165. >php_admin_value</SPAN
  12166. >
  12167.         <VAR
  12168. CLASS="parameter"
  12169. >name</VAR
  12170. >
  12171.         <VAR
  12172. CLASS="parameter"
  12173. >value</VAR
  12174. ></DT
  12175. ><DD
  12176. ><P
  12177. >          Sets the value of the specified directive.
  12178.          This <SPAN
  12179. CLASS="emphasis"
  12180. ><I
  12181. CLASS="emphasis"
  12182. >can not be used</I
  12183. ></SPAN
  12184. > in <TT
  12185. CLASS="filename"
  12186. >.htaccess</TT
  12187. > files.
  12188.          Any directive type set with <SPAN
  12189. CLASS="systemitem"
  12190. >php_admin_value</SPAN
  12191. >
  12192.          can not be overridden by <TT
  12193. CLASS="filename"
  12194. >.htaccess</TT
  12195. > or virtualhost directives.
  12196.          To clear a previously set value use <VAR
  12197. CLASS="literal"
  12198. >none</VAR
  12199. > as the value.
  12200.         </P
  12201. ></DD
  12202. ><DT
  12203. ><SPAN
  12204. CLASS="systemitem"
  12205. >php_admin_flag</SPAN
  12206. >
  12207.         <VAR
  12208. CLASS="parameter"
  12209. >name</VAR
  12210. >
  12211.         <VAR
  12212. CLASS="parameter"
  12213. >on|off</VAR
  12214. ></DT
  12215. ><DD
  12216. ><P
  12217. >          Used to set a boolean configuration directive.
  12218.          This <SPAN
  12219. CLASS="emphasis"
  12220. ><I
  12221. CLASS="emphasis"
  12222. >can not be used</I
  12223. ></SPAN
  12224. > in <TT
  12225. CLASS="filename"
  12226. >.htaccess</TT
  12227. > files.
  12228.          Any directive type set with <SPAN
  12229. CLASS="systemitem"
  12230. >php_admin_flag</SPAN
  12231. >
  12232.          can not be overridden by <TT
  12233. CLASS="filename"
  12234. >.htaccess</TT
  12235. > or virtualhost directives.
  12236.         </P
  12237. ></DD
  12238. ></DL
  12239. ></DIV
  12240. >
  12241.     </P
  12242. ><P
  12243. >      <TABLE
  12244. WIDTH="100%"
  12245. BORDER="0"
  12246. CELLPADDING="0"
  12247. CELLSPACING="0"
  12248. CLASS="EXAMPLE"
  12249. ><TR
  12250. ><TD
  12251. ><DIV
  12252. CLASS="example"
  12253. ><A
  12254. NAME="AEN2394"
  12255. ></A
  12256. ><P
  12257. ><B
  12258. >Beispiel 8-2. Apache configuration example</B
  12259. ></P
  12260. ><TABLE
  12261. BORDER="0"
  12262. BGCOLOR="#E0E0E0"
  12263. CELLPADDING="5"
  12264. ><TR
  12265. ><TD
  12266. ><PRE
  12267. CLASS="ini"
  12268. ><IfModule mod_php5.c>
  12269.   php_value include_path ".:/usr/local/lib/php"
  12270.   php_admin_flag safe_mode on
  12271. </IfModule>
  12272. <IfModule mod_php4.c>
  12273.   php_value include_path ".:/usr/local/lib/php"
  12274.   php_admin_flag safe_mode on
  12275. </IfModule>
  12276. <IfModule mod_php3.c>
  12277.   php3_include_path ".:/usr/local/lib/php"
  12278.   php3_safe_mode on
  12279. </IfModule></PRE
  12280. ></TD
  12281. ></TR
  12282. ></TABLE
  12283. ></DIV
  12284. ></TD
  12285. ></TR
  12286. ></TABLE
  12287. >
  12288.     </P
  12289. ><DIV
  12290. CLASS="caution"
  12291. ><P
  12292. ></P
  12293. ><TABLE
  12294. CLASS="caution"
  12295. BORDER="1"
  12296. WIDTH="100%"
  12297. ><TR
  12298. ><TD
  12299. ALIGN="CENTER"
  12300. ><B
  12301. >Achtung</B
  12302. ></TD
  12303. ></TR
  12304. ><TR
  12305. ><TD
  12306. ALIGN="LEFT"
  12307. ><P
  12308. >       PHP constants do not exist outside of PHP. For example, in 
  12309.       <TT
  12310. CLASS="filename"
  12311. >httpd.conf</TT
  12312. > you can not use PHP constants 
  12313.       such as <TT
  12314. CLASS="constant"
  12315. ><B
  12316. >E_ALL</B
  12317. ></TT
  12318. > or <TT
  12319. CLASS="constant"
  12320. ><B
  12321. >E_NOTICE</B
  12322. ></TT
  12323.       to set the <A
  12324. HREF="#ini.error-reporting"
  12325. >error_reporting</A
  12326.       directive as they will have no meaning and will evaluate to
  12327.       <SPAN
  12328. CLASS="emphasis"
  12329. ><I
  12330. CLASS="emphasis"
  12331. >0</I
  12332. ></SPAN
  12333. >. Use the associated bitmask values instead.
  12334.       These constants can be used in <TT
  12335. CLASS="filename"
  12336. >php.ini</TT
  12337. >
  12338.      </P
  12339. ></TD
  12340. ></TR
  12341. ></TABLE
  12342. ></DIV
  12343. ></DIV
  12344. ><DIV
  12345. CLASS="sect2"
  12346. ><HR><H3
  12347. CLASS="sect2"
  12348. ><A
  12349. NAME="configuration.changes.windows"
  12350. >Changing PHP configuration via the Windows registry</A
  12351. ></H3
  12352. ><P
  12353. >       When running PHP on Windows, the configuration values can be
  12354.       modified on a per-directory basis using the Windows registry. The
  12355.       configuration values are stored in the registry key 
  12356.       <VAR
  12357. CLASS="literal"
  12358. >HKLM\SOFTWARE\PHP\Per Directory Values</VAR
  12359. >, 
  12360.       in the sub-keys corresponding to the path names. For example, configuration 
  12361.       values for the directory <VAR
  12362. CLASS="literal"
  12363. >c:\inetpub\wwwroot</VAR
  12364. > would
  12365.       be stored in the key <VAR
  12366. CLASS="literal"
  12367. >HKLM\SOFTWARE\PHP\Per Directory
  12368.       Values\c\inetpub\wwwroot</VAR
  12369. >. The settings for the
  12370.       directory would be active for any script running from this
  12371.       directory or any subdirectory of it. The values under the key
  12372.       should have the name of the PHP configuration directive and the
  12373.       string value. PHP constants in the values are not parsed. 
  12374.      </P
  12375. ></DIV
  12376. ><DIV
  12377. CLASS="sect2"
  12378. ><HR><H3
  12379. CLASS="sect2"
  12380. ><A
  12381. NAME="configuration.changes.other"
  12382. >Other interfaces to PHP</A
  12383. ></H3
  12384. ><P
  12385. >      Regardless of how you run PHP, you can change certain values at runtime
  12386.      of your scripts through <A
  12387. HREF="#function.ini-set"
  12388. ><B
  12389. CLASS="function"
  12390. >ini_set()</B
  12391. ></A
  12392. >. See the documentation
  12393.      on the <A
  12394. HREF="#function.ini-set"
  12395. ><B
  12396. CLASS="function"
  12397. >ini_set()</B
  12398. ></A
  12399. > page for more information.
  12400.     </P
  12401. ><P
  12402. >      If you are interested in a complete list of configuration settings
  12403.      on your system with their current values, you can execute the
  12404.      <A
  12405. HREF="#function.phpinfo"
  12406. ><B
  12407. CLASS="function"
  12408. >phpinfo()</B
  12409. ></A
  12410. > function, and review the resulting
  12411.      page. You can also access the values of individual configuration
  12412.      directives at runtime using <A
  12413. HREF="#function.ini-get"
  12414. ><B
  12415. CLASS="function"
  12416. >ini_get()</B
  12417. ></A
  12418. > or
  12419.      <A
  12420. HREF="#function.get-cfg-var"
  12421. ><B
  12422. CLASS="function"
  12423. >get_cfg_var()</B
  12424. ></A
  12425. >.
  12426.     </P
  12427. ></DIV
  12428. ></DIV
  12429. ></DIV
  12430. ></DIV
  12431. ><DIV
  12432. CLASS="PART"
  12433. ><A
  12434. NAME="langref"
  12435. ></A
  12436. ><DIV
  12437. CLASS="TITLEPAGE"
  12438. ><H1
  12439. CLASS="title"
  12440. >III. Sprachreferenz</H1
  12441. ><DIV
  12442. CLASS="TOC"
  12443. ><DL
  12444. ><DT
  12445. ><B
  12446. >Inhaltsverzeichnis</B
  12447. ></DT
  12448. ><DT
  12449. >9. <A
  12450. HREF="#language.basic-syntax"
  12451. >Grundlagen der Syntax</A
  12452. ></DT
  12453. ><DT
  12454. >10. <A
  12455. HREF="#language.types"
  12456. >Typen</A
  12457. ></DT
  12458. ><DT
  12459. >11. <A
  12460. HREF="#language.variables"
  12461. >Variablen</A
  12462. ></DT
  12463. ><DT
  12464. >12. <A
  12465. HREF="#language.constants"
  12466. >Konstanten</A
  12467. ></DT
  12468. ><DT
  12469. >13. <A
  12470. HREF="#language.expressions"
  12471. >Ausdrⁿcke</A
  12472. ></DT
  12473. ><DT
  12474. >14. <A
  12475. HREF="#language.operators"
  12476. >Operatoren</A
  12477. ></DT
  12478. ><DT
  12479. >15. <A
  12480. HREF="#language.control-structures"
  12481. >Kontroll-Strukturen</A
  12482. ></DT
  12483. ><DT
  12484. >16. <A
  12485. HREF="#functions"
  12486. >Funktionen</A
  12487. ></DT
  12488. ><DT
  12489. >17. <A
  12490. HREF="#language.oop"
  12491. >Klassen und Objekte</A
  12492. ></DT
  12493. ><DT
  12494. >18. <A
  12495. HREF="#language.oop5"
  12496. >Classes and Objects (PHP 5)</A
  12497. ></DT
  12498. ><DT
  12499. >19. <A
  12500. HREF="#language.references"
  12501. >Referenzen in PHP</A
  12502. ></DT
  12503. ></DL
  12504. ></DIV
  12505. ></DIV
  12506. ><DIV
  12507. CLASS="chapter"
  12508. ><HR><H1
  12509. ><A
  12510. NAME="language.basic-syntax"
  12511. >Kapitel 9. Grundlagen der Syntax</A
  12512. ></H1
  12513. ><DIV
  12514. CLASS="sect1"
  12515. ><H2
  12516. CLASS="sect1"
  12517. ><A
  12518. NAME="language.basic-syntax.phpmode"
  12519. >Den HTML-Bereich der Datei verlassen</A
  12520. ></H2
  12521. ><P
  12522. >     WΣhrend des Parsens einer Datei geht PHP den Text solange einfach
  12523.     durch, bis einer der speziellen Tags gefunden wird, der PHP mitteilt,
  12524.     dass ab nun mit der Interpretation des Textes als PHP Code zu beginnen
  12525.     ist. Der Parser fⁿhrt nun den Code solange aus, bis er auf einen
  12526.     schlie▀enden PHP Tag st÷▀t, welcher dem Parser mitteilt, den Text ab
  12527.     hier wieder nur einfach durchzugehen. Das ist der Mechanismus der es
  12528.     erlaubt, PHP Code in HTML einzubinden: alles au▀erhalb der PHP Tags
  12529.     wird einfach alleine gelassen, wΣhrend alles innerhalb dieser Tags
  12530.     als Code geparsed wird.
  12531.    </P
  12532. ><P
  12533. >     Es gibt vier Arten von Tags, welche die Bl÷cke mit PHP Code kennzeichnen.
  12534.     Davon sind nur zwei immer verfⁿgbar (<?php. . .?> und <script
  12535.     language="php">. . .</script>), die anderen k÷nnen in der
  12536.     Konfigurationsdatei <TT
  12537. CLASS="filename"
  12538. >php.ini</TT
  12539. > aktiviert bzw. deaktiviert werden. Die
  12540.     Tags in der Kurzform bzw. im ASP-Stil m÷gen zwar praktisch erscheinen,
  12541.     sind jedoch nicht so portabel wie die lΣngeren Versionen. Wenn Sie
  12542.     des Weiteren beabsichtigen, PHP Code in XML oder XHTML einzubinden, werden
  12543.     Sie die XML-konformen <?php. . .?> verwenden mⁿssen.
  12544.    </P
  12545. ><P
  12546. >     Die von PHP unterstⁿtzten Tags sind:
  12547.    </P
  12548. ><P
  12549. >      <TABLE
  12550. WIDTH="100%"
  12551. BORDER="0"
  12552. CELLPADDING="0"
  12553. CELLSPACING="0"
  12554. CLASS="EXAMPLE"
  12555. ><TR
  12556. ><TD
  12557. ><DIV
  12558. CLASS="example"
  12559. ><A
  12560. NAME="AEN2431"
  12561. ></A
  12562. ><P
  12563. ><B
  12564. >Beispiel 9-1. M÷glichkeiten, den HTML-Bereich zu verlassen</B
  12565. ></P
  12566. ><TABLE
  12567. BORDER="0"
  12568. BGCOLOR="#E0E0E0"
  12569. CELLPADDING="5"
  12570. ><TR
  12571. ><TD
  12572. ><PRE
  12573. CLASS="php"
  12574. >1.  <?php echo("In XHTML- oder XML-konformen Dokumenten benutzen Sie diese Syntax\n"); ?>
  12575.  
  12576. 2.  <? echo ("Die einfachste M÷glichkeit: eine SGML-┤processing instruction┤\n"); ?>
  12577.     <?= expression ?> Dies ist eine Abkⁿrzung fⁿr "<? echo expression ?>"
  12578.  
  12579. 3.  <script language="php">
  12580.         echo ("manche Editoren(wie FrontPage) m÷gen
  12581.               keine ┤processing instructions┤");
  12582.     </script>
  12583.  
  12584. 4.  <% echo ("Optional k÷nnen Sie auch Tags im ASP-Stil verwenden"); %>
  12585.     <%= $variable; # Das ist ein Abkⁿrzung fuer "<% echo . . ." %></PRE
  12586. ></TD
  12587. ></TR
  12588. ></TABLE
  12589. ></DIV
  12590. ></TD
  12591. ></TR
  12592. ></TABLE
  12593. >
  12594.     </P
  12595. ><P
  12596. >     Die erste Methode (<?php. . .?>) wird bevorzugt, da sie auch
  12597.     die Verwendung von PHP in XML-konformen Code, wie XHTML, erlaubt.
  12598.    </P
  12599. ><P
  12600. >     Die zweite Methode ist nicht immer verfⁿgbar. Die Kurzform der Tags
  12601.     ist nur m÷glich, wenn diese zuvor aktiviert wurde. Dies kann mittels
  12602.     der Funktion <B
  12603. CLASS="function"
  12604. >short_tags()</B
  12605. > (nur PHP 3), dem Setzen
  12606.     der Konfigurationsoption <A
  12607. HREF="#ini.short-open-tag"
  12608. >short_open_tag</A
  12609. > in der PHP
  12610.     Konfigurationsdatei, oder durch das Kompilieren von PHP mit der
  12611.     Option  --enable-short-tags. Auch wenn diese Methode standardmΣ▀ig
  12612.     in der php.ini.dist aktiviert ist, wird die Verwendung dieser
  12613.     Kurzform nicht empfohlen.
  12614.    </P
  12615. ><P
  12616. >     Die vierte Methode ist nur verfⁿgbar, wenn die Konfigurationsoption
  12617.     <A
  12618. HREF="#ini.asp-tags"
  12619. >asp_tags</A
  12620. > aktiviert ist.
  12621.  
  12622.     <DIV
  12623. CLASS="note"
  12624. ><BLOCKQUOTE
  12625. CLASS="note"
  12626. ><P
  12627. ><B
  12628. >Anmerkung: </B
  12629. >Die Unterstⁿtzung der Tags im ASP-Stil wurde in Version 3.0.4.
  12630.       hinzugefⁿgt.
  12631.      </P
  12632. ></BLOCKQUOTE
  12633. ></DIV
  12634. >
  12635.    </P
  12636. ><DIV
  12637. CLASS="note"
  12638. ><BLOCKQUOTE
  12639. CLASS="note"
  12640. ><P
  12641. ><B
  12642. >Anmerkung: </B
  12643. >
  12644.      Die Verwendung der ┤short tags┤ sollten Sie vermeiden, wenn Sie
  12645.      Applikationen oder Bibliotheken entwickeln, die verteilt oder auf
  12646.      PHP-Servern eingesetzt werden soll, die nicht unter Ihrer Kontrolle
  12647.      stehen, da die ┤short tags┤ auf dem einzusetzenden Server nicht
  12648.      unterstⁿtzt werden k÷nnten. Stellen Sie also sicher, dass fⁿr
  12649.      portablen, weiterverteilbaren Code keine ┤short tags┤ verwendet
  12650.      werden.
  12651.     </P
  12652. ></BLOCKQUOTE
  12653. ></DIV
  12654. ><P
  12655. >      Der schlie▀ende Tag fⁿr den PHP-Block schlie▀t eine sofort
  12656.      folgende Zeilenschaltung mit ein, falls diese vorhanden
  12657.      ist. Au▀erdem beinhaltet der schlie▀ende Tag ein implizites Semikolon;
  12658.      Sie mⁿssen also die letzte Zeile eines PHP-Blocks nicht mit einem
  12659.      Semikolon beenden.
  12660.     </P
  12661. ><P
  12662. >     PHP erm÷glicht auch die Verwendung folgender Strukturen:
  12663.     <TABLE
  12664. WIDTH="100%"
  12665. BORDER="0"
  12666. CELLPADDING="0"
  12667. CELLSPACING="0"
  12668. CLASS="EXAMPLE"
  12669. ><TR
  12670. ><TD
  12671. ><DIV
  12672. CLASS="example"
  12673. ><A
  12674. NAME="AEN2446"
  12675. ></A
  12676. ><P
  12677. ><B
  12678. >Beispiel 9-2. Erweitertes Verlassen</B
  12679. ></P
  12680. ><TABLE
  12681. BORDER="0"
  12682. BGCOLOR="#E0E0E0"
  12683. CELLPADDING="5"
  12684. ><TR
  12685. ><TD
  12686. ><PRE
  12687. CLASS="php"
  12688. ><?php
  12689. if ($expression) {
  12690.     ?>
  12691.     <strong>Das ist richtig.</strong>
  12692.     <?php
  12693. } else {
  12694.     ?>
  12695.     <strong>Das ist falsch.</strong>
  12696.     <?php
  12697. }
  12698. ?></PRE
  12699. ></TD
  12700. ></TR
  12701. ></TABLE
  12702. ></DIV
  12703. ></TD
  12704. ></TR
  12705. ></TABLE
  12706. >
  12707.     Dies funktioniert wie erwartet, da PHP nach dem Auffinden eines ?>
  12708.     schlie▀enden Tags einfach alles ausgibt, bis es wieder auf einen
  12709.     ÷ffnenden Tag st÷▀t. Das obige Beispiel ist natⁿrlich gekⁿnstelt,
  12710.     aber fⁿr die Ausgabe von gro▀en Textbl÷cken ist der Ausstieg aus
  12711.     dem Parse-Modus generell effizienter, als den gesamten Text durch
  12712.     <A
  12713. HREF="#function.echo"
  12714. ><B
  12715. CLASS="function"
  12716. >echo()</B
  12717. ></A
  12718. >, <A
  12719. HREF="#function.print"
  12720. ><B
  12721. CLASS="function"
  12722. >print()</B
  12723. ></A
  12724. >, etc. zu
  12725.     jagen.
  12726.    </P
  12727. ></DIV
  12728. ><DIV
  12729. CLASS="sect1"
  12730. ><HR><H2
  12731. CLASS="sect1"
  12732. ><A
  12733. NAME="language.basic-syntax.instruction-separation"
  12734. >Abgrenzung von Anweisungen</A
  12735. ></H2
  12736. ><P
  12737. >      Einzelne Anweisungen werden genauso voneinander abgetrennt wie
  12738.      in C oder Perl - jedes Statement wird mit einem Semikolon beendet.
  12739.     </P
  12740. ><P
  12741. >      Auch der schlie▀ende Tag (?>) bedeutet das Ende eines Statements,
  12742.      deshalb sind die folgenden Beispiele gleichwertig:
  12743.  
  12744.      <DIV
  12745. CLASS="informalexample"
  12746. ><P
  12747. ></P
  12748. ><A
  12749. NAME="AEN2455"
  12750. ></A
  12751. ><TABLE
  12752. BORDER="0"
  12753. BGCOLOR="#E0E0E0"
  12754. CELLPADDING="5"
  12755. ><TR
  12756. ><TD
  12757. ><PRE
  12758. CLASS="php"
  12759. ><?php
  12760.     echo "Dies ist ein Test";
  12761. ?>
  12762.  
  12763. <?php echo "Dies ist ein Test" ?></PRE
  12764. ></TD
  12765. ></TR
  12766. ></TABLE
  12767. ><P
  12768. ></P
  12769. ></DIV
  12770. >
  12771.     </P
  12772. ></DIV
  12773. ><DIV
  12774. CLASS="sect1"
  12775. ><HR><H2
  12776. CLASS="sect1"
  12777. ><A
  12778. NAME="language.basic-syntax.comments"
  12779. >Kommentare</A
  12780. ></H2
  12781. ><P
  12782. >      PHP unterstⁿtzt 'C', 'C++' und Unix-Shell-artige Kommentare. Beispiele:
  12783.  
  12784.     <DIV
  12785. CLASS="informalexample"
  12786. ><P
  12787. ></P
  12788. ><A
  12789. NAME="AEN2460"
  12790. ></A
  12791. ><TABLE
  12792. BORDER="0"
  12793. BGCOLOR="#E0E0E0"
  12794. CELLPADDING="5"
  12795. ><TR
  12796. ><TD
  12797. ><PRE
  12798. CLASS="php"
  12799. ><?php
  12800.     echo "Dies ist ein Test"; // Dies ist ein einzeiliger Kommentar im C++-Stil.
  12801.     /* Dies ist ein mehrzeiliger Kommentar
  12802.        und noch eine Kommentar-Zeile */
  12803.     echo "Dies ist noch ein Test";
  12804.     echo "... und ein letzter Test"; # Dies ist ein Shell-artiger Kommentar.
  12805. ?></PRE
  12806. ></TD
  12807. ></TR
  12808. ></TABLE
  12809. ><P
  12810. ></P
  12811. ></DIV
  12812. >
  12813.    </P
  12814. ><P
  12815. >      Die einzeiligen Kommentar-Arten kommentieren sΣmtlichen Text bis
  12816.      zum Zeilenende oder bis zum Ende des aktuellen PHP-Blocks aus, je
  12817.      nachdem, was zuerst eintritt.
  12818.     </P
  12819. ><DIV
  12820. CLASS="informalexample"
  12821. ><P
  12822. ></P
  12823. ><A
  12824. NAME="AEN2463"
  12825. ></A
  12826. ><TABLE
  12827. BORDER="0"
  12828. BGCOLOR="#E0E0E0"
  12829. CELLPADDING="5"
  12830. ><TR
  12831. ><TD
  12832. ><PRE
  12833. CLASS="php"
  12834. ><h1>Dies ist ein  <?php # echo "einfaches";?> Beispiel.</h1>
  12835. <p>Obige ▄berschrift wird lauten: 'Dies ist ein Beispiel.'.</PRE
  12836. ></TD
  12837. ></TR
  12838. ></TABLE
  12839. ><P
  12840. ></P
  12841. ></DIV
  12842. ><P
  12843. >      Man sollte darauf achten, nicht mehrere ┤C┤-artigen Kommentare ineinander
  12844.      zu setzen, was vorkommen kann, wenn man gro▀e Bl÷cke auskommentiert.
  12845.      </P
  12846. ><DIV
  12847. CLASS="informalexample"
  12848. ><P
  12849. ></P
  12850. ><A
  12851. NAME="AEN2466"
  12852. ></A
  12853. ><TABLE
  12854. BORDER="0"
  12855. BGCOLOR="#E0E0E0"
  12856. CELLPADDING="5"
  12857. ><TR
  12858. ><TD
  12859. ><PRE
  12860. CLASS="php"
  12861. ><?php
  12862. /*
  12863.    echo "Dies ist ein Test"; /* Dieser Kommentar wird ein Problem verursachen. */
  12864. */
  12865. ?></PRE
  12866. ></TD
  12867. ></TR
  12868. ></TABLE
  12869. ><P
  12870. ></P
  12871. ></DIV
  12872. ><P
  12873. >     Die einzeiligen Kommentar-Arten kommentieren den Text tatsΣchlich
  12874.     nur bis zum Zeilenende oder bis zum Ende des aktuellen PHP-Blocks aus,
  12875.     je nachdem, was zuerst eintritt. Das hei▀t, dass HTML Code nach // ?>
  12876.     ausgegeben wird: ?> steigt aus dem PHP-Modus aus und kehrt in den HTML
  12877.     Modus zurⁿck, ohne dass // dies beeinflussen k÷nnte.
  12878.    </P
  12879. ></DIV
  12880. ></DIV
  12881. ><DIV
  12882. CLASS="chapter"
  12883. ><HR><H1
  12884. ><A
  12885. NAME="language.types"
  12886. >Kapitel 10. Typen</A
  12887. ></H1
  12888. ><DIV
  12889. CLASS="sect1"
  12890. ><H2
  12891. CLASS="sect1"
  12892. ><A
  12893. NAME="language.types.intro"
  12894. >Einfⁿhrung</A
  12895. ></H2
  12896. ><P
  12897. >     PHP unterstⁿtzt acht primitive Typen.
  12898.    </P
  12899. ><P
  12900. >     Vier skalare Typen:
  12901.     <P
  12902. ></P
  12903. ><UL
  12904. ><LI
  12905. ><P
  12906. >        Boolean
  12907.       </P
  12908. ></LI
  12909. ><LI
  12910. ><P
  12911. >        Integer
  12912.       </P
  12913. ></LI
  12914. ><LI
  12915. ><P
  12916. >        Flie▀komma-Zahl (float)
  12917.       </P
  12918. ></LI
  12919. ><LI
  12920. ><P
  12921. >        String / Zeichenkette
  12922.       </P
  12923. ></LI
  12924. ></UL
  12925. >
  12926.  
  12927.     Zwei zusammengesetzte Typen:
  12928.  
  12929.     <P
  12930. ></P
  12931. ><UL
  12932. ><LI
  12933. ><P
  12934. >        Array
  12935.       </P
  12936. ></LI
  12937. ><LI
  12938. ><P
  12939. >        Object
  12940.       </P
  12941. ></LI
  12942. ></UL
  12943. >
  12944.  
  12945.     Und zuletzt zwei spezielle Typen:
  12946.  
  12947.     <P
  12948. ></P
  12949. ><UL
  12950. ><LI
  12951. ><P
  12952. >        Resource
  12953.       </P
  12954. ></LI
  12955. ><LI
  12956. ><P
  12957. >        <A
  12958. HREF="#language.types.null"
  12959. ><B
  12960. CLASS="type"
  12961. >NULL</B
  12962. ></A
  12963. >
  12964.       </P
  12965. ></LI
  12966. ></UL
  12967. >
  12968.  
  12969.     Fⁿr die bessere Lesbarkeit fⁿhrt dieses Handbuch ein paar <A
  12970. HREF="#language.pseudo-types"
  12971. >Pseudo-Typen</A
  12972. > ein:
  12973.  
  12974.     <P
  12975. ></P
  12976. ><UL
  12977. ><LI
  12978. ><P
  12979. >        <A
  12980. HREF="#language.types.mixed"
  12981. >Mixed</A
  12982. >
  12983.       </P
  12984. ></LI
  12985. ><LI
  12986. ><P
  12987. >        <A
  12988. HREF="#language.types.number"
  12989. >Number</A
  12990. >
  12991.       </P
  12992. ></LI
  12993. ><LI
  12994. ><P
  12995. >        <A
  12996. HREF="#language.types.mixed"
  12997. >Callback</A
  12998. >
  12999.       </P
  13000. ></LI
  13001. ></UL
  13002. >
  13003.     Sie werden auch ein paar Hinweise auf den Typ "Double" finden.
  13004.     Betrachten Sie Double als dasselbe wie Float. Die beiden
  13005.     Bezeichnungen existieren nur aus historischen Grⁿnden.
  13006.    </P
  13007. ><P
  13008. >     Der Typ einer Variablen wird normalerweise nicht vom
  13009.     Programmierer bestimmt. Zur Laufzeit von PHP wird entschieden,
  13010.     welchen Typs eine Variable ist, abhΣngig vom Zusammenhang in dem
  13011.     die Variable benutzt wird.
  13012.    </P
  13013. ><DIV
  13014. CLASS="note"
  13015. ><BLOCKQUOTE
  13016. CLASS="note"
  13017. ><P
  13018. ><B
  13019. >Anmerkung: </B
  13020. >
  13021.      Um den Typ und den Wert eines bestimmten <A
  13022. HREF="#language.expressions"
  13023. >Ausdrucks (Expression)</A
  13024. > zu
  13025.      ⁿberprⁿfen, k÷nnen Sie <A
  13026. HREF="#function.var-dump"
  13027. ><B
  13028. CLASS="function"
  13029. >var_dump()</B
  13030. ></A
  13031. > benutzen.
  13032.     </P
  13033. ><P
  13034. ><B
  13035. >Anmerkung: </B
  13036. >
  13037.      Wenn Sie zur Fehlersuche einfach nur eine lesbare Darstellung
  13038.      eines Typs ben÷tigen, benutzen Sie <A
  13039. HREF="#function.gettype"
  13040. ><B
  13041. CLASS="function"
  13042. >gettype()</B
  13043. ></A
  13044. >.
  13045.      Um auf einen bestimmten Typ zu prⁿfen, sollten Sie
  13046.      <SPAN
  13047. CLASS="emphasis"
  13048. ><I
  13049. CLASS="emphasis"
  13050. >nicht</I
  13051. ></SPAN
  13052. > <A
  13053. HREF="#function.gettype"
  13054. ><B
  13055. CLASS="function"
  13056. >gettype()</B
  13057. ></A
  13058. > benutzen.
  13059.      Stattdessen sollten Sie die
  13060.      <VAR
  13061. CLASS="literal"
  13062. >is_<VAR
  13063. CLASS="replaceable"
  13064. >type</VAR
  13065. ></VAR
  13066. > Funktionen
  13067.      verwenden.  Ein paar Beispiele:
  13068.      <DIV
  13069. CLASS="informalexample"
  13070. ><P
  13071. ></P
  13072. ><A
  13073. NAME="AEN2524"
  13074. ></A
  13075. ><TABLE
  13076. BORDER="0"
  13077. BGCOLOR="#E0E0E0"
  13078. CELLPADDING="5"
  13079. ><TR
  13080. ><TD
  13081. ><PRE
  13082. CLASS="php"
  13083. ><?php
  13084. $bool = TRUE;   // ein Boolean (Wahrheitswert)
  13085. $str  = "foo";  // ein String (Zeichenkette)
  13086. $int  = 12;     // ein Integer (Ganzzahl)
  13087.  
  13088. echo gettype($bool); // gibt "boolean" aus
  13089. echo gettype($str);  // gibt "string" aus
  13090.  
  13091. // Falls es ein Integer ist, erh÷he ihn um vier
  13092. if (is_int($int)) {
  13093.     $int += 4;
  13094. }
  13095.  
  13096. // Falls $bool ein String ist, gebe ihn aus
  13097. // (gibt ⁿberhaupt nichts aus)
  13098. if (is_string($bool)) {
  13099.     echo "String: $bool";
  13100. }
  13101. ?></PRE
  13102. ></TD
  13103. ></TR
  13104. ></TABLE
  13105. ><P
  13106. ></P
  13107. ></DIV
  13108. >
  13109.     </P
  13110. ></BLOCKQUOTE
  13111. ></DIV
  13112. ><P
  13113. >     Wenn sie die Umwandlung in einen bestimmten Variablen-Typ
  13114.     erzwingen wollen, erreichen Sie dies entweder durch <A
  13115. HREF="#language.types.typecasting"
  13116. >Typ-Umwandlung</A
  13117. > oder
  13118.     durch Gebrauch der Funktion <A
  13119. HREF="#function.settype"
  13120. ><B
  13121. CLASS="function"
  13122. >settype()</B
  13123. ></A
  13124. >.
  13125.    </P
  13126. ><P
  13127. >     Beachten Sie, dass eine Variable abhΣngig vom Typ, dem die
  13128.     Variable zu dem Zeitpunkt entspricht, in bestimmten Situationen
  13129.     unterschiedlich ausgewertet werden kann. Weitere Informationen
  13130.     entnehmen Sie dem Abschnitt zur <A
  13131. HREF="#language.types.type-juggling"
  13132. >Typ-VerΣnderung</A
  13133. >.
  13134.     Schauen Sie sich au▀erdem <A
  13135. HREF="#types.comparisons"
  13136. >PHP
  13137.     type comparison tables</A
  13138. > an, wenn Sie an Beispielen
  13139.     verschiedener typenbezogener Vergleiche interessiert sind.
  13140.    </P
  13141. ></DIV
  13142. ><DIV
  13143. CLASS="sect1"
  13144. ><HR><H2
  13145. CLASS="sect1"
  13146. ><A
  13147. NAME="language.types.boolean"
  13148. >Boolscher Typ</A
  13149. ></H2
  13150. ><P
  13151. >     Das ist der einfachste Typ. Ein <A
  13152. HREF="#language.types.boolean"
  13153. ><B
  13154. CLASS="type"
  13155. >boolean</B
  13156. ></A
  13157. > drⁿckt einen
  13158.     Wahrheitswert aus. Dieser kann entweder <TT
  13159. CLASS="constant"
  13160. ><B
  13161. >TRUE</B
  13162. ></TT
  13163. > oder <TT
  13164. CLASS="constant"
  13165. ><B
  13166. >FALSE</B
  13167. ></TT
  13168. > sein.
  13169.    </P
  13170. ><DIV
  13171. CLASS="note"
  13172. ><BLOCKQUOTE
  13173. CLASS="note"
  13174. ><P
  13175. ><B
  13176. >Anmerkung: </B
  13177. >
  13178.      Der boolsche Typ wurde in PHP 4 eingefⁿhrt.
  13179.     </P
  13180. ></BLOCKQUOTE
  13181. ></DIV
  13182. ><DIV
  13183. CLASS="sect2"
  13184. ><HR><H3
  13185. CLASS="sect2"
  13186. ><A
  13187. NAME="language.types.boolean.syntax"
  13188. >Syntax</A
  13189. ></H3
  13190. ><P
  13191. >      Um einen boolschen Typ w÷rtlich anzugeben, benutzen Sie entweder
  13192.      das Schlⁿsselwort <TT
  13193. CLASS="constant"
  13194. ><B
  13195. >TRUE</B
  13196. ></TT
  13197. > oder <TT
  13198. CLASS="constant"
  13199. ><B
  13200. >FALSE</B
  13201. ></TT
  13202. >.  Beide unterscheiden sich
  13203.      nicht bezⁿglich Gro▀- und Kleinschreibung.
  13204.      <DIV
  13205. CLASS="informalexample"
  13206. ><P
  13207. ></P
  13208. ><A
  13209. NAME="AEN2545"
  13210. ></A
  13211. ><TABLE
  13212. BORDER="0"
  13213. BGCOLOR="#E0E0E0"
  13214. CELLPADDING="5"
  13215. ><TR
  13216. ><TD
  13217. ><PRE
  13218. CLASS="php"
  13219. ><?php
  13220. $foo = True; // $foo wird der Wert TRUE zugewiesen
  13221. ?></PRE
  13222. ></TD
  13223. ></TR
  13224. ></TABLE
  13225. ><P
  13226. ></P
  13227. ></DIV
  13228. >
  13229.     </P
  13230. ><P
  13231. >      ▄blicherweise verwenden Sie einen der <A
  13232. HREF="#language.operators"
  13233. >Operatoren</A
  13234. >, der Ihnen einen
  13235.      <A
  13236. HREF="#language.types.boolean"
  13237. ><B
  13238. CLASS="type"
  13239. >boolean</B
  13240. ></A
  13241. > Wert liefert, den Sie dann an eine der <A
  13242. HREF="#language.control-structures"
  13243. >Kontroll-Strukturen</A
  13244. >
  13245.      weiterreichen.
  13246.      <DIV
  13247. CLASS="informalexample"
  13248. ><P
  13249. ></P
  13250. ><A
  13251. NAME="AEN2551"
  13252. ></A
  13253. ><TABLE
  13254. BORDER="0"
  13255. BGCOLOR="#E0E0E0"
  13256. CELLPADDING="5"
  13257. ><TR
  13258. ><TD
  13259. ><PRE
  13260. CLASS="php"
  13261. ><?php
  13262. // == ist ein Vergleichs-Operator der auf Gleichheit ⁿberprⁿft und
  13263. // einen boolschen Wert liefert
  13264. if ($action == "show_version") {
  13265.     echo "Die Version ist 1.23";
  13266. }
  13267.  
  13268. // Das ist nicht notwendig...
  13269. if ($show_separators == TRUE) {
  13270.     echo "<hr>\n";
  13271. }
  13272.  
  13273. // ...weil Sie einfach schreiben k÷nnen:
  13274. if ($show_separators) {
  13275.     echo "<hr>\n";
  13276. }
  13277. ?></PRE
  13278. ></TD
  13279. ></TR
  13280. ></TABLE
  13281. ><P
  13282. ></P
  13283. ></DIV
  13284. >
  13285.     </P
  13286. ></DIV
  13287. ><DIV
  13288. CLASS="sect2"
  13289. ><HR><H3
  13290. CLASS="sect2"
  13291. ><A
  13292. NAME="language.types.boolean.casting"
  13293. >Umwandlung nach boolean</A
  13294. ></H3
  13295. ><P
  13296. >      Um einen Wert ausdrⁿcklich nach <A
  13297. HREF="#language.types.boolean"
  13298. ><B
  13299. CLASS="type"
  13300. >boolean</B
  13301. ></A
  13302. > zu
  13303.      konvertieren benutzen Sie entweder die Umwandlung mittels
  13304.      <VAR
  13305. CLASS="literal"
  13306. >(bool)</VAR
  13307. > oder <VAR
  13308. CLASS="literal"
  13309. >(boolean)</VAR
  13310. >. In
  13311.      den allermeisten FΣllen ist es jedoch nicht notwendig die
  13312.      Umwandlung selbst vorzunehmen. Ein Wert wird automatisch
  13313.      konvertiert, falls ein Operator, eine Funktion oder eine
  13314.      Kontrollstruktur ein <A
  13315. HREF="#language.types.boolean"
  13316. ><B
  13317. CLASS="type"
  13318. >boolean</B
  13319. ></A
  13320. > Argument erfordern.
  13321.     </P
  13322. ><P
  13323. >      Siehe auch <A
  13324. HREF="#language.types.type-juggling"
  13325. >Typ-VerΣnderung</A
  13326. >.
  13327.     </P
  13328. ><P
  13329. >      Bei der Umwandlung nach <A
  13330. HREF="#language.types.boolean"
  13331. ><B
  13332. CLASS="type"
  13333. >boolean</B
  13334. ></A
  13335. > werden folgende
  13336.      Werte als <TT
  13337. CLASS="constant"
  13338. ><B
  13339. >FALSE</B
  13340. ></TT
  13341. > angesehen:
  13342.      <P
  13343. ></P
  13344. ><UL
  13345. ><LI
  13346. ><P
  13347. >         das <A
  13348. HREF="#language.types.boolean"
  13349. >boolean</A
  13350. >
  13351.         <TT
  13352. CLASS="constant"
  13353. ><B
  13354. >FALSE</B
  13355. ></TT
  13356. > selbst
  13357.        </P
  13358. ></LI
  13359. ><LI
  13360. ><P
  13361. >         die <A
  13362. HREF="#language.types.integer"
  13363. >Integer</A
  13364. > 0
  13365.         (Null)
  13366.        </P
  13367. ></LI
  13368. ><LI
  13369. ><P
  13370. >         die <A
  13371. HREF="#language.types.float"
  13372. >Flie▀komma-Zahl</A
  13373. > 0.0 (Null)
  13374.        </P
  13375. ></LI
  13376. ><LI
  13377. ><P
  13378. >die leere <A
  13379. HREF="#language.types.string"
  13380. >Zeichenkette</A
  13381. > und die
  13382.         <A
  13383. HREF="#language.types.string"
  13384. >Zeichenkette</A
  13385. > "0"
  13386.        </P
  13387. ></LI
  13388. ><LI
  13389. ><P
  13390. >         ein <A
  13391. HREF="#language.types.array"
  13392. >Array</A
  13393. > ohne
  13394.         Elemente
  13395.        </P
  13396. ></LI
  13397. ><LI
  13398. ><P
  13399. >         ein <A
  13400. HREF="#language.types.object"
  13401. >Objekt</A
  13402. > ohne
  13403.         Mitgliedsvariablen
  13404.        </P
  13405. ></LI
  13406. ><LI
  13407. ><P
  13408. >         der spezielle Typ <A
  13409. HREF="#language.types.null"
  13410. >NULL</A
  13411. > (einschlie▀lich
  13412.         nicht definierter Variablen)
  13413.        </P
  13414. ></LI
  13415. ></UL
  13416. >
  13417.  
  13418.      Jeder andere Wert wird als <TT
  13419. CLASS="constant"
  13420. ><B
  13421. >TRUE</B
  13422. ></TT
  13423. > angesehen (einschlie▀lich jeder
  13424.      <A
  13425. HREF="#language.types.resource"
  13426. >Resource</A
  13427. >).
  13428.      <DIV
  13429. CLASS="warning"
  13430. ><P
  13431. ></P
  13432. ><TABLE
  13433. CLASS="warning"
  13434. BORDER="1"
  13435. WIDTH="100%"
  13436. ><TR
  13437. ><TD
  13438. ALIGN="CENTER"
  13439. ><B
  13440. >Warnung</B
  13441. ></TD
  13442. ></TR
  13443. ><TR
  13444. ><TD
  13445. ALIGN="LEFT"
  13446. ><P
  13447. >        <VAR
  13448. CLASS="literal"
  13449. >-1</VAR
  13450. > wird als <TT
  13451. CLASS="constant"
  13452. ><B
  13453. >TRUE</B
  13454. ></TT
  13455. > angesehen, wie jede
  13456.        andere Zahl ungleich Null (egal ob negativ oder positiv)!
  13457.       </P
  13458. ></TD
  13459. ></TR
  13460. ></TABLE
  13461. ></DIV
  13462. >
  13463.      <DIV
  13464. CLASS="informalexample"
  13465. ><P
  13466. ></P
  13467. ><A
  13468. NAME="AEN2595"
  13469. ></A
  13470. ><TABLE
  13471. BORDER="0"
  13472. BGCOLOR="#E0E0E0"
  13473. CELLPADDING="5"
  13474. ><TR
  13475. ><TD
  13476. ><PRE
  13477. CLASS="php"
  13478. ><?php
  13479. echo gettype((bool) "");        // bool(falsch)
  13480. echo gettype((bool) 1);         // bool(wahr)
  13481. echo gettype((bool) -2);        // bool(wahr)
  13482. echo gettype((bool) "foo");     // bool(wahr)
  13483. echo gettype((bool) 2.3e5);     // bool(wahr)
  13484. echo gettype((bool) array(12)); // bool(wahr)
  13485. echo gettype((bool) array());   // bool(falsch)
  13486. ?></PRE
  13487. ></TD
  13488. ></TR
  13489. ></TABLE
  13490. ><P
  13491. ></P
  13492. ></DIV
  13493. >
  13494.     </P
  13495. ></DIV
  13496. ></DIV
  13497. ><DIV
  13498. CLASS="sect1"
  13499. ><HR><H2
  13500. CLASS="sect1"
  13501. ><A
  13502. NAME="language.types.integer"
  13503. >Integer Typen</A
  13504. ></H2
  13505. ><P
  13506. >     Ein Integer ist eine Zahl aus der Menge Z = {..., -2,
  13507.     -1, 0, 1, 2, ...}.
  13508.    </P
  13509. ><P
  13510. >     Siehe auch: <A
  13511. HREF="#ref.gmp"
  13512. >Ganzzahlen beliebiger LΣnge /
  13513.     GMP</A
  13514. >, <A
  13515. HREF="#language.types.float"
  13516. >Flie▀komma-Zahlen</A
  13517. > und <A
  13518. HREF="#ref.bc"
  13519. >Mathematische Funktionen mit beliebiger
  13520.     Genauigkeit</A
  13521. >
  13522.    </P
  13523. ><DIV
  13524. CLASS="sect2"
  13525. ><HR><H3
  13526. CLASS="sect2"
  13527. ><A
  13528. NAME="language.types.integer.syntax"
  13529. >Syntax</A
  13530. ></H3
  13531. ><P
  13532. >      Ganzzahlen k÷nnen in dezimaler (10-basierter), hexadezimaler
  13533.      (16-basierter) oder oktaler (8-basierter) Schreibweise angegeben
  13534.      werden, wahlweise mit einem vorangestellten Zeichen (- oder +).
  13535.     </P
  13536. ><P
  13537. >      Wenn Sie die oktale Schreibweise verwenden, mⁿssen Sie die Zahl
  13538.      mit einer vorangestellten Null <VAR
  13539. CLASS="literal"
  13540. >0</VAR
  13541. > schreiben; in
  13542.      hexadezimaler Schreibweise mⁿssen Sie vor die Zahl ein
  13543.      <VAR
  13544. CLASS="literal"
  13545. >0x</VAR
  13546. > schreiben.
  13547.      <TABLE
  13548. WIDTH="100%"
  13549. BORDER="0"
  13550. CELLPADDING="0"
  13551. CELLSPACING="0"
  13552. CLASS="EXAMPLE"
  13553. ><TR
  13554. ><TD
  13555. ><DIV
  13556. CLASS="example"
  13557. ><A
  13558. NAME="AEN2611"
  13559. ></A
  13560. ><P
  13561. ><B
  13562. >Beispiel 10-1. Integer Literale</B
  13563. ></P
  13564. ><TABLE
  13565. BORDER="0"
  13566. BGCOLOR="#E0E0E0"
  13567. CELLPADDING="5"
  13568. ><TR
  13569. ><TD
  13570. ><PRE
  13571. CLASS="php"
  13572. ><?php
  13573. $a = 1234; // Dezimalzahl
  13574. $a = -123; // eine negative Zahl
  13575. $a = 0123; // Oktalzahl (entspricht 83 dezimal)
  13576. $a = 0x1A; // Hexadezimalzahl (entspricht 26 dezimal)
  13577. ?></PRE
  13578. ></TD
  13579. ></TR
  13580. ></TABLE
  13581. ></DIV
  13582. ></TD
  13583. ></TR
  13584. ></TABLE
  13585. >
  13586.      Formell ist die m÷gliche Struktur fⁿr Integer Literale:
  13587.      <DIV
  13588. CLASS="informalexample"
  13589. ><P
  13590. ></P
  13591. ><A
  13592. NAME="AEN2614"
  13593. ></A
  13594. ><TABLE
  13595. BORDER="0"
  13596. BGCOLOR="#E0E0E0"
  13597. CELLPADDING="5"
  13598. ><TR
  13599. ><TD
  13600. ><PRE
  13601. CLASS="programlisting"
  13602. >dezimal     : [1-9][0-9]*
  13603.             | 0
  13604.  
  13605. hexadezimal : 0[xX][0-9a-fA-F]+
  13606.  
  13607. oktal       : 0[0-7]+
  13608.  
  13609. integer     : [+-]?dezimal
  13610.             | [+-]?hexadezimal
  13611.             | [+-]?oktal</PRE
  13612. ></TD
  13613. ></TR
  13614. ></TABLE
  13615. ><P
  13616. ></P
  13617. ></DIV
  13618. >
  13619.      Die Gr÷▀e eines Integer-Wertes ist plattformabhΣngig, ein
  13620.      Maximalwert von ungefΣhr zwei Milliarden ist jedoch ⁿblich
  13621.      (vorzeichenbehafteter 32-Bit-Wert). PHP unterstⁿtzt keine
  13622.      vorzeichenlosen Integer-Werte.
  13623.     </P
  13624. ></DIV
  13625. ><DIV
  13626. CLASS="sect2"
  13627. ><HR><H3
  13628. CLASS="sect2"
  13629. ><A
  13630. NAME="language.types.integer.overflow"
  13631. >Integer ▄berlauf</A
  13632. ></H3
  13633. ><P
  13634. >      Wenn Sie eine Zahl jenseits der Grenzen des Typs
  13635.      Integer angeben, wird diese stattdessen als Typ
  13636.      <A
  13637. HREF="#language.types.float"
  13638. ><B
  13639. CLASS="type"
  13640. >float</B
  13641. ></A
  13642. > interpretiert.  Wenn Sie eine Operation
  13643.      ausfⁿhren, deren Ergebnis eine Zahl jenseits der Grenzen des Typs
  13644.      Integer ist, wird ebenso eine Zahl vom Typ
  13645.      <A
  13646. HREF="#language.types.float"
  13647. ><B
  13648. CLASS="type"
  13649. >float</B
  13650. ></A
  13651. > zurⁿckgegeben.
  13652.  
  13653.      <DIV
  13654. CLASS="informalexample"
  13655. ><P
  13656. ></P
  13657. ><A
  13658. NAME="AEN2623"
  13659. ></A
  13660. ><TABLE
  13661. BORDER="0"
  13662. BGCOLOR="#E0E0E0"
  13663. CELLPADDING="5"
  13664. ><TR
  13665. ><TD
  13666. ><PRE
  13667. CLASS="php"
  13668. ><?php
  13669. $grosse_zahl =  2147483647;
  13670. var_dump($grosse_zahl);
  13671. // Ausgabe: int(2147483647)
  13672.  
  13673. $grosse_zahl =  2147483648;
  13674. var_dump($grosse_zahl);
  13675. // Ausgabe: float(2147483648)
  13676.  
  13677. // das gilt auch fⁿr Integers in hexadezimaler Schreibweise:
  13678. var_dump( 0x80000000 );
  13679. // Ausgabe: float(2147483648)
  13680.  
  13681. $million = 1000000;
  13682. $grosse_zahl =  50000 * $million;
  13683. var_dump($grosse_zahl);
  13684. // Ausgabe: float(50000000000)
  13685. ?></PRE
  13686. ></TD
  13687. ></TR
  13688. ></TABLE
  13689. ><P
  13690. ></P
  13691. ></DIV
  13692. >
  13693.      <DIV
  13694. CLASS="warning"
  13695. ><P
  13696. ></P
  13697. ><TABLE
  13698. CLASS="warning"
  13699. BORDER="1"
  13700. WIDTH="100%"
  13701. ><TR
  13702. ><TD
  13703. ALIGN="CENTER"
  13704. ><B
  13705. >Warnung</B
  13706. ></TD
  13707. ></TR
  13708. ><TR
  13709. ><TD
  13710. ALIGN="LEFT"
  13711. ><P
  13712. >        Bedauerlicherweise gab es einen Bug in PHP, der die korrekte
  13713.        Funktionsweise verhinderte, wenn negative Zahlen verwendet
  13714.        wurden.  Ein Beispiel: Bei der Ausfⁿhrung von <VAR
  13715. CLASS="literal"
  13716. >-50000
  13717.        * $million</VAR
  13718. > war das Ergebnis
  13719.        <VAR
  13720. CLASS="literal"
  13721. >-429496728</VAR
  13722. >. Sind beide Operanden positiv
  13723.        gibt es keine Probleme.
  13724.       </P
  13725. ><P
  13726. >        Dieses Problem ist in PHP 4.1.0 behoben worden.
  13727.       </P
  13728. ></TD
  13729. ></TR
  13730. ></TABLE
  13731. ></DIV
  13732. >
  13733.     </P
  13734. ><P
  13735. >      In PHP gibt es keinen Operator fⁿr Integer-Divisonen.
  13736.      <VAR
  13737. CLASS="literal"
  13738. >1/2</VAR
  13739. > ergibt <A
  13740. HREF="#language.types.float"
  13741. ><B
  13742. CLASS="type"
  13743. >float</B
  13744. ></A
  13745. >
  13746.      <VAR
  13747. CLASS="literal"
  13748. >0.5</VAR
  13749. >.  Sie k÷nnen den Wert in einen Integer
  13750.      umwandeln, um ihn immer abzurunden oder die Funktion
  13751.      <A
  13752. HREF="#function.round"
  13753. ><B
  13754. CLASS="function"
  13755. >round()</B
  13756. ></A
  13757. > benutzen.
  13758.      <DIV
  13759. CLASS="informalexample"
  13760. ><P
  13761. ></P
  13762. ><A
  13763. NAME="AEN2635"
  13764. ></A
  13765. ><TABLE
  13766. BORDER="0"
  13767. BGCOLOR="#E0E0E0"
  13768. CELLPADDING="5"
  13769. ><TR
  13770. ><TD
  13771. ><PRE
  13772. CLASS="php"
  13773. ><?php
  13774. var_dump(25/7);         // float(3.5714285714286)
  13775. var_dump((int) (25/7)); // int(3)
  13776. var_dump(round(25/7));  // float(4)
  13777. ?></PRE
  13778. ></TD
  13779. ></TR
  13780. ></TABLE
  13781. ><P
  13782. ></P
  13783. ></DIV
  13784. >
  13785.     </P
  13786. ></DIV
  13787. ><DIV
  13788. CLASS="sect2"
  13789. ><HR><H3
  13790. CLASS="sect2"
  13791. ><A
  13792. NAME="language.types.integer.casting"
  13793. >Umwandlung nach integer</A
  13794. ></H3
  13795. ><P
  13796. >      Um einen Wert ausdrⁿcklich nach <A
  13797. HREF="#language.types.integer"
  13798. ><B
  13799. CLASS="type"
  13800. >integer</B
  13801. ></A
  13802. > zu
  13803.      konvertieren, benutzen Sie entweder die Umwandlung mittels
  13804.      <VAR
  13805. CLASS="literal"
  13806. >(int)</VAR
  13807. > oder <VAR
  13808. CLASS="literal"
  13809. >(integer)</VAR
  13810. >. In
  13811.      den allermeisten FΣllen ist es jedoch nicht notwendig die
  13812.      Umwandlung selbst vorzunehmen. Ein Wert wird automatisch
  13813.      konvertiert, falls ein Operator, eine Funktion oder eine
  13814.      Kontrollstruktur ein <A
  13815. HREF="#language.types.integer"
  13816. ><B
  13817. CLASS="type"
  13818. >integer</B
  13819. ></A
  13820. > Argument erfordern.
  13821.      Sie k÷nnen einen Wert auch mit der Funktion
  13822.      <A
  13823. HREF="#function.intval"
  13824. ><B
  13825. CLASS="function"
  13826. >intval()</B
  13827. ></A
  13828. > in einen Integer umwandeln.
  13829.     </P
  13830. ><P
  13831. >      Siehe auch <A
  13832. HREF="#language.types.type-juggling"
  13833. >Typ-VerΣnderung</A
  13834. >.
  13835.     </P
  13836. ><DIV
  13837. CLASS="sect3"
  13838. ><HR><H4
  13839. CLASS="sect3"
  13840. ><A
  13841. NAME="language.types.integer.casting.from-boolean"
  13842. >Von <A
  13843. HREF="#language.types.boolean"
  13844. >Booleans</A
  13845. ></A
  13846. ></H4
  13847. ><P
  13848. >       <TT
  13849. CLASS="constant"
  13850. ><B
  13851. >FALSE</B
  13852. ></TT
  13853. > ergibt <VAR
  13854. CLASS="literal"
  13855. >0</VAR
  13856. > (Null), und <TT
  13857. CLASS="constant"
  13858. ><B
  13859. >TRUE</B
  13860. ></TT
  13861. > ergibt
  13862.       <VAR
  13863. CLASS="literal"
  13864. >1</VAR
  13865. > (Eins).
  13866.      </P
  13867. ></DIV
  13868. ><DIV
  13869. CLASS="sect3"
  13870. ><HR><H4
  13871. CLASS="sect3"
  13872. ><A
  13873. NAME="language.types.integer.casting.from-float"
  13874. >Von <A
  13875. HREF="#language.types.float"
  13876. >Flie▀komma-Zahlen</A
  13877. ></A
  13878. ></H4
  13879. ><P
  13880. >       Bei der Umwandlung von <A
  13881. HREF="#language.types.float"
  13882. ><B
  13883. CLASS="type"
  13884. >float</B
  13885. ></A
  13886. > nach integer wird die
  13887.       Zahl <SPAN
  13888. CLASS="emphasis"
  13889. ><I
  13890. CLASS="emphasis"
  13891. >in Richtung Null</I
  13892. ></SPAN
  13893. > gerundet.
  13894.      </P
  13895. ><P
  13896. >       Wenn der float jenseits der Grenzen von integer liegt
  13897.       (ⁿblicherweise <VAR
  13898. CLASS="literal"
  13899. >+/- 2.15e+9 = 2^31</VAR
  13900. >), ist das
  13901.       Ergebnis nicht definiert, weil float nicht genug PrΣzision
  13902.       besitzt um ein genaues integer Ergebnis zu liefern. Keine
  13903.       Warnung, nicht einmal eine Notiz wird in diesem Fall ausgegeben.
  13904.      </P
  13905. ><DIV
  13906. CLASS="warning"
  13907. ><P
  13908. ></P
  13909. ><TABLE
  13910. CLASS="warning"
  13911. BORDER="1"
  13912. WIDTH="100%"
  13913. ><TR
  13914. ><TD
  13915. ALIGN="CENTER"
  13916. ><B
  13917. >Warnung</B
  13918. ></TD
  13919. ></TR
  13920. ><TR
  13921. ><TD
  13922. ALIGN="LEFT"
  13923. ><P
  13924. >        Wandeln Sie nie einen Teil eines Ausdrucks nach
  13925.        <A
  13926. HREF="#language.types.integer"
  13927. ><B
  13928. CLASS="type"
  13929. >integer</B
  13930. ></A
  13931. > um, da dies manchmal zu unerwarteten
  13932.        Ergebnissen fⁿhren kann.
  13933.        <DIV
  13934. CLASS="informalexample"
  13935. ><P
  13936. ></P
  13937. ><A
  13938. NAME="AEN2666"
  13939. ></A
  13940. ><TABLE
  13941. BORDER="0"
  13942. BGCOLOR="#E0E0E0"
  13943. CELLPADDING="5"
  13944. ><TR
  13945. ><TD
  13946. ><PRE
  13947. CLASS="php"
  13948. ><?php
  13949. echo (int) ( (0.1+0.7) * 10 ); // Ausgabe: 7!
  13950. ?></PRE
  13951. ></TD
  13952. ></TR
  13953. ></TABLE
  13954. ><P
  13955. ></P
  13956. ></DIV
  13957. >
  13958.        Fⁿr mehr Informationen schauen Sie unter <A
  13959. HREF="#warn.float-precision"
  13960. >Warnung ⁿber
  13961.        float-PrΣzision</A
  13962. > nach.
  13963.       </P
  13964. ></TD
  13965. ></TR
  13966. ></TABLE
  13967. ></DIV
  13968. ></DIV
  13969. ><DIV
  13970. CLASS="sect3"
  13971. ><HR><H4
  13972. CLASS="sect3"
  13973. ><A
  13974. NAME="language.types.integer.casting.from-string"
  13975. >Von Zeichenketten / Strings</A
  13976. ></H4
  13977. ><P
  13978. >       Siehe <A
  13979. HREF="#language.types.string.conversion"
  13980. >Umwandlung von
  13981.       Strings in Zahlen</A
  13982. >
  13983.      </P
  13984. ></DIV
  13985. ><DIV
  13986. CLASS="sect3"
  13987. ><HR><H4
  13988. CLASS="sect3"
  13989. ><A
  13990. NAME="language.types.integer.casting.from-other"
  13991. >Von anderen Typen</A
  13992. ></H4
  13993. ><P
  13994. >       <DIV
  13995. CLASS="caution"
  13996. ><P
  13997. ></P
  13998. ><TABLE
  13999. CLASS="caution"
  14000. BORDER="1"
  14001. WIDTH="100%"
  14002. ><TR
  14003. ><TD
  14004. ALIGN="CENTER"
  14005. ><B
  14006. >Achtung</B
  14007. ></TD
  14008. ></TR
  14009. ><TR
  14010. ><TD
  14011. ALIGN="LEFT"
  14012. ><P
  14013. >         Das Verhalten bei der Umwandlung nach integer ist fⁿr andere
  14014.         Typen nicht definiert. Zum gegenwΣrtigen Zeitpunkt ist das
  14015.         Verhalten so, als ob der Wert zuerst nach <A
  14016. HREF="#language.types.boolean.casting"
  14017. >boolean</A
  14018. >
  14019.         konvertiert wird. Auf jeden Fall sollten Sie sich auf dieses
  14020.         Verhalten <SPAN
  14021. CLASS="emphasis"
  14022. ><I
  14023. CLASS="emphasis"
  14024. >nicht</I
  14025. ></SPAN
  14026. > verlassen. Es kann sich
  14027.         ohne Ankⁿndigung Σndern.
  14028.        </P
  14029. ></TD
  14030. ></TR
  14031. ></TABLE
  14032. ></DIV
  14033. >
  14034.      </P
  14035. ></DIV
  14036. ></DIV
  14037. ></DIV
  14038. ><DIV
  14039. CLASS="sect1"
  14040. ><HR><H2
  14041. CLASS="sect1"
  14042. ><A
  14043. NAME="language.types.float"
  14044. >Flie▀komma-Zahlenwerte</A
  14045. ></H2
  14046. ><P
  14047. >     Flie▀komma-Zahlenwerte ("floats", "doubles" oder "reelle Zahlen")
  14048.     k÷nnen durch eine der folgenden Anweisungen zugewiesen werden:
  14049.     <DIV
  14050. CLASS="informalexample"
  14051. ><P
  14052. ></P
  14053. ><A
  14054. NAME="AEN2683"
  14055. ></A
  14056. ><TABLE
  14057. BORDER="0"
  14058. BGCOLOR="#E0E0E0"
  14059. CELLPADDING="5"
  14060. ><TR
  14061. ><TD
  14062. ><PRE
  14063. CLASS="php"
  14064. ><?php
  14065. $a = 1.234;
  14066. $a = 1.2e3;
  14067. $a = 7E-10;
  14068. ?></PRE
  14069. ></TD
  14070. ></TR
  14071. ></TABLE
  14072. ><P
  14073. ></P
  14074. ></DIV
  14075. >
  14076.     Formell:
  14077.     <DIV
  14078. CLASS="informalexample"
  14079. ><P
  14080. ></P
  14081. ><A
  14082. NAME="AEN2685"
  14083. ></A
  14084. ><TABLE
  14085. BORDER="0"
  14086. BGCOLOR="#E0E0E0"
  14087. CELLPADDING="5"
  14088. ><TR
  14089. ><TD
  14090. ><PRE
  14091. CLASS="php"
  14092. >LNUM          [0-9]+
  14093. DNUM          ([0-9]*[\.]{LNUM}) | ({LNUM}[\.][0-9]*)
  14094. EXPONENT_DNUM ( ({LNUM} | {DNUM}) [eE][+-]? {LNUM})</PRE
  14095. ></TD
  14096. ></TR
  14097. ></TABLE
  14098. ><P
  14099. ></P
  14100. ></DIV
  14101. >
  14102.     Die Gr÷▀e einer Flie▀komma-Zahl ist plattformabhΣngig, dennoch
  14103.     stellt ein Maximum von ~1.8e308 mit einer Genauigkeit von 14
  14104.     Nachkomma-Stellen einen ⁿblichen Wert dar (das entspricht 64-Bit
  14105.     im IEEE-Format).
  14106.    </P
  14107. ><DIV
  14108. CLASS="warning"
  14109. ><P
  14110. ></P
  14111. ><TABLE
  14112. CLASS="warning"
  14113. BORDER="1"
  14114. WIDTH="100%"
  14115. ><TR
  14116. ><TD
  14117. ALIGN="CENTER"
  14118. ><B
  14119. ><A
  14120. NAME="warn.float-precision"
  14121. ></A
  14122. >Flie▀komma PrΣzision</B
  14123. ></TD
  14124. ></TR
  14125. ><TR
  14126. ><TD
  14127. ALIGN="LEFT"
  14128. ><P
  14129. >      Es ist ziemlich normal, dass einfache Dezimalzahlen wie
  14130.      <VAR
  14131. CLASS="literal"
  14132. >0.1</VAR
  14133. > oder <VAR
  14134. CLASS="literal"
  14135. >0.7</VAR
  14136. > nicht in ihre
  14137.      internen binΣren Entsprechungen konvertiert werden k÷nnen, ohne
  14138.      einen kleinen Teil ihrer Genauigkeit zu verlieren. Das kann zu
  14139.      verwirrenden Ergebnissen fⁿhren. So wird <VAR
  14140. CLASS="literal"
  14141. >floor((0.1 +
  14142.      0.7) * 10)</VAR
  14143. > normalerweise <VAR
  14144. CLASS="literal"
  14145. >7</VAR
  14146. > statt des
  14147.      erwarteten Wertes <VAR
  14148. CLASS="literal"
  14149. >8</VAR
  14150. > zurⁿck geben (als Ergebnis
  14151.      der internen Entsprechung von <VAR
  14152. CLASS="literal"
  14153. >7.9999999999...</VAR
  14154. >.
  14155.     </P
  14156. ><P
  14157. >      Das grⁿndet sich auf die Tatsache, dass es unm÷glich ist, manche
  14158.      Dezimal-Zahlen durch eine endliche Anzahl an Nachkomma-Stellen
  14159.      darzustellen. Dem Wert <VAR
  14160. CLASS="literal"
  14161. >1/3</VAR
  14162. > entspricht z.B.
  14163.      der interne Wert von <VAR
  14164. CLASS="literal"
  14165. >0.3333333. . .</VAR
  14166. >.
  14167.     </P
  14168. ><P
  14169. >      Deshalb sollten Sie nie den Ergebnissen von
  14170.      Flie▀komma-Operationen bis auf die letzte Nachkomma-Stelle trauen
  14171.      und nie solche auf Gleichheit prⁿfen. Ben÷tigen Sie wirklich eine
  14172.      gr÷▀ere Genauigkeit, sollten sie die <A
  14173. HREF="#ref.bc"
  14174. >mathematischen Funktionen beliebiger
  14175.      Genauigkeit</A
  14176. > oder die <A
  14177. HREF="#ref.gmp"
  14178. >Gmp</A
  14179. >
  14180.      Funktionen benutzen.
  14181.     </P
  14182. ></TD
  14183. ></TR
  14184. ></TABLE
  14185. ></DIV
  14186. ><DIV
  14187. CLASS="sect2"
  14188. ><HR><H3
  14189. CLASS="sect2"
  14190. ><A
  14191. NAME="language.types.float.casting"
  14192. >Umwandlung nach float</A
  14193. ></H3
  14194. ><P
  14195. >      Fⁿr Informationen darⁿber, wann und wie Strings in Float
  14196.      umgewandelt werden, lesen Sie bitte den Abschnitt <A
  14197. HREF="#language.types.string.conversion"
  14198. >Umwandlung von Strings
  14199.      in Zahlen</A
  14200. >. Fⁿr die Werte anderer Typen ist die Umwandlung
  14201.      diesselbe, wie wenn der Wert in eine Ganzzahl und dann in einen
  14202.      Float umgewandelt worden wΣre. Fⁿr weitere Informationen siehe
  14203.      Abschnitt <A
  14204. HREF="#language.types.integer.casting"
  14205. >Umwandlung nach
  14206.      integer</A
  14207. >.
  14208.     </P
  14209. ></DIV
  14210. ></DIV
  14211. ><DIV
  14212. CLASS="sect1"
  14213. ><HR><H2
  14214. CLASS="sect1"
  14215. ><A
  14216. NAME="language.types.string"
  14217. >Strings / Zeichenketten</A
  14218. ></H2
  14219. ><P
  14220. >     Ein String ist eine Folge von Zeichen. In PHP
  14221.     entspricht ein Zeichen einem Byte, das hei▀t, dass exakt 256
  14222.     unterschiedliche Zeichen m÷glich sind. Das impliziert auch, dass
  14223.     PHP keine native Unterstⁿtzung fⁿr Unicode bietet. Siehe
  14224.     <A
  14225. HREF="#function.utf8-encode"
  14226. ><B
  14227. CLASS="function"
  14228. >utf8_encode()</B
  14229. ></A
  14230. > und
  14231.     <A
  14232. HREF="#function.utf8-decode"
  14233. ><B
  14234. CLASS="function"
  14235. >utf8_decode()</B
  14236. ></A
  14237. > fⁿr etwas Unicode-Unterstⁿtzung.
  14238.    </P
  14239. ><DIV
  14240. CLASS="note"
  14241. ><BLOCKQUOTE
  14242. CLASS="note"
  14243. ><P
  14244. ><B
  14245. >Anmerkung: </B
  14246. >
  14247.      Fⁿr einen String stellt die LΣnge kein Problem dar. Von PHP-Seite
  14248.      aus gibt es keine praktische Grenze fⁿr die Gr÷▀e eines Strings.
  14249.      Daher gibt es keinen Grund sich Sorgen ⁿber lange Strings zu
  14250.      machen.
  14251.     </P
  14252. ></BLOCKQUOTE
  14253. ></DIV
  14254. ><DIV
  14255. CLASS="sect2"
  14256. ><HR><H3
  14257. CLASS="sect2"
  14258. ><A
  14259. NAME="language.types.string.syntax"
  14260. >Syntax</A
  14261. ></H3
  14262. ><P
  14263. >      Ein String kann auf drei verschiedene Weisen geschrieben werden.
  14264.  
  14265.      <P
  14266. ></P
  14267. ><UL
  14268. ><LI
  14269. ><P
  14270. >         <A
  14271. HREF="#language.types.string.syntax.single"
  14272. >Einfache
  14273.         Anfⁿhrungszeichen (single quoted)</A
  14274. >
  14275.        </P
  14276. ></LI
  14277. ><LI
  14278. ><P
  14279. >         <A
  14280. HREF="#language.types.string.syntax.double"
  14281. >Doppelte
  14282.         Anfⁿhrungszeichen (double quoted)</A
  14283. >
  14284.        </P
  14285. ></LI
  14286. ><LI
  14287. ><P
  14288. >         <A
  14289. HREF="#language.types.string.syntax.heredoc"
  14290. >Heredoc
  14291.         Syntax</A
  14292. >
  14293.        </P
  14294. ></LI
  14295. ></UL
  14296. >
  14297.     </P
  14298. ><DIV
  14299. CLASS="sect3"
  14300. ><HR><H4
  14301. CLASS="sect3"
  14302. ><A
  14303. NAME="language.types.string.syntax.single"
  14304. >Einfache Anfⁿhrungszeichen (Single quoted)</A
  14305. ></H4
  14306. ><P
  14307. >       Der leichteste Weg einen einfachen String zu schreiben, ist der
  14308.       Einschluss in einfache Anfⁿhrungszeichen (das Zeichen
  14309.       <VAR
  14310. CLASS="literal"
  14311. >'</VAR
  14312. >).
  14313.      </P
  14314. ><P
  14315. >       Um ein einfaches Anfⁿhrungszeichen w÷rtlich auszugeben, muss
  14316.       dieses, wie in vielen anderen Programmiersprachen auch mit einem
  14317.       Backslash (<VAR
  14318. CLASS="literal"
  14319. >\</VAR
  14320. >) escaped werden. Wenn Sie
  14321.       innerhalb eines Strings einen Backslash vor einem einfachen
  14322.       Anfⁿhrungszeichen oder am Ende eines Strings ausgeben wollen,
  14323.       mⁿssen Sie diesen verdoppeln.  Beachten Sie: wenn Sie versuchen
  14324.       irgendwelche anderen Zeichen zu escapen, wird der Backslash
  14325.       ebenfalls ausgegeben! Daher besteht fⁿr gew÷hnlich keine
  14326.       Notwendigkeit den Backslash selbst zu escapen.
  14327.       <DIV
  14328. CLASS="note"
  14329. ><BLOCKQUOTE
  14330. CLASS="note"
  14331. ><P
  14332. ><B
  14333. >Anmerkung: </B
  14334. >
  14335.         In PHP 3 wird eine Warnung der Stufe
  14336.         <VAR
  14337. CLASS="literal"
  14338. >E_NOTICE</VAR
  14339. > ausgegeben, wenn das passiert.
  14340.        </P
  14341. ></BLOCKQUOTE
  14342. ></DIV
  14343. >
  14344.       <DIV
  14345. CLASS="note"
  14346. ><BLOCKQUOTE
  14347. CLASS="note"
  14348. ><P
  14349. ><B
  14350. >Anmerkung: </B
  14351. >
  14352.         Anders als bei den zwei anderen Schreibweisen werden <A
  14353. HREF="#language.variables"
  14354. >Variablen</A
  14355. > und
  14356.         escape-Sequenzen fⁿr spezielle Zeichen innerhalb von
  14357.         single-quoted Strings <SPAN
  14358. CLASS="emphasis"
  14359. ><I
  14360. CLASS="emphasis"
  14361. >nicht</I
  14362. ></SPAN
  14363. > ausgewertet.
  14364.        </P
  14365. ></BLOCKQUOTE
  14366. ></DIV
  14367. >
  14368.       <DIV
  14369. CLASS="informalexample"
  14370. ><P
  14371. ></P
  14372. ><A
  14373. NAME="AEN2741"
  14374. ></A
  14375. ><TABLE
  14376. BORDER="0"
  14377. BGCOLOR="#E0E0E0"
  14378. CELLPADDING="5"
  14379. ><TR
  14380. ><TD
  14381. ><PRE
  14382. CLASS="php"
  14383. ><?php
  14384. echo 'Das ist ein einfacher String';
  14385.  
  14386. echo 'Sie k÷nnen auf diese Weise auch Zeilenumbrⁿche
  14387. innerhalb von Strings verwenden, wenn
  14388. Ihnen danach ist';
  14389.  
  14390. // Ausgabe: Arnold sagte einmal: "I'll be back"
  14391. echo 'Arnold sagte einmal: "I\'ll be back"';
  14392.  
  14393. // Ausgabe: Sie haben C:\*.* gel÷scht?
  14394. echo 'Sie haben C:\\*.* gel÷scht?';
  14395.  
  14396. // Ausgabe: Sie haben C:\*.* gel÷scht?
  14397. echo 'Sie haben C:\*.* gel÷scht?';
  14398.  
  14399. // Ausgabe: Das wird nicht ausgewertet: \n ein Zeilenumbruch
  14400. echo 'Das wird nicht ausgewertet: \n ein Zeilenumbruch';
  14401.  
  14402. // Ausgabe: Variablen werden auch $nicht $ausgewertet
  14403. echo 'Variablen werden auch $nicht $ausgewertet';
  14404. ?></PRE
  14405. ></TD
  14406. ></TR
  14407. ></TABLE
  14408. ><P
  14409. ></P
  14410. ></DIV
  14411. >
  14412.      </P
  14413. ></DIV
  14414. ><DIV
  14415. CLASS="sect3"
  14416. ><HR><H4
  14417. CLASS="sect3"
  14418. ><A
  14419. NAME="language.types.string.syntax.double"
  14420. >Doppelte Anfⁿhrungszeichen (Double quoted)</A
  14421. ></H4
  14422. ><P
  14423. >       Wenn ein String in doppelten Anfⁿhrungszeichen (")
  14424.       eingeschlossen ist, versteht PHP mehr Escape-Folgen fⁿr
  14425.       spezielle Zeichen:
  14426.      </P
  14427. ><DIV
  14428. CLASS="table"
  14429. ><A
  14430. NAME="AEN2746"
  14431. ></A
  14432. ><P
  14433. ><B
  14434. >Tabelle 10-1. Nicht ausgewertete / ⁿbergangene Zeichen:</B
  14435. ></P
  14436. ><TABLE
  14437. BORDER="1"
  14438. CLASS="CALSTABLE"
  14439. ><COL><COL><THEAD
  14440. ><TR
  14441. ><TH
  14442. >Zeichenfolge</TH
  14443. ><TH
  14444. >Bedeutung</TH
  14445. ></TR
  14446. ></THEAD
  14447. ><TBODY
  14448. ><TR
  14449. ><TD
  14450. ><VAR
  14451. CLASS="literal"
  14452. >\n</VAR
  14453. ></TD
  14454. ><TD
  14455. >Zeilenvorschub (LF oder 0x0A als ASCII-Code)</TD
  14456. ></TR
  14457. ><TR
  14458. ><TD
  14459. ><VAR
  14460. CLASS="literal"
  14461. >\r</VAR
  14462. ></TD
  14463. ><TD
  14464. >Wagenrⁿcklauf (CR oder 0x0D als ASCII-Code)</TD
  14465. ></TR
  14466. ><TR
  14467. ><TD
  14468. ><VAR
  14469. CLASS="literal"
  14470. >\t</VAR
  14471. ></TD
  14472. ><TD
  14473. >           horizontaler Tabulator (HT oder 0x09 als ASCII-Code)
  14474.          </TD
  14475. ></TR
  14476. ><TR
  14477. ><TD
  14478. ><VAR
  14479. CLASS="literal"
  14480. >\\</VAR
  14481. ></TD
  14482. ><TD
  14483. >Backslash / Rⁿckstrich</TD
  14484. ></TR
  14485. ><TR
  14486. ><TD
  14487. ><VAR
  14488. CLASS="literal"
  14489. >\$</VAR
  14490. ></TD
  14491. ><TD
  14492. >Dollar-Symbol</TD
  14493. ></TR
  14494. ><TR
  14495. ><TD
  14496. ><VAR
  14497. CLASS="literal"
  14498. >\"</VAR
  14499. ></TD
  14500. ><TD
  14501. >doppelte Anfⁿhrungszeichen</TD
  14502. ></TR
  14503. ><TR
  14504. ><TD
  14505. ><VAR
  14506. CLASS="literal"
  14507. >\[0-7]{1,3}</VAR
  14508. ></TD
  14509. ><TD
  14510. >           die Zeichenfolge, die dem regulΣren Ausdruck entspricht ist
  14511.           ein Zeichen in Oktal-Schreibweise
  14512.          </TD
  14513. ></TR
  14514. ><TR
  14515. ><TD
  14516. ><VAR
  14517. CLASS="literal"
  14518. >\x[0-9A-Fa-f]{1,2}</VAR
  14519. ></TD
  14520. ><TD
  14521. >           die Zeichenfolge, die dem regulΣren Ausdruck entspricht ist
  14522.           ein Zeichen in Hexadezimal-Schreibweise
  14523.          </TD
  14524. ></TR
  14525. ></TBODY
  14526. ></TABLE
  14527. ></DIV
  14528. ><P
  14529. >       Noch einmal: wenn Sie versuchen, irgend ein anderes Zeichen zu
  14530.       escapen wird der Backslash ebenfalls ausgegeben!
  14531.      </P
  14532. ><P
  14533. >       Das wichtigste Merkmal von double-quoted Strings ist die
  14534.       Tatsache, dass Variablennamen ausgewertet werden. Fⁿr Details
  14535.       siehe <A
  14536. HREF="#language.types.string.parsing"
  14537. >String
  14538.       Analyse (parsing)</A
  14539. >
  14540.      </P
  14541. ></DIV
  14542. ><DIV
  14543. CLASS="sect3"
  14544. ><HR><H4
  14545. CLASS="sect3"
  14546. ><A
  14547. NAME="language.types.string.syntax.heredoc"
  14548. >Heredoc</A
  14549. ></H4
  14550. ><P
  14551. >       Eine andere M÷glichkeit Strings einzufassen, besteht im Gebrauch
  14552.       der heredoc-Syntax ("<<<"). Hierfⁿr ist nach
  14553.       <VAR
  14554. CLASS="literal"
  14555. ><<<</VAR
  14556. > ein Bezeichner zu setzen. Nun
  14557.       folgt der eigentliche String und dann derselbe Bezeichner um den
  14558.       String abzuschlie▀en.
  14559.      </P
  14560. ><P
  14561. >       Der schlie▀ende Bezeichner <SPAN
  14562. CLASS="emphasis"
  14563. ><I
  14564. CLASS="emphasis"
  14565. >muss</I
  14566. ></SPAN
  14567. > in der
  14568.       ersten Spalte der Zeile stehen. Die verwendeten Bezeichner
  14569.       mⁿssen den gleichen Regeln entsprechen wie alle anderen
  14570.       PHP-Labels auch: Sie dⁿrfen lediglich alphanumerische Zeichen
  14571.       und den Unterstrich enthalten und mⁿssen mit einem Unterstrich
  14572.       oder einem Buchstaben beginnen.
  14573.      </P
  14574. ><DIV
  14575. CLASS="warning"
  14576. ><P
  14577. ></P
  14578. ><TABLE
  14579. CLASS="warning"
  14580. BORDER="1"
  14581. WIDTH="100%"
  14582. ><TR
  14583. ><TD
  14584. ALIGN="CENTER"
  14585. ><B
  14586. >Warnung</B
  14587. ></TD
  14588. ></TR
  14589. ><TR
  14590. ><TD
  14591. ALIGN="LEFT"
  14592. ><P
  14593. >        Es ist sehr wichtig zu beachten, dass die Zeile mit dem
  14594.        schlie▀enden Bezeichner keine anderen Zeichen enthΣlt,
  14595.        ausgenommen <SPAN
  14596. CLASS="emphasis"
  14597. ><I
  14598. CLASS="emphasis"
  14599. >m÷glicherweise</I
  14600. ></SPAN
  14601. > ein Semikolon
  14602.        (<VAR
  14603. CLASS="literal"
  14604. >;</VAR
  14605. >). Das bedeuted im Besonderen, dass der
  14606.        Bezeichner <SPAN
  14607. CLASS="emphasis"
  14608. ><I
  14609. CLASS="emphasis"
  14610. >nicht eingerⁿckt werden darf</I
  14611. ></SPAN
  14612. >
  14613.        und es dⁿrfen keine Leerzeichen oder Tabulatoren vor oder nach
  14614.        dem Semikolon stehen. Au▀erdem ist es wichtig, zu beachten,
  14615.        dass das erste Zeichen vor dem schlie▀enden Bezeichner ein der
  14616.        Definition Ihres Betriebssystems entsprechender Zeilenvorschub,
  14617.        sein muss. Das ist zum Beispiel auf einem Macintosh ein
  14618.        <VAR
  14619. CLASS="literal"
  14620. >\r</VAR
  14621. >.
  14622.       </P
  14623. ><P
  14624. >        Falls diese Regel gebrochen wird und der schlie▀ende Bezeichner
  14625.        nicht "sauber" ist, wird er nicht als schlie▀ender Bezeichner
  14626.        betrachtet und PHP wird weiter danach suchen. Wird in diesem
  14627.        Fall kein korrekter schlie▀ender Bezeichner gefunden, gibt es
  14628.        einen Parser-Fehler mit der Zeilennummer vom Ende des Skripts.
  14629.       </P
  14630. ></TD
  14631. ></TR
  14632. ></TABLE
  14633. ></DIV
  14634. ><P
  14635. >       Heredoc-Text funktioniert wie ein String innnerhalb doppelter
  14636.       Anfⁿhrungszeichen, nur ohne doppelte Anfⁿhrungszeichen.
  14637.       Anfⁿhrungszeichen innerhalb von heredoc-Texten mⁿssen also
  14638.       keiner Sonderbehandlung (escapen) unterzogen werden, aber Sie
  14639.       k÷nnen dennoch die oben aufgefⁿhrten Escape-Anweisungen
  14640.       verwenden. Variablen werden ausgewertet, aber besondere
  14641.       Aufmerksamkeit muss komplexen Variablen gewidmet werden, genau
  14642.       wie bei Strings.
  14643.       <TABLE
  14644. WIDTH="100%"
  14645. BORDER="0"
  14646. CELLPADDING="0"
  14647. CELLSPACING="0"
  14648. CLASS="EXAMPLE"
  14649. ><TR
  14650. ><TD
  14651. ><DIV
  14652. CLASS="example"
  14653. ><A
  14654. NAME="AEN2803"
  14655. ></A
  14656. ><P
  14657. ><B
  14658. >Beispiel 10-2. 
  14659.         Beispiel zur String-Festlegung per "heredoc"-Methode:
  14660.        </B
  14661. ></P
  14662. ><TABLE
  14663. BORDER="0"
  14664. BGCOLOR="#E0E0E0"
  14665. CELLPADDING="5"
  14666. ><TR
  14667. ><TD
  14668. ><PRE
  14669. CLASS="php"
  14670. ><?php
  14671. $str = <<<EOD
  14672. Beispiel eines Strings
  14673. ⁿber mehrere Script-Zeilen
  14674. durch Gebrauch der heredoc-Syntax.
  14675. EOD;
  14676.  
  14677. /* komplexeres Beispiel, mit Variablen */
  14678. class foo {
  14679.     var $foo;
  14680.     var $bar;
  14681.  
  14682.     function foo() {
  14683.         $this->foo = 'Foo';
  14684.         $this->bar = array('Bar1', 'Bar2', 'Bar3');
  14685.     }
  14686. }
  14687.  
  14688. $foo = new foo();
  14689. $name = 'Mein Name';
  14690.  
  14691. echo <<<EOT
  14692. Mein Name ist "$name". Ich schreibe einige $foo->foo.
  14693. Nun schreibe ich gerade einige {$foo->bar[1]}.
  14694. Dies sollte ein gro▀es 'A' schreiben: \x41
  14695. EOT;
  14696. ?></PRE
  14697. ></TD
  14698. ></TR
  14699. ></TABLE
  14700. ></DIV
  14701. ></TD
  14702. ></TR
  14703. ></TABLE
  14704. >
  14705.      </P
  14706. ><DIV
  14707. CLASS="note"
  14708. ><BLOCKQUOTE
  14709. CLASS="note"
  14710. ><P
  14711. ><B
  14712. >Anmerkung: </B
  14713. >
  14714.        Die heredoc Unterstⁿtzung wurde in PHP 4 eingefⁿhrt.
  14715.       </P
  14716. ></BLOCKQUOTE
  14717. ></DIV
  14718. ></DIV
  14719. ><DIV
  14720. CLASS="sect3"
  14721. ><HR><H4
  14722. CLASS="sect3"
  14723. ><A
  14724. NAME="language.types.string.parsing"
  14725. >Variablen-Analyse (parsing)</A
  14726. ></H4
  14727. ><P
  14728. >       Wird ein String in doppelten Anfⁿhrungszeichen oder mit heredoc
  14729.       angegeben, werden enthaltene <A
  14730. HREF="#language.variables"
  14731. >Variablen</A
  14732. > ausgewertet
  14733.       (geparst).
  14734.      </P
  14735. ><P
  14736. >       Es gibt zwei Syntax-Typen: eine <A
  14737. HREF="#language.types.string.parsing.simple"
  14738. >einfache</A
  14739. >
  14740.       und eine <A
  14741. HREF="#language.types.string.parsing.complex"
  14742. >komplexe</A
  14743. >.
  14744.       Die einfache Syntax ist die gelΣufigste und bequemste. Sie
  14745.       bietet die M÷glichkeit eine Variable, einen
  14746.       Array-Wert oder eine
  14747.       Objekt-Eigenschaft auszuwerten (parsen).
  14748.      </P
  14749. ><P
  14750. >       Die komplexe Syntax wurde in PHP 4 eingefⁿhrt und ist an den
  14751.       geschweiften Klammern <VAR
  14752. CLASS="literal"
  14753. >{}</VAR
  14754. >erkennbar, die den
  14755.       Ausdruck umschlie▀en.
  14756.      </P
  14757. ><DIV
  14758. CLASS="sect4"
  14759. ><HR><H5
  14760. CLASS="sect4"
  14761. ><A
  14762. NAME="language.types.string.parsing.simple"
  14763. >Einfache Syntax</A
  14764. ></H5
  14765. ><P
  14766. >        Sobald ein Dollarzeichen (<VAR
  14767. CLASS="literal"
  14768. >$</VAR
  14769. >) auftaucht, wird
  14770.        der Parser versuchen, gierig so viele Zeichen wie m÷glich zu
  14771.        bekommen, um einen gⁿltigen Variablennamen zu bilden.
  14772.        Schlie▀en Sie Ihren Varaiblennamen in geschweifte Klammern ein,
  14773.        wenn Sie ausdrⁿcklich das Ende des Namens angeben wollen.
  14774.       </P
  14775. ><DIV
  14776. CLASS="informalexample"
  14777. ><P
  14778. ></P
  14779. ><A
  14780. NAME="AEN2823"
  14781. ></A
  14782. ><TABLE
  14783. BORDER="0"
  14784. BGCOLOR="#E0E0E0"
  14785. CELLPADDING="5"
  14786. ><TR
  14787. ><TD
  14788. ><PRE
  14789. CLASS="php"
  14790. ><?php
  14791. $beer = 'Heineken';
  14792. echo "$beer's Geschmack ist gro▀artig";  // funktioniert, "'" ist kein gⁿltiges
  14793.                                          // Zeichen fⁿr einen Variablennamen
  14794. echo "Er hat einige $beers getrunken";   // funktioniert nicht, 's' ist ein gⁿltiges
  14795.                                          // Zeichen fⁿr einen Variablennamen
  14796. echo "Er hat einige ${beer}s getrunken"; // funktioniert
  14797. echo "Er hat einige {$beer}s getrunken"; // funktioniert
  14798. ?></PRE
  14799. ></TD
  14800. ></TR
  14801. ></TABLE
  14802. ><P
  14803. ></P
  14804. ></DIV
  14805. ><P
  14806. >        Auf Σhnliche Weise k÷nnen Sie erreichen, dass ein
  14807.        Array-Index oder eine
  14808.        Objekt-Eigenschaft ausgewertet wird. Bei
  14809.        Array-Indizes markiert die schlie▀ende eckige Klammer
  14810.        (<VAR
  14811. CLASS="literal"
  14812. >]</VAR
  14813. >) das Ende des Index. Fⁿr
  14814.        Objekt-Eigenschaften gelten die gleichen Regeln wie bei
  14815.        einfachen Variablen, obwohl es bei Objekt-Eigenschaften keinen
  14816.        Trick gibt, wie dies bei Variablen der Fall ist.
  14817.       </P
  14818. ><DIV
  14819. CLASS="informalexample"
  14820. ><P
  14821. ></P
  14822. ><A
  14823. NAME="AEN2829"
  14824. ></A
  14825. ><TABLE
  14826. BORDER="0"
  14827. BGCOLOR="#E0E0E0"
  14828. CELLPADDING="5"
  14829. ><TR
  14830. ><TD
  14831. ><PRE
  14832. CLASS="php"
  14833. ><?php
  14834. // Diese Beispiele sind spezifisch fⁿr die Verwendung von Arrays
  14835. // innerhalb von Strings. Setzen sie die String-Schlⁿssel Ihrer Arrays
  14836. // au▀erhalb von Strings immer in Anfⁿhrungszeichen und verwenden Sie
  14837. // au▀erhalb von Strings auch keine {geschweiften Klammern}.
  14838.  
  14839. // Wir lassen uns alle Fehlermeldungen anzeigen
  14840. error_reporting(E_ALL);
  14841.  
  14842. $frⁿchte = array('Erdbeere' => 'rot' , 'Banane' => 'gelb');
  14843.  
  14844. // Funktioniert aber beachten Sie: au▀erhalb von
  14845. // String-Anfⁿhrungszeichen funktioniert das anders
  14846. echo "Eine Banane ist $frⁿchte[Banane].";
  14847.  
  14848. // Funktioniert
  14849. echo "Eine Banane ist {$frⁿchte['Banane']}.";
  14850.  
  14851. // Funktioniert, aber PHP sucht, wie unten beschrieben, zuerst nach
  14852. // einer Konstanten namens Banane.
  14853. echo "Eine Banane ist {$frⁿchte[Banane]}.";
  14854.  
  14855. // Funktioniert nicht; verwenden Sie geschweifte Klammern. Das
  14856. // erzeugt einen Parser-Fehler.
  14857. echo "Eine Banane ist $frⁿchte['Banane'].";
  14858.  
  14859. // Funktioniert
  14860. echo "Eine Banane ist " . $frⁿchte['Banane'] . ".";
  14861.  
  14862. // Funktioniert
  14863. echo "Dieses Quadrat ist $quadrat->breite Meter breit.";
  14864.  
  14865. // Funktioniert nicht. Fⁿr eine L÷sung siehe die komplexe Syntax.
  14866. echo "Dieses Quadrat ist $quadrat->breite00 Zentimeter breit.";
  14867. ?></PRE
  14868. ></TD
  14869. ></TR
  14870. ></TABLE
  14871. ><P
  14872. ></P
  14873. ></DIV
  14874. ><P
  14875. >        Fⁿr irgendetwas Komplexeres sollten Sie die komplexe Syntax
  14876.        nutzen.
  14877.       </P
  14878. ></DIV
  14879. ><DIV
  14880. CLASS="sect4"
  14881. ><HR><H5
  14882. CLASS="sect4"
  14883. ><A
  14884. NAME="language.types.string.parsing.complex"
  14885. >Komplexe (geschweifte) Syntax</A
  14886. ></H5
  14887. ><P
  14888. >        Diese wird nicht komplex genannt, weil etwa die Syntax komplex
  14889.        ist, sondern weil Sie auf diesem Weg komplexe Ausdrⁿcke
  14890.        einbeziehen k÷nnen.
  14891.       </P
  14892. ><P
  14893. >        TatsΣchlich k÷nnen Sie jeden beliebigen Wert einbeziehen, der
  14894.        im Namensbereich in Strings gⁿltig ist. Schreiben Sie den
  14895.        Ausdruck einfach auf die gleiche Art und Weise, wie au▀erhalb
  14896.        des Strings, und umschlie▀en diesen mit { und }. Da Sie '{'
  14897.        nicht escapen k÷nnen, wird diese Syntax nur erkannt, wenn auf {
  14898.        unmittelbar $ folgt.  (Benutzen Sie "{\$" oder "\{$" um ein
  14899.        w÷rtliches "{$" zu erhalten.) Einige Beispiele, um dies zu
  14900.        verdeutlichen:
  14901.       </P
  14902. ><DIV
  14903. CLASS="informalexample"
  14904. ><P
  14905. ></P
  14906. ><A
  14907. NAME="AEN2836"
  14908. ></A
  14909. ><TABLE
  14910. BORDER="0"
  14911. BGCOLOR="#E0E0E0"
  14912. CELLPADDING="5"
  14913. ><TR
  14914. ><TD
  14915. ><PRE
  14916. CLASS="php"
  14917. ><?php
  14918. // Wir lassen uns alle Fehlermeldungen anzeigen
  14919. error_reporting(E_ALL);
  14920.  
  14921. $great = 'fantastisch';
  14922.  
  14923. // Funktioniert nicht, Ausgabe: Das ist { fantastisch}
  14924. echo "Das ist { $great}";
  14925.  
  14926. // Funktioniert, Ausgabe: Das ist fantastisch
  14927. echo "Das ist {$great}";
  14928. echo "Das ist ${great}";
  14929.  
  14930. // Funktioniert
  14931. echo "Dieses Quadrat ist {$square->width}00 Zentimeter breit.";
  14932.  
  14933. // Funktioniert
  14934. echo "Das funktioniert: {$arr[4][3]}";
  14935.  
  14936. // Das ist aus dem gleichen Grund falsch
  14937. // wie $foo[bar] au▀erhalb eines Strings falsch ist. Mit
  14938. // anderen Worten, es funktioniert zwar, aber weil PHP
  14939. // zunΣchst nach einer Konstanten namens foo sucht, gibt
  14940. // es einen Fehler der Stufe E_NOTICE (undefined constant)
  14941. // aus.
  14942. echo "Das ist falsch: {$arr[foo][3]}";
  14943.  
  14944. // Funktioniert. Benutzen Sie bei der Verwendung
  14945. // mehrdimensionaler Arrays innerhalb von Strings immer
  14946. // Klammern um die Arrays.
  14947. echo "Das funktioniert: {$arr['foo'][3]}";
  14948.  
  14949. // Funktioniert
  14950. echo "Das funktioniert: " . $arr['foo'][3];
  14951.  
  14952. echo "Sie k÷nnen sogar schreiben {$obj->values[3]->name}";
  14953.  
  14954. echo "Das ist der Wert der Variable mit Namen $name: {${$name}}";
  14955. ?></PRE
  14956. ></TD
  14957. ></TR
  14958. ></TABLE
  14959. ><P
  14960. ></P
  14961. ></DIV
  14962. ></DIV
  14963. ></DIV
  14964. ><DIV
  14965. CLASS="sect3"
  14966. ><HR><H4
  14967. CLASS="sect3"
  14968. ><A
  14969. NAME="language.types.string.substr"
  14970. >Zugriff und Modifikation von Zeichen in Strings</A
  14971. ></H4
  14972. ><P
  14973. >       Innerhalb von Zeichenketten (strings) kann durch die Angabe des
  14974.       nullbasierten Offsets in geschweiften Klammern nach dem String auf das
  14975.       gewⁿnschte Zeichen zugegriffen oder dieses modifiziert werden.
  14976.      </P
  14977. ><DIV
  14978. CLASS="note"
  14979. ><BLOCKQUOTE
  14980. CLASS="note"
  14981. ><P
  14982. ><B
  14983. >Anmerkung: </B
  14984. >
  14985.        Fⁿr AbwΣrtskompatibilitΣt k÷nnen Sie fⁿr den selben Zweck immer
  14986.        noch die Array-Klammern verwenden. Diese Syntax wird jedoch
  14987.        seit PHP 4 missbilligt.
  14988.       </P
  14989. ></BLOCKQUOTE
  14990. ></DIV
  14991. ><P
  14992. >       <TABLE
  14993. WIDTH="100%"
  14994. BORDER="0"
  14995. CELLPADDING="0"
  14996. CELLSPACING="0"
  14997. CLASS="EXAMPLE"
  14998. ><TR
  14999. ><TD
  15000. ><DIV
  15001. CLASS="example"
  15002. ><A
  15003. NAME="AEN2844"
  15004. ></A
  15005. ><P
  15006. ><B
  15007. >Beispiel 10-3. Einige String-Beispiele</B
  15008. ></P
  15009. ><TABLE
  15010. BORDER="0"
  15011. BGCOLOR="#E0E0E0"
  15012. CELLPADDING="5"
  15013. ><TR
  15014. ><TD
  15015. ><PRE
  15016. CLASS="php"
  15017. ><?php
  15018. // Das erste Zeichen eines Strings.
  15019. $str = 'Das ist ein Test.'
  15020. $erstes = $str{0};                // $erstes enthΣlt "D"
  15021.  
  15022. // Das dritte Zeichen eines Strings.
  15023. $drittes = $str{2};
  15024.  
  15025. // Das letzte Zeichen eines Strings.
  15026. $str = 'Das ist immer noch ein Test.'
  15027. $letztes = $str{strlen($str)-1};    // $letztes enthΣlt "."
  15028.  
  15029. // Das letzte Zeichen eines Strings verΣndern
  15030.       $str = 'Schau auf die Stra▀i';
  15031.       $str{strlen($str)-1} = 'e';
  15032.  
  15033. ?></PRE
  15034. ></TD
  15035. ></TR
  15036. ></TABLE
  15037. ></DIV
  15038. ></TD
  15039. ></TR
  15040. ></TABLE
  15041. >
  15042.      </P
  15043. ></DIV
  15044. ></DIV
  15045. ><DIV
  15046. CLASS="sect2"
  15047. ><HR><H3
  15048. CLASS="sect2"
  15049. ><A
  15050. NAME="language.types.string.useful-funcs"
  15051. >Nⁿtzliche Funktionen und Operatoren</A
  15052. ></H3
  15053. ><P
  15054. >      Strings k÷nnen mittels des '.'(dot)-Operators miteinander
  15055.      verbunden werden. Beachten Sie, dass dafⁿr nicht der '+'
  15056.      (Additions)-Operator verwendet werden kann. Fⁿr mehr
  15057.      Informationen schauen Sie bitte unter den <A
  15058. HREF="#language.operators.string"
  15059. >Zeichenketten-Operatoren</A
  15060. >
  15061.      nach.
  15062.     </P
  15063. ><P
  15064. >      Es gibt eine Menge nⁿtzlicher Funktionen zur String-Manipulation.
  15065.     </P
  15066. ><P
  15067. >      Fⁿr allgemeine Funktionen schauen Sie sich den Abschnitt ⁿber
  15068.      <A
  15069. HREF="#ref.strings"
  15070. >String Funktionen</A
  15071. > an, und fⁿr
  15072.      fortgeschrittenes Suchen & Ersetzen die Funktionen zu
  15073.      RegulΣren Ausdrⁿcken (in zwei Ausfⁿhrungen: <A
  15074. HREF="#ref.pcre"
  15075. >Perl Kompatibel</A
  15076. > und <A
  15077. HREF="#ref.regex"
  15078. >POSIX erweitert</A
  15079. >).
  15080.     </P
  15081. ><P
  15082. >      Weiterhin gibt es auch noch <A
  15083. HREF="#ref.url"
  15084. >Funktionen
  15085.      fⁿr URL-Strings</A
  15086. >, und Funktionen zum
  15087.      Verschlⁿsseln/Entschlⁿsseln von Strings (<A
  15088. HREF="#ref.mcrypt"
  15089. >mcrypt</A
  15090. > und <A
  15091. HREF="#ref.mhash"
  15092. >mhash</A
  15093. >).
  15094.     </P
  15095. ><P
  15096. >      Schlie▀lich, falls Sie immer noch nicht das gefunden haben wonach
  15097.      Sie suchen, schauen Sie unter den <A
  15098. HREF="#ref.ctype"
  15099. >Zeichen-Typen Funktionen</A
  15100. > nach.
  15101.     </P
  15102. ></DIV
  15103. ><DIV
  15104. CLASS="sect2"
  15105. ><HR><H3
  15106. CLASS="sect2"
  15107. ><A
  15108. NAME="language.types.string.casting"
  15109. >Umwandlung nach string</A
  15110. ></H3
  15111. ><P
  15112. >      Sie k÷nnen einen Wert mit der
  15113.      <VAR
  15114. CLASS="literal"
  15115. >(string)</VAR
  15116. >-Umwandlung oder mit der Funktion
  15117.      <A
  15118. HREF="#function.strval"
  15119. ><B
  15120. CLASS="function"
  15121. >strval()</B
  15122. ></A
  15123. > in einen String umwandeln. Die
  15124.      Umwandlung in einen String wird im dem Bereich eines Ausdrucks,
  15125.      in dem ein String ben÷tigt wird, automatisch fⁿr Sie vorgenommen.
  15126.      Dies geschieht, wenn Sie die Funktionen <A
  15127. HREF="#function.echo"
  15128. ><B
  15129. CLASS="function"
  15130. >echo()</B
  15131. ></A
  15132. >
  15133.      oder <A
  15134. HREF="#function.print"
  15135. ><B
  15136. CLASS="function"
  15137. >print()</B
  15138. ></A
  15139. > benutzen oder wenn Sie den Wert
  15140.      einer Variablen mit einem String vergleichen. Die Abschnitte ⁿber
  15141.      <A
  15142. HREF="#language.types"
  15143. >Typen</A
  15144. > und <A
  15145. HREF="#language.types.type-juggling"
  15146. >Typen-Tricks</A
  15147. >
  15148.      verdeutlichen das folgende. Siehe auch
  15149.      <A
  15150. HREF="#function.settype"
  15151. ><B
  15152. CLASS="function"
  15153. >settype()</B
  15154. ></A
  15155. >.
  15156.     </P
  15157. ><P
  15158. >      Ein Boolean <TT
  15159. CLASS="constant"
  15160. ><B
  15161. >TRUE</B
  15162. ></TT
  15163. >-Wert wird in den String
  15164.      <VAR
  15165. CLASS="literal"
  15166. >"1"</VAR
  15167. > umgewandelt, der <TT
  15168. CLASS="constant"
  15169. ><B
  15170. >FALSE</B
  15171. ></TT
  15172. >-Wert wird als
  15173.      <VAR
  15174. CLASS="literal"
  15175. >""</VAR
  15176. > (leerer String) dargestellt. Dadurch k÷nnen
  15177.      Sie Boolean- und String-Werte ineinander umwandeln.
  15178.     </P
  15179. ><P
  15180. >      Ein Integer oder eine Flie▀kommazahl
  15181.      (Float) wird in einen String umgewandelt, der die
  15182.      Zahl durch seine Ziffern darstellt (bei Flie▀kommazahlen
  15183.      inklusive Exponententeil).
  15184.     </P
  15185. ><P
  15186. >      Arrays werden immer in den String <VAR
  15187. CLASS="literal"
  15188. >"Array"</VAR
  15189. >
  15190.      umgewandelt. Sie k÷nnen also den Inhalt eines Arrays
  15191.      nicht mit <A
  15192. HREF="#function.echo"
  15193. ><B
  15194. CLASS="function"
  15195. >echo()</B
  15196. ></A
  15197. > oder
  15198.      <A
  15199. HREF="#function.print"
  15200. ><B
  15201. CLASS="function"
  15202. >print()</B
  15203. ></A
  15204. > ausgeben, um zu sehen, was es enthΣlt.
  15205.      Um ein Element anzuschauen, ben÷tigen Sie etwas in der Art
  15206.      <VAR
  15207. CLASS="literal"
  15208. >echo $arr['foo']</VAR
  15209. >. Siehe weiter unten fⁿr
  15210.      Hinweise zur Ausgabe/Ansicht des kompletten Inhalts.
  15211.     </P
  15212. ><P
  15213. >      Objekte werden immer in den String <VAR
  15214. CLASS="literal"
  15215. >"Object"</VAR
  15216. >
  15217.      umgewandelt. Wenn Sie fⁿr die Fehlersuche die Werte der
  15218.      Mitgliedsvariablen eines Objekts ausgeben m÷chten,
  15219.      lesen Sie bitte die Abschnitte weiter unten. Benutzen Sie
  15220.      <A
  15221. HREF="#function.get-class"
  15222. ><B
  15223. CLASS="function"
  15224. >get_class()</B
  15225. ></A
  15226. >, wenn Sie den Namen der Klasse
  15227.      erfahren m÷chten, von der ein Objekt eine Instanz ist.
  15228.     </P
  15229. ><P
  15230. >      Ressourcen werden immer in Strings mit der Struktur
  15231.      <VAR
  15232. CLASS="literal"
  15233. >"Resource id #1"</VAR
  15234. > umgewandelt, wobei
  15235.      <VAR
  15236. CLASS="literal"
  15237. >1</VAR
  15238. > die eindeutige Nummer ist, die der
  15239.      Resource von PHP zur Laufzeit zugeordnet wurde.
  15240.      Benutzen Sie <A
  15241. HREF="#function.get-resource-type"
  15242. ><B
  15243. CLASS="function"
  15244. >get_resource_type()</B
  15245. ></A
  15246. >, wenn Sie
  15247.      wissen m÷chten, welchen Typs die Ressource ist.
  15248.     </P
  15249. ><P
  15250. >      <TT
  15251. CLASS="constant"
  15252. ><B
  15253. >NULL</B
  15254. ></TT
  15255. > wird immer in einen leeren String umgewandelt.
  15256.     </P
  15257. ><P
  15258. >      Wie Sie oben erfahren haben, liefert Ihnen die Ausgabe von
  15259.      Arrays, Objekten oder Ressourcen keine brauchbaren Informationen
  15260.      ⁿber die Werte selbst. Schauen Sie sich fⁿr eine bessere
  15261.      M÷glichkeit, sich Werte fⁿr die Fehlersuche ausgeben zu lassen,
  15262.      die Funktionen <A
  15263. HREF="#function.print-r"
  15264. ><B
  15265. CLASS="function"
  15266. >print_r()</B
  15267. ></A
  15268. > und
  15269.      <A
  15270. HREF="#function.var-dump"
  15271. ><B
  15272. CLASS="function"
  15273. >var_dump()</B
  15274. ></A
  15275. > an.
  15276.     </P
  15277. ><P
  15278. >      Sie k÷nnen PHP-Werte auch in Strings umwandeln, um sie dauerhaft
  15279.      zu speichern. Diese Methode wird als Serialisierung bezeichnet
  15280.      und kann mit der Funktion <A
  15281. HREF="#function.serialize"
  15282. ><B
  15283. CLASS="function"
  15284. >serialize()</B
  15285. ></A
  15286. >
  15287.      vorgenommen werden. Falls Ihr PHP ⁿber <A
  15288. HREF="#ref.wddx"
  15289. >WDDX</A
  15290. >-Unterstⁿtzung verfⁿgt, k÷nnen Sie
  15291.      PHP-Werte auch in XML-Strukturen serialisieren.
  15292.     </P
  15293. ></DIV
  15294. ><DIV
  15295. CLASS="sect2"
  15296. ><HR><H3
  15297. CLASS="sect2"
  15298. ><A
  15299. NAME="language.types.string.conversion"
  15300. >Umwandlung von Strings in Zahlen</A
  15301. ></H3
  15302. ><P
  15303. >      Sobald ein String als numerischer Wert ausgewertet wird, werden
  15304.      der resultierende Wert und der Typ wie folgt festgelegt.
  15305.     </P
  15306. ><P
  15307. >      Der String wird als <A
  15308. HREF="#language.types.float"
  15309. ><B
  15310. CLASS="type"
  15311. >float</B
  15312. ></A
  15313. > ausgewertet, wenn er eines
  15314.      der Zeichen '.', 'e' oder 'E' enthΣlt. Ansonsten wird er als
  15315.      Integer-Wert interpretiert.
  15316.     </P
  15317. ><P
  15318. >      Der Wert wird durch den Anfangsteil des Strings bestimmt.  Sofern
  15319.      der String mit gⁿltigen numerischen Daten beginnt, werden diese
  15320.      als Wert benutzt. Andernfalls wird der Wert 0 (Null) sein.
  15321.      Gⁿltige numerische Daten sind ein optionales Vorzeichen, gefolgt
  15322.      von einer oder mehreren Zahlen (optional mit einem Dezimalpunkt).
  15323.      Wahlweise kann auch ein Exponent angegeben werden. Der Exponent
  15324.      besteht aus einem 'e' oder 'E', gefolgt von einer oder mehreren
  15325.      Zahlen.
  15326.     </P
  15327. ><DIV
  15328. CLASS="informalexample"
  15329. ><P
  15330. ></P
  15331. ><A
  15332. NAME="AEN2910"
  15333. ></A
  15334. ><TABLE
  15335. BORDER="0"
  15336. BGCOLOR="#E0E0E0"
  15337. CELLPADDING="5"
  15338. ><TR
  15339. ><TD
  15340. ><PRE
  15341. CLASS="php"
  15342. ><?php
  15343. $foo = 1 + "10.5";               // $foo ist float   (11.5)
  15344. $foo = 1 + "-1.3e3";             // $foo ist float   (-1299)
  15345. $foo = 1 + "bob-1.3e3";          // $foo ist integer (1)
  15346. $foo = 1 + "bob3";               // $foo ist integer (1)
  15347. $foo = 1 + "10 Kleine Schweine"; // $foo ist integer (11)
  15348. $foo = 4 + "10.2 Ferkel";        // $foo ist float   (14.2)
  15349. $foo = "10 Schweine " + 1;       // $foo ist integer (11)
  15350. $foo = "10.0 Schweine " + 1;     // $foo ist float   (11)
  15351. $foo = "10.0 Schweine " + 1.0;   // $foo ist float (11)
  15352. ?></PRE
  15353. ></TD
  15354. ></TR
  15355. ></TABLE
  15356. ><P
  15357. ></P
  15358. ></DIV
  15359. ><P
  15360. >      Weitere Informationen ⁿber solche Umwandlungen finden Sie in den
  15361.      UNIX Manualseiten unter strtod(3).
  15362.     </P
  15363. ><P
  15364. >      Wenn Sie irgendein Beispiel dieses Abschnitts testen wollen,
  15365.      k÷nnen Sie dieses per "Copy und Paste" ⁿbernehmen. Fⁿgen Sie die
  15366.      folgende Zeile Ihrem Skript hinzu und Sie sehen selbst was
  15367.      passiert:
  15368.      <DIV
  15369. CLASS="informalexample"
  15370. ><P
  15371. ></P
  15372. ><A
  15373. NAME="AEN2914"
  15374. ></A
  15375. ><TABLE
  15376. BORDER="0"
  15377. BGCOLOR="#E0E0E0"
  15378. CELLPADDING="5"
  15379. ><TR
  15380. ><TD
  15381. ><PRE
  15382. CLASS="php"
  15383. ><?php
  15384. echo "\$foo==$foo; Typ ist " . gettype ($foo) . "<br />\n";
  15385. ?></PRE
  15386. ></TD
  15387. ></TR
  15388. ></TABLE
  15389. ><P
  15390. ></P
  15391. ></DIV
  15392. >
  15393.     </P
  15394. ><P
  15395. >      Erwarten Sie nicht, den Code eines Zeichens zu bekommen, indem
  15396.      Sie es in einen Integer umwandeln (wie das z.B. in C der Fall
  15397.      wΣre). Benutzen Sie die Funktionen <A
  15398. HREF="#function.ord"
  15399. ><B
  15400. CLASS="function"
  15401. >ord()</B
  15402. ></A
  15403. > und
  15404.      <A
  15405. HREF="#function.chr"
  15406. ><B
  15407. CLASS="function"
  15408. >chr()</B
  15409. ></A
  15410. >, um Zeichencodes und Zeichen ineinander
  15411.      umzuwandeln.
  15412.     </P
  15413. ></DIV
  15414. ></DIV
  15415. ><DIV
  15416. CLASS="sect1"
  15417. ><HR><H2
  15418. CLASS="sect1"
  15419. ><A
  15420. NAME="language.types.array"
  15421. >Arrays</A
  15422. ></H2
  15423. ><P
  15424. >     Ein Array in PHP ist eigentlich eine geordnete Abbildung. Eine
  15425.     Abbildung ist ein Typ der <SPAN
  15426. CLASS="emphasis"
  15427. ><I
  15428. CLASS="emphasis"
  15429. >Werte</I
  15430. ></SPAN
  15431. > auf
  15432.     <SPAN
  15433. CLASS="emphasis"
  15434. ><I
  15435. CLASS="emphasis"
  15436. >Schlⁿssel</I
  15437. ></SPAN
  15438. > abbildet. Dieser Typ ist auf
  15439.     mehrere Arten optimiert, so dass Sie ihn auf verschiedene Weise
  15440.     benutzen k÷nnen: als reales Array, als Liste (Vektor), als
  15441.     Hash-Tabelle (das ist eine praktische Anwendung einer Abbildung),
  15442.     als Verzeichnis, als Sammlung, als Stapel (Stack), als
  15443.     Warteschlange (Queue) und m÷glicherweise mehr. Da Sie ein weiteres
  15444.     PHP-Array als Wert benutzen k÷nnen, ist es ziemlich einfach
  15445.     m÷glich Baumstrukturen zu simulieren.
  15446.    </P
  15447. ><P
  15448. >     Die ErklΣrung dieser Datenstrukturen sprengt den Rahmen dieses
  15449.     Handbuchs, aber Sie finden zumindest ein Beispiel fⁿr jede dieser
  15450.     Strukturen. Fⁿr weitergehende Informationen verweisen wir auf
  15451.     externe Literatur zu diesem breit gefΣcherten Thema.
  15452.    </P
  15453. ><DIV
  15454. CLASS="sect2"
  15455. ><HR><H3
  15456. CLASS="sect2"
  15457. ><A
  15458. NAME="language.types.array.syntax"
  15459. >Syntax</A
  15460. ></H3
  15461. ><DIV
  15462. CLASS="sect3"
  15463. ><H4
  15464. CLASS="sect3"
  15465. ><A
  15466. NAME="language.types.array.syntax.array-func"
  15467. >Angabe mit <A
  15468. HREF="#function.array"
  15469. ><B
  15470. CLASS="function"
  15471. >array()</B
  15472. ></A
  15473. ></A
  15474. ></H4
  15475. ><P
  15476. >       Ein <A
  15477. HREF="#language.types.array"
  15478. ><B
  15479. CLASS="type"
  15480. >array</B
  15481. ></A
  15482. > kann mit Hilfe des Sparchkonstrukts
  15483.       <A
  15484. HREF="#function.array"
  15485. ><B
  15486. CLASS="function"
  15487. >array()</B
  15488. ></A
  15489. > erzeugt werden. Es ben÷tigt eine
  15490.       bestimmte Anzahl von Komma-getrennten
  15491.       <VAR
  15492. CLASS="literal"
  15493. ><VAR
  15494. CLASS="replaceable"
  15495. >Schlⁿssel</VAR
  15496. > =>
  15497.       <VAR
  15498. CLASS="replaceable"
  15499. >Wert</VAR
  15500. ></VAR
  15501. > Paaren.
  15502.      </P
  15503. ><P
  15504. >       <TABLE
  15505. BORDER="0"
  15506. BGCOLOR="#E0E0E0"
  15507. CELLPADDING="5"
  15508. ><TR
  15509. ><TD
  15510. ><PRE
  15511. CLASS="synopsis"
  15512. >array( [<VAR
  15513. CLASS="replaceable"
  15514. >Schlⁿssel</VAR
  15515. > =>] <VAR
  15516. CLASS="replaceable"
  15517. >Wert</VAR
  15518. >
  15519.      , ...
  15520.      )
  15521. // <VAR
  15522. CLASS="replaceable"
  15523. >Schlⁿssel</VAR
  15524. > kann ein Integer oder String sein
  15525. // <VAR
  15526. CLASS="replaceable"
  15527. >Wert</VAR
  15528. > kann irgendetwas sein</PRE
  15529. ></TD
  15530. ></TR
  15531. ></TABLE
  15532. >
  15533.      </P
  15534. ><P
  15535. >       <DIV
  15536. CLASS="informalexample"
  15537. ><P
  15538. ></P
  15539. ><A
  15540. NAME="AEN2946"
  15541. ></A
  15542. ><TABLE
  15543. BORDER="0"
  15544. BGCOLOR="#E0E0E0"
  15545. CELLPADDING="5"
  15546. ><TR
  15547. ><TD
  15548. ><PRE
  15549. CLASS="php"
  15550. ><?php
  15551. $arr = array("foo" => "bar", 12 => true);
  15552.  
  15553. echo $arr["foo"]; // bar
  15554. echo $arr[12];    // 1
  15555. ?></PRE
  15556. ></TD
  15557. ></TR
  15558. ></TABLE
  15559. ><P
  15560. ></P
  15561. ></DIV
  15562. >
  15563.      </P
  15564. ><P
  15565. >       Ein <VAR
  15566. CLASS="varname"
  15567. >Schlⁿssel</VAR
  15568. > kann entweder ein
  15569.       <VAR
  15570. CLASS="literal"
  15571. >integer</VAR
  15572. > oder ein <A
  15573. HREF="#language.types.string"
  15574. ><B
  15575. CLASS="type"
  15576. >string</B
  15577. ></A
  15578. > sein.
  15579.       Wenn ein Schlⁿssel die Standard-Darstellung einer
  15580.       <A
  15581. HREF="#language.types.integer"
  15582. ><B
  15583. CLASS="type"
  15584. >integer</B
  15585. ></A
  15586. > Zahl ist, wird es als solche interpretiert
  15587.       werden, (z.B. <VAR
  15588. CLASS="literal"
  15589. >"8"</VAR
  15590. > wird als
  15591.       <VAR
  15592. CLASS="literal"
  15593. >8</VAR
  15594. > interpretiert, wΣhrend
  15595.       <VAR
  15596. CLASS="literal"
  15597. >"08"</VAR
  15598. > als <VAR
  15599. CLASS="literal"
  15600. >"08"</VAR
  15601. >
  15602.       interpretiert werden wird). Es gibt in PHP keine
  15603.       unterschiedlichen Typen indizierter oder assoziativer Arrays.
  15604.       Es gibt nur einen Array-Typ, der sowohl Integer- als auch
  15605.       String-Indizes enthalten kann.
  15606.      </P
  15607. ><P
  15608. >       Ein Wert kann jeder PHP-Typ sein.
  15609.       <DIV
  15610. CLASS="informalexample"
  15611. ><P
  15612. ></P
  15613. ><A
  15614. NAME="AEN2958"
  15615. ></A
  15616. ><TABLE
  15617. BORDER="0"
  15618. BGCOLOR="#E0E0E0"
  15619. CELLPADDING="5"
  15620. ><TR
  15621. ><TD
  15622. ><PRE
  15623. CLASS="php"
  15624. ><?php
  15625. $arr = array("einarray" => array(6 => 5, 13 => 9, "a" => 42));
  15626.  
  15627. echo $arr["einarray"][6];    // 5
  15628. echo $arr["einarray"][13];   // 9
  15629. echo $arr["einarray"]["a"];  // 42
  15630. ?></PRE
  15631. ></TD
  15632. ></TR
  15633. ></TABLE
  15634. ><P
  15635. ></P
  15636. ></DIV
  15637. >
  15638.      </P
  15639. ><P
  15640. >       Falls Sie fⁿr einen Wert keinen Schlⁿssel angeben, wird der
  15641.       gr÷▀te der Ganzzahl-Indizes genommen und der neue Schlⁿssel wird
  15642.       dieses Maximum + 1 sein. Falls Sie einen Schlⁿssel angeben dem
  15643.       schon ein Wert zugeordnet wurde, wird dieser Wert ⁿberschrieben.
  15644.       <DIV
  15645. CLASS="informalexample"
  15646. ><P
  15647. ></P
  15648. ><A
  15649. NAME="AEN2961"
  15650. ></A
  15651. ><TABLE
  15652. BORDER="0"
  15653. BGCOLOR="#E0E0E0"
  15654. CELLPADDING="5"
  15655. ><TR
  15656. ><TD
  15657. ><PRE
  15658. CLASS="php"
  15659. ><?php
  15660. // Dieses Array ist dasselbe wie ...
  15661. array(5 => 43, 32, 56, "b" => 12);
  15662.  
  15663. // ... dieses Array
  15664. array(5 => 43, 6 => 32, 7 => 56, "b" => 12);
  15665. ?></PRE
  15666. ></TD
  15667. ></TR
  15668. ></TABLE
  15669. ><P
  15670. ></P
  15671. ></DIV
  15672. >
  15673.      </P
  15674. ><DIV
  15675. CLASS="warning"
  15676. ><P
  15677. ></P
  15678. ><TABLE
  15679. CLASS="warning"
  15680. BORDER="1"
  15681. WIDTH="100%"
  15682. ><TR
  15683. ><TD
  15684. ALIGN="CENTER"
  15685. ><B
  15686. >Warnung</B
  15687. ></TD
  15688. ></TR
  15689. ><TR
  15690. ><TD
  15691. ALIGN="LEFT"
  15692. ><P
  15693. >        Ab PHP 4.3.0 hat sich die oben beschriebene Generierung von
  15694.        Indizes geΣndert. Wenn Sie etwas an ein Array anhΣngen, in dem
  15695.        der gr÷▀te Schlⁿssel negativ ist, wird der nΣchste Schlⁿssel
  15696.        jetzt Null (<VAR
  15697. CLASS="literal"
  15698. >0</VAR
  15699. >) sein. Davor wΣre der neue
  15700.        Index, genauso wie bei positiven Indizes, der gr÷▀te vorhandene
  15701.        Schlⁿssel + 1 gewesen.
  15702.       </P
  15703. ></TD
  15704. ></TR
  15705. ></TABLE
  15706. ></DIV
  15707. ><P
  15708. >       Wenn Sie <TT
  15709. CLASS="constant"
  15710. ><B
  15711. >TRUE</B
  15712. ></TT
  15713. > als Schlⁿssel benutzen, wird dies als Schlⁿssel
  15714.       vom Typ <A
  15715. HREF="#language.types.integer"
  15716. ><B
  15717. CLASS="type"
  15718. >integer</B
  15719. ></A
  15720. > <VAR
  15721. CLASS="literal"
  15722. >1</VAR
  15723. > ausgewertet.
  15724.       Benutzen Sie <TT
  15725. CLASS="constant"
  15726. ><B
  15727. >FALSE</B
  15728. ></TT
  15729. > als Schlⁿssel, wird dies als Schlⁿssel vom
  15730.       Typ <A
  15731. HREF="#language.types.integer"
  15732. ><B
  15733. CLASS="type"
  15734. >integer</B
  15735. ></A
  15736. > <VAR
  15737. CLASS="literal"
  15738. >0</VAR
  15739. > ausgewertet. Die
  15740.       Benutzung von <VAR
  15741. CLASS="literal"
  15742. >NULL</VAR
  15743. > als Schlⁿssel fⁿhrt dazu,
  15744.       dass der Schlⁿssel als leerer String gewertet wird.  Verwenden
  15745.       Sie einen leeren String als Schlⁿssel, wird ein Schlⁿssel mit
  15746.       einem leeren String und seinem Wert erzeugt (oder
  15747.       ⁿberschrieben).  Das entspricht nicht der Verwendung von leeren
  15748.       Klammern.
  15749.      </P
  15750. ><P
  15751. >       Sie k÷nnen keine Arrays oder Objekte als Schlⁿssel benutzen.
  15752.       Der Versuch wird mit einer Warnung enden: <VAR
  15753. CLASS="literal"
  15754. >Illegal
  15755.       offset type</VAR
  15756. >.
  15757.      </P
  15758. ></DIV
  15759. ><DIV
  15760. CLASS="sect3"
  15761. ><HR><H4
  15762. CLASS="sect3"
  15763. ><A
  15764. NAME="language.types.array.syntax.modifying"
  15765. >Erzeugen / VerΣndern mit der eckigen Klammer-Syntax</A
  15766. ></H4
  15767. ><P
  15768. >       Sie k÷nnen ein bestehendes Array durch explizites Zuweisen von
  15769.       Werten verΣndern.
  15770.      </P
  15771. ><P
  15772. >       Weisen Sie dem Array Werte zu indem Sie den Schlⁿssel in eckigen
  15773.       Klammern angeben. Sie k÷nnen den Schlⁿssel auch weglassen. In
  15774.       diesem Fall schreiben Sie einfach ein leeres Klammerpaar
  15775.       ("<VAR
  15776. CLASS="literal"
  15777. >[]</VAR
  15778. >") hinter den Variablennamen.
  15779.       <TABLE
  15780. BORDER="0"
  15781. BGCOLOR="#E0E0E0"
  15782. CELLPADDING="5"
  15783. ><TR
  15784. ><TD
  15785. ><PRE
  15786. CLASS="synopsis"
  15787. >$arr[<VAR
  15788. CLASS="replaceable"
  15789. >Schlⁿssel</VAR
  15790. >] = <VAR
  15791. CLASS="replaceable"
  15792. >Wert</VAR
  15793. >;
  15794. $arr[] = <VAR
  15795. CLASS="replaceable"
  15796. >Wert</VAR
  15797. >;
  15798. // <VAR
  15799. CLASS="replaceable"
  15800. >Schlⁿssel</VAR
  15801. > kann ein <A
  15802. HREF="#language.types.integer"
  15803. ><B
  15804. CLASS="type"
  15805. >integer</B
  15806. ></A
  15807. > oder ein <A
  15808. HREF="#language.types.string"
  15809. ><B
  15810. CLASS="type"
  15811. >string</B
  15812. ></A
  15813. > sein
  15814. // <VAR
  15815. CLASS="replaceable"
  15816. >Wert</VAR
  15817. > kann irgendetwas sein.</PRE
  15818. ></TD
  15819. ></TR
  15820. ></TABLE
  15821. >
  15822.       Falls <VAR
  15823. CLASS="varname"
  15824. >$arr</VAR
  15825. > bis dahin nicht existiert, wird es
  15826.       erzeugt. Das ist also eine alternative Syntax um ein Array zu
  15827.       erzeugen.  Um einen bestimmten Wert zu Σndern, weisen Sie
  15828.       einfach einem Element, das Sie mit seinem Schlⁿssel
  15829.       spezifizieren, einen neuen Wert zu. Wenn Sie ein Schlⁿssel/Wert
  15830.       Paar entfernen m÷chten, benutzen Sie <A
  15831. HREF="#function.unset"
  15832. ><B
  15833. CLASS="function"
  15834. >unset()</B
  15835. ></A
  15836. >.
  15837.       <DIV
  15838. CLASS="informalexample"
  15839. ><P
  15840. ></P
  15841. ><A
  15842. NAME="AEN2991"
  15843. ></A
  15844. ><TABLE
  15845. BORDER="0"
  15846. BGCOLOR="#E0E0E0"
  15847. CELLPADDING="5"
  15848. ><TR
  15849. ><TD
  15850. ><PRE
  15851. CLASS="php"
  15852. ><?php
  15853. $arr = array(5 => 1, 12 => 2);
  15854.  
  15855. $arr[] = 56;    // An dieser Stelle des Skrips ist das
  15856.                 // dasselbe wie $arr[13] = 56;
  15857.  
  15858. $arr["x"] = 42; // Fⁿgt dem Array ein neues Element mit
  15859.                 // dem Schlⁿssel "x" hinzu
  15860.  
  15861. unset($arr[5]); // Entfernt das Element aus dem Array
  15862.  
  15863. unset($arr);    // L÷scht das komplette Array
  15864. ?></PRE
  15865. ></TD
  15866. ></TR
  15867. ></TABLE
  15868. ><P
  15869. ></P
  15870. ></DIV
  15871. >
  15872.      </P
  15873. ><DIV
  15874. CLASS="note"
  15875. ><BLOCKQUOTE
  15876. CLASS="note"
  15877. ><P
  15878. ><B
  15879. >Anmerkung: </B
  15880. >
  15881.        Wie weiter oben schon erwΣhnt, wird, falls Sie die Klammern
  15882.        setzen ohne einen Schlⁿssel anzugeben, der gr÷▀te der
  15883.        Integer-Indizes genommen und der neue Schlⁿssel wird dieses
  15884.        Maximum + 1 sein. Falls es noch keine Integer-Indizes gibt,
  15885.        wird der Schlⁿssel zu <VAR
  15886. CLASS="literal"
  15887. >0</VAR
  15888. > (Null).  Falls Sie
  15889.        einen Schlⁿssel angeben dem schon ein Wert zugeordnet wurde,
  15890.        wird dieser Wert ⁿberschrieben.
  15891.       </P
  15892. ><P
  15893. >        <DIV
  15894. CLASS="warning"
  15895. ><P
  15896. ></P
  15897. ><TABLE
  15898. CLASS="warning"
  15899. BORDER="1"
  15900. WIDTH="100%"
  15901. ><TR
  15902. ><TD
  15903. ALIGN="CENTER"
  15904. ><B
  15905. >Warnung</B
  15906. ></TD
  15907. ></TR
  15908. ><TR
  15909. ><TD
  15910. ALIGN="LEFT"
  15911. ><P
  15912. >          Ab PHP 4.3.0 hat sich die oben beschriebene Generierung von
  15913.          Indizes geΣndert. Wenn Sie etwas an ein Array anhΣngen, in
  15914.          dem der gr÷▀te Schlⁿssel negativ ist, wird der nΣchste
  15915.          Schlⁿssel jetzt Null (<VAR
  15916. CLASS="literal"
  15917. >0</VAR
  15918. >) sein. Davor wΣre
  15919.          der neue Index, genauso wie bei positiven Indizes, der gr÷▀te
  15920.          vorhandene Schlⁿssel + 1 gewesen.
  15921.         </P
  15922. ></TD
  15923. ></TR
  15924. ></TABLE
  15925. ></DIV
  15926. >
  15927.       </P
  15928. ><P
  15929. >        Beachten Sie, dass der hierbei verwendete gr÷▀te
  15930.        Integer-Schlⁿssel <SPAN
  15931. CLASS="emphasis"
  15932. ><I
  15933. CLASS="emphasis"
  15934. >im Array zu diesem Zeitpunkt nicht
  15935.        vorhanden sein muss</I
  15936. ></SPAN
  15937. >. Er muss nur irgendwann im Array
  15938.        existiert haben, seitdem es zum letzten Mal neu indiziert
  15939.        wurde. Folgendes Beispiel zur Veranschaulichung:
  15940.       </P
  15941. ><DIV
  15942. CLASS="informalexample"
  15943. ><P
  15944. ></P
  15945. ><A
  15946. NAME="AEN3002"
  15947. ></A
  15948. ><TABLE
  15949. BORDER="0"
  15950. BGCOLOR="#E0E0E0"
  15951. CELLPADDING="5"
  15952. ><TR
  15953. ><TD
  15954. ><PRE
  15955. CLASS="php"
  15956. ><?php
  15957. // Wir erzeugen ein einfaches Array
  15958. $array = array(1, 2, 3, 4, 5);
  15959. print_r($array);
  15960.  
  15961. // Nun l÷schen wir alle Elemente, lassen das Array selbst
  15962. // aber intakt:
  15963. foreach ($array as $i => $wert) {
  15964.     unset($array[$i]);
  15965. }
  15966. print_r($array);
  15967.  
  15968. // Wir hΣngen ein Element an (beachten Sie, dass der neue Schlⁿssel 5
  15969. // ist, statt 0, wie sie vielleicht erwarten wⁿrden).
  15970. $array[] = 6;
  15971. print_r($array);
  15972.  
  15973. // Neu indizieren:
  15974. $array = array_values($array);
  15975. $array[] = 7;
  15976. print_r($array);
  15977. ?></PRE
  15978. ></TD
  15979. ></TR
  15980. ></TABLE
  15981. ><P
  15982. >         Obiges Beispiel wⁿrde folgende Ausgabe erzeugen:
  15983.         <TABLE
  15984. BORDER="0"
  15985. BGCOLOR="#E0E0E0"
  15986. CELLPADDING="5"
  15987. ><TR
  15988. ><TD
  15989. ><PRE
  15990. CLASS="screen"
  15991. >Array
  15992. (
  15993.     [0] => 1
  15994.     [1] => 2
  15995.     [2] => 3
  15996.     [3] => 4
  15997.     [4] => 5
  15998. )
  15999. Array
  16000. (
  16001. )
  16002. Array
  16003. (
  16004.     [5] => 6
  16005. )
  16006. Array
  16007. (
  16008.     [0] => 6
  16009.     [1] => 7
  16010. )</PRE
  16011. ></TD
  16012. ></TR
  16013. ></TABLE
  16014. >
  16015.        </P
  16016. ><P
  16017. ></P
  16018. ></DIV
  16019. ></BLOCKQUOTE
  16020. ></DIV
  16021. ></DIV
  16022. ></DIV
  16023. ><DIV
  16024. CLASS="sect2"
  16025. ><HR><H3
  16026. CLASS="sect2"
  16027. ><A
  16028. NAME="language.types.array.useful-funcs"
  16029. >Nⁿtzliche Funktionen</A
  16030. ></H3
  16031. ><P
  16032. >      Es gibt viele nⁿtzliche Funktionen um mit Arrays zu arbeiten.
  16033.      Schauen Sie unter dem Abschnitt <A
  16034. HREF="#ref.array"
  16035. >Array
  16036.      Funktionen</A
  16037. > nach.
  16038.     </P
  16039. ><DIV
  16040. CLASS="note"
  16041. ><BLOCKQUOTE
  16042. CLASS="note"
  16043. ><P
  16044. ><B
  16045. >Anmerkung: </B
  16046. >
  16047.       Mit <A
  16048. HREF="#function.unset"
  16049. ><B
  16050. CLASS="function"
  16051. >unset()</B
  16052. ></A
  16053. > k÷nnen Sie Schlⁿssel eines Arrays
  16054.       l÷schen. Halten Sie sich vor Augen, dass das Array NICHT neu
  16055.       indiziert wird. Wenn Sie nur "gew÷hnliche Integer-Indizes" (bei
  16056.       Null beginnend, jeweils um eins steigend) verwenden, erreichen
  16057.       Sie die Neuindizierung durch Verwendung von
  16058.       <A
  16059. HREF="#function.array-values"
  16060. ><B
  16061. CLASS="function"
  16062. >array_values()</B
  16063. ></A
  16064. >.
  16065.       <DIV
  16066. CLASS="informalexample"
  16067. ><P
  16068. ></P
  16069. ><A
  16070. NAME="AEN3014"
  16071. ></A
  16072. ><TABLE
  16073. BORDER="0"
  16074. BGCOLOR="#E0E0E0"
  16075. CELLPADDING="5"
  16076. ><TR
  16077. ><TD
  16078. ><PRE
  16079. CLASS="php"
  16080. ><?php
  16081. $a = array(1 => 'eins', 2 => 'zwei', 3 => 'drei');
  16082. unset($a[2]);
  16083.  
  16084. /* erzeugt ein Array das wie folgt definiert worden wΣre:
  16085.    $a = array(1 => 'eins', 3 => 'drei');
  16086.    und NICHT
  16087.    $a = array(1 => 'eins', 2 => 'drei');
  16088. */
  16089.  
  16090. $b = array_values($a);
  16091. // Jetzt ist $b array(1 => 'eins', 2 =>'drei')
  16092. ?></PRE
  16093. ></TD
  16094. ></TR
  16095. ></TABLE
  16096. ><P
  16097. ></P
  16098. ></DIV
  16099. >
  16100.  
  16101.      </P
  16102. ></BLOCKQUOTE
  16103. ></DIV
  16104. ><P
  16105. >      Die <A
  16106. HREF="#control-structures.foreach"
  16107. >foreach</A
  16108. >
  16109.      Kontrollstruktur gibt es speziell fⁿr Arrays. Damit ist es leicht
  16110.      ein Array zu durchlaufen.
  16111.     </P
  16112. ></DIV
  16113. ><DIV
  16114. CLASS="sect2"
  16115. ><HR><H3
  16116. CLASS="sect2"
  16117. ><A
  16118. NAME="language.types.array.donts"
  16119. >Array do's und don'ts</A
  16120. ></H3
  16121. ><DIV
  16122. CLASS="sect3"
  16123. ><H4
  16124. CLASS="sect3"
  16125. ><A
  16126. NAME="language.types.array.foo-bar"
  16127. >Warum ist <VAR
  16128. CLASS="literal"
  16129. >$foo[bar]</VAR
  16130. > falsch?</A
  16131. ></H4
  16132. ><P
  16133. >       Sie sollten immer Anfⁿhrungszeichen fⁿr einen
  16134.       String-Literal-Index eines Arrays benutzen. Zum Beispiel
  16135.       sollten Sie $foo['bar'] und nicht
  16136.       $foo[bar] benutzen. Aber warum ist $foo[bar] falsch? Vieleicht
  16137.       kennen Sie folgende Syntax aus alten Skripts:
  16138.       <DIV
  16139. CLASS="informalexample"
  16140. ><P
  16141. ></P
  16142. ><A
  16143. NAME="AEN3024"
  16144. ></A
  16145. ><TABLE
  16146. BORDER="0"
  16147. BGCOLOR="#E0E0E0"
  16148. CELLPADDING="5"
  16149. ><TR
  16150. ><TD
  16151. ><PRE
  16152. CLASS="php"
  16153. ><?php
  16154. $foo[bar] = 'Feind';
  16155. echo $foo[bar];
  16156. // usw
  16157. ?></PRE
  16158. ></TD
  16159. ></TR
  16160. ></TABLE
  16161. ><P
  16162. ></P
  16163. ></DIV
  16164. >
  16165.       Es ist falsch, funktioniert aber. Warum ist es dann falsch?  Der
  16166.       Grund ist, dass dieser Code statt eines Strings ('bar'- beachten
  16167.       Sie die Anfⁿhrungszeichen) eine undefinierte Konstante (bar)
  16168.       enthΣlt und PHP in Zukunft Konstanten definieren k÷nnte, die,
  16169.       unglⁿcklicherweise fⁿr Ihren Code, den gleichen Namen verwenden.
  16170.       Es funktioniert, weil PHP einen <SPAN
  16171. CLASS="emphasis"
  16172. ><I
  16173. CLASS="emphasis"
  16174. >blo▀en
  16175.       String</I
  16176. ></SPAN
  16177. > (ein String ohne Anfⁿhrungszeichen, der keinem
  16178.       bekannten Symbol entpricht) automatisch in einen String
  16179.       umwandelt, der den blo▀en String enthΣlt. Wenn beispielsweise
  16180.       keine Konstante namens <TT
  16181. CLASS="constant"
  16182. ><B
  16183. >bar</B
  16184. ></TT
  16185. > definiert ist,
  16186.       ersetzt es PHP durch den String <VAR
  16187. CLASS="literal"
  16188. >'bar'</VAR
  16189. > und
  16190.       verwendet diesen.
  16191.      </P
  16192. ><DIV
  16193. CLASS="note"
  16194. ><BLOCKQUOTE
  16195. CLASS="note"
  16196. ><P
  16197. ><B
  16198. >Anmerkung: </B
  16199. >
  16200.        Das bedeutet nicht, dass Schlⁿssel <SPAN
  16201. CLASS="emphasis"
  16202. ><I
  16203. CLASS="emphasis"
  16204. >immer</I
  16205. ></SPAN
  16206. >
  16207.        in Anfⁿhrungszeichen gesetzt werden mⁿssen. Wenn Sie nΣmlich
  16208.        Schlⁿssel, die <A
  16209. HREF="#language.constants"
  16210. >Konstanten</A
  16211. > oder <A
  16212. HREF="#language.variables"
  16213. >Variablen</A
  16214. > sind, in
  16215.        Anfⁿhrungszeichen setzen, werden diese von PHP nicht
  16216.        ausgewertet.
  16217.       </P
  16218. ><DIV
  16219. CLASS="informalexample"
  16220. ><P
  16221. ></P
  16222. ><A
  16223. NAME="AEN3034"
  16224. ></A
  16225. ><TABLE
  16226. BORDER="0"
  16227. BGCOLOR="#E0E0E0"
  16228. CELLPADDING="5"
  16229. ><TR
  16230. ><TD
  16231. ><PRE
  16232. CLASS="php"
  16233. ><?php
  16234. error_reporting(E_ALL);
  16235. ini_set('display_errors', true);
  16236. ini_set('html_errors', false);
  16237.  
  16238. // Ein einfaches Array:
  16239. $array = array(1, 2);
  16240. $anzahl = count($array);
  16241. for ($i = 0; $i < $anzahl; $i++) {
  16242.     echo "\n▄berprⁿfe $i: \n";
  16243.     echo "Schlecht: " . $array['$i'] . "\n";
  16244.     echo "Gut: " . $array[$i] . "\n";
  16245.     echo "Schlecht: {$array['$i']}\n";
  16246.     echo "Gut: {$array[$i]}\n";
  16247. }
  16248. ?></PRE
  16249. ></TD
  16250. ></TR
  16251. ></TABLE
  16252. ><P
  16253. ></P
  16254. ></DIV
  16255. ><P
  16256. ><B
  16257. >Anmerkung: </B
  16258. >
  16259.        Obiges Beispiel wⁿrde folgende Ausgabe erzeugen:
  16260.        <TABLE
  16261. BORDER="0"
  16262. BGCOLOR="#E0E0E0"
  16263. CELLPADDING="5"
  16264. ><TR
  16265. ><TD
  16266. ><PRE
  16267. CLASS="screen"
  16268. >▄berprⁿfe 0:
  16269. Notice: Undefined index:  $i in /path/to/script.html on line 9
  16270. Schlecht:
  16271. Gut: 1
  16272. Notice: Undefined index:  $i in /path/to/script.html on line 11
  16273. Schlecht:
  16274. Gut: 1
  16275.  
  16276. ▄berprⁿfe 1:
  16277. Notice: Undefined index:  $i in /path/to/script.html on line 9
  16278. Schlecht:
  16279. Gut: 2
  16280. Notice: Undefined index:  $i in /path/to/script.html on line 11
  16281. Schlecht:
  16282. Gut: 2</PRE
  16283. ></TD
  16284. ></TR
  16285. ></TABLE
  16286. >
  16287.       </P
  16288. ></BLOCKQUOTE
  16289. ></DIV
  16290. ><P
  16291. >       Weitere Beispiele zur Veranschaulichung dieses Sachverhalts:
  16292.       <DIV
  16293. CLASS="informalexample"
  16294. ><P
  16295. ></P
  16296. ><A
  16297. NAME="AEN3039"
  16298. ></A
  16299. ><TABLE
  16300. BORDER="0"
  16301. BGCOLOR="#E0E0E0"
  16302. CELLPADDING="5"
  16303. ><TR
  16304. ><TD
  16305. ><PRE
  16306. CLASS="php"
  16307. ><?php
  16308. // Wir lassen uns alle Fehlermeldungen anzeigen
  16309. error_reporting(E_ALL);
  16310.  
  16311. $arr = array('obst' => 'Apfel', 'gemuese' => 'Karotte');
  16312.  
  16313. // Richtig
  16314. print $arr['obst'];  // Apfel
  16315. print $arr['gemuese']; // Karotte
  16316.  
  16317. // Falsch. Es funktioniert, gibt aber wegen der undefinierten
  16318. // Konstante namens obst auch einen PHP-Fehler der Stufe E_NOTICE
  16319. // aus:
  16320. //
  16321. // Notice: Use of undefined constant obst - assumed 'obst' in...
  16322. print $arr[obst];    // Apfel
  16323.  
  16324. // Definieren wir nun eine Konstante um zu veranschaulichen was
  16325. // passiert. Wir weisen einer Konstanten namens obst den Wert
  16326. // 'gemuese' zu.
  16327. define('obst', 'gemuese');
  16328.  
  16329. // Beachten Sie jetzt den Unterschied
  16330. print $arr['obst'];  // Apfel
  16331. print $arr[obst];    // Karotte
  16332.  
  16333. // Folgendes ist in Ordnung, weil es innerhalb eines Strings ist.
  16334. // Innerhalb eines Strings wird nicht nach Konstanten gesucht und
  16335. // deshalb gibt es hier auch keinen E_NOTICE-Fehler.
  16336. print "Hallo $arr[obst]";      // Hallo Apfel
  16337.  
  16338. // Eine Ausnahme: innerhalb von Strings erm÷glichen {Klammern}
  16339. // um Arrays, dass nach Konstanten gesucht wird
  16340. print "Hallo {$arr[obst]}";    // Hallo Karotte
  16341. print "Hallo {$arr['obst']}";  // Hallo Apfel
  16342.  
  16343. // Das funktioniert nicht und ergibt in etwa folgenden Parser-Fehler:
  16344. // Parse error: parse error, expecting T_STRING' or T_VARIABLE' or T_NUM_STRING'
  16345. // Das gilt natⁿrlich auch fⁿr die Verwendung von Autoglobalen in
  16346. // Strings
  16347. print "Hallo $arr['obst']";
  16348. print "Hallo $_GET['foo']";
  16349.  
  16350. // Eine andere M÷glichkeit ist die Verkettung
  16351. print "Hallo " . $arr['obst']; // Hallo Apfel
  16352. ?></PRE
  16353. ></TD
  16354. ></TR
  16355. ></TABLE
  16356. ><P
  16357. ></P
  16358. ></DIV
  16359. >
  16360.      </P
  16361. ><P
  16362. >       Wenn Sie <A
  16363. HREF="#function.error-reporting"
  16364. ><B
  16365. CLASS="function"
  16366. >error_reporting()</B
  16367. ></A
  16368. > auf Fehler der
  16369.       Stufe <TT
  16370. CLASS="constant"
  16371. ><B
  16372. >E_NOTICE</B
  16373. ></TT
  16374. > einstellen (beispielsweise
  16375.       durch setzen auf <TT
  16376. CLASS="constant"
  16377. ><B
  16378. >E_ALL</B
  16379. ></TT
  16380. >), werden Sie diese
  16381.       Fehlermeldungen zu sehen bekommen. StandardmΣ▀ig ist <A
  16382. HREF="#ini.error-reporting"
  16383. >error_reporting</A
  16384. > so
  16385.       eingestellt, dass sie nicht angezeigt werden.
  16386.      </P
  16387. ><P
  16388. >       Wie im Abschnitt <A
  16389. HREF="#language.types.array.syntax"
  16390. >Syntax</A
  16391. > ausgefⁿhrt,
  16392.       muss zwischen den eckigen Klammern ('<VAR
  16393. CLASS="literal"
  16394. >[</VAR
  16395. >' und
  16396.       '<VAR
  16397. CLASS="literal"
  16398. >]</VAR
  16399. >') ein Ausdruck stehen.  Das hei▀t, dass
  16400.       Sie Dinge Σhnlich diesen schreiben k÷nnen:
  16401.       <DIV
  16402. CLASS="informalexample"
  16403. ><P
  16404. ></P
  16405. ><A
  16406. NAME="AEN3050"
  16407. ></A
  16408. ><TABLE
  16409. BORDER="0"
  16410. BGCOLOR="#E0E0E0"
  16411. CELLPADDING="5"
  16412. ><TR
  16413. ><TD
  16414. ><PRE
  16415. CLASS="php"
  16416. ><?php
  16417. echo $arr[somefunc($bar)];
  16418. ?></PRE
  16419. ></TD
  16420. ></TR
  16421. ></TABLE
  16422. ><P
  16423. ></P
  16424. ></DIV
  16425. >
  16426.       Das ist ein Beispiel dafⁿr, wie Sie den Rⁿckgabewert einer
  16427.       Funktion als Array-Index verwenden k÷nnen. Ebenso kennt PHP
  16428.       Konstanten. Vielleicht haben Sie die <VAR
  16429. CLASS="literal"
  16430. >E_*</VAR
  16431. >
  16432.       Konstanten schon einmal gesehen.
  16433.       <DIV
  16434. CLASS="informalexample"
  16435. ><P
  16436. ></P
  16437. ><A
  16438. NAME="AEN3053"
  16439. ></A
  16440. ><TABLE
  16441. BORDER="0"
  16442. BGCOLOR="#E0E0E0"
  16443. CELLPADDING="5"
  16444. ><TR
  16445. ><TD
  16446. ><PRE
  16447. CLASS="php"
  16448. ><?php
  16449. $error_descriptions[E_ERROR]   = "Ein schwerwiegender Fehler ist aufgetreten";
  16450. $error_descriptions[E_WARNING] = "PHP hat eine Warnung ausgegeben";
  16451. $error_descriptions[E_NOTICE]  = "Das ist nur eine informelle Notiz";
  16452. ?></PRE
  16453. ></TD
  16454. ></TR
  16455. ></TABLE
  16456. ><P
  16457. ></P
  16458. ></DIV
  16459. >
  16460.       Beachten Sie, dass <VAR
  16461. CLASS="literal"
  16462. >E_ERROR</VAR
  16463. > ebenso ein
  16464.       gⁿltiger Bezeichner ist, genau wie <VAR
  16465. CLASS="literal"
  16466. >bar</VAR
  16467. > im
  16468.       ersten Beispiel.  Das letzte Beispiel entspricht aber
  16469.       tatsΣchlich dem folgendem Code:
  16470.       <DIV
  16471. CLASS="informalexample"
  16472. ><P
  16473. ></P
  16474. ><A
  16475. NAME="AEN3057"
  16476. ></A
  16477. ><TABLE
  16478. BORDER="0"
  16479. BGCOLOR="#E0E0E0"
  16480. CELLPADDING="5"
  16481. ><TR
  16482. ><TD
  16483. ><PRE
  16484. CLASS="php"
  16485. ><?php
  16486. $error_descriptions[1] = "Ein schwerwiegender Fehler ist aufgetreten";
  16487. $error_descriptions[2] = "PHP hat eine Warnung ausgegeben";
  16488. $error_descriptions[8] = "Das ist nur eine informelle Notiz";
  16489. ?></PRE
  16490. ></TD
  16491. ></TR
  16492. ></TABLE
  16493. ><P
  16494. ></P
  16495. ></DIV
  16496. >
  16497.       weil <VAR
  16498. CLASS="literal"
  16499. >E_ERROR</VAR
  16500. > gleich <VAR
  16501. CLASS="literal"
  16502. >1</VAR
  16503. > ist,
  16504.       usw.
  16505.      </P
  16506. ><P
  16507. >       Wie schon in den obigen Beispielen erklΣrt wurde, funktioniert
  16508.       <VAR
  16509. CLASS="literal"
  16510. >$foo[bar]</VAR
  16511. > zwar, ist aber falsch. Es
  16512.       funktioniert, weil <VAR
  16513. CLASS="literal"
  16514. >bar</VAR
  16515. > aufgrund seiner Syntax
  16516.       als Konstante ausgewertet wird. In diesem Fall jedoch existiert
  16517.       keine Konstane mit dem Namen <VAR
  16518. CLASS="literal"
  16519. >bar</VAR
  16520. >. PHP nimmt
  16521.       an, dass Sie <VAR
  16522. CLASS="literal"
  16523. >bar</VAR
  16524. > w÷rtlich gemeint haben, wie
  16525.       den String <VAR
  16526. CLASS="literal"
  16527. >'bar'</VAR
  16528. >, aber vergessen haben, die
  16529.       Anfⁿhrungszeichen zu setzen.
  16530.      </P
  16531. ><DIV
  16532. CLASS="sect4"
  16533. ><HR><H5
  16534. CLASS="sect4"
  16535. ><A
  16536. NAME="AEN3067"
  16537. >Aber warum ist es schlecht?</A
  16538. ></H5
  16539. ><P
  16540. >        Eines Tages k÷nnte sich das PHP-Team entscheiden eine weitere
  16541.        Konstante oder ein Schlⁿsselwort hinzuzufⁿgen oder Sie k÷nnten
  16542.        eine weitere Konstante in Ihre Anwendung einfⁿgen. Und dann
  16543.        geraten Sie in Schwierigkeiten. Zum Beispiel k÷nnen Sie bereits
  16544.        die W÷rter <VAR
  16545. CLASS="literal"
  16546. >empty</VAR
  16547. > und
  16548.        <VAR
  16549. CLASS="literal"
  16550. >default</VAR
  16551. > auf diese Art nicht benutzen, weil
  16552.        es speziele Schlⁿsselw÷rter sind.
  16553.       </P
  16554. ><DIV
  16555. CLASS="note"
  16556. ><BLOCKQUOTE
  16557. CLASS="note"
  16558. ><P
  16559. ><B
  16560. >Anmerkung: </B
  16561. >
  16562.         Um es nochmals zu wiederholen, innerhalb eines Strings in
  16563.         doppelten Anfⁿhrungszeichen ist es zulΣssig, Array-Indizes
  16564.         ohne Anfⁿhrungszeichen zu schreiben, weshalb
  16565.         <VAR
  16566. CLASS="literal"
  16567. >"$foo[bar]"</VAR
  16568. > gⁿltig ist. Schauen Sie sich
  16569.         fⁿr Einzelheiten darⁿber, warum das so ist, obige Beispiele
  16570.         und den Abschnitt ⁿber <A
  16571. HREF="#language.types.string.parsing"
  16572. >Variablen-Analyse in
  16573.         Strings</A
  16574. > an.
  16575.        </P
  16576. ></BLOCKQUOTE
  16577. ></DIV
  16578. ></DIV
  16579. ></DIV
  16580. ></DIV
  16581. ><DIV
  16582. CLASS="sect2"
  16583. ><HR><H3
  16584. CLASS="sect2"
  16585. ><A
  16586. NAME="language.types.array.casting"
  16587. >Umwandlung nach array</A
  16588. ></H3
  16589. ><P
  16590. >      Fⁿr die Typen Integer, Float,
  16591.      String, Boolean und
  16592.      Resource gilt: wenn Sie einen Wert in ein Array
  16593.      umwandeln, bekommen Sie ein Array mit einem Element (mit Index
  16594.      0), das der skalare Wert ist, den Sie anfangs hatten.
  16595.     </P
  16596. ><P
  16597. >      Wenn Sie ein Objekt in ein Array umwandeln, bekommen
  16598.      Sie die Eigenschaften (Mitgliedsvariablen) des Objekts als
  16599.      Elemente des Arrays. Die Schlⁿssel sind die Namen der
  16600.      Mitgliedsvariablen.
  16601.     </P
  16602. ><P
  16603. >      Wenn Sie einen <TT
  16604. CLASS="constant"
  16605. ><B
  16606. >NULL</B
  16607. ></TT
  16608. >-Wert in ein Array umwandeln, bekommen Sie
  16609.      ein leeres Array.
  16610.     </P
  16611. ></DIV
  16612. ><DIV
  16613. CLASS="sect2"
  16614. ><HR><H3
  16615. CLASS="sect2"
  16616. ><A
  16617. NAME="language.types.array.comparing"
  16618. >Vergleiche</A
  16619. ></H3
  16620. ><P
  16621. >      Arrays k÷nnen Sie mit der Funktion <A
  16622. HREF="#function.array-diff"
  16623. ><B
  16624. CLASS="function"
  16625. >array_diff()</B
  16626. ></A
  16627. > und
  16628.      mit den <A
  16629. HREF="#language.operators.array"
  16630. >Array Operatoren
  16631.      </A
  16632. > vergleichen.
  16633.     </P
  16634. ></DIV
  16635. ><DIV
  16636. CLASS="sect2"
  16637. ><HR><H3
  16638. CLASS="sect2"
  16639. ><A
  16640. NAME="language.types.array.examples"
  16641. >Beispiele</A
  16642. ></H3
  16643. ><P
  16644. >      Der Array-Typ in PHP ist sehr vielseitig. Hier folgen einige
  16645.      Beispiele um Ihnen die MΣchtigkeit von Arrays zu
  16646.      veranschaulichen.
  16647.     </P
  16648. ><P
  16649. >      <DIV
  16650. CLASS="informalexample"
  16651. ><P
  16652. ></P
  16653. ><A
  16654. NAME="AEN3097"
  16655. ></A
  16656. ><TABLE
  16657. BORDER="0"
  16658. BGCOLOR="#E0E0E0"
  16659. CELLPADDING="5"
  16660. ><TR
  16661. ><TD
  16662. ><PRE
  16663. CLASS="php"
  16664. ><?php
  16665. // Das hier
  16666. $a = array('Farbe'     => 'rot',
  16667.            'Geschmack' => 'sⁿ▀',
  16668.            'Form'      => 'rund',
  16669.            'Name'      => 'Apfel',
  16670.                           4          // Schlⁿssel ist 0
  16671.           );
  16672.  
  16673. // ist komplett gleichwertig mit
  16674. $a['Farbe']     = 'rot';
  16675. $a['Geschmack'] = 'sⁿ▀';
  16676. $a['Form']      = 'rund';
  16677. $a['Name']      = 'Apfel';
  16678. $a[]            = 4;          // Schlⁿssel ist 0
  16679.  
  16680. $b[] = 'a';
  16681. $b[] = 'b';
  16682. $b[] = 'c';
  16683. /* ergibt das Array: array(0 => 'a', 1 => 'b', 2 => 'c'),
  16684.    oder einfacher: array('a', 'b', 'c')
  16685. */
  16686. ?></PRE
  16687. ></TD
  16688. ></TR
  16689. ></TABLE
  16690. ><P
  16691. ></P
  16692. ></DIV
  16693. >
  16694.     </P
  16695. ><TABLE
  16696. WIDTH="100%"
  16697. BORDER="0"
  16698. CELLPADDING="0"
  16699. CELLSPACING="0"
  16700. CLASS="EXAMPLE"
  16701. ><TR
  16702. ><TD
  16703. ><DIV
  16704. CLASS="example"
  16705. ><A
  16706. NAME="AEN3099"
  16707. ></A
  16708. ><P
  16709. ><B
  16710. >Beispiel 10-4. Verwenden von <A
  16711. HREF="#function.array"
  16712. ><B
  16713. CLASS="function"
  16714. >array()</B
  16715. ></A
  16716. ></B
  16717. ></P
  16718. ><TABLE
  16719. BORDER="0"
  16720. BGCOLOR="#E0E0E0"
  16721. CELLPADDING="5"
  16722. ><TR
  16723. ><TD
  16724. ><PRE
  16725. CLASS="php"
  16726. ><?php
  16727. // Array als (Eigenschafts-)Abbildung
  16728. $map = array('version'    => 4,
  16729.              'OS'         => 'Linux',
  16730.              'Sprache'    => 'englisch',
  16731.              'short_tags' => true
  16732.             );
  16733.  
  16734. // strikt numerische Schlⁿssel
  16735. $array = array(7,
  16736.                8,
  16737.                0,
  16738.                156,
  16739.                -10,
  16740.               );
  16741. // Dies entspricht: array(0 => 7, 1 => 8, ...)
  16742.  
  16743. // wechselnde Schlⁿssel
  16744. $wechselnd = array(        10,  // Schlⁿssel: 0
  16745.                    5    =>  6,
  16746.                    3    =>  7,
  16747.                    'a'  =>  4,
  16748.                            11,  // Schlⁿssel: 6 (Maximum der Integer-Indices war 5)
  16749.                    '8'  =>  2,  // Schlⁿssel: 8 (integer!)
  16750.                    '02' => 77,  // Schlⁿssel: '02'
  16751.                    0    => 12   // 10 wird mit dem neuen Wert 12 ⁿberschrieben
  16752.                   );
  16753.  
  16754. // leeres Array
  16755. $leer = array();
  16756. ?></PRE
  16757. ></TD
  16758. ></TR
  16759. ></TABLE
  16760. ></DIV
  16761. ></TD
  16762. ></TR
  16763. ></TABLE
  16764. ><TABLE
  16765. WIDTH="100%"
  16766. BORDER="0"
  16767. CELLPADDING="0"
  16768. CELLSPACING="0"
  16769. CLASS="EXAMPLE"
  16770. ><TR
  16771. ><TD
  16772. ><DIV
  16773. CLASS="example"
  16774. ><A
  16775. NAME="language.types.array.examples.loop"
  16776. ></A
  16777. ><P
  16778. ><B
  16779. >Beispiel 10-5. Sammlung</B
  16780. ></P
  16781. ><TABLE
  16782. BORDER="0"
  16783. BGCOLOR="#E0E0E0"
  16784. CELLPADDING="5"
  16785. ><TR
  16786. ><TD
  16787. ><PRE
  16788. CLASS="php"
  16789. ><?php
  16790. $farben = array('rot', 'blau', 'grⁿn', 'gelb');
  16791.  
  16792. foreach ($farben as $farbe) {
  16793.     echo "GefΣllt Ihnen $farbe?\n";
  16794. }
  16795. ?></PRE
  16796. ></TD
  16797. ></TR
  16798. ></TABLE
  16799. ><P
  16800. >       Ausgabe:
  16801.      </P
  16802. ><TABLE
  16803. BORDER="0"
  16804. BGCOLOR="#E0E0E0"
  16805. CELLPADDING="5"
  16806. ><TR
  16807. ><TD
  16808. ><PRE
  16809. CLASS="screen"
  16810. >GefΣllt Ihnen rot?
  16811. GefΣllt Ihnen blau?
  16812. GefΣllt Ihnen grⁿn?
  16813. GefΣllt Ihnen gelb?</PRE
  16814. ></TD
  16815. ></TR
  16816. ></TABLE
  16817. ></DIV
  16818. ></TD
  16819. ></TR
  16820. ></TABLE
  16821. ><P
  16822. >      Beachten Sie, dass es gegenwΣrtig nicht m÷glich ist die Werte
  16823.      eines Arrays direkt in einer solchen Schleife zu Σndern. Eine
  16824.      L÷sung ist folgendes:
  16825.      <TABLE
  16826. WIDTH="100%"
  16827. BORDER="0"
  16828. CELLPADDING="0"
  16829. CELLSPACING="0"
  16830. CLASS="EXAMPLE"
  16831. ><TR
  16832. ><TD
  16833. ><DIV
  16834. CLASS="example"
  16835. ><A
  16836. NAME="language.types.array.examples.changeloop"
  16837. ></A
  16838. ><P
  16839. ><B
  16840. >Beispiel 10-6. Sammlung</B
  16841. ></P
  16842. ><TABLE
  16843. BORDER="0"
  16844. BGCOLOR="#E0E0E0"
  16845. CELLPADDING="5"
  16846. ><TR
  16847. ><TD
  16848. ><PRE
  16849. CLASS="php"
  16850. ><?php
  16851. foreach ($farben as $schluessel => $farbe) {
  16852.     // funktioniert nicht:
  16853.     //$farbe = strtoupper($farbe);
  16854.  
  16855.     // funktioniert:
  16856.     $farben[$schluessel] = strtoupper($farbe);
  16857. }
  16858. print_r($farben);
  16859. ?></PRE
  16860. ></TD
  16861. ></TR
  16862. ></TABLE
  16863. ><P
  16864. >        Ausgabe:
  16865.       </P
  16866. ><TABLE
  16867. BORDER="0"
  16868. BGCOLOR="#E0E0E0"
  16869. CELLPADDING="5"
  16870. ><TR
  16871. ><TD
  16872. ><PRE
  16873. CLASS="screen"
  16874. >Array
  16875. (
  16876.     [0] => ROT
  16877.     [1] => BLAU
  16878.     [2] => GR▄N
  16879.     [3] => GELB
  16880. )</PRE
  16881. ></TD
  16882. ></TR
  16883. ></TABLE
  16884. ></DIV
  16885. ></TD
  16886. ></TR
  16887. ></TABLE
  16888. >
  16889.     </P
  16890. ><P
  16891. >      Dieses Beispiel erzeugt ein Array, dessen Schlⁿssel bei eins
  16892.      beginnt.
  16893.      <TABLE
  16894. WIDTH="100%"
  16895. BORDER="0"
  16896. CELLPADDING="0"
  16897. CELLSPACING="0"
  16898. CLASS="EXAMPLE"
  16899. ><TR
  16900. ><TD
  16901. ><DIV
  16902. CLASS="example"
  16903. ><A
  16904. NAME="AEN3115"
  16905. ></A
  16906. ><P
  16907. ><B
  16908. >Beispiel 10-7. 1-basierter Index</B
  16909. ></P
  16910. ><TABLE
  16911. BORDER="0"
  16912. BGCOLOR="#E0E0E0"
  16913. CELLPADDING="5"
  16914. ><TR
  16915. ><TD
  16916. ><PRE
  16917. CLASS="php"
  16918. ><?php
  16919. $erstes_viertel  = array(1 => 'Januar', 'Februar', 'MΣrz');
  16920. print_r($erstes_viertel);
  16921. ?></PRE
  16922. ></TD
  16923. ></TR
  16924. ></TABLE
  16925. ><P
  16926. >        Ausgabe:
  16927.       </P
  16928. ><TABLE
  16929. BORDER="0"
  16930. BGCOLOR="#E0E0E0"
  16931. CELLPADDING="5"
  16932. ><TR
  16933. ><TD
  16934. ><PRE
  16935. CLASS="screen"
  16936. >Array 
  16937. (
  16938.     [1] => 'Januar'
  16939.     [2] => 'Februar'
  16940.     [3] => 'MΣrz'
  16941. )</PRE
  16942. ></TD
  16943. ></TR
  16944. ></TABLE
  16945. ></DIV
  16946. ></TD
  16947. ></TR
  16948. ></TABLE
  16949. >
  16950.     </P
  16951. ><TABLE
  16952. WIDTH="100%"
  16953. BORDER="0"
  16954. CELLPADDING="0"
  16955. CELLSPACING="0"
  16956. CLASS="EXAMPLE"
  16957. ><TR
  16958. ><TD
  16959. ><DIV
  16960. CLASS="example"
  16961. ><A
  16962. NAME="AEN3120"
  16963. ></A
  16964. ><P
  16965. ><B
  16966. >Beispiel 10-8. Fⁿllen eines Arrays</B
  16967. ></P
  16968. ><TABLE
  16969. BORDER="0"
  16970. BGCOLOR="#E0E0E0"
  16971. CELLPADDING="5"
  16972. ><TR
  16973. ><TD
  16974. ><PRE
  16975. CLASS="php"
  16976. ><?php
  16977. // Fⁿllen eines Arrays mit allen Inhalten eines Verzeichnisses
  16978. $handle = opendir('.');
  16979. while (false !== ($datei = readdir($handle))) {
  16980.     $dateien[] = $datei;
  16981. }
  16982. closedir($handle);
  16983. ?></PRE
  16984. ></TD
  16985. ></TR
  16986. ></TABLE
  16987. ></DIV
  16988. ></TD
  16989. ></TR
  16990. ></TABLE
  16991. ><P
  16992. >      Arrays sind geordnet. Diese Ordnung k÷nnen Sie mit Hilfe
  16993.      verschiedener Sortierfunktionen verΣndern. Fⁿr mehr Informationen
  16994.      schauen Sie unter dem Abschnitt zu den <A
  16995. HREF="#ref.array"
  16996. >Array Funktionen</A
  16997. > nach. Die Anzahl der
  16998.      Elemente in einem Array k÷nnen Sie mit der Funktion
  16999.      <A
  17000. HREF="#function.count"
  17001. ><B
  17002. CLASS="function"
  17003. >count()</B
  17004. ></A
  17005. > zΣhlen.
  17006.     </P
  17007. ><TABLE
  17008. WIDTH="100%"
  17009. BORDER="0"
  17010. CELLPADDING="0"
  17011. CELLSPACING="0"
  17012. CLASS="EXAMPLE"
  17013. ><TR
  17014. ><TD
  17015. ><DIV
  17016. CLASS="example"
  17017. ><A
  17018. NAME="AEN3126"
  17019. ></A
  17020. ><P
  17021. ><B
  17022. >Beispiel 10-9. Sortieren eines Arrays</B
  17023. ></P
  17024. ><TABLE
  17025. BORDER="0"
  17026. BGCOLOR="#E0E0E0"
  17027. CELLPADDING="5"
  17028. ><TR
  17029. ><TD
  17030. ><PRE
  17031. CLASS="php"
  17032. ><?php
  17033. sort($dateien);
  17034. print_r($dateien);
  17035. ?></PRE
  17036. ></TD
  17037. ></TR
  17038. ></TABLE
  17039. ></DIV
  17040. ></TD
  17041. ></TR
  17042. ></TABLE
  17043. ><P
  17044. >      Weil der Wert eines Arrays alles sein kann, kann dieser Wert
  17045.      wiederum ein Array sein. Somit k÷nnen Sie rekursive und
  17046.      multidimensionale Arrays erzeugen.
  17047.     </P
  17048. ><TABLE
  17049. WIDTH="100%"
  17050. BORDER="0"
  17051. CELLPADDING="0"
  17052. CELLSPACING="0"
  17053. CLASS="EXAMPLE"
  17054. ><TR
  17055. ><TD
  17056. ><DIV
  17057. CLASS="example"
  17058. ><A
  17059. NAME="AEN3130"
  17060. ></A
  17061. ><P
  17062. ><B
  17063. >Beispiel 10-10. Rekursive and multidimensionale Arrays</B
  17064. ></P
  17065. ><TABLE
  17066. BORDER="0"
  17067. BGCOLOR="#E0E0E0"
  17068. CELLPADDING="5"
  17069. ><TR
  17070. ><TD
  17071. ><PRE
  17072. CLASS="php"
  17073. ><?php
  17074. $fruits = array ("frⁿchte" => array("a" => "Orange",
  17075.                                     "b" => "Banane",
  17076.                                     "c" => "Apfel"
  17077.                                    ),
  17078.                  "nummern" => array(1,
  17079.                                     2,
  17080.                                     3,
  17081.                                     4,
  17082.                                     5,
  17083.                                     6
  17084.                                    ),
  17085.                  "l÷cher"  => array(     "erstens",
  17086.                                     5 => "zweitens",
  17087.                                          "drittens"
  17088.                                    )
  17089.                 );
  17090.  
  17091. // Ein paar Beispiele zum Ansprechen der Werte aus obigem Array
  17092. echo $fruits["l÷cher"][5];    // gibt "zweitens" aus
  17093. echo $fruits["frⁿchte"]["a"]; // gibt "Orange" aus
  17094. unset($fruits["l÷cher"][0]);  // entfernt "erstens"
  17095.  
  17096. // Erzeugen eines neuen mehrdimensionalen Arrays
  17097. $saefte["Apfel"]["gruen"] = "gut";
  17098. ?></PRE
  17099. ></TD
  17100. ></TR
  17101. ></TABLE
  17102. ></DIV
  17103. ></TD
  17104. ></TR
  17105. ></TABLE
  17106. ><P
  17107. >      Sie sollten wissen, dass beim Zuweisen eines Arrays die Werte
  17108.      immer kopiert werden. Um ein Array als Referenz zu kopieren,
  17109.      mⁿssen Sie den Referenz-Operator verwenden.
  17110.      <DIV
  17111. CLASS="informalexample"
  17112. ><P
  17113. ></P
  17114. ><A
  17115. NAME="AEN3134"
  17116. ></A
  17117. ><TABLE
  17118. BORDER="0"
  17119. BGCOLOR="#E0E0E0"
  17120. CELLPADDING="5"
  17121. ><TR
  17122. ><TD
  17123. ><PRE
  17124. CLASS="php"
  17125. ><?php
  17126. $arr1 = array(2, 3);
  17127. $arr2 = $arr1;
  17128. $arr2[] = 4; // $arr2 wird verΣndert,
  17129.              // $arr1 ist immer noch array(2, 3)
  17130.  
  17131. $arr3 = &$arr1;
  17132. $arr3[] = 4; // nun sind $arr1 und $arr3 gleich
  17133. ?></PRE
  17134. ></TD
  17135. ></TR
  17136. ></TABLE
  17137. ><P
  17138. ></P
  17139. ></DIV
  17140. >
  17141.     </P
  17142. ></DIV
  17143. ></DIV
  17144. ><DIV
  17145. CLASS="sect1"
  17146. ><HR><H2
  17147. CLASS="sect1"
  17148. ><A
  17149. NAME="language.types.object"
  17150. >Objekte</A
  17151. ></H2
  17152. ><DIV
  17153. CLASS="sect2"
  17154. ><H3
  17155. CLASS="sect2"
  17156. ><A
  17157. NAME="language.types.object.init"
  17158. >Objekt-Initialisierung</A
  17159. ></H3
  17160. ><P
  17161. >      Um ein Objekt zu initialisieren benutzen sie die Angabe
  17162.      <VAR
  17163. CLASS="literal"
  17164. >new</VAR
  17165. >, dadurch wird das Objekt einer
  17166.      Variablen-Instanz zugewiesen.
  17167.      <DIV
  17168. CLASS="informalexample"
  17169. ><P
  17170. ></P
  17171. ><A
  17172. NAME="AEN3142"
  17173. ></A
  17174. ><TABLE
  17175. BORDER="0"
  17176. BGCOLOR="#E0E0E0"
  17177. CELLPADDING="5"
  17178. ><TR
  17179. ><TD
  17180. ><PRE
  17181. CLASS="php"
  17182. ><?php
  17183. class foo {
  17184.     function tue_foo() {
  17185.         echo "Tue gerade foo.";
  17186.     }
  17187. }
  17188.  
  17189. $bar = new foo;
  17190. $bar->tue_foo();
  17191. ?></PRE
  17192. ></TD
  17193. ></TR
  17194. ></TABLE
  17195. ><P
  17196. ></P
  17197. ></DIV
  17198. >
  17199.     </P
  17200. ><P
  17201. >      Fⁿr eine ausfⁿhrliche Darstellung lesen Sie das Kapitel <A
  17202. HREF="#language.oop"
  17203. >Klassen und Objekte</A
  17204. >
  17205.     </P
  17206. ></DIV
  17207. ><DIV
  17208. CLASS="sect2"
  17209. ><HR><H3
  17210. CLASS="sect2"
  17211. ><A
  17212. NAME="language.types.object.casting"
  17213. >Umwandlung nach object</A
  17214. ></H3
  17215. ><P
  17216. >      Wenn ein Objekt in ein Objekt umgewandelt wird, wird es nicht
  17217.      verΣndert. Wenn ein Wert eines anderen Typs in ein Objekt
  17218.      umgewandelt wird, wird eine neue Instanz der eingebauten Klasse
  17219.      <VAR
  17220. CLASS="literal"
  17221. >stdClass</VAR
  17222. > erzeugt. War der Wert Null, dann ist
  17223.      die neue Instanz leer. Bei jedem anderen Wert enthΣlt eine
  17224.      Mitgliedsvariable namens <VAR
  17225. CLASS="literal"
  17226. >scalar</VAR
  17227. > den Wert.
  17228.      <DIV
  17229. CLASS="informalexample"
  17230. ><P
  17231. ></P
  17232. ><A
  17233. NAME="AEN3151"
  17234. ></A
  17235. ><TABLE
  17236. BORDER="0"
  17237. BGCOLOR="#E0E0E0"
  17238. CELLPADDING="5"
  17239. ><TR
  17240. ><TD
  17241. ><PRE
  17242. CLASS="php"
  17243. ><?php
  17244. $obj = (object) 'ciao';
  17245. echo $obj->scalar;  // gibt 'ciao' aus
  17246. ?></PRE
  17247. ></TD
  17248. ></TR
  17249. ></TABLE
  17250. ><P
  17251. ></P
  17252. ></DIV
  17253. >
  17254.     </P
  17255. ></DIV
  17256. ></DIV
  17257. ><DIV
  17258. CLASS="sect1"
  17259. ><HR><H2
  17260. CLASS="sect1"
  17261. ><A
  17262. NAME="language.types.resource"
  17263. >Resource</A
  17264. ></H2
  17265. ><P
  17266. >     Eine Resource ist eine spezielle Variable, die eine Referenz auf
  17267.     eine externe Ressource enthΣlt. Ressourcen werden von bestimmten
  17268.     Funktionen erzeugt und benutzt. Eine Liste dieser Funktionen und
  17269.     der entsprechenden Resource-Typen finden Sie im <A
  17270. HREF="#resource"
  17271. >Anhang</A
  17272. >.
  17273.    </P
  17274. ><DIV
  17275. CLASS="note"
  17276. ><BLOCKQUOTE
  17277. CLASS="note"
  17278. ><P
  17279. ><B
  17280. >Anmerkung: </B
  17281. >
  17282.      Der Resource-Typ wurde in PHP 4 eingefⁿhrt.
  17283.     </P
  17284. ></BLOCKQUOTE
  17285. ></DIV
  17286. ><DIV
  17287. CLASS="sect2"
  17288. ><HR><H3
  17289. CLASS="sect2"
  17290. ><A
  17291. NAME="language.types.resource.casting"
  17292. >Umwandlung nach resource</A
  17293. ></H3
  17294. ><P
  17295. >      Da Resource-Typen spezielle Routinen zu ge÷ffneten Dateien,
  17296.      Datenbankverbindungen, Bildinformationen und ─hnlichem
  17297.      enthalten, k÷nnen Sie keinen Wert in eine Resource umwandeln.
  17298.     </P
  17299. ></DIV
  17300. ><DIV
  17301. CLASS="sect2"
  17302. ><HR><H3
  17303. CLASS="sect2"
  17304. ><A
  17305. NAME="language.types.resource.self-destruct"
  17306. >Freigabe von Ressourcen</A
  17307. ></H3
  17308. ><P
  17309. >      Aufgrund des Reference-Counting Systems, das mit PHP 4's
  17310.      Zend Egine eingefⁿhrt wurde, wird automatisch entdeckt, wenn auf
  17311.      eine Ressource nicht mehr zugegriffen wird (wie in Java). Wenn
  17312.      dies der Fall ist werden alle Ressourcen, die fⁿr diese Ressource
  17313.      in Gebrauch waren, durch den "Mⁿllsammler" (garbage collector)
  17314.      freigegeben. Aus diesem Grund ist es selten jemals notwendig,
  17315.      Speicher manuell durch Aufruf von free_result-Funktionen
  17316.      freizugeben.
  17317.      <DIV
  17318. CLASS="note"
  17319. ><BLOCKQUOTE
  17320. CLASS="note"
  17321. ><P
  17322. ><B
  17323. >Anmerkung: </B
  17324. >
  17325.        Persistente Datenbank-Links stellen einen Sonderfall dar, sie
  17326.        werden durch den garbage collector <SPAN
  17327. CLASS="emphasis"
  17328. ><I
  17329. CLASS="emphasis"
  17330. >nicht</I
  17331. ></SPAN
  17332. >
  17333.        zerst÷rt.  Siehe auch den Abschnitt ⁿber <A
  17334. HREF="#features.persistent-connections"
  17335. >Persistente
  17336.        Datenbankverbindungen</A
  17337. >.
  17338.       </P
  17339. ></BLOCKQUOTE
  17340. ></DIV
  17341. >
  17342.     </P
  17343. ></DIV
  17344. ></DIV
  17345. ><DIV
  17346. CLASS="sect1"
  17347. ><HR><H2
  17348. CLASS="sect1"
  17349. ><A
  17350. NAME="language.types.null"
  17351. >NULL</A
  17352. ></H2
  17353. ><P
  17354. >     Der spezielle Wert <TT
  17355. CLASS="constant"
  17356. ><B
  17357. >NULL</B
  17358. ></TT
  17359. > steht dafⁿr, dass eine Varaiable keinen
  17360.     Wert hat. <TT
  17361. CLASS="constant"
  17362. ><B
  17363. >NULL</B
  17364. ></TT
  17365. > ist der einzig m÷gliche Wert des Typs
  17366.     <A
  17367. HREF="#language.types.null"
  17368. ><B
  17369. CLASS="type"
  17370. >NULL</B
  17371. ></A
  17372. >.
  17373.    </P
  17374. ><DIV
  17375. CLASS="note"
  17376. ><BLOCKQUOTE
  17377. CLASS="note"
  17378. ><P
  17379. ><B
  17380. >Anmerkung: </B
  17381. >
  17382.      Der Null-Typ wurde in PHP 4 eingefⁿhrt.
  17383.     </P
  17384. ></BLOCKQUOTE
  17385. ></DIV
  17386. ><P
  17387. >     Eine Variable wird als <TT
  17388. CLASS="constant"
  17389. ><B
  17390. >NULL</B
  17391. ></TT
  17392. > interpretiert, wenn
  17393.     <P
  17394. ></P
  17395. ><UL
  17396. ><LI
  17397. ><P
  17398. >        ihr die Konstannte <TT
  17399. CLASS="constant"
  17400. ><B
  17401. >NULL</B
  17402. ></TT
  17403. > als Wert zugewiesen wurde,
  17404.       </P
  17405. ></LI
  17406. ><LI
  17407. ><P
  17408. >        ihr bis jetzt kein Wert zugewiesen wurde,
  17409.       </P
  17410. ></LI
  17411. ><LI
  17412. ><P
  17413. >        sie mit <A
  17414. HREF="#function.unset"
  17415. ><B
  17416. CLASS="function"
  17417. >unset()</B
  17418. ></A
  17419. > gel÷scht wurde.
  17420.       </P
  17421. ></LI
  17422. ></UL
  17423. >
  17424.    </P
  17425. ><DIV
  17426. CLASS="sect2"
  17427. ><HR><H3
  17428. CLASS="sect2"
  17429. ><A
  17430. NAME="language.types.null.syntax"
  17431. >Syntax</A
  17432. ></H3
  17433. ><P
  17434. >      Es gibt nur einen Wert des Typs <TT
  17435. CLASS="constant"
  17436. ><B
  17437. >NULL</B
  17438. ></TT
  17439. >: das Schlⁿsselwort <TT
  17440. CLASS="constant"
  17441. ><B
  17442. >NULL</B
  17443. ></TT
  17444. >.
  17445.      Gro▀-/Kleinschreibung spielt keine Rolle.
  17446.      <DIV
  17447. CLASS="informalexample"
  17448. ><P
  17449. ></P
  17450. ><A
  17451. NAME="AEN3193"
  17452. ></A
  17453. ><TABLE
  17454. BORDER="0"
  17455. BGCOLOR="#E0E0E0"
  17456. CELLPADDING="5"
  17457. ><TR
  17458. ><TD
  17459. ><PRE
  17460. CLASS="php"
  17461. ><?php
  17462. $var = NULL;
  17463. ?></PRE
  17464. ></TD
  17465. ></TR
  17466. ></TABLE
  17467. ><P
  17468. ></P
  17469. ></DIV
  17470. >
  17471.     </P
  17472. ><P
  17473. >      Siehe auch <A
  17474. HREF="#function.is-null"
  17475. ><B
  17476. CLASS="function"
  17477. >is_null()</B
  17478. ></A
  17479. > und
  17480.      <A
  17481. HREF="#function.unset"
  17482. ><B
  17483. CLASS="function"
  17484. >unset()</B
  17485. ></A
  17486. >.
  17487.     </P
  17488. ></DIV
  17489. ></DIV
  17490. ><DIV
  17491. CLASS="sect1"
  17492. ><HR><H2
  17493. CLASS="sect1"
  17494. ><A
  17495. NAME="language.pseudo-types"
  17496. >In dieser Dokumentation verwendete Pseudo-Typen</A
  17497. ></H2
  17498. ><DIV
  17499. CLASS="sect2"
  17500. ><H3
  17501. CLASS="sect2"
  17502. ><A
  17503. NAME="language.types.mixed"
  17504. >Mixed</A
  17505. ></H3
  17506. ><P
  17507. >      <VAR
  17508. CLASS="literal"
  17509. >Mixed</VAR
  17510. > deutet darauf hin, dass ein Parameter
  17511.      mehrere (aber nicht notwendigerweise alle) Typen akzeptiert.
  17512.     </P
  17513. ><P
  17514. >      <A
  17515. HREF="#function.gettype"
  17516. ><B
  17517. CLASS="function"
  17518. >gettype()</B
  17519. ></A
  17520. > akzeptiert beispielsweise alle
  17521.      PHP-Typen, wΣhrend <A
  17522. HREF="#function.str-replace"
  17523. ><B
  17524. CLASS="function"
  17525. >str_replace()</B
  17526. ></A
  17527. > Strings und
  17528.      Arrays akzeptiert.
  17529.     </P
  17530. ></DIV
  17531. ><DIV
  17532. CLASS="sect2"
  17533. ><HR><H3
  17534. CLASS="sect2"
  17535. ><A
  17536. NAME="language.types.number"
  17537. >Number</A
  17538. ></H3
  17539. ><P
  17540. >      <VAR
  17541. CLASS="literal"
  17542. >Number</VAR
  17543. > deutet darauf hin, dass ein Parameter
  17544.      entweder ein Integer oder ein Float
  17545.      sein kann.
  17546.     </P
  17547. ></DIV
  17548. ><DIV
  17549. CLASS="sect2"
  17550. ><HR><H3
  17551. CLASS="sect2"
  17552. ><A
  17553. NAME="language.types.callback"
  17554. >Callback</A
  17555. ></H3
  17556. ><P
  17557. >      Einige Funktionen wie <A
  17558. HREF="#function.call-user-func"
  17559. ><B
  17560. CLASS="function"
  17561. >call_user_func()</B
  17562. ></A
  17563. > oder
  17564.      <A
  17565. HREF="#function.usort"
  17566. ><B
  17567. CLASS="function"
  17568. >usort()</B
  17569. ></A
  17570. > akzeptieren benutzerdefinierte
  17571.      Callback-Funktionen als Parameter. Callback-Funktionen k÷nnen
  17572.      nicht nur einfache Funktionen sein, sondern auch Objektmethoden
  17573.      einschlie▀lich statischer Klassenmethoden.
  17574.     </P
  17575. ><P
  17576. >      Eine PHP-Funktion wird einfach durch Ihren Namen als String
  17577.      ⁿbergeben. Sie k÷nnen jede eingebaute oder benutzerdefinierte
  17578.      Funktion ⁿbergeben mit Ausnahme von <A
  17579. HREF="#function.array"
  17580. ><B
  17581. CLASS="function"
  17582. >array()</B
  17583. ></A
  17584. >,
  17585.      <A
  17586. HREF="#function.echo"
  17587. ><B
  17588. CLASS="function"
  17589. >echo()</B
  17590. ></A
  17591. >, <A
  17592. HREF="#function.empty"
  17593. ><B
  17594. CLASS="function"
  17595. >empty()</B
  17596. ></A
  17597. >,
  17598.      <A
  17599. HREF="#function.eval"
  17600. ><B
  17601. CLASS="function"
  17602. >eval()</B
  17603. ></A
  17604. >, <A
  17605. HREF="#function.exit"
  17606. ><B
  17607. CLASS="function"
  17608. >exit()</B
  17609. ></A
  17610. >,
  17611.      <A
  17612. HREF="#function.isset"
  17613. ><B
  17614. CLASS="function"
  17615. >isset()</B
  17616. ></A
  17617. >, <A
  17618. HREF="#function.list"
  17619. ><B
  17620. CLASS="function"
  17621. >list()</B
  17622. ></A
  17623. >,
  17624.      <A
  17625. HREF="#function.print"
  17626. ><B
  17627. CLASS="function"
  17628. >print()</B
  17629. ></A
  17630. > und <A
  17631. HREF="#function.unset"
  17632. ><B
  17633. CLASS="function"
  17634. >unset()</B
  17635. ></A
  17636. >.
  17637.     </P
  17638. ><P
  17639. >      Eine Methode eines instanzierten Objekts wird als Array
  17640.      ⁿbergeben, das ein Objekt als Element mit Index 0 und einen
  17641.      Methodennamen als Element mit Index 1 enthΣlt.
  17642.     </P
  17643. ><P
  17644. >      Statische Klassenmethoden k÷nnen auch ⁿbergeben werden, ohne ein
  17645.      Objekt dieser Klasse zu instanzieren, indem statt des Objekts der
  17646.      Name der Klasse als Element mit Index 0 ⁿbergeben wird.
  17647.     </P
  17648. ><P
  17649. >      <TABLE
  17650. WIDTH="100%"
  17651. BORDER="0"
  17652. CELLPADDING="0"
  17653. CELLSPACING="0"
  17654. CLASS="EXAMPLE"
  17655. ><TR
  17656. ><TD
  17657. ><DIV
  17658. CLASS="example"
  17659. ><A
  17660. NAME="AEN3231"
  17661. ></A
  17662. ><P
  17663. ><B
  17664. >Beispiel 10-11. Beispiele zur Callback-Funktion</B
  17665. ></P
  17666. ><TABLE
  17667. BORDER="0"
  17668. BGCOLOR="#E0E0E0"
  17669. CELLPADDING="5"
  17670. ><TR
  17671. ><TD
  17672. ><PRE
  17673. CLASS="php"
  17674. ><?php
  17675.  
  17676. // einfaches callback Beispiel
  17677. function meine_callback_funktion() {
  17678.     echo 'hallo welt!';
  17679. }
  17680. call_user_func('meine_callback_funktion');
  17681.  
  17682. // Beispiele fⁿr Callbackmethoden
  17683. class MeineKlasse {
  17684.     function meineCallbackMethode() {
  17685.         echo 'Hallo Welt!';
  17686.     }
  17687. }
  17688.  
  17689. // Aufruf einer statischen Klassenmethode ohne Instanzierung
  17690. // eines Objekts
  17691. call_user_func(array('MeineKlasse', 'meineCallbackMethode'));
  17692.  
  17693. // Aufruf einer Objektmethode
  17694. $obj = new MeineKlasse();
  17695. call_user_func(array(&$obj, 'meineCallbackMethode'));
  17696. ?></PRE
  17697. ></TD
  17698. ></TR
  17699. ></TABLE
  17700. ></DIV
  17701. ></TD
  17702. ></TR
  17703. ></TABLE
  17704. >
  17705.     </P
  17706. ></DIV
  17707. ></DIV
  17708. ><DIV
  17709. CLASS="sect1"
  17710. ><HR><H2
  17711. CLASS="sect1"
  17712. ><A
  17713. NAME="language.types.type-juggling"
  17714. >Typen-Tricks</A
  17715. ></H2
  17716. ><P
  17717. >     PHP erfordert (bzw. unterstⁿtzt) keine expliziten Typ-Definitionen
  17718.     bei der Deklaration von Variablen; der Typ einer Variablen wird
  17719.     durch den Zusammenhang bestimmt in dem die Variable benutzt wird.
  17720.     Das bedeutet, dass bei der Zuweisung eines Strings zu einer
  17721.     Variablen <VAR
  17722. CLASS="parameter"
  17723. >$var</VAR
  17724. > diese Variable
  17725.     <VAR
  17726. CLASS="parameter"
  17727. >$var</VAR
  17728. > zum Typ String wird.  Sollten Sie
  17729.     dananch der Variablen <VAR
  17730. CLASS="parameter"
  17731. >$var</VAR
  17732. > einen
  17733.     Integer-Wert zuweisen, wird sie zu einem Integer-Typ.
  17734.    </P
  17735. ><P
  17736. >     Ein Beispiel fⁿr die automatische Typ-Konvertierung von PHP ist
  17737.     der Plus-Operator '+'. Ist einer der zu addierenden Werte vom Typ
  17738.     <A
  17739. HREF="#language.types.float"
  17740. ><B
  17741. CLASS="type"
  17742. >float</B
  17743. ></A
  17744. >, werden alle Werte als float-Typ behandelt.
  17745.     Auch das Ergebnis der Addition wird vom Typ float sein.
  17746.     Andernfalls werden die Werte als <A
  17747. HREF="#language.types.integer"
  17748. ><B
  17749. CLASS="type"
  17750. >integer</B
  17751. ></A
  17752. >-Typen
  17753.     angesehen und das Ergebnis wird ebenfalls vom Typ Integer sein.
  17754.     Beachten Sie, dass hierdurch NICHT der Typ der Operanden selbst
  17755.     beeinflusst wird; der Unterschied liegt einzig und allein in der
  17756.     Auswertung dieser Operanden.
  17757.     <DIV
  17758. CLASS="informalexample"
  17759. ><P
  17760. ></P
  17761. ><A
  17762. NAME="AEN3243"
  17763. ></A
  17764. ><TABLE
  17765. BORDER="0"
  17766. BGCOLOR="#E0E0E0"
  17767. CELLPADDING="5"
  17768. ><TR
  17769. ><TD
  17770. ><PRE
  17771. CLASS="php"
  17772. ><?php
  17773. $foo = "0";                         // $foo ist vom Typ String (ASCII 48)
  17774. $foo += 2;                          // $foo ist jetzt vom Typ Integer (2)
  17775. $foo = $foo + 1.3;                  // $foo ist nun vom Typ float (3.3)
  17776. $foo = 5 + "10 Sehr kleine Ferkel"; // $foo ist vom Typ Integer (15)
  17777. $foo = 5 + "10 Kleine Schweine";    // $foo ist vom Typ Integer (15)
  17778. ?></PRE
  17779. ></TD
  17780. ></TR
  17781. ></TABLE
  17782. ><P
  17783. ></P
  17784. ></DIV
  17785. >
  17786.    </P
  17787. ><P
  17788. >     Wenn Ihnen die beiden letzten Beispiele merkwⁿrdig erscheinen,
  17789.     beachten Sie die <A
  17790. HREF="#language.types.string.conversion"
  17791. >Umwandlung von Strings
  17792.     in Zahlen</A
  17793. >.
  17794.    </P
  17795. ><P
  17796. >     Wenn Sie die Auswertung einer Variablen als einen speziellen Typ
  17797.     erzwingen wollen, beachten sie den Abschnitt in <A
  17798. HREF="#language.types.typecasting"
  17799. >Typ-Umwandlung</A
  17800. >. Wollen
  17801.     Sie den Typ einer Variable Σndern, schauen Sie bei
  17802.     <A
  17803. HREF="#function.settype"
  17804. ><B
  17805. CLASS="function"
  17806. >settype()</B
  17807. ></A
  17808. > nach.
  17809.    </P
  17810. ><P
  17811. >     Um die Beispiele dieses Kapitels auszuprobieren, k÷nnen Sie die
  17812.     Funktion <A
  17813. HREF="#function.var-dump"
  17814. ><B
  17815. CLASS="function"
  17816. >var_dump()</B
  17817. ></A
  17818. > verwenden.
  17819.    </P
  17820. ><DIV
  17821. CLASS="note"
  17822. ><BLOCKQUOTE
  17823. CLASS="note"
  17824. ><P
  17825. ><B
  17826. >Anmerkung: </B
  17827. >
  17828.      Das Verhalten einer automatischen Umwandlung zum Typ Array ist
  17829.      zur Zeit nicht definiert.
  17830.      <DIV
  17831. CLASS="informalexample"
  17832. ><P
  17833. ></P
  17834. ><A
  17835. NAME="AEN3254"
  17836. ></A
  17837. ><TABLE
  17838. BORDER="0"
  17839. BGCOLOR="#E0E0E0"
  17840. CELLPADDING="5"
  17841. ><TR
  17842. ><TD
  17843. ><PRE
  17844. CLASS="php"
  17845. ><?php
  17846. $a = "1";     // $a ist ein String
  17847. $a[0] = "f";  // Was ist mit den String offsets? Was passiert?
  17848. ?></PRE
  17849. ></TD
  17850. ></TR
  17851. ></TABLE
  17852. ><P
  17853. ></P
  17854. ></DIV
  17855. >
  17856.     </P
  17857. ><P
  17858. >      Weil PHP (aus historischen Grⁿnden) die Indizierung innerhalb von
  17859.      Strings mittels der gleichen Syntax wie bei der Array-Indizierung
  17860.      unterstⁿtzt, fⁿhrt das o.a. Beispiel zu einem Problem: Soll $a zu
  17861.      einem Array werden, dessen erstes Element ein "f" ist oder soll
  17862.      "f" das erste Zeichen des Strings $a werden?
  17863.     </P
  17864. ><P
  17865. >      Die aktuellen Versionen von PHP interpretieren die zweite
  17866.      Anweisung als Stringversatz-Kennung, weshalb $a zu "f" wird. Das
  17867.      Ergebnis dieser automatischen Umwandlung sollte jedoch als
  17868.      undefiniert betrachtet werden. Mit PHP 4 wurde die neue Syntax
  17869.      mit geschweiften Klammern eingefⁿhrt um auf Zeichen in einem
  17870.      String zuzugreifen. Verwenden Sie statt der oben vorgestellten
  17871.      Syntax folgende:
  17872.      <DIV
  17873. CLASS="informalexample"
  17874. ><P
  17875. ></P
  17876. ><A
  17877. NAME="AEN3258"
  17878. ></A
  17879. ><TABLE
  17880. BORDER="0"
  17881. BGCOLOR="#E0E0E0"
  17882. CELLPADDING="5"
  17883. ><TR
  17884. ><TD
  17885. ><PRE
  17886. CLASS="php"
  17887. ><?php
  17888. $a    = "abc"; // $a ist ein String
  17889. $a{1} = "f";   // $a ist jetzt "afc"
  17890. ?></PRE
  17891. ></TD
  17892. ></TR
  17893. ></TABLE
  17894. ><P
  17895. ></P
  17896. ></DIV
  17897. >
  17898.      Fⁿr weitere Informationen siehe Abschnitt <A
  17899. HREF="#language.types.string.substr"
  17900. >Zugriff auf Zeichen in
  17901.      Strings</A
  17902. >.
  17903.     </P
  17904. ></BLOCKQUOTE
  17905. ></DIV
  17906. ><DIV
  17907. CLASS="sect2"
  17908. ><HR><H3
  17909. CLASS="sect2"
  17910. ><A
  17911. NAME="language.types.typecasting"
  17912. >Typ-Umwandlung</A
  17913. ></H3
  17914. ><P
  17915. >      Typ-Umwandlung in PHP funktioniert vielfach wie in C: Der Name
  17916.      des gewⁿnschten Typs wird vor der umzuwandelnden Variablen in
  17917.      Klammern gesetzt.
  17918.      <DIV
  17919. CLASS="informalexample"
  17920. ><P
  17921. ></P
  17922. ><A
  17923. NAME="AEN3264"
  17924. ></A
  17925. ><TABLE
  17926. BORDER="0"
  17927. BGCOLOR="#E0E0E0"
  17928. CELLPADDING="5"
  17929. ><TR
  17930. ><TD
  17931. ><PRE
  17932. CLASS="programlisting"
  17933. ><?php
  17934. $foo = 10;             // $foo ist ein Integer-Wert
  17935. $bar = (boolean) $foo; // $bar ist vom Typ boolean
  17936. ?></PRE
  17937. ></TD
  17938. ></TR
  17939. ></TABLE
  17940. ><P
  17941. ></P
  17942. ></DIV
  17943. >
  17944.     </P
  17945. ><P
  17946. >      Folgende Umwandlungen sind m÷glich:
  17947.      <P
  17948. ></P
  17949. ><UL
  17950. ><LI
  17951. ><P
  17952. >(int), (integer) - nach integer</P
  17953. ></LI
  17954. ><LI
  17955. ><P
  17956. >(bool), (boolean) - nach boolean</P
  17957. ></LI
  17958. ><LI
  17959. ><P
  17960. >(float), (double), (real) - nach float</P
  17961. ></LI
  17962. ><LI
  17963. ><P
  17964. >(string) - nach string</P
  17965. ></LI
  17966. ><LI
  17967. ><P
  17968. >(array) - nach array</P
  17969. ></LI
  17970. ><LI
  17971. ><P
  17972. >(object) - Wandlung zum Objekt</P
  17973. ></LI
  17974. ></UL
  17975. >
  17976.     </P
  17977. ><P
  17978. >      Beachten sie, dass Tabulatoren und Leerzeichen innerhalb der
  17979.      Klammern erlaubt sind. Deshalb sind die folgenden Beispiele
  17980.      identisch:
  17981.      <DIV
  17982. CLASS="informalexample"
  17983. ><P
  17984. ></P
  17985. ><A
  17986. NAME="AEN3281"
  17987. ></A
  17988. ><TABLE
  17989. BORDER="0"
  17990. BGCOLOR="#E0E0E0"
  17991. CELLPADDING="5"
  17992. ><TR
  17993. ><TD
  17994. ><PRE
  17995. CLASS="php"
  17996. ><?php
  17997. $foo = (int) $bar;
  17998. $foo = ( int ) $bar;
  17999. ?></PRE
  18000. ></TD
  18001. ></TR
  18002. ></TABLE
  18003. ><P
  18004. ></P
  18005. ></DIV
  18006. >
  18007.     </P
  18008. ><DIV
  18009. CLASS="note"
  18010. ><BLOCKQUOTE
  18011. CLASS="note"
  18012. ><P
  18013. ><B
  18014. >Anmerkung: </B
  18015. >
  18016.       Anstatt eine Variable in einen String umzuwandeln, k÷nnen Sie
  18017.       die Variable auch in doppelte Anfⁿhrungszeichen einschlie▀en.
  18018.       <DIV
  18019. CLASS="informalexample"
  18020. ><P
  18021. ></P
  18022. ><A
  18023. NAME="AEN3285"
  18024. ></A
  18025. ><TABLE
  18026. BORDER="0"
  18027. BGCOLOR="#E0E0E0"
  18028. CELLPADDING="5"
  18029. ><TR
  18030. ><TD
  18031. ><PRE
  18032. CLASS="php"
  18033. ><?php
  18034. $foo = 10;            // $foo ist ein Integer
  18035. $str = "$foo";        // $str ist ein String
  18036. $fst = (string) $foo; // $fst ist auch ein String
  18037.  
  18038. // Das gibt aus "sie sind gleich"
  18039. if ($fst === $str) {
  18040.     echo "sie sind gleich";
  18041. }
  18042. ?></PRE
  18043. ></TD
  18044. ></TR
  18045. ></TABLE
  18046. ><P
  18047. ></P
  18048. ></DIV
  18049. >
  18050.      </P
  18051. ></BLOCKQUOTE
  18052. ></DIV
  18053. ><P
  18054. >      Es ist nicht immer offenkundig, was bei der Typ-Umwandlung
  18055.      geschieht. Fⁿr weitere Informationen schauen Sie unter folgenden
  18056.      Abschnitten nach:
  18057.      <P
  18058. ></P
  18059. ><UL
  18060. ><LI
  18061. ><P
  18062. >         <A
  18063. HREF="#language.types.boolean.casting"
  18064. >Umwandlung nach
  18065.         boolean</A
  18066. >
  18067.        </P
  18068. ></LI
  18069. ><LI
  18070. ><P
  18071. >         <A
  18072. HREF="#language.types.integer.casting"
  18073. >Umwandlung nach
  18074.         integer</A
  18075. >
  18076.        </P
  18077. ></LI
  18078. ><LI
  18079. ><P
  18080. >         <A
  18081. HREF="#language.types.float.casting"
  18082. >Umwandlung nach
  18083.         float</A
  18084. >
  18085.        </P
  18086. ></LI
  18087. ><LI
  18088. ><P
  18089. >         <A
  18090. HREF="#language.types.string.casting"
  18091. >Umwandlung nach
  18092.         string</A
  18093. >
  18094.        </P
  18095. ></LI
  18096. ><LI
  18097. ><P
  18098. >         <A
  18099. HREF="#language.types.array.casting"
  18100. >Umwandlung nach
  18101.         array</A
  18102. >
  18103.        </P
  18104. ></LI
  18105. ><LI
  18106. ><P
  18107. >         <A
  18108. HREF="#language.types.object.casting"
  18109. >Umwandlung nach
  18110.         object</A
  18111. >
  18112.        </P
  18113. ></LI
  18114. ><LI
  18115. ><P
  18116. >         <A
  18117. HREF="#language.types.resource.casting"
  18118. >Umwandlung
  18119.         nach resource</A
  18120. >
  18121.        </P
  18122. ></LI
  18123. ><LI
  18124. ><P
  18125. >         <A
  18126. HREF="#types.comparisons"
  18127. >PHP type comparison
  18128.         tables</A
  18129. >
  18130.        </P
  18131. ></LI
  18132. ></UL
  18133. >
  18134.     </P
  18135. ></DIV
  18136. ></DIV
  18137. ></DIV
  18138. ><DIV
  18139. CLASS="chapter"
  18140. ><HR><H1
  18141. ><A
  18142. NAME="language.variables"
  18143. >Kapitel 11. Variablen</A
  18144. ></H1
  18145. ><DIV
  18146. CLASS="sect1"
  18147. ><H2
  18148. CLASS="sect1"
  18149. ><A
  18150. NAME="language.variables.basics"
  18151. >Grundlegendes</A
  18152. ></H2
  18153. ><P
  18154. >     Variablen werden in PHP dargestellt durch ein Dollar-Zeichen ($)
  18155.     gefolgt vom Namen der Variablen. Bei Variablen-Namen wird
  18156.     zwischen Gro▀- und Kleinschreibung unterschieden (case-sensitive).
  18157.    </P
  18158. ><P
  18159. >     Variablen-Namen werden in PHP nach den gleichen Regeln wie
  18160.     andere Bezeichner erstellt. Ein gⁿltiger Variablen-Name beginnt
  18161.     mit einem Buchstaben oder einem Unterstrich ("_"), gefolgt von
  18162.     einer beliebigen Anzahl von Buchstaben, Zahlen oder Unterstrichen.
  18163.     Als regulΣrer Ausdruck (regular expression) wⁿrde das wie folgt
  18164.     ausgedrⁿckt: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'.
  18165.    </P
  18166. ><DIV
  18167. CLASS="note"
  18168. ><BLOCKQUOTE
  18169. CLASS="note"
  18170. ><P
  18171. ><B
  18172. >Anmerkung: </B
  18173. >
  18174.      Unserem Zweck entspricht also ein Buchstabe von a bis z bzw.
  18175.      A bis Z oder einem ASCII-Zeichen von 127 bis 255 (0x7f bis 0xff).
  18176.     </P
  18177. ></BLOCKQUOTE
  18178. ></DIV
  18179. ><P
  18180. >     <DIV
  18181. CLASS="informalexample"
  18182. ><P
  18183. ></P
  18184. ><A
  18185. NAME="AEN3322"
  18186. ></A
  18187. ><TABLE
  18188. BORDER="0"
  18189. BGCOLOR="#E0E0E0"
  18190. CELLPADDING="5"
  18191. ><TR
  18192. ><TD
  18193. ><PRE
  18194. CLASS="php"
  18195. ><?php
  18196. $var = "Du";
  18197. $vaR = "und";
  18198. $Var = "ich";
  18199. $vAr = "wir lernen PHP"
  18200. echo "$var $vaR $Var, $vAr"; // gibt "Du und ich, wir lernen PHP" aus
  18201.  
  18202. $4site  = 'nicht jetzt';     // ungⁿltig, da Anfang eine Zahl
  18203. $_4site = 'nicht jetzt';     // gⁿltig, da Unterstrich am Anfang
  18204. $tΣbyte = 'irgendwas';       // gⁿltig, da 'Σ' dem (Erweiterten) ASCII-Wert 228 entspricht
  18205. ?></PRE
  18206. ></TD
  18207. ></TR
  18208. ></TABLE
  18209. ><P
  18210. ></P
  18211. ></DIV
  18212. >
  18213.    </P
  18214. ><P
  18215. >     Variablen werden in PHP 3 durch ihren Wert bestimmt. Das heisst,
  18216.     wenn Sie einer Variablen einen Ausdruck zuweisen, wird der gesamte
  18217.     Inhalt des Originalausdrucks in die Zielvariable kopiert. Die
  18218.     Folge ist, dass eine Variable, die ihren Inhalt von einer anderen
  18219.     Variablen erhalten hat, ihren Inhalt behΣlt, auch wenn Sie danach
  18220.     den Inhalt der anderen (Quell- / Ursprungs-)Variablen Σndern. Die
  18221.     Inhalte der Ziel- und Quellvariablen sind also insoweit unabhΣngig
  18222.     voneinander. Fⁿr weitere Informationen lesen Sie bitte das Kapitel
  18223.     unter <A
  18224. HREF="#language.expressions"
  18225. >Expressions / Ausdrⁿcke</A
  18226. >.
  18227.    </P
  18228. ><P
  18229. >     PHP 4 bietet eine andere M÷glichkeit der Wertzuweisung bei
  18230.     Variablen: <A
  18231. HREF="#language.references"
  18232. >Zuweisung durch
  18233.     Referenzierung</A
  18234. >. Das bedeutet, dass der Wert der neuen
  18235.     Variablen eine Referenz zur Ursprungs-Variablen darstellt (mit
  18236.     anderen Worten: Der Wert ist ein Alias bzw. Zeiger auf den Inhalt
  18237.     der Ursprungsvariablen). Beide Variablen zeigen also auf die
  18238.     selbe(n) Speicherstelle(n). ─nderungen der neuen Variablen Σndern
  18239.     auch deren Ursprungs-Variable und umgekehrt. Der Wert / Inhalt
  18240.     wird also nicht kopiert. Die ▄bertragung geschieht dadurch auch
  18241.     schneller als in PHP 3. Dies wird sich aber nur bei umfangreichen
  18242.     Schleifen oder bei der ▄bertragung von grossen <A
  18243. HREF="#language.types.array"
  18244. >Arrays</A
  18245. > oder <A
  18246. HREF="#language.types.object"
  18247. >Objekten</A
  18248. > bemerkbar machen.
  18249.    </P
  18250. ><P
  18251. >     Fⁿr die Zuweisung per Referenz mⁿssen Sie lediglich ein &
  18252.     der (Ausgangs-, Quell-) Variablen voranstellen, die
  18253.     sie einer anderen Variablen zuweisen wollen. Der folgende Skript-
  18254.     Ausschnitt wird zweimal 'Mein Name ist Bob' ausgeben:
  18255.     <DIV
  18256. CLASS="informalexample"
  18257. ><P
  18258. ></P
  18259. ><A
  18260. NAME="AEN3331"
  18261. ></A
  18262. ><TABLE
  18263. BORDER="0"
  18264. BGCOLOR="#E0E0E0"
  18265. CELLPADDING="5"
  18266. ><TR
  18267. ><TD
  18268. ><PRE
  18269. CLASS="php"
  18270. ><?php
  18271. $foo = 'Bob';             // 'Bob' der Variablen $foo zuweisen.
  18272. $bar = &$foo;             // Zeiger auf $foo in $bar erzeugen.
  18273. $bar = "Ich hei&szlig;e $bar";  // $bar verΣndern...
  18274. echo $bar;
  18275. echo $foo;                // $foo wurde dadurch ebenfalls verΣndert.
  18276. ?></PRE
  18277. ></TD
  18278. ></TR
  18279. ></TABLE
  18280. ><P
  18281. ></P
  18282. ></DIV
  18283. >
  18284.    </P
  18285. ><P
  18286. >     Zu beachten ist, dass nur Variablenbezeichner referenziert
  18287.     werden k÷nnen.
  18288.     <DIV
  18289. CLASS="informalexample"
  18290. ><P
  18291. ></P
  18292. ><A
  18293. NAME="AEN3334"
  18294. ></A
  18295. ><TABLE
  18296. BORDER="0"
  18297. BGCOLOR="#E0E0E0"
  18298. CELLPADDING="5"
  18299. ><TR
  18300. ><TD
  18301. ><PRE
  18302. CLASS="php"
  18303. ><?php
  18304. $foo = 25;
  18305. $bar = &$foo;     // Gⁿltige Zuweisung.
  18306. $bar = &(24 * 7); // Ungⁿltig, da kein Variablenbezeichner
  18307.                   // zugewiesen wird.
  18308. function test() {
  18309.     return 25;
  18310. }
  18311.  
  18312. $bar = &test();   // Ungⁿltig.
  18313. ?></PRE
  18314. ></TD
  18315. ></TR
  18316. ></TABLE
  18317. ><P
  18318. ></P
  18319. ></DIV
  18320. >
  18321.    </P
  18322. ></DIV
  18323. ><DIV
  18324. CLASS="sect1"
  18325. ><HR><H2
  18326. CLASS="sect1"
  18327. ><A
  18328. NAME="language.variables.predefined"
  18329. >Vordefinierte Variablen</A
  18330. ></H2
  18331. ><P
  18332. >     PHP bietet jedem ausgefⁿhrtem Skript eine Vielzahl von
  18333.     vordefinierten Variablen an. Viele dieser Variablen k÷nnen
  18334.     jedoch nicht vollstΣndig erlΣutert werden, da sie abhΣngig
  18335.     sind vom Web-Server, der Version und dem Setup des Web-
  18336.     Servers sowie weiteren Faktoren. Einige dieser Variablen
  18337.     stehen nicht zur Verfⁿgung, wenn PHP-Skripte per <A
  18338. HREF="#features.commandline"
  18339. >Kommando-Zeilen-Aufruf</A
  18340. >
  18341.     ausgefⁿhrt werden. Fⁿr eine Liste dieser Variablen lesen Sie bitte
  18342.     den Abschnitt <A
  18343. HREF="#reserved.variables"
  18344. >Vordefinierte
  18345.     Variablen</A
  18346. >.
  18347.    </P
  18348. ><DIV
  18349. CLASS="warning"
  18350. ><P
  18351. ></P
  18352. ><TABLE
  18353. CLASS="warning"
  18354. BORDER="1"
  18355. WIDTH="100%"
  18356. ><TR
  18357. ><TD
  18358. ALIGN="CENTER"
  18359. ><B
  18360. >Warnung</B
  18361. ></TD
  18362. ></TR
  18363. ><TR
  18364. ><TD
  18365. ALIGN="LEFT"
  18366. ><P
  18367. >      Ab PHP 4.2.0 ist der standardmΣ▀ige Wert fⁿr die PHP-Anweisung
  18368.      <A
  18369. HREF="#ini.register-globals"
  18370. >register_globals</A
  18371. >
  18372.      <SPAN
  18373. CLASS="emphasis"
  18374. ><I
  18375. CLASS="emphasis"
  18376. >off</I
  18377. ></SPAN
  18378. >. Dies ist eine wesentliche ─nderung in
  18379.      PHP. Die Anweisung register_globals <SPAN
  18380. CLASS="emphasis"
  18381. ><I
  18382. CLASS="emphasis"
  18383. >off</I
  18384. ></SPAN
  18385. >
  18386.      beeinflusst den Satz von vordefinierten Variablen, die im
  18387.      globalen Bereich verfⁿgbar sind. Um zum Beispiel
  18388.      <VAR
  18389. CLASS="varname"
  18390. >DOCUMENT_ROOT</VAR
  18391. > zu bekommen, mⁿssen Sie
  18392.      <VAR
  18393. CLASS="varname"
  18394. >$_SERVER['DOCUMENT_ROOT']</VAR
  18395. > statt
  18396.      <VAR
  18397. CLASS="varname"
  18398. >$DOCUMENT_ROOT</VAR
  18399. > verwenden oder um
  18400.      <VAR
  18401. CLASS="varname"
  18402. >$id</VAR
  18403. > von der URL
  18404.      <VAR
  18405. CLASS="literal"
  18406. >http://www.example.com/test.php?id=3</VAR
  18407. > zu
  18408.      bekommen <VAR
  18409. CLASS="varname"
  18410. >$_GET['id']</VAR
  18411. > statt
  18412.      <VAR
  18413. CLASS="varname"
  18414. >$id</VAR
  18415. > oder <VAR
  18416. CLASS="varname"
  18417. >$_ENV['HOME']</VAR
  18418. >
  18419.      statt <VAR
  18420. CLASS="varname"
  18421. >$HOME</VAR
  18422. >.
  18423.     </P
  18424. ><P
  18425. >      Fⁿr diese ─nderung betreffende Informationen lesen Sie bitte den
  18426.      Konfigurations-Eintrag fⁿr <A
  18427. HREF="#ini.register-globals"
  18428. >register_globals</A
  18429. >, das
  18430.      Sicherheitskapitel ⁿber die <A
  18431. HREF="#security.registerglobals"
  18432. >Verwendung von Register
  18433.      Globals</A
  18434. > und au▀erdem die PHP
  18435.      <A
  18436. HREF="http://www.php.net/release_4_1_0.php"
  18437. TARGET="_top"
  18438. >4.1.0</A
  18439. > und
  18440.      <A
  18441. HREF="http://www.php.net/release_4_2_0.php"
  18442. TARGET="_top"
  18443. >4.2.0</A
  18444. > Release
  18445.      Announcements.
  18446.     </P
  18447. ><P
  18448. >      Die reservierten vordefinierten Variablen, wie die
  18449.      <A
  18450. HREF="#language.variables.superglobals"
  18451. >Superglobalen
  18452.      Arrays</A
  18453. >, sollten bevorzugt verwendet werden.
  18454.     </P
  18455. ></TD
  18456. ></TR
  18457. ></TABLE
  18458. ></DIV
  18459. ><P
  18460. >     Ab Version 4.1.0 stehen in PHP eine zusΣtzliche Reihe
  18461.     vordefinierter Arrays zur Verfⁿgung, die Variablen vom Webserver
  18462.     (gegebenenfalls), von der Umgebung und von Benutzereingaben
  18463.     enthalten. Diese neuen Arrays sind insofern etwas sehr Spezielles,
  18464.     als sie automatisch global sind -- d.h., sie stehen automatisch in
  18465.     jedem Bereich zur Verfⁿgung. Deshalb sind sie auch bekannt als
  18466.     'Autoglobale' oder 'Superglobale'. (Es gibt in PHP keinen
  18467.     Mechanismus fⁿr benutzerdefinierte Superglobale.) Die Superglobale
  18468.     werden nachfolgend aufgelistet, aber fⁿr eine Liste ihres Inhalts
  18469.     und die weitere Diskussion vordefinierter Variablen und ihres
  18470.     Wesens lesen Sie bitte den Abschnitt <A
  18471. HREF="#reserved.variables"
  18472. >Reservierte vordefinierte
  18473.     Variablen</A
  18474. >. Au▀erdem werden Sie feststellen, dass die alten
  18475.     vordefinierten Variablen (<VAR
  18476. CLASS="varname"
  18477. >$HTTP_*_VARS</VAR
  18478. >) noch
  18479.     existieren.
  18480.  
  18481.     Seit PHP 5.0.0 k÷nnen Sie die
  18482. Registrierung der langen von PHP <A
  18483. HREF="#language.variables.predefined"
  18484. > vordefinierten Arrays</A
  18485. > mit der Konfigurationsoption 
  18486. <A
  18487. HREF="#ini.register-long-arrays"
  18488. >register_long_arrays</A
  18489. >
  18490. abschalten.
  18491.    </P
  18492. ><DIV
  18493. CLASS="note"
  18494. ><BLOCKQUOTE
  18495. CLASS="note"
  18496. ><P
  18497. ><B
  18498. >Variable Variablen: </B
  18499. >
  18500.      Superglobale k÷nnen nicht als <A
  18501. HREF="#language.variables.variable"
  18502. >Variable Variablen</A
  18503. >
  18504.      verwendet werden.
  18505.     </P
  18506. ></BLOCKQUOTE
  18507. ></DIV
  18508. ><P
  18509. >     Falls bestimmte Variablen nicht unter <A
  18510. HREF="#ini.variables-order"
  18511. >variables_order</A
  18512. > angegeben
  18513.     sind, dann bleiben auch ihre entsprechenden vordefinierten Arrays
  18514.     leer.
  18515.    </P
  18516. ><P
  18517. ></P
  18518. ><DIV
  18519. CLASS="variablelist"
  18520. ><P
  18521. ><B
  18522. >PHP Superglobale</B
  18523. ></P
  18524. ><DL
  18525. ><DT
  18526. ><A
  18527. HREF="#reserved.variables.globals"
  18528. >$GLOBALS</A
  18529. ></DT
  18530. ><DD
  18531. ><P
  18532. >        Diese Variable enthΣlt eine Referenz zu jeder Variable, die
  18533.        im globalen Bereich des laufenden Skripts zur Verfⁿgung
  18534.        steht. Die Schlⁿssel dieses Arrays sind die Namen der globalen
  18535.        Variablen. <VAR
  18536. CLASS="varname"
  18537. >$GLOBALS</VAR
  18538. > gibt es seit PHP 3.
  18539.       </P
  18540. ></DD
  18541. ><DT
  18542. ><A
  18543. HREF="#reserved.variables.server"
  18544. >$_SERVER</A
  18545. ></DT
  18546. ><DD
  18547. ><P
  18548. >        Variablen, die vom Webserver gesetzt werden oder anderweitig
  18549.        direkt mit der ausfⁿhrenden Umgebung des aktuellen Skripts
  18550.        zusammenhΣngen. Entspricht dem alten
  18551.        <VAR
  18552. CLASS="varname"
  18553. >$HTTP_SERVER_VARS</VAR
  18554. >-Array, das zwar noch zur
  18555.        Verfⁿgung steht, aber abzulehnen ist.
  18556.       </P
  18557. ></DD
  18558. ><DT
  18559. ><A
  18560. HREF="#reserved.variables.get"
  18561. >$_GET</A
  18562. ></DT
  18563. ><DD
  18564. ><P
  18565. >        Variablen, die dem Skript ⁿber HTTP GET geliefert werden.
  18566.        Entspricht dem alten <VAR
  18567. CLASS="varname"
  18568. >$HTTP_GET_VARS</VAR
  18569. >-Array,
  18570.        das zwar noch zur Verfⁿgung steht, aber abzulehnen ist.
  18571.       </P
  18572. ></DD
  18573. ><DT
  18574. ><A
  18575. HREF="#reserved.variables.post"
  18576. >$_POST</A
  18577. ></DT
  18578. ><DD
  18579. ><P
  18580. >        Variablen, die dem Skript ⁿber HTTP POST geliefert werden.
  18581.        Entspricht dem alten <VAR
  18582. CLASS="varname"
  18583. >$HTTP_POST_VARS</VAR
  18584. >-Array,
  18585.        das zwar noch zur Verfⁿgung steht, aber abzulehnen ist.
  18586.       </P
  18587. ></DD
  18588. ><DT
  18589. ><A
  18590. HREF="#reserved.variables.cookies"
  18591. >$_COOKIE</A
  18592. ></DT
  18593. ><DD
  18594. ><P
  18595. >        Variablen, die dem Skript ⁿber HTTP Cookies geliefert werden.
  18596.        Entspricht dem alten
  18597.        <VAR
  18598. CLASS="varname"
  18599. >$HTTP_COOKIE_VARS</VAR
  18600. >-Array, das zwar noch zur
  18601.        Verfⁿgung steht, aber abzulehnen ist.
  18602.       </P
  18603. ></DD
  18604. ><DT
  18605. ><A
  18606. HREF="#reserved.variables.files"
  18607. >$_FILES</A
  18608. ></DT
  18609. ><DD
  18610. ><P
  18611. >        Variablen, die dem Skript ⁿber HTTP Post Datei-Uploads
  18612.        geliefert werden. Entspricht dem alten
  18613.        <VAR
  18614. CLASS="varname"
  18615. >$HTTP_POST_FILES</VAR
  18616. >-Array, das zwar noch zur
  18617.        Verfⁿgung steht, aber abzulehnen ist. Fⁿr mehr Informationen
  18618.        lesen Sie bitte <A
  18619. HREF="#features.file-upload.post-method"
  18620. >Dateiuploads mit
  18621.        POST</A
  18622. >.
  18623.       </P
  18624. ></DD
  18625. ><DT
  18626. ><A
  18627. HREF="#reserved.variables.environment"
  18628. >$_ENV</A
  18629. ></DT
  18630. ><DD
  18631. ><P
  18632. >        Variablen, die dem Skript ⁿber die Umgebung geliefert werden.
  18633.        Entspricht dem alten <VAR
  18634. CLASS="varname"
  18635. >$HTTP_ENV_VARS</VAR
  18636. >-Array,
  18637.        das zwar noch zur Verfⁿgung steht, aber abzulehnen ist.
  18638.       </P
  18639. ></DD
  18640. ><DT
  18641. ><A
  18642. HREF="#reserved.variables.request"
  18643. >$_REQUEST</A
  18644. ></DT
  18645. ><DD
  18646. ><P
  18647. >        Variablen, die dem Skript ⁿber die GET-, POST- und
  18648.        COOKIE-Eingabemechanismen geliefert werden und von daher nicht
  18649.        vertrauenswⁿrdig sind. Die PrΣsenz und die Reihenfolge der
  18650.        Aufnahme der Variablen in dieses Array ist entsprechend der
  18651.        Konfigurationsanweisung <A
  18652. HREF="#ini.variables-order"
  18653. >variables_order</A
  18654. > definiert.
  18655.        Dieses Array hat in PHP vor Version 4.1.0 keine direkte
  18656.        Entsprechung. Siehe auch
  18657.        <A
  18658. HREF="#function.import-request-variables"
  18659. ><B
  18660. CLASS="function"
  18661. >import_request_variables()</B
  18662. ></A
  18663. >.
  18664.       </P
  18665. ><DIV
  18666. CLASS="caution"
  18667. ><P
  18668. ></P
  18669. ><TABLE
  18670. CLASS="caution"
  18671. BORDER="1"
  18672. WIDTH="100%"
  18673. ><TR
  18674. ><TD
  18675. ALIGN="CENTER"
  18676. ><B
  18677. >Achtung</B
  18678. ></TD
  18679. ></TR
  18680. ><TR
  18681. ><TD
  18682. ALIGN="LEFT"
  18683. ><P
  18684. >         Seit PHP 4.3.0 gibt es in <VAR
  18685. CLASS="varname"
  18686. >$_REQUEST</VAR
  18687. > keine
  18688.         FILE-Informationen von <VAR
  18689. CLASS="varname"
  18690. >$_FILES</VAR
  18691. > mehr.
  18692.        </P
  18693. ></TD
  18694. ></TR
  18695. ></TABLE
  18696. ></DIV
  18697. ><DIV
  18698. CLASS="note"
  18699. ><BLOCKQUOTE
  18700. CLASS="note"
  18701. ><P
  18702. ><B
  18703. >Anmerkung: </B
  18704. >
  18705.         Wenn PHP-Skripte auf der <A
  18706. HREF="#features.commandline"
  18707. >Kommandozeile</A
  18708. > ausgefⁿhrt
  18709.         werden, sind die EintrΣge <VAR
  18710. CLASS="varname"
  18711. >argv</VAR
  18712. > und
  18713.         <VAR
  18714. CLASS="varname"
  18715. >argc</VAR
  18716. > <SPAN
  18717. CLASS="emphasis"
  18718. ><I
  18719. CLASS="emphasis"
  18720. >nicht</I
  18721. ></SPAN
  18722. > in diesem
  18723.         Array enthalten; diese befinden sich im
  18724.         <VAR
  18725. CLASS="varname"
  18726. >$_SERVER</VAR
  18727. >-Array.
  18728.        </P
  18729. ></BLOCKQUOTE
  18730. ></DIV
  18731. ></DD
  18732. ><DT
  18733. ><A
  18734. HREF="#reserved.variables.session"
  18735. >$_SESSION</A
  18736. ></DT
  18737. ><DD
  18738. ><P
  18739. >        Variablen, die aktuell in der Session eines Skripts registriert
  18740.        sind. Entspricht dem alten
  18741.        <VAR
  18742. CLASS="varname"
  18743. >$HTTP_SESSION_VARS</VAR
  18744. >-Array, das zwar noch zur
  18745.        Verfⁿgung steht, aber abzulehnen ist. Fⁿr mehr Informationen
  18746.        lesen Sie bitte den Abschnitt <A
  18747. HREF="#ref.session"
  18748. >Session Funktionen</A
  18749. >.
  18750.       </P
  18751. ></DD
  18752. ></DL
  18753. ></DIV
  18754. ></DIV
  18755. ><DIV
  18756. CLASS="sect1"
  18757. ><HR><H2
  18758. CLASS="sect1"
  18759. ><A
  18760. NAME="language.variables.scope"
  18761. >Geltungsbereich von Variablen</A
  18762. ></H2
  18763. ><P
  18764. >     Der Geltungsbereich einer Variablen ergibt sich aus dem
  18765.     Zusammenhang, in dem sie definiert wurde. Meistens besteht
  18766.     dieser aus einem einzigen Bereich. Dieser beinhaltet auch den
  18767.     Bereich fⁿr Dateien, die per "include"- oder "require"-Anweisung
  18768.     eingebunden wurden, z.B.:
  18769.    </P
  18770. ><DIV
  18771. CLASS="informalexample"
  18772. ><P
  18773. ></P
  18774. ><A
  18775. NAME="AEN3446"
  18776. ></A
  18777. ><TABLE
  18778. BORDER="0"
  18779. BGCOLOR="#E0E0E0"
  18780. CELLPADDING="5"
  18781. ><TR
  18782. ><TD
  18783. ><PRE
  18784. CLASS="php"
  18785. ><?php
  18786. $a = 1;
  18787. include "b.inc";
  18788. ?></PRE
  18789. ></TD
  18790. ></TR
  18791. ></TABLE
  18792. ><P
  18793. ></P
  18794. ></DIV
  18795. ><P
  18796. >     Die Variable $a ist auch in der eingebundenen Datei
  18797.     <TT
  18798. CLASS="filename"
  18799. >b.inc</TT
  18800. > verfⁿgbar. In benutzerdefinierten Funktionen
  18801.     wird ein auf die Funktion beschrΣnkter Geltungsbereich eingefⁿhrt. Jede in
  18802.     einer Funktion benutzte Variable ist zunΣchst auf den lokalen Bereich
  18803.     der Funktion beschrΣnkt, z.B.:
  18804.    </P
  18805. ><DIV
  18806. CLASS="informalexample"
  18807. ><P
  18808. ></P
  18809. ><A
  18810. NAME="AEN3450"
  18811. ></A
  18812. ><TABLE
  18813. BORDER="0"
  18814. BGCOLOR="#E0E0E0"
  18815. CELLPADDING="5"
  18816. ><TR
  18817. ><TD
  18818. ><PRE
  18819. CLASS="php"
  18820. ><?php
  18821. $a = 1; // globaler Bereich
  18822.  
  18823. function test () { 
  18824.     echo $a; // Referenz auf einen lokalen Variablen-Bereich
  18825.  
  18826. test ();
  18827. ?></PRE
  18828. ></TD
  18829. ></TR
  18830. ></TABLE
  18831. ><P
  18832. ></P
  18833. ></DIV
  18834. ><P
  18835. >     Dieses Skript erzeugt keine Bildschirm-Ausgabe, da sich die Echo-
  18836.     Anweisung auf eine lokale Variable namens <VAR
  18837. CLASS="varname"
  18838. >$a</VAR
  18839. >
  18840.     bezieht und dieser kein Wert im lokalen Bezug zugewiesen worden ist.
  18841.     Dies ist ein kleiner Unterschied zu C, wo globale Variablen auch in
  18842.     Funktionen vorhanden sind, es sei denn, sie werden durch eine
  18843.     funktionsinterne Definition ⁿberschrieben. Das kann zu Problemen fⁿhren,
  18844.     denn in PHP mⁿssen global geltende Variablen innerhalb von Funktionen als
  18845.     solche definiert werden.
  18846.    </P
  18847. ><DIV
  18848. CLASS="sect2"
  18849. ><HR><H3
  18850. CLASS="sect2"
  18851. ><A
  18852. NAME="language.variables.scope.global"
  18853. >Das global Schlⁿsselwort</A
  18854. ></H3
  18855. ><P
  18856. >      ZunΣchst ein Beispiel fⁿr die Verwendung von
  18857.      <VAR
  18858. CLASS="literal"
  18859. >global</VAR
  18860. >:
  18861.     </P
  18862. ><P
  18863. >      <TABLE
  18864. WIDTH="100%"
  18865. BORDER="0"
  18866. CELLPADDING="0"
  18867. CELLSPACING="0"
  18868. CLASS="EXAMPLE"
  18869. ><TR
  18870. ><TD
  18871. ><DIV
  18872. CLASS="example"
  18873. ><A
  18874. NAME="AEN3459"
  18875. ></A
  18876. ><P
  18877. ><B
  18878. >Beispiel 11-1. Die Verwendung von global</B
  18879. ></P
  18880. ><TABLE
  18881. BORDER="0"
  18882. BGCOLOR="#E0E0E0"
  18883. CELLPADDING="5"
  18884. ><TR
  18885. ><TD
  18886. ><PRE
  18887. CLASS="php"
  18888. ><?php
  18889. $a = 1;
  18890. $b = 2;
  18891.  
  18892. function Summe()
  18893. {
  18894.     global $a, $b;
  18895.  
  18896.     $b = $a + $b;
  18897.  
  18898. Summe();
  18899. echo $b;
  18900. ?></PRE
  18901. ></TD
  18902. ></TR
  18903. ></TABLE
  18904. ></DIV
  18905. ></TD
  18906. ></TR
  18907. ></TABLE
  18908. >
  18909.     </P
  18910. ><P
  18911. >     Das obige Skript gibt "3" aus. Durch das Deklararieren
  18912.     der Variablen <VAR
  18913. CLASS="varname"
  18914. >$a</VAR
  18915. > und <VAR
  18916. CLASS="varname"
  18917. >$b</VAR
  18918. >innerhalb
  18919.     der Funktion als global, weisen alle Referenzen zu beiden Variablen auf
  18920.     die nun globalen Werte. Es gibt keine BeschrΣnkungen bei der Anzahl an
  18921.     globalen Variablen, die durch eine Funktion verΣndert werden k÷nnen.
  18922.    </P
  18923. ><P
  18924. >     Eine weitere M÷glichkeit besteht in der Verwendung des speziellen
  18925.     <VAR
  18926. CLASS="varname"
  18927. >$GLOBALS</VAR
  18928. > PHP-Array. Das obige Beispiel kann damit
  18929.     auch so  geschrieben werden:
  18930.    </P
  18931. ><P
  18932. >     <TABLE
  18933. WIDTH="100%"
  18934. BORDER="0"
  18935. CELLPADDING="0"
  18936. CELLSPACING="0"
  18937. CLASS="EXAMPLE"
  18938. ><TR
  18939. ><TD
  18940. ><DIV
  18941. CLASS="example"
  18942. ><A
  18943. NAME="AEN3468"
  18944. ></A
  18945. ><P
  18946. ><B
  18947. >Beispiel 11-2. 
  18948.       Die Verwendung von <VAR
  18949. CLASS="varname"
  18950. >$GLOBALS</VAR
  18951. > statt global
  18952.      </B
  18953. ></P
  18954. ><TABLE
  18955. BORDER="0"
  18956. BGCOLOR="#E0E0E0"
  18957. CELLPADDING="5"
  18958. ><TR
  18959. ><TD
  18960. ><PRE
  18961. CLASS="php"
  18962. ><?php
  18963. $a = 1;
  18964. $b = 2;
  18965.  
  18966. function Summe()
  18967. {
  18968.     $GLOBALS["b"] = $GLOBALS["a"] + $GLOBALS["b"];
  18969.  
  18970. Summe();
  18971. echo $b;
  18972. ?></PRE
  18973. ></TD
  18974. ></TR
  18975. ></TABLE
  18976. ></DIV
  18977. ></TD
  18978. ></TR
  18979. ></TABLE
  18980. >
  18981.    </P
  18982. ><P
  18983. >     Das <VAR
  18984. CLASS="varname"
  18985. >$GLOBALS</VAR
  18986. >-Array ist ein assoziatives Array
  18987.     mit dem Bezeichner der globalen Variablen als Schlⁿssel und dem
  18988.     Inhalt dieser Variablen als Wert des Array-Elements. Beachten Sie,
  18989.     dass <VAR
  18990. CLASS="varname"
  18991. >$GLOBALS</VAR
  18992. > in jedem Bereich existiert, weil
  18993.     $GLOBALS eine <A
  18994. HREF="#language.variables.superglobals"
  18995. >Superglobale</A
  18996. > ist.
  18997.     Hier ist ein Beispiel, das die StΣrke von Superglobalen
  18998.     demonstriert:
  18999.    </P
  19000. ><P
  19001. >     <TABLE
  19002. WIDTH="100%"
  19003. BORDER="0"
  19004. CELLPADDING="0"
  19005. CELLSPACING="0"
  19006. CLASS="EXAMPLE"
  19007. ><TR
  19008. ><TD
  19009. ><DIV
  19010. CLASS="example"
  19011. ><A
  19012. NAME="AEN3477"
  19013. ></A
  19014. ><P
  19015. ><B
  19016. >Beispiel 11-3. 
  19017.       Beispiel zur Demonstration von Superglobalen und Bereich
  19018.      </B
  19019. ></P
  19020. ><TABLE
  19021. BORDER="0"
  19022. BGCOLOR="#E0E0E0"
  19023. CELLPADDING="5"
  19024. ><TR
  19025. ><TD
  19026. ><PRE
  19027. CLASS="php"
  19028. ><?php
  19029. function test_global()
  19030. {
  19031.     // Die meisten vordefinierten Variablen sind nicht "super" und
  19032.     // ben÷tigen 'global', um im lokalen Bereich von Funktionen zur
  19033.     // Verfⁿgung zu stehen.
  19034.     global $HTTP_POST_VARS;
  19035.  
  19036.     echo $HTTP_POST_VARS['name'];
  19037.  
  19038.     // Superglobale stehen in jedem Bereich zur Verfⁿgung und
  19039.     // ben÷tigen kein 'global'. Superglobale stehen seit PHP 4.1.0
  19040.     // zur Verfⁿgung.
  19041.     echo $_POST['name'];
  19042. }
  19043. ?></PRE
  19044. ></TD
  19045. ></TR
  19046. ></TABLE
  19047. ></DIV
  19048. ></TD
  19049. ></TR
  19050. ></TABLE
  19051. >
  19052.    </P
  19053. ></DIV
  19054. ><DIV
  19055. CLASS="sect2"
  19056. ><HR><H3
  19057. CLASS="sect2"
  19058. ><A
  19059. NAME="language.variables.scope.static"
  19060. >Die Verwendung von statischen Variablen</A
  19061. ></H3
  19062. ><P
  19063. >     Ein weiterer wichtiger Anwendungszweck von Variablen-Bereichen
  19064.     ist die <SPAN
  19065. CLASS="emphasis"
  19066. ><I
  19067. CLASS="emphasis"
  19068. >static</I
  19069. ></SPAN
  19070. >-Variable. Eine statische
  19071.     Variable existiert nur in einem lokalen Funktions-Bereich, der
  19072.     Wert geht beim Verlassen dieses Bereichs aber nicht verloren.
  19073.     Schauen Sie das folgende Beispiel an:
  19074.    </P
  19075. ><P
  19076. >     <TABLE
  19077. WIDTH="100%"
  19078. BORDER="0"
  19079. CELLPADDING="0"
  19080. CELLSPACING="0"
  19081. CLASS="EXAMPLE"
  19082. ><TR
  19083. ><TD
  19084. ><DIV
  19085. CLASS="example"
  19086. ><A
  19087. NAME="AEN3485"
  19088. ></A
  19089. ><P
  19090. ><B
  19091. >Beispiel 11-4. 
  19092.       Beispiel, das die Notwendigkeit von statischen Variablen
  19093.       demonstriert
  19094.      </B
  19095. ></P
  19096. ><TABLE
  19097. BORDER="0"
  19098. BGCOLOR="#E0E0E0"
  19099. CELLPADDING="5"
  19100. ><TR
  19101. ><TD
  19102. ><PRE
  19103. CLASS="php"
  19104. ><?php
  19105. function test ()
  19106. {
  19107.     $a = 0;
  19108.     echo $a;
  19109.     $a++;
  19110. }
  19111. ?></PRE
  19112. ></TD
  19113. ></TR
  19114. ></TABLE
  19115. ></DIV
  19116. ></TD
  19117. ></TR
  19118. ></TABLE
  19119. >
  19120.    </P
  19121. ><P
  19122. >     Diese Funktion ist sinnlos, da sie bei jedem Aufruf <VAR
  19123. CLASS="varname"
  19124. >$a</VAR
  19125. >
  19126.     auf <VAR
  19127. CLASS="literal"
  19128. >0</VAR
  19129. > setzt und "0" ausgibt. Die Anweisung
  19130.     $a++, welche den Wert erh÷ht, macht keinen Sinn, da der Wert von
  19131.     <VAR
  19132. CLASS="varname"
  19133. >$a</VAR
  19134. > beim Verlassen der Funktion verloren geht. Um eine
  19135.     sinnvolle ZΣhlfunktion zu implementieren, die ihren aktuell gesetzten Wert
  19136.     nicht vergisst, mⁿssen Sie die Variable <VAR
  19137. CLASS="varname"
  19138. >$a</VAR
  19139. >als "static"
  19140.     deklarieren:
  19141.    </P
  19142. ><P
  19143. >     <TABLE
  19144. WIDTH="100%"
  19145. BORDER="0"
  19146. CELLPADDING="0"
  19147. CELLSPACING="0"
  19148. CLASS="EXAMPLE"
  19149. ><TR
  19150. ><TD
  19151. ><DIV
  19152. CLASS="example"
  19153. ><A
  19154. NAME="AEN3494"
  19155. ></A
  19156. ><P
  19157. ><B
  19158. >Beispiel 11-5. Beispiel zur Verwendung statischer Variablen</B
  19159. ></P
  19160. ><TABLE
  19161. BORDER="0"
  19162. BGCOLOR="#E0E0E0"
  19163. CELLPADDING="5"
  19164. ><TR
  19165. ><TD
  19166. ><PRE
  19167. CLASS="php"
  19168. ><?php
  19169. function Test()
  19170. {
  19171.     static $a = 0;
  19172.     echo $a;
  19173.     $a++;
  19174. }
  19175. ?></PRE
  19176. ></TD
  19177. ></TR
  19178. ></TABLE
  19179. ></DIV
  19180. ></TD
  19181. ></TR
  19182. ></TABLE
  19183. >
  19184.    </P
  19185. ><P
  19186. >     Jetzt wird bei jedem Aufruf der Test()-Funktion der aktuelle
  19187.     Wert von <VAR
  19188. CLASS="varname"
  19189. >$a</VAR
  19190. > ausgegeben und dann um 1 erh÷ht.
  19191.    </P
  19192. ><P
  19193. >     Static-Variablen erm÷glichen auch einen Weg zum Umgang mit
  19194.     rekursiven Funktionen. Das sind Funktionen, die sich selbst
  19195.     aufrufen. Hierbei besteht die Gefahr, so genannte Endlos-
  19196.     Schleifen zu programmieren. Sie mⁿssen also einen Weg vorsehen,
  19197.     diese Rekursion zu beenden. Die folgende einfache Funktion zΣhlt
  19198.     rekursiv bis 10. Die statische Variable
  19199.     <VAR
  19200. CLASS="varname"
  19201. >$zaehler</VAR
  19202. > wird benutzt, um die Rekursion zu
  19203.     beenden:
  19204.    </P
  19205. ><P
  19206. >     <TABLE
  19207. WIDTH="100%"
  19208. BORDER="0"
  19209. CELLPADDING="0"
  19210. CELLSPACING="0"
  19211. CLASS="EXAMPLE"
  19212. ><TR
  19213. ><TD
  19214. ><DIV
  19215. CLASS="example"
  19216. ><A
  19217. NAME="AEN3502"
  19218. ></A
  19219. ><P
  19220. ><B
  19221. >Beispiel 11-6. Statische Variablen in rekursiven Funktionen</B
  19222. ></P
  19223. ><TABLE
  19224. BORDER="0"
  19225. BGCOLOR="#E0E0E0"
  19226. CELLPADDING="5"
  19227. ><TR
  19228. ><TD
  19229. ><PRE
  19230. CLASS="php"
  19231. ><?php
  19232. function Test()
  19233. {
  19234.     static $zaehler = 0;
  19235.  
  19236.     $zaehler++;
  19237.     echo $zaehler;
  19238.     if ($zaehler < 10) {
  19239.         Test ();
  19240.     }
  19241.     $zaehler--;
  19242. }
  19243. ?></PRE
  19244. ></TD
  19245. ></TR
  19246. ></TABLE
  19247. ></DIV
  19248. ></TD
  19249. ></TR
  19250. ></TABLE
  19251. >
  19252.    </P
  19253. ><DIV
  19254. CLASS="note"
  19255. ><BLOCKQUOTE
  19256. CLASS="note"
  19257. ><P
  19258. ><B
  19259. >Anmerkung: </B
  19260. >  
  19261.       Statische Variablen werden wie in oben stehenden Beispielen deklariert. 
  19262.       Das Zuweisen eines Wertes, welcher das Ergebnis eines Ausdrucks ist,
  19263.       wird mit einem parse error quittiert.
  19264.     </P
  19265. ><P
  19266. >  
  19267.      <TABLE
  19268. WIDTH="100%"
  19269. BORDER="0"
  19270. CELLPADDING="0"
  19271. CELLSPACING="0"
  19272. CLASS="EXAMPLE"
  19273. ><TR
  19274. ><TD
  19275. ><DIV
  19276. CLASS="example"
  19277. ><A
  19278. NAME="AEN3508"
  19279. ></A
  19280. ><P
  19281. ><B
  19282. >Beispiel 11-7. Statische Variablen deklarieren</B
  19283. ></P
  19284. ><TABLE
  19285. BORDER="0"
  19286. BGCOLOR="#E0E0E0"
  19287. CELLPADDING="5"
  19288. ><TR
  19289. ><TD
  19290. ><PRE
  19291. CLASS="php"
  19292. ><?php
  19293. function foo(){
  19294.     static $int = 0;          // korrekt
  19295.     static $int = 1+2;        // falsch  (da ein Ausdruck vorliegt)
  19296.     static $int = sqrt(121);  // falsch  (ebenfalls ein Ausdruck)
  19297.  
  19298.     $int++;
  19299.     echo $int;
  19300. }
  19301. ?></PRE
  19302. ></TD
  19303. ></TR
  19304. ></TABLE
  19305. ></DIV
  19306. ></TD
  19307. ></TR
  19308. ></TABLE
  19309. >
  19310.    </P
  19311. ></BLOCKQUOTE
  19312. ></DIV
  19313. ></DIV
  19314. ><DIV
  19315. CLASS="sect2"
  19316. ><HR><H3
  19317. CLASS="sect2"
  19318. ><A
  19319. NAME="language.variables.scope.references"
  19320. >Referenzen bei globalen und statischen Variablen</A
  19321. ></H3
  19322. ><P
  19323. >     Die Zend Engine 1, die <VAR
  19324. CLASS="literal"
  19325. >PHP 4</VAR
  19326. > zugrunde liegt,
  19327.     fⁿhrt die <A
  19328. HREF="#language.variables.scope.static"
  19329. >static</A
  19330. >- und
  19331.     <A
  19332. HREF="#language.variables.scope.global"
  19333. >global</A
  19334. >-Wandler
  19335.     fⁿr Variablen in Bezug auf <A
  19336. HREF="#language.references"
  19337. >Referenzen</A
  19338. > aus. Zum Beispiel
  19339.     erzeugt eine echte globale Variable, die mit der Anweisung
  19340.     <VAR
  19341. CLASS="literal"
  19342. >global</VAR
  19343. > in den Funktionsbereich importiert
  19344.     wurde, tatsΣchlich eine Referenz zur globalen Variable. Das kann
  19345.     zu einem unerwarteten Verhalten fⁿhren, auf das im folgenden
  19346.     Beispiel eingegangen wird:
  19347.    </P
  19348. ><DIV
  19349. CLASS="informalexample"
  19350. ><P
  19351. ></P
  19352. ><A
  19353. NAME="AEN3519"
  19354. ></A
  19355. ><TABLE
  19356. BORDER="0"
  19357. BGCOLOR="#E0E0E0"
  19358. CELLPADDING="5"
  19359. ><TR
  19360. ><TD
  19361. ><PRE
  19362. CLASS="php"
  19363. ><?php
  19364. function test_global_ref() {
  19365.     global $obj;
  19366.     $obj = &new stdclass;
  19367. }
  19368.  
  19369. function test_global_noref() {
  19370.     global $obj;
  19371.     $obj = new stdclass;
  19372. }
  19373.  
  19374. test_global_ref();
  19375. var_dump($obj);
  19376. test_global_noref();
  19377. var_dump($obj);
  19378. ?></PRE
  19379. ></TD
  19380. ></TR
  19381. ></TABLE
  19382. ><P
  19383. ></P
  19384. ></DIV
  19385. ><P
  19386. >     Die Ausfⁿhrung dieses Beispiels erzeugt die folgende Ausgabe:
  19387.    </P
  19388. ><TABLE
  19389. BORDER="0"
  19390. BGCOLOR="#E0E0E0"
  19391. CELLPADDING="5"
  19392. ><TR
  19393. ><TD
  19394. ><PRE
  19395. CLASS="screen"
  19396. >NULL
  19397. object(stdClass)(0) {
  19398. }</PRE
  19399. ></TD
  19400. ></TR
  19401. ></TABLE
  19402. ><P
  19403. >     Ein Σhnliches Verhalten gilt auch fⁿr die Anweisung
  19404.     <VAR
  19405. CLASS="literal"
  19406. >static</VAR
  19407. >. Referenzen werden nicht statisch
  19408.     gespeichert:
  19409.    </P
  19410. ><DIV
  19411. CLASS="informalexample"
  19412. ><P
  19413. ></P
  19414. ><A
  19415. NAME="AEN3525"
  19416. ></A
  19417. ><TABLE
  19418. BORDER="0"
  19419. BGCOLOR="#E0E0E0"
  19420. CELLPADDING="5"
  19421. ><TR
  19422. ><TD
  19423. ><PRE
  19424. CLASS="php"
  19425. ><?php
  19426. function &get_instance_ref() {
  19427.     static $obj;
  19428.  
  19429.     echo "Statisches Objekt: ";
  19430.     var_dump($obj);
  19431.    if (!isset($obj)) {
  19432.         // Der statischen Variablen eine Referenz zuweisen
  19433.         $obj = &new stdclass;
  19434.     }
  19435.     $obj->eigenschaft++;
  19436.     return $obj;
  19437. }
  19438.  
  19439. function &get_instance_noref() {
  19440.     static $obj;
  19441.  
  19442.     echo "Statisches Objekt: ";
  19443.     var_dump($obj);
  19444.     if (!isset($obj)) {
  19445.         // Der statischen Variablen ein Objekt zuweisen
  19446.         $obj = new stdclass;
  19447.     }
  19448.     $obj->eigenschaft++;
  19449.     return $obj;
  19450. }
  19451.  
  19452. $obj1 = get_instance_ref();
  19453. $immer_noch_obj1 = get_instance_ref();
  19454. echo "\n";
  19455. $obj2 = get_instance_noref();
  19456. $immer_noch_obj2 = get_instance_noref();
  19457. ?></PRE
  19458. ></TD
  19459. ></TR
  19460. ></TABLE
  19461. ><P
  19462. ></P
  19463. ></DIV
  19464. ><P
  19465. >     Die Ausfⁿhrung dieses Beispiels erzeugt die folgende Ausgabe:
  19466.    </P
  19467. ><TABLE
  19468. BORDER="0"
  19469. BGCOLOR="#E0E0E0"
  19470. CELLPADDING="5"
  19471. ><TR
  19472. ><TD
  19473. ><PRE
  19474. CLASS="screen"
  19475. >Statisches Objekt: NULL
  19476. Statisches Objekt: NULL
  19477.  
  19478. Statisches Objekt: NULL
  19479. Statisches Objekt: object(stdClass)(1) {
  19480.   ["eigenschaft"]=>
  19481.   int(1)
  19482. }</PRE
  19483. ></TD
  19484. ></TR
  19485. ></TABLE
  19486. ><P
  19487. >     Dieses Beispiel demonstriert, dass die Referenz, die einer
  19488.     statischen Variablen zugewiesen wird, beim zweiten Aufruf der
  19489.     Funktion <VAR
  19490. CLASS="literal"
  19491. >&get_instance_ref()</VAR
  19492. > vergessen ist.
  19493.    </P
  19494. ></DIV
  19495. ></DIV
  19496. ><DIV
  19497. CLASS="sect1"
  19498. ><HR><H2
  19499. CLASS="sect1"
  19500. ><A
  19501. NAME="language.variables.variable"
  19502. >Variable Variablen</A
  19503. ></H2
  19504. ><P
  19505. >     Manchmal ist es komfortabel, variable Variablen-Bezeichner zu
  19506.     benutzen. Das bedeutet, einen Variablen-Namen zu setzen und
  19507.     dynamisch zu gebrauchen. Eine normale Variable wird wie folgt
  19508.     gebildet:
  19509.    </P
  19510. ><DIV
  19511. CLASS="informalexample"
  19512. ><P
  19513. ></P
  19514. ><A
  19515. NAME="AEN3534"
  19516. ></A
  19517. ><TABLE
  19518. BORDER="0"
  19519. BGCOLOR="#E0E0E0"
  19520. CELLPADDING="5"
  19521. ><TR
  19522. ><TD
  19523. ><PRE
  19524. CLASS="php"
  19525. ><?php
  19526. $a = "Hallo";
  19527. ?></PRE
  19528. ></TD
  19529. ></TR
  19530. ></TABLE
  19531. ><P
  19532. ></P
  19533. ></DIV
  19534. ><P
  19535. >     Eine variable Variable nimmt den Wert einer Variablen und
  19536.     behandelt ihn als Bezeichner der Variablen. Im obigen Beispiel
  19537.     kann <SPAN
  19538. CLASS="emphasis"
  19539. ><I
  19540. CLASS="emphasis"
  19541. >Hallo</I
  19542. ></SPAN
  19543. > als Variablen-Name gebraucht
  19544.     werden, indem man zwei $-Zeichen benutzt, also schreibt:
  19545.    </P
  19546. ><DIV
  19547. CLASS="informalexample"
  19548. ><P
  19549. ></P
  19550. ><A
  19551. NAME="AEN3538"
  19552. ></A
  19553. ><TABLE
  19554. BORDER="0"
  19555. BGCOLOR="#E0E0E0"
  19556. CELLPADDING="5"
  19557. ><TR
  19558. ><TD
  19559. ><PRE
  19560. CLASS="php"
  19561. ><?php
  19562. $$a = "Welt";
  19563. ?></PRE
  19564. ></TD
  19565. ></TR
  19566. ></TABLE
  19567. ><P
  19568. ></P
  19569. ></DIV
  19570. ><P
  19571. >     Nun existieren in der PHP-Symbol-Struktur zwei definierte und
  19572.     gespeicherte Variablen: <VAR
  19573. CLASS="varname"
  19574. >$a</VAR
  19575. > mit dem Inhalt "Hallo"
  19576.     und <VAR
  19577. CLASS="varname"
  19578. >$Hallo</VAR
  19579. > mit dem Inhalt "Welt". Deshalb wird die
  19580.     Anweisung
  19581.    </P
  19582. ><DIV
  19583. CLASS="informalexample"
  19584. ><P
  19585. ></P
  19586. ><A
  19587. NAME="AEN3543"
  19588. ></A
  19589. ><TABLE
  19590. BORDER="0"
  19591. BGCOLOR="#E0E0E0"
  19592. CELLPADDING="5"
  19593. ><TR
  19594. ><TD
  19595. ><PRE
  19596. CLASS="php"
  19597. ><?php
  19598. echo "$a ${$a}";
  19599. ?></PRE
  19600. ></TD
  19601. ></TR
  19602. ></TABLE
  19603. ><P
  19604. ></P
  19605. ></DIV
  19606. ><P
  19607. >     zur genau gleichen Ausgabe fⁿhren wie:
  19608.    </P
  19609. ><DIV
  19610. CLASS="informalexample"
  19611. ><P
  19612. ></P
  19613. ><A
  19614. NAME="AEN3546"
  19615. ></A
  19616. ><TABLE
  19617. BORDER="0"
  19618. BGCOLOR="#E0E0E0"
  19619. CELLPADDING="5"
  19620. ><TR
  19621. ><TD
  19622. ><PRE
  19623. CLASS="programlisting"
  19624. ><?php
  19625. echo "$a $Hallo";
  19626. ?></PRE
  19627. ></TD
  19628. ></TR
  19629. ></TABLE
  19630. ><P
  19631. ></P
  19632. ></DIV
  19633. ><P
  19634. >     also zu: <SAMP
  19635. CLASS="computeroutput"
  19636. >Hallo Welt</SAMP
  19637. >.
  19638.    </P
  19639. ><P
  19640. >     Wenn Sie variable Variablen mit Arrays verwenden, mⁿssen Sie eine
  19641.     Doppeldeutigkeit beachten. Wenn Sie nΣmlich
  19642.     <VAR
  19643. CLASS="varname"
  19644. >$$a[1]</VAR
  19645. > schreiben, dann muss der Parser wissen,
  19646.     ob Sie <VAR
  19647. CLASS="varname"
  19648. >$a[1]</VAR
  19649. > als Variable oder
  19650.     <VAR
  19651. CLASS="varname"
  19652. >$$a</VAR
  19653. > als Variable und dann [1] als Index dieser
  19654.     Variablen verwenden wollen bzw. gemeint haben. Die Syntax zur
  19655.     L÷sung dieser Doppeldeutigkeit: Verwenden Sie im ersten Fall
  19656.     <VAR
  19657. CLASS="varname"
  19658. >${$a[1]}</VAR
  19659. > und im zweiten Fall
  19660.     <VAR
  19661. CLASS="varname"
  19662. >${$a}[1]</VAR
  19663. >.
  19664.    </P
  19665. ><DIV
  19666. CLASS="warning"
  19667. ><P
  19668. ></P
  19669. ><TABLE
  19670. CLASS="warning"
  19671. BORDER="1"
  19672. WIDTH="100%"
  19673. ><TR
  19674. ><TD
  19675. ALIGN="CENTER"
  19676. ><B
  19677. >Warnung</B
  19678. ></TD
  19679. ></TR
  19680. ><TR
  19681. ><TD
  19682. ALIGN="LEFT"
  19683. ><P
  19684. >      Bitte beachten Sie, dass variable Variablen nicht bei <A
  19685. HREF="#language.variables.superglobals"
  19686. >Superglobalen
  19687.      Arrays</A
  19688. > verwendet werden k÷nnen. Das bedeutet, etwas wie
  19689.      <VAR
  19690. CLASS="varname"
  19691. >${$_GET}</VAR
  19692. > ist nicht m÷glich. Wenn Sie nach
  19693.      einer M÷glichkeit suchen, die Verfⁿgbarkeit von Superglobalen und
  19694.      den alten <VAR
  19695. CLASS="varname"
  19696. >HTTP_*_VARS</VAR
  19697. > zu handhaben, k÷nnen Sie
  19698.      das mit <A
  19699. HREF="#language.references"
  19700. >referenzieren</A
  19701. >
  19702.      versuchen.
  19703.     </P
  19704. ></TD
  19705. ></TR
  19706. ></TABLE
  19707. ></DIV
  19708. ></DIV
  19709. ><DIV
  19710. CLASS="sect1"
  19711. ><HR><H2
  19712. CLASS="sect1"
  19713. ><A
  19714. NAME="language.variables.external"
  19715. >Variablen ausserhalb von PHP</A
  19716. ></H2
  19717. ><DIV
  19718. CLASS="sect2"
  19719. ><H3
  19720. CLASS="sect2"
  19721. ><A
  19722. NAME="language.variables.external.form"
  19723. >HTML-Formulare (GET and POST)</A
  19724. ></H3
  19725. ><P
  19726. >      Sobald ein Formular an ein PHP-Skript ⁿbergeben wird, werden die
  19727.      Informationen dieses Formulars dem Skript automatisch verfⁿgbar
  19728.      gemacht. Es gibt viele M÷glichkeiten, auf diese Informationen
  19729.      zuzugreifen, zum Beispiel:
  19730.     </P
  19731. ><P
  19732. >      <TABLE
  19733. WIDTH="100%"
  19734. BORDER="0"
  19735. CELLPADDING="0"
  19736. CELLSPACING="0"
  19737. CLASS="EXAMPLE"
  19738. ><TR
  19739. ><TD
  19740. ><DIV
  19741. CLASS="example"
  19742. ><A
  19743. NAME="AEN3568"
  19744. ></A
  19745. ><P
  19746. ><B
  19747. >Beispiel 11-8. Ein einfaches HTML-Formular</B
  19748. ></P
  19749. ><TABLE
  19750. BORDER="0"
  19751. BGCOLOR="#E0E0E0"
  19752. CELLPADDING="5"
  19753. ><TR
  19754. ><TD
  19755. ><PRE
  19756. CLASS="html"
  19757. ><form action="foo.php" method="post">
  19758.     Name:  <input type="text" name="username" /><br />
  19759.     Email: <input type="text" name="email" /><br />
  19760.     <input type="submit" name="submit" value="Und ab!" />
  19761. </form></PRE
  19762. ></TD
  19763. ></TR
  19764. ></TABLE
  19765. ></DIV
  19766. ></TD
  19767. ></TR
  19768. ></TABLE
  19769. >
  19770.     </P
  19771. ><P
  19772. >      AbhΣngig von Ihrem speziellen Setup und Ihren pers÷nlichen
  19773.      Vorlieben gibt es viele M÷glichkeiten, auf die Daten von Ihren
  19774.      HTML-Formularen zuzugreifen. Hier einige Beispiele:
  19775.     </P
  19776. ><P
  19777. >      <TABLE
  19778. WIDTH="100%"
  19779. BORDER="0"
  19780. CELLPADDING="0"
  19781. CELLSPACING="0"
  19782. CLASS="EXAMPLE"
  19783. ><TR
  19784. ><TD
  19785. ><DIV
  19786. CLASS="example"
  19787. ><A
  19788. NAME="AEN3573"
  19789. ></A
  19790. ><P
  19791. ><B
  19792. >Beispiel 11-9. 
  19793.        Zugriff auf die Daten von einem einfachen POST HTML-Formular
  19794.       </B
  19795. ></P
  19796. ><TABLE
  19797. BORDER="0"
  19798. BGCOLOR="#E0E0E0"
  19799. CELLPADDING="5"
  19800. ><TR
  19801. ><TD
  19802. ><PRE
  19803. CLASS="html"
  19804. ><?php
  19805. // Seit PHP 4.1.0 verfⁿgbar
  19806.  
  19807.    echo $_POST['benutzername'];
  19808.    echo $_REQUEST['benutzername'];
  19809.  
  19810.    import_request_variables('p', 'p_');
  19811.    echo $p_benutzername;
  19812.  
  19813. // Seit PHP 3 verfⁿgbar. Ab PHP 5.0.0 k÷nnen diese langen
  19814. // vordefinierten Variablen mit der Anweisung register_long_arrays
  19815. // deaktiviert werden.
  19816.  
  19817.    echo $HTTP_POST_VARS['benutzername'];
  19818.  
  19819. // Verfⁿgbar, falls die PHP-Anweisung register_globals = on. Ab
  19820. // PHP 4.2.0 ist der standardmΣ▀ige Wert von register_globals = off.
  19821. // Es ist nicht empfehlenswert, diese Methode zu verwenden, bzw. sich
  19822. // darauf zu verlassen.
  19823.  
  19824.    echo $benutzername;
  19825. ?></PRE
  19826. ></TD
  19827. ></TR
  19828. ></TABLE
  19829. ></DIV
  19830. ></TD
  19831. ></TR
  19832. ></TABLE
  19833. >
  19834.    </P
  19835. ><P
  19836. >     Die Verwendung eines GET Formulars ist, davon abgesehen, dass Sie
  19837.     stattdessen die entsprechende vordefinierte GET-Variable erhalten,
  19838.     Σhnlich. Au▀erdem wird GET auch fⁿr den QUERY_STRING (die
  19839.     Information nach dem '?' in einer URL) verwendet. So enthΣlt zum
  19840.     Beispiel <VAR
  19841. CLASS="literal"
  19842. >http://www.example.com/test.php?id=3</VAR
  19843. >
  19844.     GET-Daten, auf die mit <VAR
  19845. CLASS="varname"
  19846. >$_GET['id']</VAR
  19847. > zugegriffen
  19848.     werden kann. Siehe auch <A
  19849. HREF="#reserved.variables.request"
  19850. >$_REQUEST</A
  19851. > und
  19852.     <A
  19853. HREF="#function.import-request-variables"
  19854. ><B
  19855. CLASS="function"
  19856. >import_request_variables()</B
  19857. ></A
  19858. >.
  19859.    </P
  19860. ><DIV
  19861. CLASS="note"
  19862. ><BLOCKQUOTE
  19863. CLASS="note"
  19864. ><P
  19865. ><B
  19866. >Anmerkung: </B
  19867. >
  19868.      <A
  19869. HREF="#language.variables.superglobals"
  19870. >Superglobale
  19871.      Arrays</A
  19872. > wie <VAR
  19873. CLASS="varname"
  19874. >$_POST</VAR
  19875. > und
  19876.      <VAR
  19877. CLASS="varname"
  19878. >$_GET</VAR
  19879. > stehen seit PHP 4.1.0 zur Verfⁿgung.
  19880.     </P
  19881. ></BLOCKQUOTE
  19882. ></DIV
  19883. ><P
  19884. >     Wie gezeigt, war <A
  19885. HREF="#ini.register-globals"
  19886. >register_globals</A
  19887. > vor PHP
  19888.     4.2.0 standardmΣ▀ig <SPAN
  19889. CLASS="emphasis"
  19890. ><I
  19891. CLASS="emphasis"
  19892. >on</I
  19893. ></SPAN
  19894. >. In PHP 3 war es immer
  19895.     aktiviert. Die PHP-Gemeinschaft ermuntert alle, sich nicht auf
  19896.     diese Anweisung zu stⁿtzen, weil es vorzuziehen ist, davon
  19897.     auszugehen, dass sie <SPAN
  19898. CLASS="emphasis"
  19899. ><I
  19900. CLASS="emphasis"
  19901. >off</I
  19902. ></SPAN
  19903. > ist und entsprechend
  19904.     zu programmieren.
  19905.    </P
  19906. ><DIV
  19907. CLASS="note"
  19908. ><BLOCKQUOTE
  19909. CLASS="note"
  19910. ><P
  19911. ><B
  19912. >Anmerkung: </B
  19913. >
  19914.      Die Konfigurationseinstellung zu <A
  19915. HREF="#ini.magic-quotes-gpc"
  19916. >magic_quotes_gpc</A
  19917. > betrifft
  19918.      Get-, Post- und Cookie-Werte. Ist diese Einstellung aktiv, wird
  19919.      der Wert (It's "PHP!") automatisch zu (It\'s \"PHP!\"). Escaping
  19920.      ist notwendig, wenn Sie ihre Daten in eine Datenbank einfⁿgen
  19921.      wollen. Siehe auch <A
  19922. HREF="#function.addslashes"
  19923. ><B
  19924. CLASS="function"
  19925. >addslashes()</B
  19926. ></A
  19927. >,
  19928.      <A
  19929. HREF="#function.stripslashes"
  19930. ><B
  19931. CLASS="function"
  19932. >stripslashes()</B
  19933. ></A
  19934. > und <A
  19935. HREF="#ini.magic-quotes-sybase"
  19936. >magic_quotes_sybase</A
  19937. >.
  19938.     </P
  19939. ></BLOCKQUOTE
  19940. ></DIV
  19941. ><P
  19942. >     Im Zusammenhang mit Formular-Variablen versteht PHP auch
  19943.     Arrays (siehe auch die <A
  19944. HREF="#faq.html"
  19945. >verwandte Faq</A
  19946. >).
  19947.     Sie k÷nnen z.B. die betreffenden Variablen gruppieren oder dieses
  19948.     Leistungsmerkmal nutzen, um Werte aus Mehrfach-Auswahl-Bereichen
  19949.     zu erhalten. Schicken wir zum Beispiel ein Formular an sich selbst
  19950.     und lassen nach dem Abschicken die Daten anzeigen:
  19951.    </P
  19952. ><P
  19953. >     <TABLE
  19954. WIDTH="100%"
  19955. BORDER="0"
  19956. CELLPADDING="0"
  19957. CELLSPACING="0"
  19958. CLASS="EXAMPLE"
  19959. ><TR
  19960. ><TD
  19961. ><DIV
  19962. CLASS="example"
  19963. ><A
  19964. NAME="AEN3599"
  19965. ></A
  19966. ><P
  19967. ><B
  19968. >Beispiel 11-10. Komplexere Formular-Variablen</B
  19969. ></P
  19970. ><TABLE
  19971. BORDER="0"
  19972. BGCOLOR="#E0E0E0"
  19973. CELLPADDING="5"
  19974. ><TR
  19975. ><TD
  19976. ><PRE
  19977. CLASS="php"
  19978. ><?php
  19979. if (isset($_POST['action']) && $_POST['action'] == 'abgeschickt') {
  19980.     echo '<pre>';
  19981.     print_r($_POST);
  19982.     echo '<a href="'. $_SERVER['PHP_SELF'] .'">Bitte versuchen Sie es nochmal</a>';
  19983.  
  19984.     echo '</pre>';
  19985. } else {
  19986. ?>
  19987. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  19988.     Name:  <input type="text" name="personal[name]" /><br />
  19989.     Email: <input type="text" name="personal[email]" /><br />
  19990.     Bier: <br />
  19991.     <select multiple name="bier[]">
  19992.         <option value="warthog">Warthog</option>
  19993.         <option value="guinness">Guinness</option>
  19994.         <option value="stuttgarter">Stuttgarter SchwabenbrΣu</option>
  19995.     </select><br />
  19996.     <input type="hidden" name="action" value="abgeschickt" />
  19997.     <input type="submit" name="submit" value="Und ab!" />
  19998. </form>
  19999. <?php
  20000. }
  20001. ?></PRE
  20002. ></TD
  20003. ></TR
  20004. ></TABLE
  20005. ></DIV
  20006. ></TD
  20007. ></TR
  20008. ></TABLE
  20009. >
  20010.     </P
  20011. ><P
  20012. >      In PHP 3 ist die Verwendung von Arrays in Formularvariablen auf
  20013.      eindimensionale Arrays beschrΣnkt. In PHP 4 besteht diese EinschrΣnkung
  20014.      nicht mehr.
  20015.     </P
  20016. ><DIV
  20017. CLASS="sect3"
  20018. ><HR><H4
  20019. CLASS="sect3"
  20020. ><A
  20021. NAME="language.variables.external.form.submit"
  20022. >IMAGE SUBMIT Variablen-Bezeichner</A
  20023. ></H4
  20024. ><P
  20025. >       Zur ▄bertragung eines Formulars kann auch ein Bild (Image)
  20026.       statt eines ▄bertragungs-Schalters (Submit-Button) benutzt
  20027.       werden, dessen Tag wie folgt aussieht:
  20028.      </P
  20029. ><DIV
  20030. CLASS="informalexample"
  20031. ><P
  20032. ></P
  20033. ><A
  20034. NAME="AEN3606"
  20035. ></A
  20036. ><TABLE
  20037. BORDER="0"
  20038. BGCOLOR="#E0E0E0"
  20039. CELLPADDING="5"
  20040. ><TR
  20041. ><TD
  20042. ><PRE
  20043. CLASS="html"
  20044. ><input type="image" src="image.gif" name="sub" /></PRE
  20045. ></TD
  20046. ></TR
  20047. ></TABLE
  20048. ><P
  20049. ></P
  20050. ></DIV
  20051. ><P
  20052. >       Klickt der Benutzer irgendwo auf das Bild, wird das
  20053.       entsprechende Formular an den Web-Server ⁿbertragen. Hierbei
  20054.       sind zwei zusΣtzliche Variablen vorhanden, sub_x und sub_y.
  20055.       Diese enthalten die Koordinaten des Klick-Punktes innerhalb des
  20056.       Bildes. Die Erfahreneren werden sagen, dass die Variablen, die
  20057.       vom Browser gesendet werden einen Punkt enthalten statt eines
  20058.       Unterstrichs. Dieser Punkt wird von PHP automatisch in einen
  20059.       Unterstrich verwandelt.
  20060.      </P
  20061. ></DIV
  20062. ></DIV
  20063. ><DIV
  20064. CLASS="sect2"
  20065. ><HR><H3
  20066. CLASS="sect2"
  20067. ><A
  20068. NAME="language.variables.external.cookies"
  20069. >HTTP-Cookies</A
  20070. ></H3
  20071. ><P
  20072. >      PHP unterstⁿtzt HTTP-Cookies, wie sie in <A
  20073. HREF="http://www.netscape.com/newsref/std/cookie_spec.html"
  20074. TARGET="_top"
  20075. >Netscape's Spec</A
  20076. > definiert sind.
  20077.      Cookies erm÷glichen die Daten-Speicherung innerhalb der
  20078.      jeweiligen Browser-Umgebung zur Weiterleitung oder wiederholten
  20079.      Identifikation von Benutzern. Sie k÷nnen Cookies erzeugen, indem
  20080.      Sie die Funktion <A
  20081. HREF="#function.setcookie"
  20082. ><B
  20083. CLASS="function"
  20084. >setcookie()</B
  20085. ></A
  20086. > benutzen. Cookies
  20087.      sind Teil des HTTP-Headers, deshalb muss die setcookie-Funktion
  20088.      aufgerufen werden, bevor irgendeine Ausgabe an den Browser
  20089.      gesendet wird. Dabei handelt es sich um die gleiche
  20090.      EinschrΣnkung, die auch fⁿr die
  20091.      <A
  20092. HREF="#function.header"
  20093. ><B
  20094. CLASS="function"
  20095. >header()</B
  20096. ></A
  20097. >-Funktion gilt. Cookie-Daten stehen
  20098.      dann sowohl in den entsprechenden Cookie-Daten-Arrays, wie zum
  20099.      Beispiel <VAR
  20100. CLASS="varname"
  20101. >$_COOKIE</VAR
  20102. >,
  20103.      <VAR
  20104. CLASS="varname"
  20105. >$HTTP_COOKIE_VARS</VAR
  20106. > als auch in
  20107.      <VAR
  20108. CLASS="varname"
  20109. >$_REQUEST</VAR
  20110. > zur Verfⁿgung. Fⁿr weitere Details
  20111.      und Beispiele lesen Sie bitte die
  20112.      <A
  20113. HREF="#function.setcookie"
  20114. ><B
  20115. CLASS="function"
  20116. >setcookie()</B
  20117. ></A
  20118. >-Seite des Handbuchs.
  20119.     </P
  20120. ><P
  20121. >      Wenn Sie einer einzelnen Cookie-Variable mehrere Werte zuweisen
  20122.      wollen, mⁿssen Sie diese als Array ⁿbertragen. Zum Beispiel:
  20123.     </P
  20124. ><DIV
  20125. CLASS="informalexample"
  20126. ><P
  20127. ></P
  20128. ><A
  20129. NAME="AEN3620"
  20130. ></A
  20131. ><TABLE
  20132. BORDER="0"
  20133. BGCOLOR="#E0E0E0"
  20134. CELLPADDING="5"
  20135. ><TR
  20136. ><TD
  20137. ><PRE
  20138. CLASS="php"
  20139. ><?php
  20140. setcookie("MeinCookie[foo]", "Ich teste 1", time()+3600);
  20141. setcookie("MeinCookie[bar]", "Ich teste 2", time()+3600);
  20142. ?></PRE
  20143. ></TD
  20144. ></TR
  20145. ></TABLE
  20146. ><P
  20147. ></P
  20148. ></DIV
  20149. ><P
  20150. >      Das erzeugt zwei einzelne Cookies obwohl MeinCookie in Ihrem
  20151.      Skript nun ein einziges Array ist. Wenn Sie nur ein Cookie mit
  20152.      mehreren Werten setzen wollen, sollten Sie zuerst
  20153.      <A
  20154. HREF="#function.serialize"
  20155. ><B
  20156. CLASS="function"
  20157. >serialize()</B
  20158. ></A
  20159. > oder <A
  20160. HREF="#function.explode"
  20161. ><B
  20162. CLASS="function"
  20163. >explode()</B
  20164. ></A
  20165. >
  20166.      auf das Array anwenden.
  20167.     </P
  20168. ><P
  20169. >      Bedenken Sie, dass ein Cookie ein vorhergehendes Cookie
  20170.      gleichen Namens ⁿberschreibt, es sei denn, der Pfad oder
  20171.      die Domain ist anders. Fⁿr eine Warenkorb-Anwendung k÷nnen
  20172.      Sie deshalb z.B. einen ZΣhler bilden und diesen weiterleiten:
  20173.     </P
  20174. ><TABLE
  20175. WIDTH="100%"
  20176. BORDER="0"
  20177. CELLPADDING="0"
  20178. CELLSPACING="0"
  20179. CLASS="EXAMPLE"
  20180. ><TR
  20181. ><TD
  20182. ><DIV
  20183. CLASS="example"
  20184. ><A
  20185. NAME="AEN3626"
  20186. ></A
  20187. ><P
  20188. ><B
  20189. >Beispiel 11-11. Ein <A
  20190. HREF="#function.setcookie"
  20191. ><B
  20192. CLASS="function"
  20193. >setcookie()</B
  20194. ></A
  20195. >-Beispiel</B
  20196. ></P
  20197. ><TABLE
  20198. BORDER="0"
  20199. BGCOLOR="#E0E0E0"
  20200. CELLPADDING="5"
  20201. ><TR
  20202. ><TD
  20203. ><PRE
  20204. CLASS="php"
  20205. ><?php
  20206. if (isset($_COOKIE['zaehler'])) {
  20207.     $zaehler = $_COOKIE['zaehler'] + 1;
  20208. } else {
  20209.     $zaehler = 1;
  20210. }
  20211. setcookie("zaehler", $zaehler, time()+3600);
  20212. setcookie("Cart[$zaehler]", $item, time()+3600);
  20213. ?></PRE
  20214. ></TD
  20215. ></TR
  20216. ></TABLE
  20217. ></DIV
  20218. ></TD
  20219. ></TR
  20220. ></TABLE
  20221. ></DIV
  20222. ><DIV
  20223. CLASS="sect2"
  20224. ><HR><H3
  20225. CLASS="sect2"
  20226. ><A
  20227. NAME="language.variables.external.dot-in-names"
  20228. >Punkte in eingelesenen Variablen-Bezeichnern</A
  20229. ></H3
  20230. ><P
  20231. >      Normalerweise verΣndert PHP die Variablen-Bezeichner nicht,
  20232.      wenn sie einem Skript ⁿbergeben werden. Es sollte aber beachtet
  20233.      werden, dass der Punkt (".") kein gⁿltiger Bestandteil eines
  20234.      Variablen-Bezeichners ist. Deshalb achten Sie auf folgendes:
  20235.      <TABLE
  20236. BORDER="0"
  20237. BGCOLOR="#E0E0E0"
  20238. CELLPADDING="5"
  20239. ><TR
  20240. ><TD
  20241. ><PRE
  20242. CLASS="php"
  20243. ><?php
  20244. $varname.ext;  /* ungⁿltiger Variablen-Bezeichner */
  20245. ?></PRE
  20246. ></TD
  20247. ></TR
  20248. ></TABLE
  20249. >
  20250.      Der PHP-Parser sieht eine Variable namens <VAR
  20251. CLASS="varname"
  20252. >$varname</VAR
  20253. >,
  20254.      gefolgt von einem Zeichenketten-Verbindungs-Operator, dieser wiederrum
  20255.      gefolgt von der offenen Zeichenkette 'ext' (also nicht eingegrenzt
  20256.      durch '"' und auch keinem Schlⁿssel oder reserviertem Bezeichner
  20257.      entsprechend). Das kann natⁿrlich nicht zum gewⁿnschten Ergebnis
  20258.      fⁿhren.
  20259.     </P
  20260. ><P
  20261. >      Deshalb ist es wichtig zu wissen, dass PHP in den ihm ⁿbergebenen
  20262.      Variablen alle Punkte (.) automatisch durch einen 
  20263.      Unterstrich (_) ersetzt.
  20264.     </P
  20265. ></DIV
  20266. ><DIV
  20267. CLASS="sect2"
  20268. ><HR><H3
  20269. CLASS="sect2"
  20270. ><A
  20271. NAME="language.variables.determining-type-of"
  20272. >Bestimmung des Variablen-Typs</A
  20273. ></H3
  20274. ><P
  20275. >      Da PHP den Typ der Variablen bestimmt und (im Allgemeinen) selbst
  20276.      eine entsprechende Umformung vornimmt, ist es nicht immer klar,
  20277.      welchen Typ eine Variable gerade hat. PHP beinhaltet einige
  20278.      Funktionen, die dies herausfinden, wie zum Beispiel:
  20279.      <A
  20280. HREF="#function.gettype"
  20281. ><B
  20282. CLASS="function"
  20283. >gettype()</B
  20284. ></A
  20285. >, <A
  20286. HREF="#function.is-array"
  20287. ><B
  20288. CLASS="function"
  20289. >is_array()</B
  20290. ></A
  20291. >,
  20292.      <A
  20293. HREF="#function.is-float"
  20294. ><B
  20295. CLASS="function"
  20296. >is_float()</B
  20297. ></A
  20298. >, <A
  20299. HREF="#function.is-int"
  20300. ><B
  20301. CLASS="function"
  20302. >is_int()</B
  20303. ></A
  20304. >,
  20305.      <A
  20306. HREF="#function.is-object"
  20307. ><B
  20308. CLASS="function"
  20309. >is_object()</B
  20310. ></A
  20311. > und
  20312.      <A
  20313. HREF="#function.is-string"
  20314. ><B
  20315. CLASS="function"
  20316. >is_string()</B
  20317. ></A
  20318. >. Lesen Sie bitte auch das Kapitel
  20319.      ⁿber <A
  20320. HREF="#language.types"
  20321. >Typen</A
  20322. >.
  20323.     </P
  20324. ></DIV
  20325. ></DIV
  20326. ></DIV
  20327. ><DIV
  20328. CLASS="chapter"
  20329. ><HR><H1
  20330. ><A
  20331. NAME="language.constants"
  20332. >Kapitel 12. Konstanten</A
  20333. ></H1
  20334. ><P
  20335. >    Eine Konstante ist ein Bezeichner (Name) fⁿr eine simple Variable.
  20336.    Wie der Name schon ausdrⁿckt, kann sich der Wert einer Konstanten
  20337.    zur Laufzeit eines Skripts nicht Σndern (eine Ausnahme bilden die
  20338.    <A
  20339. HREF="#language.constants.predefined"
  20340. >Magischen Konstanten</A
  20341. >,
  20342.    die aber tatsΣchlich keine Konstanten sind.) Eine Konstante unterscheidet
  20343.    zwischen Gro▀- und KLeinschreinbung (case-sensitive). Nach gΣngiger
  20344.    Konvention werden Konstanten immer in Gro▀buchstaben geschrieben.
  20345.   </P
  20346. ><P
  20347. >    Der Name einer Konstanten folgt den gleichen Regeln wie alle anderen
  20348.    Bezeichner in PHP. Ein gⁿltiger Name beginnt mit einem Buchstaben
  20349.    oder einem Unterstrich, gefolgt von beliebig vielen Buchstaben, Nummern
  20350.    oder Understrichen. Als regulΣrer Ausdruck geschrieben:
  20351.    <VAR
  20352. CLASS="literal"
  20353. >[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*</VAR
  20354. >
  20355.   </P
  20356. ><P
  20357. >    <TABLE
  20358. WIDTH="100%"
  20359. BORDER="0"
  20360. CELLPADDING="0"
  20361. CELLSPACING="0"
  20362. CLASS="EXAMPLE"
  20363. ><TR
  20364. ><TD
  20365. ><DIV
  20366. CLASS="example"
  20367. ><A
  20368. NAME="AEN3653"
  20369. ></A
  20370. ><P
  20371. ><B
  20372. >Beispiel 12-1. Gⁿltige und ungⁿltige Namen fⁿr Konstanten</B
  20373. ></P
  20374. ><TABLE
  20375. BORDER="0"
  20376. BGCOLOR="#E0E0E0"
  20377. CELLPADDING="5"
  20378. ><TR
  20379. ><TD
  20380. ><PRE
  20381. CLASS="php"
  20382. ><?php
  20383.  
  20384. // Gⁿltige Namen fⁿr Konstanten
  20385. define("FOO",     "irgendwas");
  20386. define("FOO2",    "etwas anderes");
  20387. define("FOO_BAR", "irgendwas ganz anderes")
  20388.  
  20389. // Invalid constant names
  20390. define("2FOO",    "irgendwas");
  20391.  
  20392. // Folgendes ist korrekt, sollte aber vermieden werden:
  20393. // Eines Tages k÷nnte es in PHP eine Magische Konstante
  20394. // __FOO__ geben und Ihr Skript wird dadurch nicht mehr
  20395. // wie gewⁿnscht funktionieren.
  20396.  
  20397. define("__FOO__", "irgendwas"); 
  20398.  
  20399. ?></PRE
  20400. ></TD
  20401. ></TR
  20402. ></TABLE
  20403. ></DIV
  20404. ></TD
  20405. ></TR
  20406. ></TABLE
  20407. >
  20408.   </P
  20409. ><DIV
  20410. CLASS="note"
  20411. ><BLOCKQUOTE
  20412. CLASS="note"
  20413. ><P
  20414. ><B
  20415. >Anmerkung: </B
  20416. >
  20417.     Fⁿr unsere Zwecke ist ein Buchstabe a-z, A-Z und die ASCII-Zeichen
  20418.     von 127 bis 255 (0x7f-0xff).
  20419.    </P
  20420. ></BLOCKQUOTE
  20421. ></DIV
  20422. ><P
  20423. >    Wie bei <A
  20424. HREF="#language.variables.predefined"
  20425. >superglobals</A
  20426. > ist der Gⁿltigkeitsbereich einer Konstanten
  20427.    global. UnabhΣngig vom Gⁿltigkeitsbereich k÷nnen Sie in Ihrem Skript
  20428.    ⁿberall auf eine Konstante zugreifen. Fⁿr mehr Information zum
  20429.    Gⁿltigkeitsbereich lesen Sie bitte den Abschnitt ⁿber den
  20430.    <A
  20431. HREF="#language.variables.scope"
  20432. >Geltungsbereich von Variablen</A
  20433. >.
  20434.    
  20435.       For more information on scope, read the manual section on
  20436.    <A
  20437. HREF="#language.variables.scope"
  20438. >variable scope</A
  20439. >.
  20440.   </P
  20441. ><DIV
  20442. CLASS="sect1"
  20443. ><HR><H2
  20444. CLASS="sect1"
  20445. ><A
  20446. NAME="language.constants.syntax"
  20447. >Syntax</A
  20448. ></H2
  20449. ><P
  20450. >     Eine Konstante k÷nnen Sie ⁿber die Funktion <A
  20451. HREF="#function.define"
  20452. ><B
  20453. CLASS="function"
  20454. >define()</B
  20455. ></A
  20456. >
  20457.     definieren. Einmal definiert, kann eine Konstane weder verΣndert
  20458.     noch gel÷scht werden.
  20459.    </P
  20460. ><P
  20461. >     Konstanten k÷nnen nur scalare Daten (<A
  20462. HREF="#language.types.boolean"
  20463. ><B
  20464. CLASS="type"
  20465. >boolean</B
  20466. ></A
  20467. >,
  20468.     <A
  20469. HREF="#language.types.integer"
  20470. ><B
  20471. CLASS="type"
  20472. >integer</B
  20473. ></A
  20474. >, <A
  20475. HREF="#language.types.float"
  20476. ><B
  20477. CLASS="type"
  20478. >float</B
  20479. ></A
  20480. > und <A
  20481. HREF="#language.types.string"
  20482. ><B
  20483. CLASS="type"
  20484. >string</B
  20485. ></A
  20486. >)
  20487.     enthalten.
  20488.    </P
  20489. ><P
  20490. >     Den Wert einer Konstanten erhalten Sie ganz einfach durch die Angabe ihres
  20491.     Namens. Einer Konstanten sollten Sie <SPAN
  20492. CLASS="emphasis"
  20493. ><I
  20494. CLASS="emphasis"
  20495. >nicht</I
  20496. ></SPAN
  20497. >, wie bei
  20498.     Variablen, ein <VAR
  20499. CLASS="literal"
  20500. >$</VAR
  20501. > voranstellen. Ebenso k÷nnen Sie die
  20502.     Funktion <A
  20503. HREF="#function.constant"
  20504. ><B
  20505. CLASS="function"
  20506. >constant()</B
  20507. ></A
  20508. > benutzen um den Wert einer Konstanten
  20509.     auszulesen, wenn Sie den Namen der Konstanten dynamisch erhalten wollen.
  20510.     Benutzen Sie <A
  20511. HREF="#function.get-defined-constants"
  20512. ><B
  20513. CLASS="function"
  20514. >get_defined_constants()</B
  20515. ></A
  20516. > um eine Liste
  20517.     aller definierten Konstanten zu erhalten.
  20518.    </P
  20519. ><DIV
  20520. CLASS="note"
  20521. ><BLOCKQUOTE
  20522. CLASS="note"
  20523. ><P
  20524. ><B
  20525. >Anmerkung: </B
  20526. >
  20527.      Konstanten und (globale) Variablen befinden sich in unterschiedlichen
  20528.      NamensrΣumen. Das hat zum Beispiel zur Folge, dass <TT
  20529. CLASS="constant"
  20530. ><B
  20531. >TRUE</B
  20532. ></TT
  20533. > und 
  20534.      <VAR
  20535. CLASS="varname"
  20536. >$TRUE</VAR
  20537. > grundsΣtzlich unterschiedlich sind.
  20538.     </P
  20539. ></BLOCKQUOTE
  20540. ></DIV
  20541. ><P
  20542. >     Falls Sie eine undefinierte Konstante verwenden nimmt PHP an, dass
  20543.     Sie den Namen der Konstanten selber meinen, genauso als ob Sie einen
  20544.     <A
  20545. HREF="#language.types.string"
  20546. ><B
  20547. CLASS="type"
  20548. >string</B
  20549. ></A
  20550. > (CONSTANT vs "CONSTANT") angegeben hΣtten. Falls das
  20551.     passiert, wird Ihnen ein Fehler vom Typ
  20552.     <A
  20553. HREF="#ref.errorfunc"
  20554. >E_NOTICE</A
  20555. > ausgegeben. Lesen Sie hier
  20556.     nach, warum die Angabe
  20557.     <A
  20558. HREF="#language.types.array.foo-bar"
  20559. >$foo[bar]</A
  20560. > falsch ist
  20561.     (zumindest solange Sie nicht zuerst <VAR
  20562. CLASS="literal"
  20563. >bar</VAR
  20564. > mittels
  20565.     <A
  20566. HREF="#function.define"
  20567. ><B
  20568. CLASS="function"
  20569. >define()</B
  20570. ></A
  20571. > als Konstante definiert haben). M÷chten Sie
  20572.     einfach nur nachprⁿfen, ob eine Konstante definiert ist, benutzen Sie die
  20573.     Funktion <A
  20574. HREF="#function.defined"
  20575. ><B
  20576. CLASS="function"
  20577. >defined()</B
  20578. ></A
  20579. > fⁿr diesen Zweck.
  20580.    </P
  20581. ><P
  20582. >     Das hier sind die Unterschiede zwischen Konstanten und Variablen:
  20583.     <P
  20584. ></P
  20585. ><UL
  20586. ><LI
  20587. ><P
  20588. >        Konstanten haben kein Dollarzeichen (<VAR
  20589. CLASS="literal"
  20590. >$</VAR
  20591. >)
  20592.        vorangestellt;
  20593.       </P
  20594. ></LI
  20595. ><LI
  20596. ><P
  20597. >        Konstanten k÷nnen nur ⁿber die Funktion <A
  20598. HREF="#function.define"
  20599. ><B
  20600. CLASS="function"
  20601. >define()</B
  20602. ></A
  20603. >
  20604.        definiert werden, nicht durch einfache Zuweisung;
  20605.       </P
  20606. ></LI
  20607. ><LI
  20608. ><P
  20609. >        Konstanten k÷nnen ⁿberall definiert werden und auf Ihren Wert
  20610.        k÷nnen Sie ohne Rⁿcksicht auf Namensraumregeln von Variablen zugreifen;
  20611.       </P
  20612. ></LI
  20613. ><LI
  20614. ><P
  20615. >        Sobald Konstanten definiert sind, k÷nnen sie nicht neu definiert
  20616.        oder gel÷scht werden; und
  20617.       </P
  20618. ></LI
  20619. ><LI
  20620. ><P
  20621. >        Konstanten k÷nnen nur skalare Werte haben.
  20622.        </P
  20623. ></LI
  20624. ></UL
  20625. >
  20626.    </P
  20627. ><P
  20628. >     <TABLE
  20629. WIDTH="100%"
  20630. BORDER="0"
  20631. CELLPADDING="0"
  20632. CELLSPACING="0"
  20633. CLASS="EXAMPLE"
  20634. ><TR
  20635. ><TD
  20636. ><DIV
  20637. CLASS="example"
  20638. ><A
  20639. NAME="AEN3702"
  20640. ></A
  20641. ><P
  20642. ><B
  20643. >Beispiel 12-2. Definiton von Konstanten</B
  20644. ></P
  20645. ><TABLE
  20646. BORDER="0"
  20647. BGCOLOR="#E0E0E0"
  20648. CELLPADDING="5"
  20649. ><TR
  20650. ><TD
  20651. ><PRE
  20652. CLASS="php"
  20653. ><?php
  20654. define("CONSTANT", "Hallo Welt.");
  20655. echo CONSTANT; // Ausgabe: "Hallo Welt."
  20656. echo Constant; // Ausgabe: "Constant" und eine Notice.
  20657. ?></PRE
  20658. ></TD
  20659. ></TR
  20660. ></TABLE
  20661. ></DIV
  20662. ></TD
  20663. ></TR
  20664. ></TABLE
  20665. >
  20666.  
  20667.    </P
  20668. ></DIV
  20669. ><DIV
  20670. CLASS="sect1"
  20671. ><HR><H2
  20672. CLASS="sect1"
  20673. ><A
  20674. NAME="language.constants.predefined"
  20675. >Magische Konstanten</A
  20676. ></H2
  20677. ><P
  20678. >     PHP stellt jedem Skript eine Vielzahl von <A
  20679. HREF="#reserved.constants"
  20680. >vordefinierten Konstanten</A
  20681. >
  20682.     zur Verfⁿgung. Viele dieser Konstanten werden jedoch von verschiedenen
  20683.     Erweiterungen definiert, die nur zur Verfⁿgung stehen, wenn diese
  20684.     Erweiterungen selbst zur Verfⁿgung stehen, d.h. entweder ⁿber dynamisches
  20685.     Laden zur Laufzeit oder sie sind einkompiliert.
  20686.    </P
  20687. ><P
  20688. >     Es gibt fⁿnf magische Konstanten, die abhΣngig davon, wo sie eingesetzt
  20689.     werden, einen unterschiedlichen Wert haben. Zum Beispiel hΣngt
  20690.     der Wert der Konstanten <TT
  20691. CLASS="constant"
  20692. ><B
  20693. >__LINE__</B
  20694. ></TT
  20695. > davon ab, in welcher
  20696.     Zeile ihres Skripts Sie diese Konstante verwenden. Diese besonderen
  20697.     Konstanten sind unabhΣngig von Gro▀-/Kleinschreibung und sind folgende:
  20698.    </P
  20699. ><P
  20700. >     <DIV
  20701. CLASS="table"
  20702. ><A
  20703. NAME="AEN3712"
  20704. ></A
  20705. ><P
  20706. ><B
  20707. >Tabelle 12-1. Einige "magische" PHP "Konstanten"</B
  20708. ></P
  20709. ><TABLE
  20710. BORDER="1"
  20711. CLASS="CALSTABLE"
  20712. ><COL><COL><THEAD
  20713. ><TR
  20714. ><TH
  20715. >Name</TH
  20716. ><TH
  20717. >Beschreibung</TH
  20718. ></TR
  20719. ></THEAD
  20720. ><TBODY
  20721. ><TR
  20722. ><TD
  20723. ><TT
  20724. CLASS="constant"
  20725. ><B
  20726. >__LINE__</B
  20727. ></TT
  20728. ></TD
  20729. ><TD
  20730. >          Die aktuelle Zeilennummer einer Datei.
  20731.         </TD
  20732. ></TR
  20733. ><TR
  20734. ><TD
  20735. ><TT
  20736. CLASS="constant"
  20737. ><B
  20738. >__FILE__</B
  20739. ></TT
  20740. ></TD
  20741. ><TD
  20742. >          Der vollstΣndige Pfad- und Dateiname einer Datei.
  20743.         </TD
  20744. ></TR
  20745. ><TR
  20746. ><TD
  20747. ><TT
  20748. CLASS="constant"
  20749. ><B
  20750. >__FUNCTION__</B
  20751. ></TT
  20752. ></TD
  20753. ><TD
  20754. >          Der Name einer Funktion. Steht seit PHP 4.3.0 zur Verfⁿgung.
  20755.         </TD
  20756. ></TR
  20757. ><TR
  20758. ><TD
  20759. ><TT
  20760. CLASS="constant"
  20761. ><B
  20762. >__CLASS__</B
  20763. ></TT
  20764. ></TD
  20765. ><TD
  20766. >          Der Name einer Klasse. Steht seit PHP 4.3.0 zur Verfⁿgung.
  20767.         </TD
  20768. ></TR
  20769. ><TR
  20770. ><TD
  20771. ><TT
  20772. CLASS="constant"
  20773. ><B
  20774. >__METHOD__</B
  20775. ></TT
  20776. ></TD
  20777. ><TD
  20778. >          Der Name einer Klassenmethode. Steht seit PHP 5.0.0 zur Verfⁿgung.
  20779.         </TD
  20780. ></TR
  20781. ></TBODY
  20782. ></TABLE
  20783. ></DIV
  20784. >
  20785.    </P
  20786. ></DIV
  20787. ></DIV
  20788. ><DIV
  20789. CLASS="chapter"
  20790. ><HR><H1
  20791. ><A
  20792. NAME="language.expressions"
  20793. >Kapitel 13. Ausdrⁿcke</A
  20794. ></H1
  20795. ><P
  20796. >     Ausdrⁿcke (Expressions) sind die wichtigsten Bausteine von PHP. In
  20797.     PHP ist fast alles, was geschrieben wird, ein Ausdruck. Die einfachste,
  20798.     aber auch zutreffenste Definition fⁿr einen Ausdruck ist "alles, was
  20799.     einen Wert hat".</P
  20800. ><P
  20801. >     Die grundlegendste Formen von Ausdrⁿcken sind Konstanten und Variablen.
  20802.     Wenn man "$a = 5" schreibt, weist man $a den Ausdruck ┤5┤ zu. ┤5┤ hat 
  20803.     offensichtlich den Wert 5. Anders ausgedrⁿckt: ┤5┤ ist ein Ausdruck 
  20804.     mit dem Wert 5 (in diesem Fall ist ┤5┤ eine Integer-Konstante).</P
  20805. ><P
  20806. >     Nach dieser Zuweisung wⁿrde man erwarten, dass der Wert von $a nun 
  20807.     ebenfalls 5 ist, wenn man also $b = $a schreibt, sollte  
  20808.     dasselbe dabei herauskommen, als hΣtte man $b = 5 geschrieben.
  20809.     Anders ausgedrⁿckt: $a wΣre ebenfalls ein  Ausdruck mit dem Wert 5.
  20810.     Wenn alles richtig funktioniert, wird genau das passieren.</P
  20811. ><P
  20812. >     Etwas kompliziertere Beispiele fⁿr Ausdrⁿcke sind Funktionen:
  20813.  
  20814.     <DIV
  20815. CLASS="informalexample"
  20816. ><P
  20817. ></P
  20818. ><A
  20819. NAME="AEN3746"
  20820. ></A
  20821. ><TABLE
  20822. BORDER="0"
  20823. BGCOLOR="#E0E0E0"
  20824. CELLPADDING="5"
  20825. ><TR
  20826. ><TD
  20827. ><PRE
  20828. CLASS="programlisting"
  20829. >function foo () {
  20830.     return 5;
  20831. }</PRE
  20832. ></TD
  20833. ></TR
  20834. ></TABLE
  20835. ><P
  20836. ></P
  20837. ></DIV
  20838. ></P
  20839. ><P
  20840. >     Angenommen, Sie sind mit dem Konzept von Funktionen vertraut (wenn
  20841.     Sie es nicht sind, lesen Sie das Kapitel ⁿber Funktionen), dann
  20842.     wⁿrden Sie annehmen, dass die Eingabe von <VAR
  20843. CLASS="literal"
  20844. >$c = foo()</VAR
  20845. >
  20846.     grundsΣtzlich daselbe bedeutet, als wⁿrde man schreiben 
  20847.     <VAR
  20848. CLASS="literal"
  20849. >$c = 5</VAR
  20850. >,und genau das trifft zu. Funktionen sind
  20851.     Ausdrⁿcke mit dem Wert ihres Rⁿckgabewertes. Da foo() den Wert 5
  20852.     zurⁿckgibt, ist der Wert des Ausdruckes ┤foo()┤ 5. Normalerweise
  20853.     geben Funktionen nicht einfach einen statischen Wert zurⁿck, sondern
  20854.     berechnen irgendetwas.</P
  20855. ><P
  20856. >     Natⁿrlich mⁿssen Werte in PHP keine Integer-Zahlen sein, und oft sind
  20857.     sie es auch nicht. PHP unterstⁿtzt drei skalare Datentypen: integer values 
  20858.     (Integer-Zahlen),floating point values (Flie▀kommazahlen) und string values
  20859.     (Zeichenketten).
  20860.     (Skalare sind Datentypen, die man nicht in kleinere Stⁿcke ┤brechen┤ kann, 
  20861.     im Gegensatz zu Arrays).
  20862.     PHP unsterstⁿtzt auch zwei zusammengesetzte (nicht-skalare) Datentypen:
  20863.     Arrays und Objekte. Jeder dieser Datentypen kann Variablen zugewiesen
  20864.     und von Funktionen zurⁿckgegeben werden.</P
  20865. ><P
  20866. >     Bis hierhin sollten Benutzer von PHP/FI 2 keine VerΣnderung bemerkt haben.
  20867.     PHP fasst den Begriff ┤Ausdruck┤ aber noch viel weiter, wie es auch andere 
  20868.     Programmiersprachen tun. PHP ist in dem Sinne eine ausdrucksoriente Sprache,
  20869.     dass fast alles ein Ausdruck ist. Zurⁿck zu dem Beispiel, mit dem wir 
  20870.     uns schon beschΣftigt haben: ┤$a = 5┤. Es ist einfach zu erkennen, dass
  20871.     hier zwei Werte enthalten sind: Der Wert der Integer-Konstanten ┤5┤ und
  20872.     der Wert von $a, der auf 5 geΣndert wird. In Wirklichkeit ist aber noch
  20873.     ein zusΣtzlicher Wert enthalten, nΣmlich der Wert der Zuweisung selbst.
  20874.     Die Zuweisung selbst enthΣlt den zugewiesenen Wert, in diesem Fall 5.
  20875.     In der Praxis bedeutet dies, dass ┤$a = 5┤, egal was es tut, immer
  20876.     einen Ausdruck mit dem Wert 5 darstellt. Folglich ist 
  20877.     ┤$b = ($a = 5)┤ gleichbedeutend mit ┤$a = 5; $b = 5;┤ (ein Semikolon
  20878.     markiert das Ende einer Anweisung). Da Wertzuweisungen von rechts
  20879.     nach links geparst werden, kann man auch ┤$b = $a = 5┤ schreiben.
  20880.     </P
  20881. ><P
  20882. >     Ein anderes gutes Beispiel fⁿr die Ausdrucksorientierung von PHP
  20883.     sind PrΣ- und Post-Inkrement sowie die entsprechenden Dekremente.
  20884.     Benutzer von PHP/FI 2 und vielen anderen Sprachen sind vermutlich 
  20885.     mit den Notationen ┤variable++┤ und ┤variable--┤ vertraut. Dies 
  20886.     sind Inkrement- und Dekrement-Operatoren. IN PHP/FI 2 hat das 
  20887.     Statement ┤$a++┤ keinen Wert (es ist kein Ausdruck) und daher
  20888.     kann man es nicht als Wert zuweisen oder in irgendeiner Weise
  20889.     benutzen. PHP erweitert die Eigenschaften von Dekrement und 
  20890.     Inkrement, indem es die beiden ebenfalls zu Ausdrⁿcken macht.
  20891.     In PHP gibt es, wie in C, zwei Arten von Inkrementen - 
  20892.     PrΣ-Inkrement und Post-Inkrement. GrundsΣtzlich erh÷hen sowohl
  20893.     PrΣ- als auch Post-Inkrement den Wert der Variable, und der
  20894.     Effekt auf die Variable ist derselbe. Der Unterschied ist der 
  20895.     Wert des Inkrement-Ausdruckes.
  20896.     Das PrΣ-Inkrement, das ┤++$variable┤ geschrieben wird, enthΣlt
  20897.     als Wert den Wert der erh÷hten Variabe (PHP erh÷ht den Wert
  20898.     der Variable, bevor es ihren Wert ausliest, daher der Name
  20899.     ┤PR─-Inkrement┤). Das Post-Inkrement, das ┤$variable++┤ 
  20900.     geschrieben wird, enthΣlt dagegen den ursprⁿnglichen Wert der
  20901.     Variablen vor der Erh÷hung (PHP erh÷ht den Wert der Variablen,
  20902.     nachdem es ihren Wert ausgelesen hat, daher der Name 
  20903.     ┤POST-Inkrement┤).</P
  20904. ><P
  20905. >     Ein sehr gebrΣuchlicher Typ von Ausdrⁿcken sind Vergleichsausdrⁿcke.
  20906.     Diese Ausdrⁿcke geben entweder 0 (=FALSCH) oder 1 (=WAHR) zurⁿck.
  20907.     PHP unterstⁿtzt > (gr÷▀er), >= (gr÷▀er oder gleich), == (gleich),
  20908.     != (ungleich), < (kleiner), und <= (kleiner oder gleich). Diese
  20909.     Ausdrⁿcke werden meistens in bedingten Anweisungen, wie z. B. in
  20910.     <VAR
  20911. CLASS="literal"
  20912. >if</VAR
  20913. >-Anweisungen,  verwendet.</P
  20914. ><P
  20915. >     Im letzten Beispiel fⁿr Ausdrⁿcke befassen wir uns mit kombinierten
  20916.     Zuweisungs- und Operator-Ausdrⁿcken. Wir haben schon gezeigt, wie
  20917.     man den Wert von $a um 1 erh÷ht, nΣmlich indem man einfach ┤$a++┤
  20918.     oder ┤++$a┤ schreibt. Aber was tut man, wenn man den Wert um 
  20919.     mehr als eins erh÷hen will, z. B. um 3? Man k÷nnte mehrer Male
  20920.     ┤$a++┤ schreiben, aber das ist offensichtlich weder effizient 
  20921.     noch sehr komfortabel. Viel ⁿblicher ist es, einfach 
  20922.     ┤$a = $a + 3┤ zu schreiben. ┤$a + 3┤ gibt den Wert von $a plus
  20923.     3 zurⁿck, dieser wird wieder $a zugewiesen, was dazu fⁿhrt, dass
  20924.     $a nun um 3 erh÷ht wurde. In PHP - wie in einigen anderen 
  20925.     Programmiersprachen, z. B. in C - kann man dies aber noch 
  20926.     kⁿrzer schreiben, was mit der Zeit klarer wird und auch einfacher
  20927.     zu verstehen ist. Um 3 zu dem aktuellen Wert hinzuzufⁿgen, schreibt
  20928.     man ┤$a += 3┤. Das bedeutet exakt: "Nimm┤ den Wert von $a, addiere
  20929.     3 hinzu und weise $a den entstandenen Wert zu". ZusΣtzlich dazu,
  20930.     dass diese Schreibweise kⁿrzer und klarer ist, resultiert sie auch
  20931.     in einer schnelleren Ausfⁿhrung. Der Wert von ┤$a += 3┤ ist, wie
  20932.     der Wert einer regulΣren Zuweisung, der zugewiesene Wert. Es ist
  20933.     zu beachten, dass dieser Wert NICHT 3, sondern dem kombinierten
  20934.     Wert von $a plus 3 entspricht (Das ist der Wert, der $a zugewiesen
  20935.     wird). Jeder Operator, der zwei Elemente verbindet, kann in dieser
  20936.     Schreibweise verwendet werden, z. B. ┤$a -= 5┤ (vermindert den 
  20937.     Wert von $a um 5) oder ┤$a *= 7┤ (multipliziert den Wert von
  20938.     $a mit 7 und weist das Ergebnis $a zu), usw.</P
  20939. ><P
  20940. >     Es gibt einen weiteren Ausdruck, der Ihnen vielleicht seltsam vorkommt,
  20941.     wenn Sie ihn bisher noch in keiner Programmiersprache kennengelernt 
  20942.     haben, den dreifach konditionalen Operator:
  20943.  
  20944.     <DIV
  20945. CLASS="informalexample"
  20946. ><P
  20947. ></P
  20948. ><A
  20949. NAME="AEN3758"
  20950. ></A
  20951. ><TABLE
  20952. BORDER="0"
  20953. BGCOLOR="#E0E0E0"
  20954. CELLPADDING="5"
  20955. ><TR
  20956. ><TD
  20957. ><PRE
  20958. CLASS="programlisting"
  20959. >$eins ? $zwei : $drei</PRE
  20960. ></TD
  20961. ></TR
  20962. ></TABLE
  20963. ><P
  20964. ></P
  20965. ></DIV
  20966. >
  20967.  
  20968.     Wenn der Wert des ersten Sub-Ausdruckes (hier: $eins) wahr ist 
  20969.     (d. h. nicht <TT
  20970. CLASS="constant"
  20971. ><B
  20972. >NULL</B
  20973. ></TT
  20974. >), dann wird der Wert des zweiten Subausdrucks 
  20975.     (hier: $zwei) zurⁿckgeben und ist das Ergebnis des konditionalen 
  20976.     Ausdrucks. 
  20977.     Andernfalls (d. h. wenn der erste Ausdruck falsch ist), wird 
  20978.     der Wert des dritten Subausdruckes (hier: $drei) zurⁿckgeben.
  20979.     </P
  20980. ><P
  20981. >     Das folgende Beispiel sollte das VerstΣndnis von PrΣ- und
  20982.     Post-Inkrement und von Ausdrⁿcken im allgemeinen erleichtern:    
  20983.  
  20984.     <DIV
  20985. CLASS="informalexample"
  20986. ><P
  20987. ></P
  20988. ><A
  20989. NAME="AEN3762"
  20990. ></A
  20991. ><TABLE
  20992. BORDER="0"
  20993. BGCOLOR="#E0E0E0"
  20994. CELLPADDING="5"
  20995. ><TR
  20996. ><TD
  20997. ><PRE
  20998. CLASS="programlisting"
  20999. >function verdoppeln($i) {
  21000.     return $i*2;
  21001. }
  21002. $b = $a = 5;        /* Weise den Variablen $a und $b beiden den Wert 5 zu */
  21003. $c = $a++;          /* Post-Inkrement, der urspruengliche Wert von $a (also 5)
  21004.                        wird $c zugewiesen. */
  21005. $e = $d = ++$b;     /* Prae-Inkrement, der erh÷hte Wert von $b (= 6) wird $d und
  21006.                        $e zugewiesen. */
  21007.  
  21008. /* An diesem Punkt sind $d und $e beide gleich 6 */
  21009.  
  21010. $f = verdoppeln($d++);  /* Weise $f den doppelten Wert von $d <SPAN
  21011. CLASS="emphasis"
  21012. ><I
  21013. CLASS="emphasis"
  21014. >vor</I
  21015. ></SPAN
  21016.                        der Erh÷hung um eins zu, 2*6 = 12 */
  21017. $g = double(++$e);  /* Weise $g den doppelten Wert von $e <SPAN
  21018. CLASS="emphasis"
  21019. ><I
  21020. CLASS="emphasis"
  21021. >nach</I
  21022. ></SPAN
  21023. >
  21024.                        der Erhoehung zu, 2*7 = 14 to $g */
  21025. $h = $g += 10;      /* Zuerst wie $g um 10 erh÷ht und hat schliesslich den Wert
  21026.                        24. Der Wert dieser Zuweisung (24) wird dann $h zugewiesen,
  21027.                        womit $h ebenfalls den Wert von 24 hat. */</PRE
  21028. ></TD
  21029. ></TR
  21030. ></TABLE
  21031. ><P
  21032. ></P
  21033. ></DIV
  21034. ></P
  21035. ><P
  21036. >     Am Anfang dieses Kapitels hatten wir gesagt, wir wⁿrden die
  21037.     verschiedenen Arten von Anweisungen beschreiben und, wie versprochen,
  21038.     Ausdrⁿcke k÷nnen Anweisungen sein. Trotzdem ist nicht jeder Ausdruck
  21039.     eine Anweisung. In diesem Fall hat eine Anweisung die Form 
  21040.     ┤Ausdr┤ ┤;┤, d. h. ein Ausdruck gefolgt von einem Semikolon.
  21041.     In ┤$b=$a=5;┤ ist $a=5 ein gⁿltiger Ausdruck, aber fⁿr sich 
  21042.     allein keine Anweisung. ┤$b=$a=5;┤ ist jedoch eine gⁿltige
  21043.     Anweisung.</P
  21044. ><P
  21045. >     Ein letzter Punkt, der noch zu erwΣhnen ist, ist der ┤wahr┤-Wert
  21046.     von Ausdrⁿcken. In vielen FΣllen, hauptsΣchlich in bedingten 
  21047.     Anweisungen und Schleifen, ist man nicht am spezifischen Wert
  21048.     eines Ausdrucks interessiert, sondern kⁿmmert sich nur darum,
  21049.     ob er WAHR oder FALSCH bedeutet (PHP hat keinen speziellen
  21050.     boolean-Datentyp). Der Wahrheitswert eines Ausdrucks in 
  21051.     in PHP wird Σhnlich bestimmt wie in Perl. Jeder numerische
  21052.     Wert, der nicht <TT
  21053. CLASS="constant"
  21054. ><B
  21055. >NULL</B
  21056. ></TT
  21057. > ist, bedeutet WAHR, <TT
  21058. CLASS="constant"
  21059. ><B
  21060. >NULL</B
  21061. ></TT
  21062. > bedeutet FALSCH.
  21063.     Es ist zu beachten, dass negative Werte nicht <TT
  21064. CLASS="constant"
  21065. ><B
  21066. >NULL</B
  21067. ></TT
  21068. > sind und deshalb
  21069.     als WAHR aufgefasst werden! Eine leere Zeichenkette und die 
  21070.     Zeichenkette "0" sind FALSCH; alle anderen Zeichenketten sind
  21071.     WAHR. Nicht-skalare Datentypen (Arrays und Objekte) werden als
  21072.     FALSCH betrachtet, wenn sie keine Elemente enthalten, anderfalls
  21073.     geben sie WAHR zurⁿck.</P
  21074. ><P
  21075. >     PHP stellt eine vollstΣndige und mΣchtige Implementat von Ausdrⁿcken
  21076.     bereit und, deren vollstΣndige Dokumentation den Rahmen dieses Manuals
  21077.     sprengen wⁿrde. Die obigen Beispiele sollten Ihnen einen guten Eindruck
  21078.     darⁿber verschaffen, was Ausdrⁿcke sind und wie man nⁿtzliche Ausdrⁿcke
  21079.     konstruieren kann. Im Rest dieses Manuals werden wir 
  21080.     <VAR
  21081. CLASS="replaceable"
  21082. >ausdr</VAR
  21083. > schreiben, um ausdrⁿcken, dass an dieser
  21084.     Stelle  jeder gⁿltige PHP-Ausdruck stehen kann.</P
  21085. ></DIV
  21086. ><DIV
  21087. CLASS="chapter"
  21088. ><HR><H1
  21089. ><A
  21090. NAME="language.operators"
  21091. >Kapitel 14. Operatoren</A
  21092. ></H1
  21093. ><P
  21094. >    Ein Operator ist etwas das Sie mit einem oder mehreren Werten fⁿttern (oder
  21095.    Ausdrⁿcken, um im Programmierjargon zu sprechen) und Sie erhalten als
  21096.    Ergebnis einen anderen Wert (damit wird diese Konstruktion selbst zu einem
  21097.    Ausdruck). Als Eselsbrⁿcke k÷nnen Sie sich Operatoren als Funktionen oder
  21098.    Konstrukte vorstellen, die Ihnen einen Wert zurⁿck liefern (Σhnlich print)
  21099.    und alles, was Ihnen keinen Wert zurⁿck liefert (Σhnlich echo) als irgend
  21100.    etwas Anderes.
  21101.   </P
  21102. ><P
  21103. >    Es gibt drei Arten von Opratoren. Als erstes gibt es den unΣren Operator,
  21104.    der nur mit einem Wert umgehen kann, zum Beispiel ! (der
  21105.    Verneinungsoperator) oder ++ (der Inkrementoperator). Die zweite Gruppe
  21106.    sind die sogenannten binΣren Operatoren; diese Gruppe enthΣlt die meisten
  21107.    Operatoren, die PHP unterstⁿtzt. Eine Liste dieser Operatoren finden Sie
  21108.    weiter unten im Abschnitt
  21109.    <A
  21110. HREF="#language.operators.precedence"
  21111. >Operator-Rangfolge
  21112.    </A
  21113. >.
  21114.   </P
  21115. ><P
  21116. >    Die dritte Gruppe bildet der ternΣre Operator : ?:. Dieser sollte eher
  21117.    benutzt werden um abhΣngig von einem dritten Ausdruck eine Auswahl zwischen
  21118.    zwei Ausdrⁿcken zu treffen, als zwischen zwei SΣtzen oder Pfaden der
  21119.    Programmausfⁿhrung zu wΣhlen. ▄brigens ist es eine sehr gute Idee ternΣre
  21120.    Ausdrⁿcke in Klammern zu setzen.
  21121.   </P
  21122. ><DIV
  21123. CLASS="sect1"
  21124. ><HR><H2
  21125. CLASS="sect1"
  21126. ><A
  21127. NAME="language.operators.precedence"
  21128. >Operator-Rangfolge</A
  21129. ></H2
  21130. ><P
  21131. >     Die Operator-Rangfolge legt fest, wie "eng" ein Operator zwei
  21132.     Ausdrⁿcke miteinander verbindet. Zum Beispiel ist das Ergebnis des
  21133.     Ausdruckes <VAR
  21134. CLASS="literal"
  21135. >1 + 5 * 3</VAR
  21136. > <VAR
  21137. CLASS="literal"
  21138. >16</VAR
  21139. >
  21140.     und nicht <VAR
  21141. CLASS="literal"
  21142. >18</VAR
  21143. >, da der Multiplikations-Operator
  21144.     ("*") in der Rangfolge h÷her steht als der Additions-Operator
  21145.     ("+"). Wenn n÷tig, k÷nnen Sie Klammern setzen, um die Rangfolge
  21146.     der Operatoren zu beeinflussen. Zum Beispiel ergibt: <VAR
  21147. CLASS="literal"
  21148. >(1 + 5) *
  21149.     3</VAR
  21150. > <VAR
  21151. CLASS="literal"
  21152. >18</VAR
  21153. >. Ist die Rangfolge der Operatoren gleich,
  21154.     wird links nach rechts AssoziativitΣt benutzt.
  21155.    </P
  21156. ><P
  21157. >     Die folgende Tabelle zeigt die Rangfolge der Operatoren, oben
  21158.     steht der Operator mit dem h÷chsten Rang.
  21159.  
  21160.     <DIV
  21161. CLASS="table"
  21162. ><A
  21163. NAME="AEN3788"
  21164. ></A
  21165. ><P
  21166. ><B
  21167. >Tabelle 14-1. Operator-Rangfolge</B
  21168. ></P
  21169. ><TABLE
  21170. BORDER="1"
  21171. CLASS="CALSTABLE"
  21172. ><COL><COL><THEAD
  21173. ><TR
  21174. ><TH
  21175. >AssoziativitΣt</TH
  21176. ><TH
  21177. >Operator</TH
  21178. ></TR
  21179. ></THEAD
  21180. ><TBODY
  21181. ><TR
  21182. ><TD
  21183. >keine Richtung</TD
  21184. ><TD
  21185. >new</TD
  21186. ></TR
  21187. ><TR
  21188. ><TD
  21189. >rechts</TD
  21190. ><TD
  21191. >[</TD
  21192. ></TR
  21193. ><TR
  21194. ><TD
  21195. >rechts</TD
  21196. ><TD
  21197. >          ! ~ ++ -- (int) (float) (string) (array) (object) @
  21198.         </TD
  21199. ></TR
  21200. ><TR
  21201. ><TD
  21202. >links</TD
  21203. ><TD
  21204. >* / %</TD
  21205. ></TR
  21206. ><TR
  21207. ><TD
  21208. >links</TD
  21209. ><TD
  21210. >+ - .</TD
  21211. ></TR
  21212. ><TR
  21213. ><TD
  21214. >links</TD
  21215. ><TD
  21216. ><< >></TD
  21217. ></TR
  21218. ><TR
  21219. ><TD
  21220. >keine Richtung</TD
  21221. ><TD
  21222. >< <= > >=</TD
  21223. ></TR
  21224. ><TR
  21225. ><TD
  21226. >keine Richtung</TD
  21227. ><TD
  21228. >== != === !==</TD
  21229. ></TR
  21230. ><TR
  21231. ><TD
  21232. >links</TD
  21233. ><TD
  21234. >&</TD
  21235. ></TR
  21236. ><TR
  21237. ><TD
  21238. >links</TD
  21239. ><TD
  21240. >^</TD
  21241. ></TR
  21242. ><TR
  21243. ><TD
  21244. >links</TD
  21245. ><TD
  21246. >|</TD
  21247. ></TR
  21248. ><TR
  21249. ><TD
  21250. >links</TD
  21251. ><TD
  21252. >&&</TD
  21253. ></TR
  21254. ><TR
  21255. ><TD
  21256. >links</TD
  21257. ><TD
  21258. >||</TD
  21259. ></TR
  21260. ><TR
  21261. ><TD
  21262. >links</TD
  21263. ><TD
  21264. >? :</TD
  21265. ></TR
  21266. ><TR
  21267. ><TD
  21268. >rechts</TD
  21269. ><TD
  21270. >          = += -= *= /= .= %= &= |= ^= <<= >>=
  21271.         </TD
  21272. ></TR
  21273. ><TR
  21274. ><TD
  21275. >rechts</TD
  21276. ><TD
  21277. >print</TD
  21278. ></TR
  21279. ><TR
  21280. ><TD
  21281. >links</TD
  21282. ><TD
  21283. >and</TD
  21284. ></TR
  21285. ><TR
  21286. ><TD
  21287. >links</TD
  21288. ><TD
  21289. >xor</TD
  21290. ></TR
  21291. ><TR
  21292. ><TD
  21293. >links</TD
  21294. ><TD
  21295. >or</TD
  21296. ></TR
  21297. ><TR
  21298. ><TD
  21299. >links</TD
  21300. ><TD
  21301. >,</TD
  21302. ></TR
  21303. ></TBODY
  21304. ></TABLE
  21305. ></DIV
  21306. >
  21307.    </P
  21308. ><DIV
  21309. CLASS="note"
  21310. ><BLOCKQUOTE
  21311. CLASS="note"
  21312. ><P
  21313. ><B
  21314. >Anmerkung: </B
  21315. >
  21316.      Obwohl <VAR
  21317. CLASS="literal"
  21318. >!</VAR
  21319. > einen h÷heren Rang gegenⁿber
  21320.      <VAR
  21321. CLASS="literal"
  21322. >=</VAR
  21323. > hat, erlaubt es Ihnen PHP immer noch
  21324.      Σhnliche Ausdrⁿcke wie den folgenden zu schreiben: <VAR
  21325. CLASS="literal"
  21326. >if
  21327.      (!$a =foo())</VAR
  21328. >.In diesem Ausdruck wird die Ausgabe von
  21329.      <VAR
  21330. CLASS="literal"
  21331. >foo()</VAR
  21332. > der Variablen <VAR
  21333. CLASS="varname"
  21334. >$a</VAR
  21335. >
  21336.      zugewiesen.
  21337.     </P
  21338. ></BLOCKQUOTE
  21339. ></DIV
  21340. ></DIV
  21341. ><DIV
  21342. CLASS="sect1"
  21343. ><HR><H2
  21344. CLASS="sect1"
  21345. ><A
  21346. NAME="language.operators.arithmetic"
  21347. >Arithmetische Operatoren</A
  21348. ></H2
  21349. ><P
  21350. >     Erinnern Sie sich noch an die Grundrechenarten aus der Schule? Die
  21351.     arithmetischen Operatoren funktionieren genauso:
  21352.    </P
  21353. ><DIV
  21354. CLASS="table"
  21355. ><A
  21356. NAME="AEN3866"
  21357. ></A
  21358. ><P
  21359. ><B
  21360. >Tabelle 14-2. Arithmetische Operatoren</B
  21361. ></P
  21362. ><TABLE
  21363. BORDER="1"
  21364. CLASS="CALSTABLE"
  21365. ><COL><COL><COL><THEAD
  21366. ><TR
  21367. ><TH
  21368. >Beispiel</TH
  21369. ><TH
  21370. >Name</TH
  21371. ><TH
  21372. >Ergebnis</TH
  21373. ></TR
  21374. ></THEAD
  21375. ><TBODY
  21376. ><TR
  21377. ><TD
  21378. >$a + $b</TD
  21379. ><TD
  21380. >Addition</TD
  21381. ><TD
  21382. >Summe von $a und $b.</TD
  21383. ></TR
  21384. ><TR
  21385. ><TD
  21386. >$a - $b</TD
  21387. ><TD
  21388. >Subtraktion</TD
  21389. ><TD
  21390. >Differenz von $a und $b.</TD
  21391. ></TR
  21392. ><TR
  21393. ><TD
  21394. >$a * $b</TD
  21395. ><TD
  21396. >Multiplikation</TD
  21397. ><TD
  21398. >Produkt von $a und $b.</TD
  21399. ></TR
  21400. ><TR
  21401. ><TD
  21402. >$a / $b</TD
  21403. ><TD
  21404. >Division</TD
  21405. ><TD
  21406. >Quotient von $a und  $b.</TD
  21407. ></TR
  21408. ><TR
  21409. ><TD
  21410. >$a % $b</TD
  21411. ><TD
  21412. >Modulus</TD
  21413. ><TD
  21414. >Rest von $a geteilt durch $b.</TD
  21415. ></TR
  21416. ></TBODY
  21417. ></TABLE
  21418. ></DIV
  21419. ><P
  21420. >     Der Divisions-Operator ("/") gibt immer eine Flie▀kommazahl
  21421.     zurⁿck, sogar wenn die zwei Operanden Ganzzahlen sind (oder
  21422.     Zeichenketten, die nach Ganzzahlen umgewandelt wurden).
  21423.    </P
  21424. ><P
  21425. >     Siehe auch im Handbuch das Kapitel ⁿber <A
  21426. HREF="#ref.math"
  21427. >Mathematische Funktionen</A
  21428. >.
  21429.    </P
  21430. ></DIV
  21431. ><DIV
  21432. CLASS="sect1"
  21433. ><HR><H2
  21434. CLASS="sect1"
  21435. ><A
  21436. NAME="language.operators.assignment"
  21437. >Zuweisungsoperatoren</A
  21438. ></H2
  21439. ><P
  21440. >     Der einfachste Zuweisungsoperator ist "=". Wahrscheinlich kommt
  21441.     man als erstes auf die Idee, ihn mit "ist gleich" zu bezeichnen.
  21442.     Das ist falsch. In Wirklichkeit bedeutet er, dass dem linken
  21443.     Operanden der Wert des Ausdrucks auf der rechten Seite zugewiesen
  21444.     wird (man mⁿsste ihn also mit "wird gesetzt auf den Wert von"
  21445.     ⁿbersetzen).
  21446.    </P
  21447. ><P
  21448. >     Der Wert eines Zuweisungs-Ausdruckes ist der zugewiesene Wert.
  21449.     D.h. der Wert des Ausdruckes "$a = 3" ist 3. Das erlaubt es,
  21450.     einige raffinierte Dinge anzustellen:
  21451.     <DIV
  21452. CLASS="informalexample"
  21453. ><P
  21454. ></P
  21455. ><A
  21456. NAME="AEN3902"
  21457. ></A
  21458. ><TABLE
  21459. BORDER="0"
  21460. BGCOLOR="#E0E0E0"
  21461. CELLPADDING="5"
  21462. ><TR
  21463. ><TD
  21464. ><PRE
  21465. CLASS="php"
  21466. ><?php
  21467.  
  21468. $a = ($b = 4) + 5; // $a ist nun gleich 9 und $b wurde auf den Wert 4 gesetzt.
  21469.  
  21470. ?></PRE
  21471. ></TD
  21472. ></TR
  21473. ></TABLE
  21474. ><P
  21475. ></P
  21476. ></DIV
  21477. >
  21478.    </P
  21479. ><P
  21480. >     ZusΣtzlich zu dem oben vorgestellten Zuweisungsoperator "=" gibt
  21481.     es "kombinierte Operatoren" fⁿr alle
  21482.     <A
  21483. HREF="#language.operators"
  21484. >binΣren, arithmetischen</A
  21485. > und
  21486.     String-Operatoren, die es erlauben, den Wert einer Variablen in
  21487.     einem Ausdruck zu benutzen, und dieser anschlie▀end das Ergebnis
  21488.     des Ausdrucks als neuen Wert zuzuweisen. Zum Beispiel: 
  21489.     <DIV
  21490. CLASS="informalexample"
  21491. ><P
  21492. ></P
  21493. ><A
  21494. NAME="AEN3906"
  21495. ></A
  21496. ><TABLE
  21497. BORDER="0"
  21498. BGCOLOR="#E0E0E0"
  21499. CELLPADDING="5"
  21500. ><TR
  21501. ><TD
  21502. ><PRE
  21503. CLASS="php"
  21504. ><?php
  21505.  
  21506. $a = 3;
  21507. $a += 5; // setzt $a auf den Wert 8, als ob wir geschrieben haetten: $a = $a + 5;
  21508. $b = "Hallo ";
  21509. $b .= "Du!"; // setzt $b auf den Wert "Hallo Du!", aequivalent zu 
  21510.              // $b = $b . "Du!";
  21511. ?></PRE
  21512. ></TD
  21513. ></TR
  21514. ></TABLE
  21515. ><P
  21516. ></P
  21517. ></DIV
  21518. >
  21519.    </P
  21520. ><P
  21521. >     Man beachte, dass die Zuweisung nur den Wert der Ursprungsvarialbe
  21522.     der neuen Variable zuweist (Zuweisung als Wert, sie "kopiert"),
  21523.     weshalb sich ─nderungen an der einen Variablen nicht auf die
  21524.     andere auswirken werden. Das kann wichtig sein, wenn man ein
  21525.     gro▀es Array o. Σ. in einer Schleife kopieren muss. PHP 4
  21526.     unterstⁿtzt 'assignement by reference' (Zuweisung als Verweis),
  21527.     mit Hilfe der Schreibweise <SAMP
  21528. CLASS="computeroutput"
  21529. >$var =
  21530.     &$othervar;</SAMP
  21531. >, das funktioniert jedoch nicht in
  21532.     PHP 3. 'Assignement by reference' bedeutet, dass beide Variablen
  21533.     nach der Zuweisung die selben Daten reprΣsentieren und nichts
  21534.     kopiert wird. Um mehr ⁿber Referenzen zu lernen, lesen Sie bitte
  21535.     den Abschnitt <A
  21536. HREF="#language.references"
  21537. >Referenzen
  21538.     erklΣrt</A
  21539. >.
  21540.    </P
  21541. ></DIV
  21542. ><DIV
  21543. CLASS="sect1"
  21544. ><HR><H2
  21545. CLASS="sect1"
  21546. ><A
  21547. NAME="language.operators.bitwise"
  21548. >Bit-Operatoren</A
  21549. ></H2
  21550. ><P
  21551. >     Bit-Operatoren erlauben es, in einem Integer bestimmte Bits "ein-
  21552.     oder  auszuschalten" (auf 0 oder 1 zu setzen). Wenn beide, der
  21553.     links- und rechtsseitige Parameter, Zeichenketten sind, arbeiten
  21554.     die Bit-Operatoren mit ASCII-Werten der einzelnen Zeichen.
  21555.    </P
  21556. ><P
  21557. >     <DIV
  21558. CLASS="informalexample"
  21559. ><P
  21560. ></P
  21561. ><A
  21562. NAME="AEN3915"
  21563. ></A
  21564. ><TABLE
  21565. BORDER="0"
  21566. BGCOLOR="#E0E0E0"
  21567. CELLPADDING="5"
  21568. ><TR
  21569. ><TD
  21570. ><PRE
  21571. CLASS="php"
  21572. ><?php
  21573. echo 12 ^ 9; // Ausgabe '5'
  21574.  
  21575. echo "12" ^ "9"; // Ausgabe: das Backspace-Zeichen (ascii 8)
  21576.                  // ('1' (ascii 49)) ^ ('9' (ascii 57)) = #8
  21577.  
  21578. echo "hallo" ^ "hello"; // Gibt die ASCII-Werte #0 #4 #0 #0 #0
  21579.                         // 'a' ^ 'e' = #4 aus
  21580. ?></PRE
  21581. ></TD
  21582. ></TR
  21583. ></TABLE
  21584. ><P
  21585. ></P
  21586. ></DIV
  21587.    </P
  21588. ><DIV
  21589. CLASS="table"
  21590. ><A
  21591. NAME="AEN3917"
  21592. ></A
  21593. ><P
  21594. ><B
  21595. >Tabelle 14-3. Bit-Operatoren</B
  21596. ></P
  21597. ><TABLE
  21598. BORDER="1"
  21599. CLASS="CALSTABLE"
  21600. ><COL><COL><COL><THEAD
  21601. ><TR
  21602. ><TH
  21603. >Beispiel</TH
  21604. ><TH
  21605. >Name</TH
  21606. ><TH
  21607. >Ergebnis</TH
  21608. ></TR
  21609. ></THEAD
  21610. ><TBODY
  21611. ><TR
  21612. ><TD
  21613. >$a & $b</TD
  21614. ><TD
  21615. >Und</TD
  21616. ><TD
  21617. >         Bits, die in $a und $b gesetzt sind werden gesetzt.
  21618.        </TD
  21619. ></TR
  21620. ><TR
  21621. ><TD
  21622. >$a | $b</TD
  21623. ><TD
  21624. >Oder</TD
  21625. ><TD
  21626. >         Bits, die in $a oder $b gesetzt sind werden gesetzt.
  21627.        </TD
  21628. ></TR
  21629. ><TR
  21630. ><TD
  21631. >$a ^ $b</TD
  21632. ><TD
  21633. >Entweder oder (Xor)</TD
  21634. ><TD
  21635. >         Bits, die entweder in $a oder $b gesetzt sind, werden gesetzt
  21636.         aber nicht in beiden.
  21637.        </TD
  21638. ></TR
  21639. ><TR
  21640. ><TD
  21641. >~ $a</TD
  21642. ><TD
  21643. >Nicht</TD
  21644. ><TD
  21645. >         Die Bits, die in $a nicht gesetzt sind, werden gesetzt und
  21646.         umgekehrt.
  21647.        </TD
  21648. ></TR
  21649. ><TR
  21650. ><TD
  21651. >$a << $b</TD
  21652. ><TD
  21653. >Nach links verschieben</TD
  21654. ><TD
  21655. >         Verschiebung der Bits von $a um $b Stellen nach links (jede
  21656.         Stelle entspricht einer Mulitplikation mit zwei).
  21657.        </TD
  21658. ></TR
  21659. ><TR
  21660. ><TD
  21661. >$a >> $b</TD
  21662. ><TD
  21663. >Nach rechts verschieben</TD
  21664. ><TD
  21665. >         Verschiebt die Bits von $a um $b Stellen nach rechts (jede
  21666.         Stelle entspricht einer Division durch zwei).
  21667.        </TD
  21668. ></TR
  21669. ></TBODY
  21670. ></TABLE
  21671. ></DIV
  21672. ></DIV
  21673. ><DIV
  21674. CLASS="sect1"
  21675. ><HR><H2
  21676. CLASS="sect1"
  21677. ><A
  21678. NAME="language.operators.comparison"
  21679. >Vergleichs-Operatoren</A
  21680. ></H2
  21681. ><P
  21682. >     Vergleichs-Operatoren erlauben es - wie der Name schon sagt -
  21683.     zwei Werte zu vergleichen. Wenn Sie an Beispielen verschiedener
  21684.     auf Typen bezogener Vergleiche interessiert sind, k÷nnen Sie sich
  21685.     <A
  21686. HREF="#types.comparisons"
  21687. >PHP type comparison
  21688.     tables</A
  21689. > anschauen.
  21690.    </P
  21691. ><DIV
  21692. CLASS="table"
  21693. ><A
  21694. NAME="AEN3954"
  21695. ></A
  21696. ><P
  21697. ><B
  21698. >Tabelle 14-4. Vergleichsoperatoren</B
  21699. ></P
  21700. ><TABLE
  21701. BORDER="1"
  21702. CLASS="CALSTABLE"
  21703. ><COL><COL><COL><THEAD
  21704. ><TR
  21705. ><TH
  21706. >Beispiel</TH
  21707. ><TH
  21708. >Name</TH
  21709. ><TH
  21710. >Ergebnis</TH
  21711. ></TR
  21712. ></THEAD
  21713. ><TBODY
  21714. ><TR
  21715. ><TD
  21716. >$a == $b</TD
  21717. ><TD
  21718. >Gleich</TD
  21719. ><TD
  21720. >Gibt <TT
  21721. CLASS="constant"
  21722. ><B
  21723. >TRUE</B
  21724. ></TT
  21725. > zurⁿck, wenn $a gleich $b ist.</TD
  21726. ></TR
  21727. ><TR
  21728. ><TD
  21729. >$a === $b</TD
  21730. ><TD
  21731. >Identisch</TD
  21732. ><TD
  21733. >         Gibt <TT
  21734. CLASS="constant"
  21735. ><B
  21736. >TRUE</B
  21737. ></TT
  21738. > zurⁿck wenn $a gleich $b ist und beide vom
  21739.         gleichen Typ sind(nur PHP 4).
  21740.        </TD
  21741. ></TR
  21742. ><TR
  21743. ><TD
  21744. >$a != $b</TD
  21745. ><TD
  21746. >Ungleich</TD
  21747. ><TD
  21748. >         Gibt <TT
  21749. CLASS="constant"
  21750. ><B
  21751. >TRUE</B
  21752. ></TT
  21753. > zurⁿck, wenn $a nicht gleich $b ist.
  21754.        </TD
  21755. ></TR
  21756. ><TR
  21757. ><TD
  21758. >$a <> $b</TD
  21759. ><TD
  21760. >Ungleich</TD
  21761. ><TD
  21762. >         Gibt <TT
  21763. CLASS="constant"
  21764. ><B
  21765. >TRUE</B
  21766. ></TT
  21767. > zurⁿck, wenn $a nicht gleich $b ist.
  21768.        </TD
  21769. ></TR
  21770. ><TR
  21771. ><TD
  21772. >$a !== $b</TD
  21773. ><TD
  21774. >Nicht identisch</TD
  21775. ><TD
  21776. >         Gibt <TT
  21777. CLASS="constant"
  21778. ><B
  21779. >TRUE</B
  21780. ></TT
  21781. > zurⁿck, wenn $a nicht gleich $b ist, oder wenn
  21782.         beide nicht vom gleichen Typ sind (nur PHP 4).
  21783.        </TD
  21784. ></TR
  21785. ><TR
  21786. ><TD
  21787. >$a < $b</TD
  21788. ><TD
  21789. >Kleiner Als</TD
  21790. ><TD
  21791. >Gibt <TT
  21792. CLASS="constant"
  21793. ><B
  21794. >TRUE</B
  21795. ></TT
  21796. > zurⁿck, wenn $a kleiner als $b ist.</TD
  21797. ></TR
  21798. ><TR
  21799. ><TD
  21800. >$a > $b</TD
  21801. ><TD
  21802. >Gr÷▀er Als</TD
  21803. ><TD
  21804. >Gibt <TT
  21805. CLASS="constant"
  21806. ><B
  21807. >TRUE</B
  21808. ></TT
  21809. > zurⁿck, wenn $a gr÷▀er als $b ist.</TD
  21810. ></TR
  21811. ><TR
  21812. ><TD
  21813. >$a <= $b</TD
  21814. ><TD
  21815. >Kleiner Gleich </TD
  21816. ><TD
  21817. >         Gibt <TT
  21818. CLASS="constant"
  21819. ><B
  21820. >TRUE</B
  21821. ></TT
  21822. > zurⁿck, wenn $a kleiner oder gleich $b ist.
  21823.        </TD
  21824. ></TR
  21825. ><TR
  21826. ><TD
  21827. >$a >= $b</TD
  21828. ><TD
  21829. >Gr÷▀er Gleich</TD
  21830. ><TD
  21831. >         Gibt <TT
  21832. CLASS="constant"
  21833. ><B
  21834. >TRUE</B
  21835. ></TT
  21836. > zurⁿck, wenn $a gr÷▀er oder gleich $b ist.
  21837.        </TD
  21838. ></TR
  21839. ></TBODY
  21840. ></TABLE
  21841. ></DIV
  21842. ><P
  21843. >     Ein weiter Vergleichs-Operator ist der "?:"- oder
  21844.     TrinitΣts-Operator.
  21845.     <DIV
  21846. CLASS="informalexample"
  21847. ><P
  21848. ></P
  21849. ><A
  21850. NAME="AEN4009"
  21851. ></A
  21852. ><TABLE
  21853. BORDER="0"
  21854. BGCOLOR="#E0E0E0"
  21855. CELLPADDING="5"
  21856. ><TR
  21857. ><TD
  21858. ><PRE
  21859. CLASS="php"
  21860. ><?php
  21861. // Beispielanwendung fⁿr den TrinitΣts-Operator
  21862. $action = (empty($_POST['action'])) ? 'standard' : $_POST['action'];
  21863.  
  21864. // Obiges ist mit dieser if/else-Anweisung identisch
  21865. if (empty($_POST['action'])) {
  21866.     $action = 'standard';
  21867. } else {
  21868.     $action = $_POST['action'];
  21869. }
  21870. ?></PRE
  21871. ></TD
  21872. ></TR
  21873. ></TABLE
  21874. ><P
  21875. ></P
  21876. ></DIV
  21877.     Der Ausdruck <VAR
  21878. CLASS="literal"
  21879. >(ausdr1) ? (ausdr2) : (ausdr3)</VAR
  21880. >
  21881.     gibt <VAR
  21882. CLASS="replaceable"
  21883. >ausdr2</VAR
  21884. > zurⁿck, wenn
  21885.     <VAR
  21886. CLASS="replaceable"
  21887. >ausdr1</VAR
  21888. > <TT
  21889. CLASS="constant"
  21890. ><B
  21891. >TRUE</B
  21892. ></TT
  21893. > zurⁿckgibt und
  21894.     <VAR
  21895. CLASS="replaceable"
  21896. >ausdr3</VAR
  21897. >, wenn
  21898.     <VAR
  21899. CLASS="replaceable"
  21900. >ausdr1</VAR
  21901. > <TT
  21902. CLASS="constant"
  21903. ><B
  21904. >FALSE</B
  21905. ></TT
  21906. > zurⁿckgibt.
  21907.    </P
  21908. ><P
  21909. >     Siehe auch <A
  21910. HREF="#function.strcasecmp"
  21911. ><B
  21912. CLASS="function"
  21913. >strcasecmp()</B
  21914. ></A
  21915. >,
  21916.     <A
  21917. HREF="#function.strcmp"
  21918. ><B
  21919. CLASS="function"
  21920. >strcmp()</B
  21921. ></A
  21922. >,
  21923.     <A
  21924. HREF="#language.operators.array"
  21925. >Array Operatoren</A
  21926. >
  21927.     und den Abschnitt ⁿber <A
  21928. HREF="#language.types"
  21929. >Typen</A
  21930. >.
  21931.    </P
  21932. ></DIV
  21933. ><DIV
  21934. CLASS="sect1"
  21935. ><HR><H2
  21936. CLASS="sect1"
  21937. ><A
  21938. NAME="language.operators.errorcontrol"
  21939. >Fehler-Kontroll-Operatoren</A
  21940. ></H2
  21941. ><P
  21942. >     PHP unterstⁿtzt einen Operator zur Fehlerkontrolle: Das @-Symbol.
  21943.     Stellt man das @ in PHP vor einen Ausdruck werden alle
  21944.     Fehlermeldungen, die von diesem Ausdruck erzeugt werden k÷nnten,
  21945.     ignoriert.
  21946.    </P
  21947. ><P
  21948. >     Ist das <A
  21949. HREF="#ini.track-errors"
  21950. ><VAR
  21951. CLASS="option"
  21952. >track_errors</VAR
  21953. ></A
  21954. >-Feature
  21955.     aktiviert, werden alle Fehlermeldungen, die von diesem Ausdruck erzeugt
  21956.     werden, in der Variablen <A
  21957. HREF="#reserved.variables.phperrormsg"
  21958. >$php_errormsg</A
  21959. >
  21960.     gespeichert. Da diese Variable mit jedem neuen Auftreten eines
  21961.     Fehlers ⁿberschrieben wird, sollte man sie m÷glichst bald nach
  21962.     Verwendung des Ausdrucks ⁿberprⁿfen, wenn man mit ihr arbeiten
  21963.     will.
  21964.    </P
  21965. ><P
  21966. >     <DIV
  21967. CLASS="informalexample"
  21968. ><P
  21969. ></P
  21970. ><A
  21971. NAME="AEN4031"
  21972. ></A
  21973. ><TABLE
  21974. BORDER="0"
  21975. BGCOLOR="#E0E0E0"
  21976. CELLPADDING="5"
  21977. ><TR
  21978. ><TD
  21979. ><PRE
  21980. CLASS="php"
  21981. ><?php
  21982. /* Beabsichtigter Dateifehler */
  21983. $my_file = @file ('nicht_vorhandene_Datei') or
  21984.     die ("Datei konnte nicht ge÷ffnetwerden: Fehler war:'$php_errormsg'");
  21985.  
  21986. // Das funktioniert bei jedem Ausdruck, nicht nur bei Funktionen:
  21987. $value = @$cache[$key]; 
  21988. // erzeugt keine Notice, falls der Index $key nicht vorhanden ist.
  21989.  
  21990. ?></PRE
  21991. ></TD
  21992. ></TR
  21993. ></TABLE
  21994. ><P
  21995. ></P
  21996. ></DIV
  21997. >
  21998.    </P
  21999. ><DIV
  22000. CLASS="note"
  22001. ><BLOCKQUOTE
  22002. CLASS="note"
  22003. ><P
  22004. ><B
  22005. >Anmerkung: </B
  22006. >
  22007.      Der @-Operator funktioniert nur bei <A
  22008. HREF="#language.expressions"
  22009. >Ausdrⁿcken</A
  22010. >. Eine einfache
  22011.      Daumenregel: wenn Sie den Wert von etwas bestimmen k÷nnen, dann
  22012.      k÷nnen Sie den @-Operator davor schreiben. Zum Beispiel k÷nnen
  22013.      Sie ihn vor Variablen, Funktionsaufrufe und vor
  22014.      <A
  22015. HREF="#function.include"
  22016. ><B
  22017. CLASS="function"
  22018. >include()</B
  22019. ></A
  22020. > setzen, vor Konstanten und so
  22021.      weiter. Nicht verwenden k÷nnen Sie diesen Operator vor Funktions-
  22022.      oder Klassendefinitionen oder vor Kontrollstrukturen wie zum
  22023.      Beispiel <VAR
  22024. CLASS="literal"
  22025. >if</VAR
  22026. > und <VAR
  22027. CLASS="literal"
  22028. >foreach</VAR
  22029. > und
  22030.      so weiter.
  22031.     </P
  22032. ></BLOCKQUOTE
  22033. ></DIV
  22034. ><P
  22035. >     Siehe auch <A
  22036. HREF="#function.error-reporting"
  22037. ><B
  22038. CLASS="function"
  22039. >error_reporting()</B
  22040. ></A
  22041. > und den Abschnitt
  22042.     ⁿber <A
  22043. HREF="#ref.errorfunc"
  22044. >Error Handling and Logging
  22045.     Functions</A
  22046. >.
  22047.    </P
  22048. ><DIV
  22049. CLASS="note"
  22050. ><BLOCKQUOTE
  22051. CLASS="note"
  22052. ><P
  22053. ><B
  22054. >Anmerkung: </B
  22055. >
  22056.      Der @ Fehler-Kontroll-Operator verhindert jedoch keine Meldungen,
  22057.      welche aus Fehlern beim Parsen resultieren.
  22058.     </P
  22059. ></BLOCKQUOTE
  22060. ></DIV
  22061. ><DIV
  22062. CLASS="warning"
  22063. ><P
  22064. ></P
  22065. ><TABLE
  22066. CLASS="warning"
  22067. BORDER="1"
  22068. WIDTH="100%"
  22069. ><TR
  22070. ><TD
  22071. ALIGN="CENTER"
  22072. ><B
  22073. >Warnung</B
  22074. ></TD
  22075. ></TR
  22076. ><TR
  22077. ><TD
  22078. ALIGN="LEFT"
  22079. ><P
  22080. >      Zum gegenwΣrtigen Zeitpunkt deaktiviert der "@"
  22081.      Fehler-Kontrolloperator die Fehlermeldungen selbst bei kritischen
  22082.      Fehlern, die die Ausfⁿhrung eines Skripts beenden. Unter anderem
  22083.      bedeutet das, wenn Sie "@" einer bestimmten Funktion
  22084.      voranstellen, diese aber nicht zur Verfⁿgung steht oder falsch
  22085.      geschrieben wurde, Ihr PHP-Skript einfach beendet wird, ohne
  22086.      Hinweis auf die Ursache.
  22087.     </P
  22088. ></TD
  22089. ></TR
  22090. ></TABLE
  22091. ></DIV
  22092. ></DIV
  22093. ><DIV
  22094. CLASS="sect1"
  22095. ><HR><H2
  22096. CLASS="sect1"
  22097. ><A
  22098. NAME="language.operators.execution"
  22099. >Operatoren zur Programmausfⁿhrung</A
  22100. ></H2
  22101. ><P
  22102. >     PHP unterstⁿtzt einen Operator zur Ausfⁿhrung externer Programme:
  22103.     Die sog. Backticks (``). Achtung: Die Backticks sind keine
  22104.     einfachen Anfⁿhrungszeichen! PHP versucht, den Text zwischen den
  22105.     Backticks als Kommandozeilen-Befehl auszufⁿhren. Die Ausgabe des
  22106.     aufgerufenen Programms wird zurⁿckgegeben (d.h. wird nicht einfach
  22107.     ausgegeben, sondern kann einer Variablen zugewiesen werden). Die
  22108.     Verwendung des Backtick-Operators ist mit
  22109.     <A
  22110. HREF="#function.shell-exec"
  22111. ><B
  22112. CLASS="function"
  22113. >shell_exec()</B
  22114. ></A
  22115. > identisch.
  22116.     <DIV
  22117. CLASS="informalexample"
  22118. ><P
  22119. ></P
  22120. ><A
  22121. NAME="AEN4050"
  22122. ></A
  22123. ><TABLE
  22124. BORDER="0"
  22125. BGCOLOR="#E0E0E0"
  22126. CELLPADDING="5"
  22127. ><TR
  22128. ><TD
  22129. ><PRE
  22130. CLASS="php"
  22131. ><?php
  22132. $output = `ls -al`;
  22133. echo "<pre>$output</pre>";
  22134. ?></PRE
  22135. ></TD
  22136. ></TR
  22137. ></TABLE
  22138. ><P
  22139. ></P
  22140. ></DIV
  22141. >
  22142.    </P
  22143. ><DIV
  22144. CLASS="note"
  22145. ><BLOCKQUOTE
  22146. CLASS="note"
  22147. ><P
  22148. ><B
  22149. >Anmerkung: </B
  22150. >
  22151.      Der Backtick-Operator steht nicht zur Verfⁿgung, wenn <A
  22152. HREF="#ini.safe-mode"
  22153. >Safe Mode</A
  22154. >
  22155.      aktiviert ist oder die Funktion <A
  22156. HREF="#function.shell-exec"
  22157. ><B
  22158. CLASS="function"
  22159. >shell_exec()</B
  22160. ></A
  22161. >
  22162.      deaktiviert wurde.
  22163.     </P
  22164. ></BLOCKQUOTE
  22165. ></DIV
  22166. ><P
  22167. >     Siehe auch den Abschnitt ⁿber <A
  22168. HREF="#ref.exec"
  22169. >Funktionen
  22170.     zur Programmausfⁿhrung</A
  22171. >, <A
  22172. HREF="#function.popen"
  22173. ><B
  22174. CLASS="function"
  22175. >popen()</B
  22176. ></A
  22177. >,
  22178.     <A
  22179. HREF="#function.proc-open"
  22180. ><B
  22181. CLASS="function"
  22182. >proc_open()</B
  22183. ></A
  22184. > und <A
  22185. HREF="#features.commandline"
  22186. >Using PHP from the
  22187.     commandline</A
  22188. >.
  22189.    </P
  22190. ></DIV
  22191. ><DIV
  22192. CLASS="sect1"
  22193. ><HR><H2
  22194. CLASS="sect1"
  22195. ><A
  22196. NAME="language.operators.increment"
  22197. >Inkrement- bzw. Dekrementoperatoren</A
  22198. ></H2
  22199. ><P
  22200. >     PHP unterstⁿtzt PrΣ- und Post-Inkrement- und Dekrementoperatoren
  22201.     im Stil der Programmiersprache C.
  22202.    </P
  22203. ><DIV
  22204. CLASS="table"
  22205. ><A
  22206. NAME="AEN4064"
  22207. ></A
  22208. ><P
  22209. ><B
  22210. >Tabelle 14-5. Inkrement- und Dekrementoperatoren</B
  22211. ></P
  22212. ><TABLE
  22213. BORDER="1"
  22214. CLASS="CALSTABLE"
  22215. ><COL><COL><COL><THEAD
  22216. ><TR
  22217. ><TH
  22218. >Beispiel</TH
  22219. ><TH
  22220. >Name</TH
  22221. ><TH
  22222. >Auswirkung</TH
  22223. ></TR
  22224. ></THEAD
  22225. ><TBODY
  22226. ><TR
  22227. ><TD
  22228. >++$a</TD
  22229. ><TD
  22230. >PrΣ-Inkrement</TD
  22231. ><TD
  22232. >         Erh÷ht den Wert von $a um eins (inkrementiert $a) und gibt
  22233.         anschlie▀end den neuen Wert von $a zurⁿck.
  22234.        </TD
  22235. ></TR
  22236. ><TR
  22237. ><TD
  22238. >$a++</TD
  22239. ><TD
  22240. >Post-Inkrement</TD
  22241. ><TD
  22242. >         Gibt zuerst den aktuellen Wert von $a zurⁿck und erh÷ht dann
  22243.         den Wert von $a um eins.
  22244.        </TD
  22245. ></TR
  22246. ><TR
  22247. ><TD
  22248. >--$a</TD
  22249. ><TD
  22250. >PrΣ-Dekrement</TD
  22251. ><TD
  22252. >         Vermindert den Wert von $a um eins (dekrementiert $a) und gibt
  22253.         anschlie▀end den neuen Wert von $a zurⁿck.
  22254.        </TD
  22255. ></TR
  22256. ><TR
  22257. ><TD
  22258. >$a--</TD
  22259. ><TD
  22260. >Post-Dekrement</TD
  22261. ><TD
  22262. >         Gibt zuerst den aktuellen Wert von $a zurⁿck und erniedrigt
  22263.         dann den Wert von $a um eins.
  22264.        </TD
  22265. ></TR
  22266. ></TBODY
  22267. ></TABLE
  22268. ></DIV
  22269. ><P
  22270. >     Ein einfaches Beispiel-Skript:
  22271.     <DIV
  22272. CLASS="informalexample"
  22273. ><P
  22274. ></P
  22275. ><A
  22276. NAME="AEN4090"
  22277. ></A
  22278. ><TABLE
  22279. BORDER="0"
  22280. BGCOLOR="#E0E0E0"
  22281. CELLPADDING="5"
  22282. ><TR
  22283. ><TD
  22284. ><PRE
  22285. CLASS="php"
  22286. ><?php
  22287. echo "<h3>Post-Inkrement</h3>";
  22288. $a = 5;
  22289. echo "Sollte 5 sein: " . $a++ . "<br />\n";
  22290. echo "Sollte 6 sein: " . $a . "<br />\n";
  22291.  
  22292. echo "<h3>Pre-Inkrement</h3>";
  22293. $a = 5;
  22294. echo "Sollte 6 sein: " . ++$a . "<br />\n";
  22295. echo "Sollte 6 sein: " . $a . "<br />\n";
  22296.  
  22297. echo "<h3>Post-Dekrement</h3>";
  22298. $a = 5;
  22299. echo "Sollte 5 sein: " . $a-- . "<br />\n";
  22300. echo "Sollte 4 sein: " . $a . "<br />\n";
  22301.  
  22302. echo "<h3>Pre-Dekrement</h3>";
  22303. $a = 5;
  22304. echo "Sollte 4 sein: " . --$a . "<br />\n";
  22305. echo "Sollte 4 sein: " . $a . "<br />\n";
  22306. ?></PRE
  22307. ></TD
  22308. ></TR
  22309. ></TABLE
  22310. ><P
  22311. ></P
  22312. ></DIV
  22313. >
  22314.    </P
  22315. ><P
  22316. >     PHP folgt bei der Behandlung arithmetischer Operationen an
  22317.     Zeichenvariablen der Perl-Konvention und nicht der von C. Zum
  22318.     Beispiel wird in Perl aus 'Z'+1 'AA', wΣhrend aus 'Z'+1 in C '['
  22319.     wird ( ord('Z') == 90, ord('[') == 91 ). Beachten Sie, dass
  22320.     Zeichenvariablen zwar inkrementiert aber nicht dekrementiert
  22321.     werden k÷nnen.
  22322.     <TABLE
  22323. WIDTH="100%"
  22324. BORDER="0"
  22325. CELLPADDING="0"
  22326. CELLSPACING="0"
  22327. CLASS="EXAMPLE"
  22328. ><TR
  22329. ><TD
  22330. ><DIV
  22331. CLASS="example"
  22332. ><A
  22333. NAME="AEN4093"
  22334. ></A
  22335. ><P
  22336. ><B
  22337. >Beispiel 14-1. Arithmetrische Operationen an Zeichenvariablen</B
  22338. ></P
  22339. ><TABLE
  22340. BORDER="0"
  22341. BGCOLOR="#E0E0E0"
  22342. CELLPADDING="5"
  22343. ><TR
  22344. ><TD
  22345. ><PRE
  22346. CLASS="php"
  22347. ><?php
  22348. $i = 'W';
  22349. for($n=0; $n<6; $n++)
  22350.   echo ++$i . "\n";
  22351.  
  22352. /*
  22353.   Erzeugt in etwa folgende Ausgabe:
  22354.  
  22355. X
  22356. Y
  22357. Z
  22358. AA
  22359. AB
  22360. AC
  22361.  
  22362. */
  22363. ?></PRE
  22364. ></TD
  22365. ></TR
  22366. ></TABLE
  22367. ></DIV
  22368. ></TD
  22369. ></TR
  22370. ></TABLE
  22371. >
  22372.    </P
  22373. ></DIV
  22374. ><DIV
  22375. CLASS="sect1"
  22376. ><HR><H2
  22377. CLASS="sect1"
  22378. ><A
  22379. NAME="language.operators.logical"
  22380. >Logische Operatoren</A
  22381. ></H2
  22382. ><DIV
  22383. CLASS="table"
  22384. ><A
  22385. NAME="AEN4098"
  22386. ></A
  22387. ><P
  22388. ><B
  22389. >Tabelle 14-6. Logische Operatoren</B
  22390. ></P
  22391. ><TABLE
  22392. BORDER="1"
  22393. CLASS="CALSTABLE"
  22394. ><COL><COL><COL><THEAD
  22395. ><TR
  22396. ><TH
  22397. >Beispiel</TH
  22398. ><TH
  22399. >Name</TH
  22400. ><TH
  22401. >Ergebnis</TH
  22402. ></TR
  22403. ></THEAD
  22404. ><TBODY
  22405. ><TR
  22406. ><TD
  22407. >$a and $b</TD
  22408. ><TD
  22409. >Und</TD
  22410. ><TD
  22411. ><TT
  22412. CLASS="constant"
  22413. ><B
  22414. >TRUE</B
  22415. ></TT
  22416. > wenn sowohl $a als auch $b <TT
  22417. CLASS="constant"
  22418. ><B
  22419. >TRUE</B
  22420. ></TT
  22421. > ist.</TD
  22422. ></TR
  22423. ><TR
  22424. ><TD
  22425. >$a or $b</TD
  22426. ><TD
  22427. >Oder</TD
  22428. ><TD
  22429. ><TT
  22430. CLASS="constant"
  22431. ><B
  22432. >TRUE</B
  22433. ></TT
  22434. > wenn $a oder $b <TT
  22435. CLASS="constant"
  22436. ><B
  22437. >TRUE</B
  22438. ></TT
  22439. > ist.</TD
  22440. ></TR
  22441. ><TR
  22442. ><TD
  22443. >$a xor $b</TD
  22444. ><TD
  22445. >Entweder Oder</TD
  22446. ><TD
  22447. >         <TT
  22448. CLASS="constant"
  22449. ><B
  22450. >TRUE</B
  22451. ></TT
  22452. > wenn entweder $a oder $b <TT
  22453. CLASS="constant"
  22454. ><B
  22455. >TRUE</B
  22456. ></TT
  22457. > ist, aber nicht beide.
  22458.        </TD
  22459. ></TR
  22460. ><TR
  22461. ><TD
  22462. >! $a</TD
  22463. ><TD
  22464. >Nicht</TD
  22465. ><TD
  22466. ><TT
  22467. CLASS="constant"
  22468. ><B
  22469. >TRUE</B
  22470. ></TT
  22471. > wenn $a nicht <TT
  22472. CLASS="constant"
  22473. ><B
  22474. >TRUE</B
  22475. ></TT
  22476. > ist.</TD
  22477. ></TR
  22478. ><TR
  22479. ><TD
  22480. >$a && $b</TD
  22481. ><TD
  22482. >Und</TD
  22483. ><TD
  22484. ><TT
  22485. CLASS="constant"
  22486. ><B
  22487. >TRUE</B
  22488. ></TT
  22489. > wenn sowohl $a als auch $b <TT
  22490. CLASS="constant"
  22491. ><B
  22492. >TRUE</B
  22493. ></TT
  22494. > ist.</TD
  22495. ></TR
  22496. ><TR
  22497. ><TD
  22498. >$a || $b</TD
  22499. ><TD
  22500. >Oder</TD
  22501. ><TD
  22502. ><TT
  22503. CLASS="constant"
  22504. ><B
  22505. >TRUE</B
  22506. ></TT
  22507. > wenn $a oder $b <TT
  22508. CLASS="constant"
  22509. ><B
  22510. >TRUE</B
  22511. ></TT
  22512. > ist.</TD
  22513. ></TR
  22514. ></TBODY
  22515. ></TABLE
  22516. ></DIV
  22517. ><P
  22518. >     Der Grund dafⁿr, dass es je zwei unterschiedliche Operatoren fⁿr 
  22519.     die "Und"- und die "Oder"-Verknⁿpfung gibt ist der, dass die beiden
  22520.     Operatoren jeweils Rangfolgen haben. (siehe auch <A
  22521. HREF="#language.operators.precedence"
  22522. >Operator-Rangfolge</A
  22523. >.)
  22524.    </P
  22525. ></DIV
  22526. ><DIV
  22527. CLASS="sect1"
  22528. ><HR><H2
  22529. CLASS="sect1"
  22530. ><A
  22531. NAME="language.operators.string"
  22532. >Zeichenketten-Operatoren</A
  22533. ></H2
  22534. ><P
  22535. >     Es gibt in PHP zwei Operatoren fⁿr <A
  22536. HREF="#language.types.string"
  22537. ><B
  22538. CLASS="type"
  22539. >string</B
  22540. ></A
  22541. >
  22542.     (Zeichenkette). Der erste ist der Vereinigungs-Operator ('.'),
  22543.     dessen Rⁿckgabewert eine zusammengesetzte Zeichenkette aus dem
  22544.     rechten und dem linken Argument ist. Der zweite ist der
  22545.     Vereinigungs-Zuweisungsoperator ('.='), der das Argument auf der
  22546.     rechten Seite an das Argument der linken Seite anhΣngt. Siehe
  22547.     <A
  22548. HREF="#language.operators.assignment"
  22549. >Zuweisungs-Operatoren</A
  22550. >
  22551.     fⁿr weitere Informationen.
  22552.    </P
  22553. ><P
  22554. >     <DIV
  22555. CLASS="informalexample"
  22556. ><P
  22557. ></P
  22558. ><A
  22559. NAME="AEN4151"
  22560. ></A
  22561. ><TABLE
  22562. BORDER="0"
  22563. BGCOLOR="#E0E0E0"
  22564. CELLPADDING="5"
  22565. ><TR
  22566. ><TD
  22567. ><PRE
  22568. CLASS="php"
  22569. ><?php
  22570. $a = "Hallo ";
  22571. $b = $a . "Welt!"; // $b enthΣlt jetzt den Text "Hallo Welt!"
  22572.  
  22573. $a = "Hallo ";
  22574. $a .= "Welt!";    // $a enthΣlt jetzt den Text "Hallo Welt!"
  22575. ?></PRE
  22576. ></TD
  22577. ></TR
  22578. ></TABLE
  22579. ><P
  22580. ></P
  22581. ></DIV
  22582. >
  22583.    </P
  22584. ><P
  22585. >     Siehe auch die Abschnitte ⁿber <A
  22586. HREF="#language.types.string"
  22587. >Strings / Zeichenketten</A
  22588. > und
  22589.     <A
  22590. HREF="#ref.strings"
  22591. >String-Funktionen</A
  22592. >.
  22593.    </P
  22594. ></DIV
  22595. ><DIV
  22596. CLASS="sect1"
  22597. ><HR><H2
  22598. CLASS="sect1"
  22599. ><A
  22600. NAME="language.operators.array"
  22601. >Array Operatoren</A
  22602. ></H2
  22603. ><DIV
  22604. CLASS="table"
  22605. ><A
  22606. NAME="AEN4158"
  22607. ></A
  22608. ><P
  22609. ><B
  22610. >Tabelle 14-7. Array Operatoren</B
  22611. ></P
  22612. ><TABLE
  22613. BORDER="1"
  22614. CLASS="CALSTABLE"
  22615. ><COL><COL><COL><THEAD
  22616. ><TR
  22617. ><TH
  22618. >Beispiel</TH
  22619. ><TH
  22620. >Name</TH
  22621. ><TH
  22622. >Ergebnis</TH
  22623. ></TR
  22624. ></THEAD
  22625. ><TBODY
  22626. ><TR
  22627. ><TD
  22628. >$a + $b</TD
  22629. ><TD
  22630. >Vereinigung</TD
  22631. ><TD
  22632. >Verinigung von $a und $b.</TD
  22633. ></TR
  22634. ><TR
  22635. ><TD
  22636. >$a == $b</TD
  22637. ><TD
  22638. >Gleichwerigkeit</TD
  22639. ><TD
  22640. ><TT
  22641. CLASS="constant"
  22642. ><B
  22643. >TRUE</B
  22644. ></TT
  22645. > wenn $a und $b die gleichen Elemente enthalten.</TD
  22646. ></TR
  22647. ><TR
  22648. ><TD
  22649. >$a === $b</TD
  22650. ><TD
  22651. >IdentitΣt</TD
  22652. ><TD
  22653. >         <TT
  22654. CLASS="constant"
  22655. ><B
  22656. >TRUE</B
  22657. ></TT
  22658. > wenn $a und $b die gleichen Elemente in der gleichen
  22659.         Reihenfolge enthalten.
  22660.        </TD
  22661. ></TR
  22662. ><TR
  22663. ><TD
  22664. >$a != $b</TD
  22665. ><TD
  22666. >Ungleichheit</TD
  22667. ><TD
  22668. ><TT
  22669. CLASS="constant"
  22670. ><B
  22671. >TRUE</B
  22672. ></TT
  22673. > wenn $a nicht gleich $b ist.</TD
  22674. ></TR
  22675. ><TR
  22676. ><TD
  22677. >$a <> $b</TD
  22678. ><TD
  22679. >Ungleichheit</TD
  22680. ><TD
  22681. ><TT
  22682. CLASS="constant"
  22683. ><B
  22684. >TRUE</B
  22685. ></TT
  22686. > wenn $a nicht gleich $b ist.</TD
  22687. ></TR
  22688. ><TR
  22689. ><TD
  22690. >$a !== $b</TD
  22691. ><TD
  22692. >nicht identisch</TD
  22693. ><TD
  22694. ><TT
  22695. CLASS="constant"
  22696. ><B
  22697. >TRUE</B
  22698. ></TT
  22699. > wenn $a nicht identisch zu $b ist.</TD
  22700. ></TR
  22701. ></TBODY
  22702. ></TABLE
  22703. ></DIV
  22704. ><P
  22705. >     Der <VAR
  22706. CLASS="literal"
  22707. >+</VAR
  22708. > Operator hΣngt das rechsstehende Array an das
  22709.     linksstehende Array an, wobei doppelte Schlⁿssel NICHT ⁿberschrieben
  22710.     werden.
  22711.    </P
  22712. ><P
  22713. >     <DIV
  22714. CLASS="informalexample"
  22715. ><P
  22716. ></P
  22717. ><A
  22718. NAME="AEN4199"
  22719. ></A
  22720. ><TABLE
  22721. BORDER="0"
  22722. BGCOLOR="#E0E0E0"
  22723. CELLPADDING="5"
  22724. ><TR
  22725. ><TD
  22726. ><PRE
  22727. CLASS="php"
  22728. ><?php
  22729. $a = array("a" => "Apfel", "b" => "Banane");
  22730. $b = array("a" =>"pear", "b" => "Erdbeere", "c" => "Kirsche");
  22731.  
  22732. $c = $a + $b; // Verinigung von $a mit $b;
  22733. echo "Vereinigung von \$a mit \$b: \n";
  22734. var_dump($c);
  22735.  
  22736. $c = $b + $a; // Vereinigung von $b mit $a;
  22737. echo "Vereinigung von \$b mit \$a: \n";
  22738. var_dump($c);
  22739. ?></PRE
  22740. ></TD
  22741. ></TR
  22742. ></TABLE
  22743. ><P
  22744. ></P
  22745. ></DIV
  22746. >
  22747.     Dieses Skript gibt folgendes aus:
  22748.     <TABLE
  22749. BORDER="0"
  22750. BGCOLOR="#E0E0E0"
  22751. CELLPADDING="5"
  22752. ><TR
  22753. ><TD
  22754. ><PRE
  22755. CLASS="php"
  22756. >Vereinigung von $a mit $b:
  22757. array(3) {
  22758.   ["a"]=>
  22759.   string(5) "Apfel"
  22760.   ["b"]=>
  22761.   string(6) "Banane"
  22762.   ["c"]=>
  22763.   string(7) "Kirsche"
  22764. }
  22765. Vereinigung von $b mit $a:
  22766. array(3) {
  22767.   ["a"]=>
  22768.   string(4) "pear"
  22769.   ["b"]=>
  22770.   string(8) "Erdbeere"
  22771.   ["c"]=>
  22772.   string(7) "Kirsche"
  22773. }</PRE
  22774. ></TD
  22775. ></TR
  22776. ></TABLE
  22777. >
  22778.    </P
  22779. ><P
  22780. >     Beim Vergleich werden Arrayelemente als gleich angesehen, wenn diese
  22781.     dieselben Schlⁿssel und Werte beinhalten.
  22782.    </P
  22783. ><P
  22784. >     <TABLE
  22785. WIDTH="100%"
  22786. BORDER="0"
  22787. CELLPADDING="0"
  22788. CELLSPACING="0"
  22789. CLASS="EXAMPLE"
  22790. ><TR
  22791. ><TD
  22792. ><DIV
  22793. CLASS="example"
  22794. ><A
  22795. NAME="AEN4204"
  22796. ></A
  22797. ><P
  22798. ><B
  22799. >Beispiel 14-2. Array Vergleiche</B
  22800. ></P
  22801. ><TABLE
  22802. BORDER="0"
  22803. BGCOLOR="#E0E0E0"
  22804. CELLPADDING="5"
  22805. ><TR
  22806. ><TD
  22807. ><PRE
  22808. CLASS="php"
  22809. ><?php
  22810. $a = array("a" => "Apfel", "b" => "Banane");
  22811. $b = array(1 => "Banane", "0" => "Apfel");
  22812.  
  22813. var_dump($a == $b); // bool(true)
  22814. var_dump($a === $b); // bool(false)
  22815. ?></PRE
  22816. ></TD
  22817. ></TR
  22818. ></TABLE
  22819. ></DIV
  22820. ></TD
  22821. ></TR
  22822. ></TABLE
  22823. >
  22824.    </P
  22825. ><P
  22826. >     Siehe auch die Abschnitte ⁿber <A
  22827. HREF="#language.types.array"
  22828. >Arrays</A
  22829. > und <A
  22830. HREF="#ref.array"
  22831. >Array Funktionen</A
  22832. >.
  22833.    </P
  22834. ></DIV
  22835. ><DIV
  22836. CLASS="sect1"
  22837. ><HR><H2
  22838. CLASS="sect1"
  22839. ><A
  22840. NAME="language.operators.type"
  22841. >Typ Operatoren</A
  22842. ></H2
  22843. ><P
  22844. >     In PHP gibt es einen einzigen Typ Operator: <VAR
  22845. CLASS="literal"
  22846. >instanceof</VAR
  22847. >.
  22848.     <VAR
  22849. CLASS="literal"
  22850. >instanceof</VAR
  22851. > wird dazu verwendet um festzustellen, ob ein
  22852.     gegebenes Objekt ein Objekt ist, das zu einer bestimmten
  22853.     <A
  22854. HREF="#language.oop"
  22855. >Klasse</A
  22856. > geh÷rt.
  22857.    </P
  22858. ><P
  22859. >     <VAR
  22860. CLASS="literal"
  22861. >instanceof</VAR
  22862. > wurde in PHP 5 eingefⁿhrt. Vorher wurde <A
  22863. HREF="#function.is-a"
  22864. ><B
  22865. CLASS="function"
  22866. >is_a()</B
  22867. ></A
  22868. >
  22869.     benutzt, aber <A
  22870. HREF="#function.is-a"
  22871. ><B
  22872. CLASS="function"
  22873. >is_a()</B
  22874. ></A
  22875. > ist veraltet und <VAR
  22876. CLASS="literal"
  22877. >instanceof</VAR
  22878. > sollte
  22879.     stattdessen benutzt werden.
  22880.    </P
  22881. ><DIV
  22882. CLASS="informalexample"
  22883. ><P
  22884. ></P
  22885. ><A
  22886. NAME="AEN4221"
  22887. ></A
  22888. ><TABLE
  22889. BORDER="0"
  22890. BGCOLOR="#E0E0E0"
  22891. CELLPADDING="5"
  22892. ><TR
  22893. ><TD
  22894. ><PRE
  22895. CLASS="programlisting"
  22896. ><?php
  22897. class A { }
  22898. class B { }
  22899.  
  22900. $ding = new A;
  22901.  
  22902. if ($ding instanceof A) {
  22903.     echo 'A';
  22904. }
  22905. if ($ding instanceof B) {
  22906.     echo 'B';
  22907. }
  22908. ?></PRE
  22909. ></TD
  22910. ></TR
  22911. ></TABLE
  22912. ><P
  22913. >      Da <VAR
  22914. CLASS="varname"
  22915. >$ding</VAR
  22916. > ein <A
  22917. HREF="#language.types.object"
  22918. ><B
  22919. CLASS="type"
  22920. >object</B
  22921. ></A
  22922. > vom Typ A und nicht
  22923.      von B ist, wird nur der Programmblock ausgefⁿhrt, der abhΣngig von Typ A ist:
  22924.     </P
  22925. ><TABLE
  22926. BORDER="0"
  22927. BGCOLOR="#E0E0E0"
  22928. CELLPADDING="5"
  22929. ><TR
  22930. ><TD
  22931. ><PRE
  22932. CLASS="screen"
  22933. >A</PRE
  22934. ></TD
  22935. ></TR
  22936. ></TABLE
  22937. ><P
  22938. ></P
  22939. ></DIV
  22940. ><P
  22941. >     See auch <A
  22942. HREF="#function.get-class"
  22943. ><B
  22944. CLASS="function"
  22945. >get_class()</B
  22946. ></A
  22947. > und 
  22948.     <A
  22949. HREF="#function.is-a"
  22950. ><B
  22951. CLASS="function"
  22952. >is_a()</B
  22953. ></A
  22954. >.
  22955.    </P
  22956. ></DIV
  22957. ></DIV
  22958. ><DIV
  22959. CLASS="chapter"
  22960. ><HR><H1
  22961. ><A
  22962. NAME="language.control-structures"
  22963. >Kapitel 15. Kontroll-Strukturen</A
  22964. ></H1
  22965. ><P
  22966. >    Jedes PHP-Skript besteht aus einer Reihe von Anweisungen. Eine Anweisung
  22967.    kann eine Zuweisung, ein Funktionsaufruf, eine Schleife, eine bedingte
  22968.    Anweisung oder ein Befehl sein, der nichts macht (eine leere Anweisung). 
  22969.    Jede Anweisung endet gew÷hnlich mit einem Semikolon. Darⁿber hinaus k÷nnen Anweisungen zu einer
  22970.    Anweisungsgruppe zusammengefasst werden, welche durch geschweifte Klammern
  22971.    begrenzt wird. Eine Anweisungsgruppe selbst ist auch wieder eine Anweisung.
  22972.    Die unterschiedlichen Arten von Anweisungen werden in diesem Kapitel
  22973.    erlΣutert.
  22974.   </P
  22975. ><DIV
  22976. CLASS="sect1"
  22977. ><HR><H2
  22978. CLASS="sect1"
  22979. ><A
  22980. NAME="control-structures.if"
  22981. ><VAR
  22982. CLASS="literal"
  22983. >if</VAR
  22984. ></A
  22985. ></H2
  22986. ><P
  22987. >     Das <VAR
  22988. CLASS="literal"
  22989. >if</VAR
  22990. >-Konstrukt ist eine der wichtigsten M÷glichkeiten
  22991.     vieler Programmier-Sprachen, PHP eingeschlossen. Es erlaubt die bedingte
  22992.     Ausfⁿhrung von Programmteilen. PHP kennt eine <VAR
  22993. CLASS="literal"
  22994. >if</VAR
  22995. >
  22996.     -Struktur, die Σhnlich wie in der Programmiersprache C implementiert ist:
  22997.     <DIV
  22998. CLASS="informalexample"
  22999. ><P
  23000. ></P
  23001. ><A
  23002. NAME="AEN4239"
  23003. ></A
  23004. ><TABLE
  23005. BORDER="0"
  23006. BGCOLOR="#E0E0E0"
  23007. CELLPADDING="5"
  23008. ><TR
  23009. ><TD
  23010. ><PRE
  23011. CLASS="programlisting"
  23012. ><?php
  23013.   if (ausdr)
  23014.     Anweisung
  23015. ?></PRE
  23016. ></TD
  23017. ></TR
  23018. ></TABLE
  23019. ><P
  23020. ></P
  23021. ></DIV
  23022. >
  23023.    </P
  23024. ><P
  23025. >     Wie im Abschnitt ⁿber
  23026.     <A
  23027. HREF="#language.expressions"
  23028. >Ausdrⁿcke</A
  23029. > beschrieben,
  23030.     wird <VAR
  23031. CLASS="replaceable"
  23032. >ausdr</VAR
  23033. > auf seinen boolschen Wertinhalt
  23034.     ausgewertet. Wenn <VAR
  23035. CLASS="replaceable"
  23036. >ausdr</VAR
  23037. > als <TT
  23038. CLASS="constant"
  23039. ><B
  23040. >TRUE</B
  23041. ></TT
  23042. > ausgewertet
  23043.     wird, fⁿhrt PHP die <VAR
  23044. CLASS="replaceable"
  23045. >Anweisung</VAR
  23046. > aus. Falls die
  23047.     Auswertung <TT
  23048. CLASS="constant"
  23049. ><B
  23050. >FALSE</B
  23051. ></TT
  23052. > ergibt, wird die <VAR
  23053. CLASS="replaceable"
  23054. >Anweisung</VAR
  23055. >
  23056.     ⁿbergangen. Mehr Informationen drⁿber welche Werte als <TT
  23057. CLASS="constant"
  23058. ><B
  23059. >FALSE</B
  23060. ></TT
  23061. > ausgewertet
  23062.     werden finden Sie im Abschnitt
  23063.     <A
  23064. HREF="#language.types.boolean.casting"
  23065. >'Umwandlung nach boolean'</A
  23066. >.
  23067.    </P
  23068. ><P
  23069. >     Das folgende Beispiel wird <SAMP
  23070. CLASS="computeroutput"
  23071. >a ist gr÷▀er als b
  23072.     </SAMP
  23073. >anzeigen, wenn <VAR
  23074. CLASS="varname"
  23075. >$a</VAR
  23076. > gr÷▀er als
  23077.     <VAR
  23078. CLASS="varname"
  23079. >$b</VAR
  23080. > ist:
  23081.     <DIV
  23082. CLASS="informalexample"
  23083. ><P
  23084. ></P
  23085. ><A
  23086. NAME="AEN4255"
  23087. ></A
  23088. ><TABLE
  23089. BORDER="0"
  23090. BGCOLOR="#E0E0E0"
  23091. CELLPADDING="5"
  23092. ><TR
  23093. ><TD
  23094. ><PRE
  23095. CLASS="php"
  23096. ><?php
  23097. if ($a > $b)
  23098.     echo "a ist gr÷▀er als b";
  23099. ?></PRE
  23100. ></TD
  23101. ></TR
  23102. ></TABLE
  23103. ><P
  23104. ></P
  23105. ></DIV
  23106. >
  23107.    </P
  23108. ><P
  23109. >     Oft werden Sie die bedingte Ausfⁿhrung von mehr als einer
  23110.     Anweisung wollen. SelbstverstΣndlich ist es nicht erforderlich,
  23111.     jede Anweisung mit einer <VAR
  23112. CLASS="literal"
  23113. >if</VAR
  23114. >-Bedingung zu
  23115.     versehen. Statt dessen k÷nnen Sie mehrere Anweisungen in Gruppen
  23116.     zusammenfassen. Der folgende Programm-Code wird zum Beispiel
  23117.     <SAMP
  23118. CLASS="computeroutput"
  23119. >a ist gr÷▀er als b</SAMP
  23120. > anzeigen,
  23121.     wenn <VAR
  23122. CLASS="varname"
  23123. >$a</VAR
  23124. > gr÷▀er als <VAR
  23125. CLASS="varname"
  23126. >$b</VAR
  23127. > ist und
  23128.     danach wird der Wert von <VAR
  23129. CLASS="varname"
  23130. >$a</VAR
  23131. > in <VAR
  23132. CLASS="varname"
  23133. >$b</VAR
  23134. >
  23135.     gespeichert:
  23136.     <DIV
  23137. CLASS="informalexample"
  23138. ><P
  23139. ></P
  23140. ><A
  23141. NAME="AEN4264"
  23142. ></A
  23143. ><TABLE
  23144. BORDER="0"
  23145. BGCOLOR="#E0E0E0"
  23146. CELLPADDING="5"
  23147. ><TR
  23148. ><TD
  23149. ><PRE
  23150. CLASS="php"
  23151. ><?php
  23152. if ($a > $b) {
  23153.     print "a ist gr÷▀er als b";
  23154.     $b = $a;
  23155. }
  23156. ?></PRE
  23157. ></TD
  23158. ></TR
  23159. ></TABLE
  23160. ><P
  23161. ></P
  23162. ></DIV
  23163. >
  23164.    </P
  23165. ><P
  23166. >     <VAR
  23167. CLASS="literal"
  23168. >if</VAR
  23169. >-Anweisungen k÷nnen beliebig oft innerhalb anderer
  23170.     <VAR
  23171. CLASS="literal"
  23172. >if</VAR
  23173. >-Anweisungen definiert werden. Das erm÷glicht
  23174.     ihnen v÷llige FlexibilitΣt bei der bedingten Ausfⁿhrung verschiedenster
  23175.     Programmteile.
  23176.    </P
  23177. ></DIV
  23178. ><DIV
  23179. CLASS="sect1"
  23180. ><HR><H2
  23181. CLASS="sect1"
  23182. ><A
  23183. NAME="control-structures.else"
  23184. ><VAR
  23185. CLASS="literal"
  23186. >else</VAR
  23187. ></A
  23188. ></H2
  23189. ><P
  23190. >     HΣufig m÷chten Sie eine Anweisung auszufⁿhren, wenn eine
  23191.     bestimmte Bedingung erfⁿllt ist und eine andere Anweisung, falls
  23192.     sie nicht erfⁿllt ist. Dafⁿr gibt es <VAR
  23193. CLASS="literal"
  23194. >else</VAR
  23195. >.
  23196.     <VAR
  23197. CLASS="literal"
  23198. >else</VAR
  23199. > erweitert eine <VAR
  23200. CLASS="literal"
  23201. >if</VAR
  23202. >-Anweisung um
  23203.     die Ausfⁿhrung von Anweisungen, sobald der Ausdruck der
  23204.     <VAR
  23205. CLASS="literal"
  23206. >if</VAR
  23207. >-Anweisung als <TT
  23208. CLASS="constant"
  23209. ><B
  23210. >FALSE</B
  23211. ></TT
  23212. > ausgewertet wird. Der folgende
  23213.     Code wird z.B. <SAMP
  23214. CLASS="computeroutput"
  23215. >a ist gr÷▀er als b</SAMP
  23216. >
  23217.     ausgeben, wenn <VAR
  23218. CLASS="varname"
  23219. >$a</VAR
  23220. > gr÷▀er als <VAR
  23221. CLASS="varname"
  23222. >$b</VAR
  23223. > ist,
  23224.     anderenfalls <SAMP
  23225. CLASS="computeroutput"
  23226. >a ist NICHT gr÷▀er als b</SAMP
  23227. >:
  23228.     <DIV
  23229. CLASS="informalexample"
  23230. ><P
  23231. ></P
  23232. ><A
  23233. NAME="AEN4282"
  23234. ></A
  23235. ><TABLE
  23236. BORDER="0"
  23237. BGCOLOR="#E0E0E0"
  23238. CELLPADDING="5"
  23239. ><TR
  23240. ><TD
  23241. ><PRE
  23242. CLASS="php"
  23243. ><?php
  23244. if ($a > $b) {
  23245.     print "a ist gr÷▀er als b";
  23246. } else {
  23247.     print "a ist NICHT gr÷▀er als b";
  23248. }
  23249. ?></PRE
  23250. ></TD
  23251. ></TR
  23252. ></TABLE
  23253. ><P
  23254. ></P
  23255. ></DIV
  23256. >
  23257.     Die <VAR
  23258. CLASS="literal"
  23259. >else</VAR
  23260. >-Anweisung wird nur ausgefⁿhrt, wenn
  23261.     der <VAR
  23262. CLASS="literal"
  23263. >if</VAR
  23264. >-Ausdruck als <TT
  23265. CLASS="constant"
  23266. ><B
  23267. >FALSE</B
  23268. ></TT
  23269. >
  23270.     ausgewertet wurde und wenn bei vorhandenen
  23271.     <VAR
  23272. CLASS="literal"
  23273. >elseif</VAR
  23274. >-Ausdrⁿcken diese ebenfalls
  23275.     <TT
  23276. CLASS="constant"
  23277. ><B
  23278. >FALSE</B
  23279. ></TT
  23280. > sind (siehe <A
  23281. HREF="#control-structures.elseif"
  23282. >elseif</A
  23283. >).
  23284.    </P
  23285. ></DIV
  23286. ><DIV
  23287. CLASS="sect1"
  23288. ><HR><H2
  23289. CLASS="sect1"
  23290. ><A
  23291. NAME="control-structures.elseif"
  23292. ><VAR
  23293. CLASS="literal"
  23294. >elseif</VAR
  23295. ></A
  23296. ></H2
  23297. ><P
  23298. >     Wie der Name schon sagt ist <VAR
  23299. CLASS="literal"
  23300. >elseif</VAR
  23301. > eine
  23302.     Verbindung von <VAR
  23303. CLASS="literal"
  23304. >if</VAR
  23305. > und <VAR
  23306. CLASS="literal"
  23307. >else</VAR
  23308. >.
  23309.     Wie <VAR
  23310. CLASS="literal"
  23311. >else</VAR
  23312. > erweitert sie eine
  23313.     <VAR
  23314. CLASS="literal"
  23315. >if</VAR
  23316. >-Anweisung um die Ausfⁿhrung anderer Anweisungen,
  23317.     sobald die normale <VAR
  23318. CLASS="literal"
  23319. >if</VAR
  23320. >-Bedingung als <TT
  23321. CLASS="constant"
  23322. ><B
  23323. >FALSE</B
  23324. ></TT
  23325. > ausgewertet
  23326.     wird. Anders als bei <VAR
  23327. CLASS="literal"
  23328. >else</VAR
  23329. > wird die Ausfⁿhrung dieser alternativen
  23330.     Anweisungen nur durchgefⁿhrt, wenn die bei <VAR
  23331. CLASS="literal"
  23332. >elseif</VAR
  23333. >
  23334.     angegebene alternative Bedingung als <TT
  23335. CLASS="constant"
  23336. ><B
  23337. >TRUE</B
  23338. ></TT
  23339. > ausgewertet wird. Der folgende
  23340.     Code wird z.B. <SAMP
  23341. CLASS="computeroutput"
  23342. >a ist gr÷▀er als b</SAMP
  23343. >,
  23344.     <SAMP
  23345. CLASS="computeroutput"
  23346. >a ist gleich b</SAMP
  23347. > oder
  23348.     <SAMP
  23349. CLASS="computeroutput"
  23350. >a ist kleiner als b</SAMP
  23351. > ausgeben:
  23352.     <DIV
  23353. CLASS="informalexample"
  23354. ><P
  23355. ></P
  23356. ><A
  23357. NAME="AEN4307"
  23358. ></A
  23359. ><TABLE
  23360. BORDER="0"
  23361. BGCOLOR="#E0E0E0"
  23362. CELLPADDING="5"
  23363. ><TR
  23364. ><TD
  23365. ><PRE
  23366. CLASS="php"
  23367. ><?php
  23368. if ($a > $b) {
  23369.     echo "a ist gr÷▀er als b";
  23370. } elseif ($a == $b) {
  23371.     echo "a ist gleich b";
  23372. } else {
  23373.     echo "a ist kleiner als b";
  23374. }
  23375. ?></PRE
  23376. ></TD
  23377. ></TR
  23378. ></TABLE
  23379. ><P
  23380. ></P
  23381. ></DIV
  23382. >
  23383.    </P
  23384. ><P
  23385. >     Es kann mehrere <VAR
  23386. CLASS="literal"
  23387. >elseif</VAR
  23388. >-Anweisungen innerhalb
  23389.     einer <VAR
  23390. CLASS="literal"
  23391. >if</VAR
  23392. >-Anweisung geben. Die erste
  23393.     <VAR
  23394. CLASS="literal"
  23395. >elseif</VAR
  23396. >-Bedingung (falls vorhanden), die <TT
  23397. CLASS="constant"
  23398. ><B
  23399. >TRUE</B
  23400. ></TT
  23401. > ist,
  23402.     wird ausgefⁿhrt. In PHP kann man auch 'else if' schreiben (zwei W÷rter).
  23403.     Das Verhalten ist identisch zu 'elseif' (ein Wort). Die Bedeutung der
  23404.     Syntax ist leicht unterschiedlich (falls Sie mit C vertraut sind, das ist
  23405.     das gleiche Verhalten) aber der Grundtenor ist der, dass beide
  23406.     Schreibweisen, bezogen auf das Ergebnis, sich exakt gleich verhalten.
  23407.    </P
  23408. ><P
  23409. >     Die <VAR
  23410. CLASS="literal"
  23411. >elseif</VAR
  23412. >-Anweisung wird nur ausgefⁿhrt, wenn die
  23413.     vorausgehende <VAR
  23414. CLASS="literal"
  23415. >if</VAR
  23416. >-Bedingung sowie jede vorherige
  23417.     <VAR
  23418. CLASS="literal"
  23419. >elseif</VAR
  23420. >-Bedingung als <TT
  23421. CLASS="constant"
  23422. ><B
  23423. >FALSE</B
  23424. ></TT
  23425. > ausgewertet wird und die
  23426.     aktuelle <VAR
  23427. CLASS="literal"
  23428. >elseif</VAR
  23429. >-Bedingung <TT
  23430. CLASS="constant"
  23431. ><B
  23432. >TRUE</B
  23433. ></TT
  23434. > ist.
  23435.    </P
  23436. ></DIV
  23437. ><DIV
  23438. CLASS="sect1"
  23439. ><HR><H2
  23440. CLASS="sect1"
  23441. ><A
  23442. NAME="control-structures.alternative-syntax"
  23443. >Alternative Syntax fⁿr Kontroll-Strukturen</A
  23444. ></H2
  23445. ><P
  23446. >     PHP bietet eine alternative Syntax fⁿr einige seiner Kontroll-Strukturen,
  23447.     als da sind <VAR
  23448. CLASS="literal"
  23449. >if</VAR
  23450. >, <VAR
  23451. CLASS="literal"
  23452. >while</VAR
  23453. >,
  23454.     <VAR
  23455. CLASS="literal"
  23456. >for</VAR
  23457. >, <VAR
  23458. CLASS="literal"
  23459. >foreach</VAR
  23460. > und
  23461.     <VAR
  23462. CLASS="literal"
  23463. >switch</VAR
  23464. >. Die ÷ffnende Klammer muss immer durch einen
  23465.     Doppelpunkt ":" und die schlie▀ende Klammer entsprechend durch
  23466.     <VAR
  23467. CLASS="literal"
  23468. >endif;</VAR
  23469. >, <VAR
  23470. CLASS="literal"
  23471. >endwhile;</VAR
  23472. >,
  23473.     <VAR
  23474. CLASS="literal"
  23475. >endfor;</VAR
  23476. >, <VAR
  23477. CLASS="literal"
  23478. >endforeach;</VAR
  23479. >
  23480.     oder <VAR
  23481. CLASS="literal"
  23482. >endswitch;</VAR
  23483. > ersetzt werden.
  23484.     <DIV
  23485. CLASS="informalexample"
  23486. ><P
  23487. ></P
  23488. ><A
  23489. NAME="AEN4334"
  23490. ></A
  23491. ><TABLE
  23492. BORDER="0"
  23493. BGCOLOR="#E0E0E0"
  23494. CELLPADDING="5"
  23495. ><TR
  23496. ><TD
  23497. ><PRE
  23498. CLASS="php"
  23499. ><?php if ($a == 5): ?>
  23500. A ist gleich 5
  23501. <?php endif; ?></PRE
  23502. ></TD
  23503. ></TR
  23504. ></TABLE
  23505. ><P
  23506. ></P
  23507. ></DIV
  23508. >
  23509.    </P
  23510. ><P
  23511. >     Im obigen Beispiel ist der HTML-Bereich "A ist gleich 5" in eine
  23512.     <VAR
  23513. CLASS="literal"
  23514. >if</VAR
  23515. >-Anweisung mit alternativer Syntax eingebettet. Der
  23516.     HTML-Bereich wird nur ausgegeben, wenn <VAR
  23517. CLASS="varname"
  23518. >$a</VAR
  23519. > gleich 5 ist.
  23520.    </P
  23521. ><P
  23522. >     Die alternative Syntax kann auch auf <VAR
  23523. CLASS="literal"
  23524. >else</VAR
  23525. > und
  23526.     <VAR
  23527. CLASS="literal"
  23528. >elseif</VAR
  23529. > angewendet werden. Es folgt eine
  23530.     <VAR
  23531. CLASS="literal"
  23532. >if</VAR
  23533. >-Struktur mit <VAR
  23534. CLASS="literal"
  23535. >elseif</VAR
  23536. >
  23537.     und <VAR
  23538. CLASS="literal"
  23539. >else</VAR
  23540. > im alternativen Format:
  23541.     <DIV
  23542. CLASS="informalexample"
  23543. ><P
  23544. ></P
  23545. ><A
  23546. NAME="AEN4345"
  23547. ></A
  23548. ><TABLE
  23549. BORDER="0"
  23550. BGCOLOR="#E0E0E0"
  23551. CELLPADDING="5"
  23552. ><TR
  23553. ><TD
  23554. ><PRE
  23555. CLASS="php"
  23556. ><?php
  23557. if ($a == 5):
  23558.     echo "a ist gleich 5";
  23559.     echo "...";
  23560. elseif ($a == 6):
  23561.     echo "a ist gleich 6";
  23562.     echo "!!!";
  23563. else:
  23564.     echo "a ist weder 5 noch 6";
  23565. endif;
  23566. ?></PRE
  23567. ></TD
  23568. ></TR
  23569. ></TABLE
  23570. ><P
  23571. ></P
  23572. ></DIV
  23573. >
  23574.    </P
  23575. ><P
  23576. >     Siehe auch <A
  23577. HREF="#control-structures.while"
  23578. >while</A
  23579. >,
  23580.     <A
  23581. HREF="#control-structures.for"
  23582. >for</A
  23583. > und <A
  23584. HREF="#control-structures.if"
  23585. >if</A
  23586. > fⁿr weitere Beispiele.
  23587.    </P
  23588. ></DIV
  23589. ><DIV
  23590. CLASS="sect1"
  23591. ><HR><H2
  23592. CLASS="sect1"
  23593. ><A
  23594. NAME="control-structures.while"
  23595. ><VAR
  23596. CLASS="literal"
  23597. >while</VAR
  23598. ></A
  23599. ></H2
  23600. ><P
  23601. >     Die <VAR
  23602. CLASS="literal"
  23603. >while</VAR
  23604. >-Schleifen sind die einfachste Form von
  23605.     Schleifen in PHP. Sie funktionieren genau wie in C. Die Grundform einer
  23606.     <VAR
  23607. CLASS="literal"
  23608. >while</VAR
  23609. >-Anweisung lautet:
  23610.     <DIV
  23611. CLASS="informalexample"
  23612. ><P
  23613. ></P
  23614. ><A
  23615. NAME="AEN4357"
  23616. ></A
  23617. ><TABLE
  23618. BORDER="0"
  23619. BGCOLOR="#E0E0E0"
  23620. CELLPADDING="5"
  23621. ><TR
  23622. ><TD
  23623. ><PRE
  23624. CLASS="programlisting"
  23625. >while (ausdr) Anweisung</PRE
  23626. ></TD
  23627. ></TR
  23628. ></TABLE
  23629. ><P
  23630. ></P
  23631. ></DIV
  23632. >
  23633.    </P
  23634. ><P
  23635. >     Die Bedeutung einer <VAR
  23636. CLASS="literal"
  23637. >while</VAR
  23638. >-Anweisung ist einfach.
  23639.     Sie weist PHP an, einen in ihr eingebetteten Befehl so lange zu
  23640.     wiederholen, wie die <VAR
  23641. CLASS="literal"
  23642. >while</VAR
  23643. >-Bedingung als <TT
  23644. CLASS="constant"
  23645. ><B
  23646. >TRUE</B
  23647. ></TT
  23648. >
  23649.     ausgewertet wird. Der Wert der Bedingung wird immer am Anfang der
  23650.     Schleife geprⁿft. Wird der Wert wΣhrend der Ausfⁿhrung der Anweisungen
  23651.     innerhalb der <VAR
  23652. CLASS="literal"
  23653. >while</VAR
  23654. >-Schleife verΣndert, endet die
  23655.     Ausfⁿhrung dieses Anweisungsblocks erst mit dem Ende der Iteration
  23656.     (Jeder Schleifendurchlauf ist eine Iteration). Falls die
  23657.     <VAR
  23658. CLASS="literal"
  23659. >while</VAR
  23660. >-Bedingung bereits beim ersten Mal <TT
  23661. CLASS="constant"
  23662. ><B
  23663. >FALSE</B
  23664. ></TT
  23665. > ist,
  23666.     werden die Anweisungen der <VAR
  23667. CLASS="literal"
  23668. >while</VAR
  23669. >-Schleife nicht ein
  23670.     einziges Mal durchlaufen.
  23671.    </P
  23672. ><P
  23673. >     Wie bei der <VAR
  23674. CLASS="literal"
  23675. >if</VAR
  23676. >-Anweisung k÷nnen Sie mehrere
  23677.     Anweisungen innerhalb der gleichen <VAR
  23678. CLASS="literal"
  23679. >while</VAR
  23680. >-Schleife
  23681.     angeben, indem Sie dieses mit geschweiften Klammern umschlie▀en oder die
  23682.     alternative Syntax verwenden:
  23683.     <DIV
  23684. CLASS="informalexample"
  23685. ><P
  23686. ></P
  23687. ><A
  23688. NAME="AEN4370"
  23689. ></A
  23690. ><TABLE
  23691. BORDER="0"
  23692. BGCOLOR="#E0E0E0"
  23693. CELLPADDING="5"
  23694. ><TR
  23695. ><TD
  23696. ><PRE
  23697. CLASS="programlisting"
  23698. >while (ausdr): Anweisung ... endwhile;</PRE
  23699. ></TD
  23700. ></TR
  23701. ></TABLE
  23702. ><P
  23703. ></P
  23704. ></DIV
  23705. >
  23706.    </P
  23707. ><P
  23708. >     Die folgenden Beispiele sind identisch; beide geben Zahlen von
  23709.     1 bis 10 aus:
  23710.     <DIV
  23711. CLASS="informalexample"
  23712. ><P
  23713. ></P
  23714. ><A
  23715. NAME="AEN4373"
  23716. ></A
  23717. ><TABLE
  23718. BORDER="0"
  23719. BGCOLOR="#E0E0E0"
  23720. CELLPADDING="5"
  23721. ><TR
  23722. ><TD
  23723. ><PRE
  23724. CLASS="programlisting"
  23725. >/* Beispiel 1 */
  23726.  
  23727. $i = 1;
  23728. while ($i <= 10) {
  23729.     echo $i++;  /* es wird erst $i ausgegeben, bevor der Wert erh÷ht wird
  23730.                   (Post-Inkrement) */
  23731. }
  23732.  
  23733. /* Beispiel 2 */
  23734.  
  23735. $i = 1;
  23736. while ($i <= 10):
  23737.     echo $i;
  23738.     $i++;
  23739. endwhile;</PRE
  23740. ></TD
  23741. ></TR
  23742. ></TABLE
  23743. ><P
  23744. ></P
  23745. ></DIV
  23746. >
  23747.    </P
  23748. ></DIV
  23749. ><DIV
  23750. CLASS="sect1"
  23751. ><HR><H2
  23752. CLASS="sect1"
  23753. ><A
  23754. NAME="control-structures.do.while"
  23755. ><VAR
  23756. CLASS="literal"
  23757. >do..while</VAR
  23758. ></A
  23759. ></H2
  23760. ><P
  23761. >     <VAR
  23762. CLASS="literal"
  23763. >do..while</VAR
  23764. >-Schleifen sind den <VAR
  23765. CLASS="literal"
  23766. >while</VAR
  23767. >
  23768.     -Schleifen sehr Σhnlich, au▀er dass der Wahrheitsgehalt des Ausdrucks erst
  23769.     am Ende jedes Durchlaufs geprⁿft wird, statt am Anfang. Der Hauptunterschied
  23770.     zu gew÷hnlichen <VAR
  23771. CLASS="literal"
  23772. >while</VAR
  23773. >-Schleifen ist der, dass die Schleife
  23774.     bei <VAR
  23775. CLASS="literal"
  23776. >do..while</VAR
  23777. > in jeden Fall einmal durchlaufen wird
  23778.     (die Bedingung wird erst am Ende eines Durchlaufs geprⁿft).Bei
  23779.     <VAR
  23780. CLASS="literal"
  23781. >while</VAR
  23782. >-Schleifen hingegen kann es durchaus passieren,
  23783.     dass die Schleife nie durchlaufen wird (die Bedingung wird immer am Anfang
  23784.     eines Durchlaufs ⁿberprⁿft. Wird diese Bedingung von Anfang an als <TT
  23785. CLASS="constant"
  23786. ><B
  23787. >FALSE</B
  23788. ></TT
  23789. >
  23790.     ausgewertet endet die Ausfⁿhrung der Schleife sofort).
  23791.    </P
  23792. ><P
  23793. >     Es gibt nur eine Syntax fⁿr <VAR
  23794. CLASS="literal"
  23795. >do..while</VAR
  23796. >-Schleifen:
  23797.     <DIV
  23798. CLASS="informalexample"
  23799. ><P
  23800. ></P
  23801. ><A
  23802. NAME="AEN4387"
  23803. ></A
  23804. ><TABLE
  23805. BORDER="0"
  23806. BGCOLOR="#E0E0E0"
  23807. CELLPADDING="5"
  23808. ><TR
  23809. ><TD
  23810. ><PRE
  23811. CLASS="php"
  23812. ><?php
  23813. $i = 0;
  23814. do {
  23815.     echo $i;
  23816. } while ($i>0);
  23817. ?></PRE
  23818. ></TD
  23819. ></TR
  23820. ></TABLE
  23821. ><P
  23822. ></P
  23823. ></DIV
  23824. >
  23825.    </P
  23826. ><P
  23827. >     Die obige Schleife wird genau einmal durchlaufen, da nach der
  23828.     ersten Wiederholung die Erfⁿllung der Bedingung geprⁿft wird. Diese
  23829.     Bedingung ist aber nicht erfⁿllt ($i ist nicht gr÷▀er als 0), wird als
  23830.     <TT
  23831. CLASS="constant"
  23832. ><B
  23833. >FALSE</B
  23834. ></TT
  23835. > ausgewertet, und die Schleifenausfⁿhrung beendet.
  23836.    </P
  23837. ><P
  23838. >     Erfahrene C-Anwender kennen auch die M÷glichkeit, Programm-Bl÷cke
  23839.     mit <VAR
  23840. CLASS="literal"
  23841. >do..while</VAR
  23842. > (0) einzuschliessen und dann die
  23843.     <A
  23844. HREF="#control-structures.break"
  23845. ><VAR
  23846. CLASS="literal"
  23847. >break</VAR
  23848. ></A
  23849. >
  23850.     Anweisung zu benutzen. Der folgende Programm-Ausschnitt zeigt diese
  23851.     M÷glichkeit:
  23852.     <DIV
  23853. CLASS="informalexample"
  23854. ><P
  23855. ></P
  23856. ><A
  23857. NAME="AEN4395"
  23858. ></A
  23859. ><TABLE
  23860. BORDER="0"
  23861. BGCOLOR="#E0E0E0"
  23862. CELLPADDING="5"
  23863. ><TR
  23864. ><TD
  23865. ><PRE
  23866. CLASS="php"
  23867. >do {
  23868.     if ($i < 5) {
  23869.         echo "i ist nicht gro▀ genug";
  23870.         break;
  23871.     }
  23872.     $i *= $factor;
  23873.     if ($i < $minimum_limit) {
  23874.         break;
  23875.     }
  23876.     echo "i ist ok";
  23877.  
  23878.     /* mach was mit i */
  23879.  
  23880. } while (0);</PRE
  23881. ></TD
  23882. ></TR
  23883. ></TABLE
  23884. ><P
  23885. ></P
  23886. ></DIV
  23887. >
  23888.    </P
  23889. ><P
  23890. >     Es ist nicht weiter tragisch, wenn Sie dieses Beispiel nicht
  23891.     oder nur zum Teil verstehen. Sie k÷nnen auch ohne dieses
  23892.     'Feature' effektive PHP-Programme und Skripte schreiben.
  23893.    </P
  23894. ></DIV
  23895. ><DIV
  23896. CLASS="sect1"
  23897. ><HR><H2
  23898. CLASS="sect1"
  23899. ><A
  23900. NAME="control-structures.for"
  23901. ><VAR
  23902. CLASS="literal"
  23903. >for</VAR
  23904. ></A
  23905. ></H2
  23906. ><P
  23907. >     Die <VAR
  23908. CLASS="literal"
  23909. >for</VAR
  23910. >-Schleifen sind die komplexesten Schleifen in
  23911.     PHP. Sie funktionieren wie ihr Gegenstⁿck in C. Die Syntax einer
  23912.     <VAR
  23913. CLASS="literal"
  23914. >for</VAR
  23915. >-Schleife sieht wie folgt aus:
  23916.     <DIV
  23917. CLASS="informalexample"
  23918. ><P
  23919. ></P
  23920. ><A
  23921. NAME="AEN4404"
  23922. ></A
  23923. ><TABLE
  23924. BORDER="0"
  23925. BGCOLOR="#E0E0E0"
  23926. CELLPADDING="5"
  23927. ><TR
  23928. ><TD
  23929. ><PRE
  23930. CLASS="programlisting"
  23931. >for (ausdr1; ausdr2; ausdr3) Anweisung</PRE
  23932. ></TD
  23933. ></TR
  23934. ></TABLE
  23935. ><P
  23936. ></P
  23937. ></DIV
  23938. >
  23939.    </P
  23940. ><P
  23941. >     Der erste Ausdruck (<VAR
  23942. CLASS="varname"
  23943. >ausdr1</VAR
  23944. >) wird beim
  23945.     Schleifenbeginn (ohne jegliche Vorbedingung) geprⁿft bzw. ausgefⁿhrt.
  23946.    </P
  23947. ><P
  23948. >     Zu Beginn jedes Durchlaufs wird nun <VAR
  23949. CLASS="varname"
  23950. >ausdr2</VAR
  23951. >
  23952.     geprⁿft. Wenn dieser <TT
  23953. CLASS="constant"
  23954. ><B
  23955. >TRUE</B
  23956. ></TT
  23957. > ist, fΣhrt die Schleife mit der Ausfⁿhrung der
  23958.     nachfolgenden Anweisung(en) fort. Ist das Ergebnis <TT
  23959. CLASS="constant"
  23960. ><B
  23961. >FALSE</B
  23962. ></TT
  23963. >, wird die
  23964.     Schleife beendet.
  23965.    </P
  23966. ><P
  23967. >     Am Ende jedes Durchlaufs wird <VAR
  23968. CLASS="varname"
  23969. >ausdr3</VAR
  23970. > geprⁿft
  23971.     (ausgefⁿhrt).
  23972.    </P
  23973. ><P
  23974. >     Jeder Ausdruck kann leer sein. Ist <VAR
  23975. CLASS="varname"
  23976. >ausdr2</VAR
  23977. > leer,
  23978.     wird die Schleife endlos oft durchlaufen (PHP wertet diesen, wie in C,
  23979.     implizit als <TT
  23980. CLASS="constant"
  23981. ><B
  23982. >TRUE</B
  23983. ></TT
  23984. >). Das ist gar nicht so sinnlos, wie Sie vielleicht
  23985.     zunΣchst glauben, weil man hΣufig eine Schleife erst durch eine bedingte
  23986.     <A
  23987. HREF="#control-structures.break"
  23988. ><VAR
  23989. CLASS="literal"
  23990. >break</VAR
  23991. >
  23992.     </A
  23993. >-Anweisung statt durch eine unwahr werdende
  23994.     <VAR
  23995. CLASS="literal"
  23996. >for</VAR
  23997. >-Bedingung beenden m÷chte.
  23998.    </P
  23999. ><P
  24000. >     Beachten Sie die folgenden Beispiele. Alle geben Zahlen von 1 bis
  24001.     10 aus:
  24002.     <DIV
  24003. CLASS="informalexample"
  24004. ><P
  24005. ></P
  24006. ><A
  24007. NAME="AEN4421"
  24008. ></A
  24009. ><TABLE
  24010. BORDER="0"
  24011. BGCOLOR="#E0E0E0"
  24012. CELLPADDING="5"
  24013. ><TR
  24014. ><TD
  24015. ><PRE
  24016. CLASS="php"
  24017. ><?php
  24018. /* Beispiel 1 */
  24019.  
  24020. for ($i = 1; $i <= 10; $i++) {
  24021.     echo $i;
  24022. }
  24023.  
  24024. /* Beispiel 2 */
  24025.  
  24026. for ($i = 1; ; $i++) {
  24027.     if ($i > 10) {
  24028.         break;
  24029.     }
  24030.     echo $i;
  24031. }
  24032.  
  24033. /* Beispiel 3 */
  24034.  
  24035. $i = 1;
  24036. for (; ; ) {
  24037.     if ($i > 10) {
  24038.         break;
  24039.     }
  24040.     echo $i;
  24041.     $i++;
  24042. }
  24043.  
  24044. /* Beispiel 4 */
  24045.  
  24046. for ($i = 1; $i <= 10; echo $i, $i++);
  24047. ?></PRE
  24048. ></TD
  24049. ></TR
  24050. ></TABLE
  24051. ><P
  24052. ></P
  24053. ></DIV
  24054. >
  24055.    </P
  24056. ><P
  24057. >     SelbstverstΣndlich sieht das erste (oder vielleicht das vierte) Beispiel
  24058.     am besten aus, aber Sie werden noch feststellen, dass es oftmals ganz
  24059.     nⁿtzlich sein kann, leere Parameter in <VAR
  24060. CLASS="literal"
  24061. >for</VAR
  24062. >-Schleifen zu
  24063.     verwenden.
  24064.    </P
  24065. ><P
  24066. >     PHP unterstⁿtzt auch bei <VAR
  24067. CLASS="literal"
  24068. >for</VAR
  24069. >-Schleifen die
  24070.     alternative "Doppelpunkt-Syntax".
  24071.     <DIV
  24072. CLASS="informalexample"
  24073. ><P
  24074. ></P
  24075. ><A
  24076. NAME="AEN4427"
  24077. ></A
  24078. ><TABLE
  24079. BORDER="0"
  24080. BGCOLOR="#E0E0E0"
  24081. CELLPADDING="5"
  24082. ><TR
  24083. ><TD
  24084. ><PRE
  24085. CLASS="programlisting"
  24086. >for (ausdr1; ausdr2; ausdr3): Anweisung; ...; endfor;</PRE
  24087. ></TD
  24088. ></TR
  24089. ></TABLE
  24090. ><P
  24091. ></P
  24092. ></DIV
  24093. >
  24094.    </P
  24095. ><P
  24096. >     Andere Sprachen haben fⁿr das Durchlaufen eines Hashs oder Arrays eine
  24097.     <VAR
  24098. CLASS="literal"
  24099. >foreach</VAR
  24100. >-Anweisung. PHP 3 hat dies nicht; im Gegensatz
  24101.     zu PHP 4 (vgl.
  24102.     <A
  24103. HREF="#control-structures.foreach"
  24104. >foreach</A
  24105. >).
  24106.     In PHP 3 k÷nnen Sie fⁿr diesen Zweck
  24107.     <A
  24108. HREF="#control-structures.while"
  24109. >while</A
  24110. > mit der
  24111.     <A
  24112. HREF="#function.list"
  24113. ><B
  24114. CLASS="function"
  24115. >list()</B
  24116. ></A
  24117. >- und <A
  24118. HREF="#function.each"
  24119. ><B
  24120. CLASS="function"
  24121. >each()</B
  24122. ></A
  24123. >-Funktion
  24124.     kombinieren. Beispiele finden Sie in der Dokumentation zu diesen
  24125.     Funktionen.
  24126.    </P
  24127. ></DIV
  24128. ><DIV
  24129. CLASS="sect1"
  24130. ><HR><H2
  24131. CLASS="sect1"
  24132. ><A
  24133. NAME="control-structures.foreach"
  24134. ><VAR
  24135. CLASS="literal"
  24136. >foreach</VAR
  24137. ></A
  24138. ></H2
  24139. ><P
  24140. >     PHP 4 (nicht PHP 3) enthΣlt ein <VAR
  24141. CLASS="literal"
  24142. >foreach</VAR
  24143. > Konstrukt,
  24144.     genau wie Perl und einige andere Sprachen. Diese erm÷glicht es, auf
  24145.     einfache Weise ein Array zu durchlaufen. <VAR
  24146. CLASS="literal"
  24147. >foreach</VAR
  24148. >
  24149.     funktioniert nur in Verbindung mit Arrays. Wenn Sie versuchen
  24150.     <VAR
  24151. CLASS="literal"
  24152. >foreach</VAR
  24153. > mit Variablen eines anderen Datentyps oder
  24154.     nicht initialisierten Variablen zu benutzen, gibt PHP einen Fehler aus. Es
  24155.     gibt zwei Syntaxformen; die zweite ist eine unbedeutende, aber sinnvolle
  24156.     Erweiterung der ersten Syntax:
  24157.     <DIV
  24158. CLASS="informalexample"
  24159. ><P
  24160. ></P
  24161. ><A
  24162. NAME="AEN4442"
  24163. ></A
  24164. ><TABLE
  24165. BORDER="0"
  24166. BGCOLOR="#E0E0E0"
  24167. CELLPADDING="5"
  24168. ><TR
  24169. ><TD
  24170. ><PRE
  24171. CLASS="programlisting"
  24172. >foreach (array_expression as $value) Anweisung
  24173. foreach (array_expression as $key => $value) Anweisung</PRE
  24174. ></TD
  24175. ></TR
  24176. ></TABLE
  24177. ><P
  24178. ></P
  24179. ></DIV
  24180. >
  24181.    </P
  24182. ><P
  24183. >     Die erste Form durchlΣuft das <VAR
  24184. CLASS="literal"
  24185. >array_expression</VAR
  24186. >-Array.
  24187.     Bei jedem Durchgang wird der Wert des aktuellen Elements
  24188.     <VAR
  24189. CLASS="literal"
  24190. >$value</VAR
  24191. > zugewiesen und der interne Array-Zeiger um eins
  24192.     erh÷ht. Dadurch wird beim nΣchsten Durchgang automatisch das nΣchste
  24193.     Element ausgewertet.
  24194.    </P
  24195. ><P
  24196. >     Die zweite Form arbeitet genauso, au▀er dass bei jedem Durchlauf
  24197.     auch der aktuelle Schlⁿssel der Variablen <VAR
  24198. CLASS="literal"
  24199. >$key</VAR
  24200. >
  24201.     zugewiesen wird.
  24202.    </P
  24203. ><P
  24204. >     <DIV
  24205. CLASS="note"
  24206. ><BLOCKQUOTE
  24207. CLASS="note"
  24208. ><P
  24209. ><B
  24210. >Anmerkung: </B
  24211. >
  24212.       Sobald <VAR
  24213. CLASS="literal"
  24214. >foreach</VAR
  24215. > zum ersten Mal ausgefⁿhrt wird,
  24216.       wird der interne Arrayzeiger automatisch auf das erste Element
  24217.       des Arrays gesetzt. Das bedeutet, dass Sie vor einem Durchlauf
  24218.       von <VAR
  24219. CLASS="literal"
  24220. >foreach</VAR
  24221. > <A
  24222. HREF="#function.reset"
  24223. ><B
  24224. CLASS="function"
  24225. >reset()</B
  24226. ></A
  24227. > nicht
  24228.       aufrufen mⁿssen.
  24229.      </P
  24230. ></BLOCKQUOTE
  24231. ></DIV
  24232. >
  24233.    </P
  24234. ><P
  24235. >     <DIV
  24236. CLASS="note"
  24237. ><BLOCKQUOTE
  24238. CLASS="note"
  24239. ><P
  24240. ><B
  24241. >Anmerkung: </B
  24242. >
  24243.       Beachten Sie auch, dass <VAR
  24244. CLASS="literal"
  24245. >foreach</VAR
  24246. > mit einer
  24247.       Kopie des angegebenen Arrays arbeitet, nicht mit dem Array selbst.
  24248.       Deshalb wird auch der Arrayzeiger nicht wie bei dem
  24249.       <A
  24250. HREF="#function.each"
  24251. ><B
  24252. CLASS="function"
  24253. >each()</B
  24254. ></A
  24255. >-Konstrukt verΣndert und VerΣnderungen an
  24256.       ausgegebenen Arrayelementen haben keine Auswirkung auf das originale
  24257.       Array. Trotzdem <SPAN
  24258. CLASS="emphasis"
  24259. ><I
  24260. CLASS="emphasis"
  24261. >wird</I
  24262. ></SPAN
  24263. > der interne Arrayzeiger
  24264.       des originalen Arrays bei der Verarbeitung bewegt. Angenommen, die
  24265.       foreach-Schleife ist komplett abgearbeitet, wird der interne
  24266.       Arrayzeiger (des originalen Arrays) auf das letzte Element zeigen.
  24267.      </P
  24268. ></BLOCKQUOTE
  24269. ></DIV
  24270. >
  24271.    </P
  24272. ><DIV
  24273. CLASS="note"
  24274. ><BLOCKQUOTE
  24275. CLASS="note"
  24276. ><P
  24277. ><B
  24278. >Anmerkung: </B
  24279. >
  24280.      Bei <VAR
  24281. CLASS="literal"
  24282. >foreach</VAR
  24283. > ist es nicht m÷glich Fehlermeldungen durch
  24284.      den Gebrauch von '@' zu unterdrⁿcken ist 
  24285.     </P
  24286. ></BLOCKQUOTE
  24287. ></DIV
  24288. ><P
  24289. >     Beachten Sie, dass die folgenden Beispiele in ihrer FunktionalitΣt
  24290.     identisch sind:
  24291.     <DIV
  24292. CLASS="informalexample"
  24293. ><P
  24294. ></P
  24295. ><A
  24296. NAME="AEN4465"
  24297. ></A
  24298. ><TABLE
  24299. BORDER="0"
  24300. BGCOLOR="#E0E0E0"
  24301. CELLPADDING="5"
  24302. ><TR
  24303. ><TD
  24304. ><PRE
  24305. CLASS="php"
  24306. ><?php
  24307. $arr = array("eins", "zwei", "drei");
  24308. reset ($arr);
  24309. while (list(, $value) = each ($arr)) {
  24310.     echo "Wert:  $value<br />\n";
  24311. }
  24312.  
  24313. foreach ($arr as $value) {
  24314.     echo "Wert:  $value<br />\n";
  24315. ?>
  24316. }</PRE
  24317. ></TD
  24318. ></TR
  24319. ></TABLE
  24320. ><P
  24321. ></P
  24322. ></DIV
  24323. >
  24324.     Auch hier funktioniert alles gleich:
  24325.     <DIV
  24326. CLASS="informalexample"
  24327. ><P
  24328. ></P
  24329. ><A
  24330. NAME="AEN4467"
  24331. ></A
  24332. ><TABLE
  24333. BORDER="0"
  24334. BGCOLOR="#E0E0E0"
  24335. CELLPADDING="5"
  24336. ><TR
  24337. ><TD
  24338. ><PRE
  24339. CLASS="php"
  24340. ><?php
  24341. $arr = array("eins", "zwei", "drei");
  24342. reset ($arr);
  24343. while (list($key, $value) = each ($arr)) {
  24344.     echo "Schlⁿssel: $key; Wert: $value<br />\n";
  24345. }
  24346.  
  24347. foreach ($arr as $key => $value) {
  24348.     echo "Schlⁿssel: $key; Wert: $value<br />\n";
  24349. }
  24350. ?></PRE
  24351. ></TD
  24352. ></TR
  24353. ></TABLE
  24354. ><P
  24355. ></P
  24356. ></DIV
  24357. >
  24358.    </P
  24359. ><P
  24360. >     Noch einige Beispiele, die die Anwendung verdeutlichen:
  24361.     <DIV
  24362. CLASS="informalexample"
  24363. ><P
  24364. ></P
  24365. ><A
  24366. NAME="AEN4470"
  24367. ></A
  24368. ><TABLE
  24369. BORDER="0"
  24370. BGCOLOR="#E0E0E0"
  24371. CELLPADDING="5"
  24372. ><TR
  24373. ><TD
  24374. ><PRE
  24375. CLASS="php"
  24376. ><?php
  24377. /* foreach Beispiel 1: Nur der Wert */
  24378.  
  24379. $a = array(1, 2, 3, 17);
  24380.  
  24381. foreach ($a as $v) {
  24382.    echo "Aktueller Wert von \$a: $v.\n";
  24383. }
  24384.  
  24385. /* foreach Beispiel 2:
  24386. Wert (mit Ausgabe des Arrayschlⁿssels zur Veranschaulichung) */
  24387.  
  24388. $a = array(1, 2, 3, 17);
  24389.  
  24390. $i = 0; /* nur zu Veranschaulichung */
  24391.  
  24392. foreach($a as $v) {
  24393.     echo "\$a[$i] => $v.\n";
  24394.     $i++;
  24395. }
  24396.  
  24397. /* foreach Beispiel 3: Schlⁿssel und Wert */
  24398.  
  24399. $a = array(
  24400.     "eins" => 1,
  24401.     "zwei" => 2,
  24402.     "drei" => 3,
  24403.     "siebzehn" => 17
  24404. );
  24405.  
  24406. foreach($a as $k => $v) {
  24407.     echo "\$a[$k] => $v.\n";
  24408. }
  24409.  
  24410. /* foreach Beispiel 4: multidimensionale Arrays */
  24411.  
  24412. $a[0][0] = "a";
  24413. $a[0][1] = "b";
  24414. $a[1][0] = "y";
  24415. $a[1][1] = "z";
  24416.  
  24417. foreach($a as $v1) {
  24418.     foreach ($v1 as $v2) {
  24419.         echo "$v2\n";
  24420.     }
  24421. }
  24422.  
  24423. /* foreach Beispiel 5: dynamische Arrays */
  24424.  
  24425. foreach (array(1, 2, 3, 4, 5) as $v) {
  24426.     echo "$v\n";
  24427. }
  24428. ?></PRE
  24429. ></TD
  24430. ></TR
  24431. ></TABLE
  24432. ><P
  24433. ></P
  24434. ></DIV
  24435. >
  24436.    </P
  24437. ></DIV
  24438. ><DIV
  24439. CLASS="sect1"
  24440. ><HR><H2
  24441. CLASS="sect1"
  24442. ><A
  24443. NAME="control-structures.break"
  24444. ><VAR
  24445. CLASS="literal"
  24446. >break</VAR
  24447. ></A
  24448. ></H2
  24449. ><P
  24450. >     <VAR
  24451. CLASS="literal"
  24452. >Break</VAR
  24453. > bricht die Ausfⁿhrung der aktuellen
  24454.     <VAR
  24455. CLASS="literal"
  24456. >for</VAR
  24457. >, <VAR
  24458. CLASS="literal"
  24459. >foreach</VAR
  24460. >
  24461.     <VAR
  24462. CLASS="literal"
  24463. >while</VAR
  24464. >, <VAR
  24465. CLASS="literal"
  24466. >do..while</VAR
  24467. > Schleife oder einer
  24468.     <VAR
  24469. CLASS="literal"
  24470. >switch</VAR
  24471. > Anweisungssequenz ab.
  24472.    </P
  24473. ><P
  24474. >     Einem <VAR
  24475. CLASS="literal"
  24476. >break</VAR
  24477. > kann optional ein nummerisches
  24478.     Argument angehΣngt werden, das die Anzahl der abzubrechenden
  24479.     Befehlssequenzen enthΣlt.
  24480.    </P
  24481. ><P
  24482. >     <DIV
  24483. CLASS="informalexample"
  24484. ><P
  24485. ></P
  24486. ><A
  24487. NAME="AEN4485"
  24488. ></A
  24489. ><TABLE
  24490. BORDER="0"
  24491. BGCOLOR="#E0E0E0"
  24492. CELLPADDING="5"
  24493. ><TR
  24494. ><TD
  24495. ><PRE
  24496. CLASS="php"
  24497. ><?php
  24498. $arr = array('eins', 'zwei', 'drei', 'vier', 'stop', 'fⁿnf');
  24499. while (list ( , $val) = each ($arr)) {
  24500.     if ($val == 'stop') {
  24501.         break;  /* Sie k÷nnten hier auch 'break 1;' schreiben. */
  24502.     }
  24503.     echo "$val<br />\n";
  24504.  
  24505. /* Benutzung des optionalen Argumentes. */
  24506.  
  24507. $i = 0;
  24508. while (++$i) {
  24509.     switch ($i) {
  24510.     case 5:
  24511.         echo "Bei 5<br />\n";
  24512.         break 1;  /* Beendet nur switch. */
  24513.     case 10:
  24514.         echo "Bei 10; aussteigen<br />\n";
  24515.         break 2;  /* Beendet switch und while. */
  24516.     default:
  24517.         break;
  24518.     }
  24519. }
  24520. ?></PRE
  24521. ></TD
  24522. ></TR
  24523. ></TABLE
  24524. ><P
  24525. ></P
  24526. ></DIV
  24527. >
  24528.    </P
  24529. ></DIV
  24530. ><DIV
  24531. CLASS="sect1"
  24532. ><HR><H2
  24533. CLASS="sect1"
  24534. ><A
  24535. NAME="control-structures.continue"
  24536. ><VAR
  24537. CLASS="literal"
  24538. >continue</VAR
  24539. ></A
  24540. ></H2
  24541. ><P
  24542. >     <VAR
  24543. CLASS="literal"
  24544. >continue</VAR
  24545. > wird innerhalb von Schleifen verwendet. Die
  24546.     Schleife wird an der aktuellen Stelle abgebrochen und es wird der nΣchste
  24547.     Durchlauf begonnen.
  24548.    </P
  24549. ><DIV
  24550. CLASS="note"
  24551. ><BLOCKQUOTE
  24552. CLASS="note"
  24553. ><P
  24554. ><B
  24555. >Anmerkung: </B
  24556. >
  24557.      Beachten Sie, dass in PHP die 
  24558.      <A
  24559. HREF="#control-structures.switch"
  24560. >switch</A
  24561. > Anweisung
  24562.      als Schleifenstruktur zum Zweck von <VAR
  24563. CLASS="literal"
  24564. >continue</VAR
  24565. > angesehen
  24566.      wird.
  24567.     </P
  24568. ></BLOCKQUOTE
  24569. ></DIV
  24570. ><P
  24571. >     Bei <VAR
  24572. CLASS="literal"
  24573. >continue</VAR
  24574. > k÷nnen Sie ein optionales nummerisches
  24575.     Argument mitgeben, das angibt, wie viele Ebenen von enhaltenen Schleifen
  24576.     ⁿbersprungen werden sollen.
  24577.    </P
  24578. ><P
  24579. >     <DIV
  24580. CLASS="informalexample"
  24581. ><P
  24582. ></P
  24583. ><A
  24584. NAME="AEN4499"
  24585. ></A
  24586. ><TABLE
  24587. BORDER="0"
  24588. BGCOLOR="#E0E0E0"
  24589. CELLPADDING="5"
  24590. ><TR
  24591. ><TD
  24592. ><PRE
  24593. CLASS="php"
  24594. ><?php
  24595. while (list ($key, $value) = each ($arr)) {
  24596.     if (!($key % 2)) { // ⁿberspringe ungerade Werte
  24597.         continue;
  24598.     }
  24599.     tue_was_mit_ungerade ($value);
  24600. }
  24601.  
  24602. $i = 0;
  24603. while ($i++ < 5) {
  24604.     echo "Au▀en<br />\n";
  24605.     while (1) {
  24606.         echo "&nbsp;&nbsp;Mitte<br />\n";
  24607.         while (1) {
  24608.             echo "&nbsp;&nbsp;Innen<br />\n";
  24609.             continue 3;
  24610.         }
  24611.         echo "Das wird nie ausgegeben.<br />\n";
  24612.     }
  24613.     echo "Das hier auch nicht.<br />\n";
  24614. }
  24615. ?></PRE
  24616. ></TD
  24617. ></TR
  24618. ></TABLE
  24619. ><P
  24620. ></P
  24621. ></DIV
  24622. >
  24623.     </P
  24624. ><P
  24625. >      Lassen Sie das Semikolon nach <VAR
  24626. CLASS="literal"
  24627. >continue</VAR
  24628. > weg, kann dies
  24629.      zu verwirrenden Ergebnissen fⁿhren. Es folgt ein Beispiel wie Sie es
  24630.      nicht machen sollten.
  24631.     </P
  24632. ><P
  24633. >      <DIV
  24634. CLASS="informalexample"
  24635. ><P
  24636. ></P
  24637. ><A
  24638. NAME="AEN4504"
  24639. ></A
  24640. ><TABLE
  24641. BORDER="0"
  24642. BGCOLOR="#E0E0E0"
  24643. CELLPADDING="5"
  24644. ><TR
  24645. ><TD
  24646. ><PRE
  24647. CLASS="php"
  24648. ><?php
  24649.   for ($i = 0; $i < 5; ++$i) {
  24650.       if ($i == 2)
  24651.           continue
  24652.       print "$i\n";
  24653.   }
  24654. ?></PRE
  24655. ></TD
  24656. ></TR
  24657. ></TABLE
  24658. ><P
  24659. >        Sie k÷nnten erwarten, dass das Ergebnis wie folgt aussieht,
  24660.       </P
  24661. ><TABLE
  24662. BORDER="0"
  24663. BGCOLOR="#E0E0E0"
  24664. CELLPADDING="5"
  24665. ><TR
  24666. ><TD
  24667. ><PRE
  24668. CLASS="screen"
  24669. >0
  24670. 1
  24671. 3
  24672. 4</PRE
  24673. ></TD
  24674. ></TR
  24675. ></TABLE
  24676. ><P
  24677. >        aber tatsΣchlich sieht die Ausgabe so aus,
  24678.       </P
  24679. ><TABLE
  24680. BORDER="0"
  24681. BGCOLOR="#E0E0E0"
  24682. CELLPADDING="5"
  24683. ><TR
  24684. ><TD
  24685. ><PRE
  24686. CLASS="screen"
  24687. >2</PRE
  24688. ></TD
  24689. ></TR
  24690. ></TABLE
  24691. ><P
  24692. >        weil der Rⁿckgabewert von <A
  24693. HREF="#function.print"
  24694. ><B
  24695. CLASS="function"
  24696. >print()</B
  24697. ></A
  24698. >
  24699.        <VAR
  24700. CLASS="literal"
  24701. >int(1)</VAR
  24702. > ist und das wird als das oben angesprochene
  24703.        optinale Argument gewertet.
  24704.       </P
  24705. ><P
  24706. ></P
  24707. ></DIV
  24708. >
  24709.     </P
  24710. ></DIV
  24711. ><DIV
  24712. CLASS="sect1"
  24713. ><HR><H2
  24714. CLASS="sect1"
  24715. ><A
  24716. NAME="control-structures.switch"
  24717. ><VAR
  24718. CLASS="literal"
  24719. >switch</VAR
  24720. ></A
  24721. ></H2
  24722. ><P
  24723. >     Die <VAR
  24724. CLASS="literal"
  24725. >switch</VAR
  24726. >-Anweisung ist gleichbedeutend einer
  24727.     Reihe von <VAR
  24728. CLASS="literal"
  24729. >if</VAR
  24730. >-Anweisungen mit dem gleichen Parameter.
  24731.     HΣufig wollen Sie ein und dieselbe Variable (bzw. den selben Ausdruck)
  24732.     mit verschiedensten Werten vergleichen und in AbhΣngigkeit vom 
  24733.     Auswertungsergebnis verschiedene Programmteile ausfⁿhren. Genau
  24734.     das erm÷glicht die <VAR
  24735. CLASS="literal"
  24736. >switch</VAR
  24737. >-Anweisung.
  24738.    </P
  24739. ><DIV
  24740. CLASS="note"
  24741. ><BLOCKQUOTE
  24742. CLASS="note"
  24743. ><P
  24744. ><B
  24745. >Anmerkung: </B
  24746. >
  24747.      Beachten Sie bitte, dass im Unterschied zu anderen Programmiersprachen
  24748.      die <A
  24749. HREF="#control-structures.continue"
  24750. >continue</A
  24751. >
  24752.      Anweisung auch bei switch ihre Gⁿltigkeit hat und Σhnlich wie
  24753.      <VAR
  24754. CLASS="literal"
  24755. >break</VAR
  24756. > funktioniert. Falls Sie switch innerhalb einer
  24757.      Schleife verwenden und mit dem nΣchsten Durchlauf der Σu▀eren Schleife
  24758.      beginnen m÷chten, verwenden Sie <VAR
  24759. CLASS="literal"
  24760. >continue 2</VAR
  24761. >.
  24762.     </P
  24763. ></BLOCKQUOTE
  24764. ></DIV
  24765. ><P
  24766. >     Das folgende Beispiele zeigt Ihnen zwei verschiedene M÷glichkeiten auf,
  24767.     das Gleiche zu erreichen. Einmal werden <VAR
  24768. CLASS="literal"
  24769. >if</VAR
  24770. > und
  24771.     <VAR
  24772. CLASS="literal"
  24773. >elseif</VAR
  24774. > Anweisungen benutzt, das andere Mal eine
  24775.     <VAR
  24776. CLASS="literal"
  24777. >switch</VAR
  24778. >-Anweisung:
  24779.     <DIV
  24780. CLASS="informalexample"
  24781. ><P
  24782. ></P
  24783. ><A
  24784. NAME="AEN4529"
  24785. ></A
  24786. ><TABLE
  24787. BORDER="0"
  24788. BGCOLOR="#E0E0E0"
  24789. CELLPADDING="5"
  24790. ><TR
  24791. ><TD
  24792. ><PRE
  24793. CLASS="php"
  24794. ><?php
  24795. if ($i == 0) {
  24796.     echo "i ist gleich 0";
  24797. } elseif ($i == 1) {
  24798.     echo "i ist gleich 1";
  24799. } elseif ($i == 2) {
  24800.     echo "i ist gleich 2";
  24801. }
  24802.  
  24803. switch ($i) {
  24804. case 0:
  24805.     echo "i ist gleich 0";
  24806.     break;
  24807. case 1:
  24808.     echo "i ist gleich 1";
  24809.     break;
  24810. case 2:
  24811.     echo "i ist gleich 2";
  24812.     break;
  24813. }
  24814. ?></PRE
  24815. ></TD
  24816. ></TR
  24817. ></TABLE
  24818. ><P
  24819. ></P
  24820. ></DIV
  24821. >
  24822.    </P
  24823. ><P
  24824. >     Es ist wichtig, die Ausfⁿhrung einer <VAR
  24825. CLASS="literal"
  24826. >switch</VAR
  24827. >-Anweisung
  24828.     zu verstehen, um Fehler zu vermeiden. Die <VAR
  24829. CLASS="literal"
  24830. >switch</VAR
  24831. >-Anweisung
  24832.     wird Zeile fⁿr Zeile (also Anweisung fⁿr Anweisung) abgearbeitet. Zu
  24833.     Beginn wird kein Code ausgefⁿhrt. Erst wenn bei einem
  24834.     <VAR
  24835. CLASS="literal"
  24836. >case</VAR
  24837. >-Teil eine Entsprechung zum
  24838.     <VAR
  24839. CLASS="literal"
  24840. >switch</VAR
  24841. >-Ausdruck vorliegt, werden die darin enthaltenen
  24842.     Anweisungen von PHP ausgefⁿhrt. PHP fΣhrt dann mit der Abarbeitung des
  24843.     restlichen Codes innerhalb des <VAR
  24844. CLASS="literal"
  24845. >switch</VAR
  24846. >-Blocks fort oder
  24847.     bis zum ersten Auftreten einer <VAR
  24848. CLASS="literal"
  24849. >break</VAR
  24850. >-Anweisung. Ohne
  24851.     <VAR
  24852. CLASS="literal"
  24853. >break</VAR
  24854. > am Ende eines case-Teils werden also
  24855.     noch die folgenden case-Bl÷cke ausgefⁿhrt. Zum Beispiel:
  24856.     <DIV
  24857. CLASS="informalexample"
  24858. ><P
  24859. ></P
  24860. ><A
  24861. NAME="AEN4539"
  24862. ></A
  24863. ><TABLE
  24864. BORDER="0"
  24865. BGCOLOR="#E0E0E0"
  24866. CELLPADDING="5"
  24867. ><TR
  24868. ><TD
  24869. ><PRE
  24870. CLASS="php"
  24871. ><?php
  24872. switch ($i) {
  24873. case 0:
  24874.     echo "i ist gleich 0";
  24875. case 1:
  24876.     echo "i ist gleich 1";
  24877. case 2:
  24878.     echo "i ist gleich 2";
  24879. }
  24880. ?></PRE
  24881. ></TD
  24882. ></TR
  24883. ></TABLE
  24884. ><P
  24885. ></P
  24886. ></DIV
  24887. >
  24888.    </P
  24889. ><P
  24890. >     Wenn hier <VAR
  24891. CLASS="varname"
  24892. >$i</VAR
  24893. > gleich 0 ist, wⁿrde PHP alle echo
  24894.     Anweisungen ausfⁿhren! Ist <VAR
  24895. CLASS="varname"
  24896. >$i</VAR
  24897. > gleich 1, werden die
  24898.     letzten beiden echo Anweisungen ausgefⁿhrt. Nur wenn <VAR
  24899. CLASS="varname"
  24900. >$i</VAR
  24901. >
  24902.     gleich 2 ist, erhalten Sie das erwartete Ergebnis: die Ausgabe von
  24903.     "i ist gleich 2". Deshalb ist es wichtig <VAR
  24904. CLASS="literal"
  24905. >break</VAR
  24906. >-Anweisungen
  24907.     zu setzen (abgesehen von bestimmten FΣllen, in denen Sie diese mit Absicht
  24908.     weglassen).
  24909.    </P
  24910. ><P
  24911. >     Bei einer <VAR
  24912. CLASS="literal"
  24913. >switch</VAR
  24914. >-Anweisung wird die Bedingung also nur
  24915.     einmal ⁿberprⁿft und das Ergebnis mit jeder <VAR
  24916. CLASS="literal"
  24917. >case</VAR
  24918. >-Anweisung
  24919.     verglichen. Bei einer <VAR
  24920. CLASS="literal"
  24921. >elseif</VAR
  24922. >-Anweisung wird die
  24923.     Bedingung neu geprⁿft. Ist ihre Bedingung komplizierter als ein einfacher
  24924.     Vergleich und/oder in einer umfangreichen Schleife eingebettet, kann eine
  24925.     <VAR
  24926. CLASS="literal"
  24927. >switch</VAR
  24928. >-Anweisung schneller sein.
  24929.    </P
  24930. ><P
  24931. >     Der Anweisungsteil von case kann auch leer sein. Dann wird die Kontrolle
  24932.     einfach an den nΣchsten case-Teil ⁿbergeben.
  24933.     <DIV
  24934. CLASS="informalexample"
  24935. ><P
  24936. ></P
  24937. ><A
  24938. NAME="AEN4552"
  24939. ></A
  24940. ><TABLE
  24941. BORDER="0"
  24942. BGCOLOR="#E0E0E0"
  24943. CELLPADDING="5"
  24944. ><TR
  24945. ><TD
  24946. ><PRE
  24947. CLASS="php"
  24948. ><?php
  24949. switch ($i) {
  24950. case 0:
  24951. case 1:
  24952. case 2:
  24953.     echo "i ist kleiner als 3 aber nicht negativ";
  24954.     break;
  24955. case 3:
  24956.     echo "i ist gleich 3";
  24957. }
  24958. ?></PRE
  24959. ></TD
  24960. ></TR
  24961. ></TABLE
  24962. ><P
  24963. ></P
  24964. ></DIV
  24965. >
  24966.    </P
  24967. ><P
  24968. >     Ein Spezialfall ist <VAR
  24969. CLASS="literal"
  24970. >default</VAR
  24971. >. Dieser Fall trifft
  24972.     auf alles zu, was nicht von den voranstehenden case-Ausdrⁿcken
  24973.     erfasst wurde und sollte als letzte <VAR
  24974. CLASS="literal"
  24975. >case</VAR
  24976. > Anweisung
  24977.     angegeben werden. Zum Beispiel:
  24978.     <DIV
  24979. CLASS="informalexample"
  24980. ><P
  24981. ></P
  24982. ><A
  24983. NAME="AEN4557"
  24984. ></A
  24985. ><TABLE
  24986. BORDER="0"
  24987. BGCOLOR="#E0E0E0"
  24988. CELLPADDING="5"
  24989. ><TR
  24990. ><TD
  24991. ><PRE
  24992. CLASS="php"
  24993. ><?php
  24994. switch ($i) {
  24995. case 0:
  24996.     echo "i ist gleich 0";
  24997.     break;
  24998. case 1:
  24999.     echo "i ist gleich 1";
  25000.     break;
  25001. case 2:
  25002.     echo "i ist gleich 2";
  25003.     break;
  25004. default:
  25005.     echo "i ist weder 0, 1 noch 2";
  25006. }
  25007. ?></PRE
  25008. ></TD
  25009. ></TR
  25010. ></TABLE
  25011. ><P
  25012. ></P
  25013. ></DIV
  25014. >
  25015.    </P
  25016. ><P
  25017. >     Der <VAR
  25018. CLASS="literal"
  25019. >case</VAR
  25020. >-Ausdruck kann eine Prⁿfung einfacher Typen
  25021.     sein, also von Integer- oder Flie▀komma-Zahlen oder von
  25022.     Strings/Zeichenketten. Arrays oder Objekte k÷nnen nicht benutzt werden, es
  25023.     sei denn, sie wurden in einfache Typen umgewandelt.
  25024.    </P
  25025. ><P
  25026. >     Die alternative Syntax der Kontrollstrukturen gilt auch fⁿr
  25027.     switch-Sequenzen. Mehr Informationen dazu erhalten Sie unter <A
  25028. HREF="#control-structures.alternative-syntax"
  25029. >Alternative Syntax
  25030.     fⁿr Kontroll-Strukturen</A
  25031. >.
  25032.     <DIV
  25033. CLASS="informalexample"
  25034. ><P
  25035. ></P
  25036. ><A
  25037. NAME="AEN4563"
  25038. ></A
  25039. ><TABLE
  25040. BORDER="0"
  25041. BGCOLOR="#E0E0E0"
  25042. CELLPADDING="5"
  25043. ><TR
  25044. ><TD
  25045. ><PRE
  25046. CLASS="php"
  25047. ><?php
  25048. switch ($i):
  25049. case 0:
  25050.     echo "i ist gleich 0";
  25051.     break;
  25052. case 1:
  25053.     echo "i ist gleich 1";
  25054.     break;
  25055. case 2:
  25056.     echo "i ist gleich 2";
  25057.     break;
  25058. default:
  25059.     echo "i ist weder 0, 1 noch 2";
  25060. endswitch;
  25061. ?></PRE
  25062. ></TD
  25063. ></TR
  25064. ></TABLE
  25065. ><P
  25066. ></P
  25067. ></DIV
  25068. >
  25069.    </P
  25070. ></DIV
  25071. ><DIV
  25072. CLASS="sect1"
  25073. ><HR><H2
  25074. CLASS="sect1"
  25075. ><A
  25076. NAME="control-structures.declare"
  25077. ><VAR
  25078. CLASS="literal"
  25079. >declare</VAR
  25080. ></A
  25081. ></H2
  25082. ><P
  25083. >     Das Sprachkonstrukt <VAR
  25084. CLASS="literal"
  25085. >declare</VAR
  25086. > wird dazu verwendet, um
  25087.     Ausfⁿhrungsdirektiven fⁿr einen Codeblock anzugeben.
  25088.     Die Schreibweise von <VAR
  25089. CLASS="literal"
  25090. >declare</VAR
  25091. > ist der anderer
  25092.     Kontrollstrukturen Σhnlich:
  25093.     <DIV
  25094. CLASS="informalexample"
  25095. ><P
  25096. ></P
  25097. ><A
  25098. NAME="AEN4571"
  25099. ></A
  25100. ><TABLE
  25101. BORDER="0"
  25102. BGCOLOR="#E0E0E0"
  25103. CELLPADDING="5"
  25104. ><TR
  25105. ><TD
  25106. ><PRE
  25107. CLASS="programlisting"
  25108. >declare (Direktive) Anweisung</PRE
  25109. ></TD
  25110. ></TR
  25111. ></TABLE
  25112. ><P
  25113. ></P
  25114. ></DIV
  25115. >
  25116.    </P
  25117. ><P
  25118. >     Die <VAR
  25119. CLASS="literal"
  25120. >Direktive</VAR
  25121. > gibt Ihnen die M÷glichkeit, das
  25122.     Verhalten des <VAR
  25123. CLASS="literal"
  25124. >declare</VAR
  25125. >-Blocks zu bestimmen.
  25126.     Zur Zeit wird nur eine Direktive unterstⁿtzt: die <VAR
  25127. CLASS="literal"
  25128. >ticks</VAR
  25129. >
  25130.     (Weiter unten finden Sie mehr Informationen zu den
  25131.     <A
  25132. HREF="#control-structures.declare.ticks"
  25133. >ticks</A
  25134. >).
  25135.    </P
  25136. ><P
  25137. >     Der <VAR
  25138. CLASS="literal"
  25139. >Anweisung</VAR
  25140. >steil des <VAR
  25141. CLASS="literal"
  25142. >declare</VAR
  25143. >-Blocks
  25144.     wird ausgefⁿhrt - wie genau diese Ausfⁿhrung passiert und welche
  25145.     Nebeneffekte wΣhrend der Ausfⁿhrung auftreten, hΣngt von der Direktive ab,
  25146.     die Sie im <VAR
  25147. CLASS="literal"
  25148. >directive</VAR
  25149. >-Block angegeben haben.
  25150.    </P
  25151. ><P
  25152. >     Das <VAR
  25153. CLASS="literal"
  25154. >declare</VAR
  25155. > Konstrukt kann auch im globalen
  25156.     Geltungsbereich benutzt werden und gilt dann fⁿr den folgenden Code.
  25157.     <DIV
  25158. CLASS="informalexample"
  25159. ><P
  25160. ></P
  25161. ><A
  25162. NAME="AEN4584"
  25163. ></A
  25164. ><TABLE
  25165. BORDER="0"
  25166. BGCOLOR="#E0E0E0"
  25167. CELLPADDING="5"
  25168. ><TR
  25169. ><TD
  25170. ><PRE
  25171. CLASS="php"
  25172. ><?php
  25173. // bewirkt das Gleiche:
  25174.  
  25175. // sie k÷nnen declare so benutzen:
  25176. declare(ticks=1) {
  25177.     // hier folgt Ihr ganzes Skript
  25178. }
  25179.  
  25180. // oder wie hier:
  25181. declare(ticks=1);
  25182. // hier folgt Ihr ganzes Skript
  25183. ?></PRE
  25184. ></TD
  25185. ></TR
  25186. ></TABLE
  25187. ><P
  25188. ></P
  25189. ></DIV
  25190. >
  25191.    </P
  25192. ><DIV
  25193. CLASS="sect2"
  25194. ><HR><H3
  25195. CLASS="sect2"
  25196. ><A
  25197. NAME="control-structures.declare.ticks"
  25198. >Ticks</A
  25199. ></H3
  25200. ><P
  25201. >      Ein tick ist ein Ereigniss, das bei jedem <VAR
  25202. CLASS="varname"
  25203. >N</VAR
  25204. >-ten
  25205.      Autreten der low-level Anweisungen innerhalb des
  25206.      <VAR
  25207. CLASS="literal"
  25208. >declare</VAR
  25209. > Blocks, die vom Parser ausgefⁿhrt werden,
  25210.      auftritt. Der Wert von <VAR
  25211. CLASS="varname"
  25212. >N</VAR
  25213. > wird durch die
  25214.      Angabe von <VAR
  25215. CLASS="literal"
  25216. >ticks=<VAR
  25217. CLASS="varname"
  25218. >N</VAR
  25219. ></VAR
  25220. >
  25221.      innerhalb des <VAR
  25222. CLASS="literal"
  25223. >declare</VAR
  25224. >-Blocks in dem
  25225.      <VAR
  25226. CLASS="literal"
  25227. >directive</VAR
  25228. > Abschnitt bestimmt.
  25229.     </P
  25230. ><P
  25231. >      Das Ereignis/die Ereignisse, die bei jedem tick eintreten, legen Sie mit
  25232.      der Funktion <A
  25233. HREF="#function.register-tick-function"
  25234. ><B
  25235. CLASS="function"
  25236. >register_tick_function()</B
  25237. ></A
  25238. > fest.
  25239.      Weitere Einzelheiten k÷nnen Sie dem Beispiel unten entnehmen. Beachten
  25240.      Sie, dass mehr als ein Ereigniss fⁿr jeden tick eintreten kann.
  25241.     </P
  25242. ><P
  25243. >      <TABLE
  25244. WIDTH="100%"
  25245. BORDER="0"
  25246. CELLPADDING="0"
  25247. CELLSPACING="0"
  25248. CLASS="EXAMPLE"
  25249. ><TR
  25250. ><TD
  25251. ><DIV
  25252. CLASS="example"
  25253. ><A
  25254. NAME="AEN4599"
  25255. ></A
  25256. ><P
  25257. ><B
  25258. >Beispiel 15-1. Profil eines Bereichs von PHP Code</B
  25259. ></P
  25260. ><TABLE
  25261. BORDER="0"
  25262. BGCOLOR="#E0E0E0"
  25263. CELLPADDING="5"
  25264. ><TR
  25265. ><TD
  25266. ><PRE
  25267. CLASS="php"
  25268. ><?php
  25269. // Funktion, die bei Aufruf die Zeit aufzeichnet
  25270. function profile($dump = FALSE)
  25271. {
  25272.     static $profile;
  25273.  
  25274.     // Rⁿckgabe der gespeicherten Zeit aus profile, danach l÷schen
  25275.     if ($dump) {
  25276.         $temp = $profile;
  25277.         unset ($profile);
  25278.         return ($temp);
  25279.     }
  25280.  
  25281.     $profile[] = microtime ();
  25282. }
  25283.  
  25284. // Einen tick handler bestimmen
  25285. register_tick_function("profile");
  25286.  
  25287. // Funktion vor dem declare-Block initialisieren
  25288. profile();
  25289.  
  25290. // Ausfⁿhren eines Code-Blocks, jede 2te Anweisung l÷st einen tick aus
  25291.  
  25292. declare(ticks=2) {
  25293.     for ($x = 1; $x < 50; ++$x) {
  25294.         echo similar_text(md5($x), md5($x*$x)), "<br />;";
  25295.     }
  25296. }
  25297.  
  25298. // Ausgabe der gespeicherten Daten aus dem Profiler
  25299. print_r(profile (TRUE));
  25300. ?></PRE
  25301. ></TD
  25302. ></TR
  25303. ></TABLE
  25304. ></DIV
  25305. ></TD
  25306. ></TR
  25307. ></TABLE
  25308. >
  25309.     Dieses Beispiel 'profiliert' den PHP Code der im 'declare'-Block steht,
  25310.     indem die Zeit festgehalten wird, zu der jede zweite low-level Anweisung
  25311.     im Codeblock ausgefⁿhrt wird. Diese Information k÷nnen Sie dazu benutzen,
  25312.     langsame Bereiche innerhalb bestimmter Codesegmente zu identifizieren. Das
  25313.     gleiche Ziel k÷nnen Sie auch mit anderen Methoden erreichen: die Benutzung
  25314.     von ticks ist bequemer und einfacher zu implementieren.
  25315.    </P
  25316. ><P
  25317. >     Ticks sind gut fⁿr Debugging, einfaches Multitasking,
  25318.     Hintergrund I/O und viele andere Aufgaben geeignet.
  25319.    </P
  25320. ><P
  25321. >     Siehe auch <A
  25322. HREF="#function.register-tick-function"
  25323. ><B
  25324. CLASS="function"
  25325. >register_tick_function()</B
  25326. ></A
  25327. > und
  25328.     <A
  25329. HREF="#function.unregister-tick-function"
  25330. ><B
  25331. CLASS="function"
  25332. >unregister_tick_function()</B
  25333. ></A
  25334. >.
  25335.    </P
  25336. ></DIV
  25337. ></DIV
  25338. ><DIV
  25339. CLASS="sect1"
  25340. ><HR><H2
  25341. CLASS="sect1"
  25342. ><A
  25343. NAME="function.return"
  25344. >return</A
  25345. ></H2
  25346. ><P
  25347. >     Wird die <A
  25348. HREF="#function.return"
  25349. ><B
  25350. CLASS="function"
  25351. >return()</B
  25352. ></A
  25353. > Anweisung innerhalb einer Funktion
  25354.     aufgerufen, wird die Ausfⁿhrung der Funktion sofort beendet und das
  25355.     Argument als Wert des Funktionsaufrufs zurⁿckgegeben.
  25356.     <A
  25357. HREF="#function.return"
  25358. ><B
  25359. CLASS="function"
  25360. >return()</B
  25361. ></A
  25362. > beendet auch die Ausfⁿhrung einer
  25363.     <A
  25364. HREF="#function.eval"
  25365. ><B
  25366. CLASS="function"
  25367. >eval()</B
  25368. ></A
  25369. > Anweisung oder einer Skriptdatei.
  25370.    </P
  25371. ><P
  25372. >     Erfolgt der Aufruf innerhalb des globalen Bereichs, wird die Ausfⁿhrung
  25373.     des aktuellen Skripts beendet. Wurde das aktuelle Skript
  25374.     <A
  25375. HREF="#function.include"
  25376. ><B
  25377. CLASS="function"
  25378. >include()</B
  25379. ></A
  25380. >ed oder <A
  25381. HREF="#function.require"
  25382. ><B
  25383. CLASS="function"
  25384. >require()</B
  25385. ></A
  25386. >ed, wird
  25387.     die Kontrolle an das aufrufende Skript zurⁿckgegeben. Wurde das
  25388.     aktuelle Skript <A
  25389. HREF="#function.include"
  25390. ><B
  25391. CLASS="function"
  25392. >include()</B
  25393. ></A
  25394. >ed, wird der Wert, der
  25395.     <A
  25396. HREF="#function.return"
  25397. ><B
  25398. CLASS="function"
  25399. >return()</B
  25400. ></A
  25401. > zugewiesen wurde, als Wert des Aufrufs
  25402.     von <A
  25403. HREF="#function.include"
  25404. ><B
  25405. CLASS="function"
  25406. >include()</B
  25407. ></A
  25408. > zurⁿckgegeben.
  25409.     Wird <A
  25410. HREF="#function.return"
  25411. ><B
  25412. CLASS="function"
  25413. >return()</B
  25414. ></A
  25415. > innerhalb des Hauptskripts aufgerufen,
  25416.     wird die Ausfⁿhrung beendet. Handelt es sich bei dem Skript um eine
  25417.     Datei, die ⁿber die EintrΣge
  25418.     <A
  25419. HREF="#ini.auto-prepend-file"
  25420. >auto_prepend_file</A
  25421. >
  25422.     oder <A
  25423. HREF="#ini.auto-append-file"
  25424. >auto_append_file</A
  25425. >
  25426.     in der <TT
  25427. CLASS="filename"
  25428. >php.ini</TT
  25429. > aufgerufen wurde, wird die Ausfⁿhrung dieses Skripts
  25430.     beendet.
  25431.    </P
  25432. ><P
  25433. >Weitere Informationen erhalten Sie im Abschnitt <A
  25434. HREF="#functions.returning-values"
  25435. >Rⁿckgabewerte</A
  25436. >.
  25437.    </P
  25438. ><DIV
  25439. CLASS="note"
  25440. ><BLOCKQUOTE
  25441. CLASS="note"
  25442. ><P
  25443. ><B
  25444. >Anmerkung: </B
  25445. >
  25446.      Beachten Sie, dass <A
  25447. HREF="#function.return"
  25448. ><B
  25449. CLASS="function"
  25450. >return()</B
  25451. ></A
  25452. > ein Sprachkonstrukt und
  25453.      keine Funktion ist. Die Klammern um ein Argument sind deshalb
  25454.      <SPAN
  25455. CLASS="emphasis"
  25456. ><I
  25457. CLASS="emphasis"
  25458. >nur</I
  25459. ></SPAN
  25460. > zwingend notwendig, wenn es sich um einen
  25461.      Ausdruck handelt, dessen Ergebnis zurⁿckgegeben werden soll.
  25462.      Es ist gebrΣuchlich die Klammern wegzulassen, wenn eine Variable zurⁿck
  25463.      gegeben soll.
  25464.     </P
  25465. ></BLOCKQUOTE
  25466. ></DIV
  25467. ></DIV
  25468. ><DIV
  25469. CLASS="sect1"
  25470. ><HR><H2
  25471. CLASS="sect1"
  25472. ><A
  25473. NAME="function.require"
  25474. ><A
  25475. HREF="#function.require"
  25476. ><B
  25477. CLASS="function"
  25478. >require()</B
  25479. ></A
  25480. ></A
  25481. ></H2
  25482. ><P
  25483. >     Die <A
  25484. HREF="#function.require"
  25485. ><B
  25486. CLASS="function"
  25487. >require()</B
  25488. ></A
  25489. > Anweisung bindet die angegebene Datei ein
  25490.     und wertet diese aus.
  25491.    </P
  25492. ><P
  25493. >     <A
  25494. HREF="#function.require"
  25495. ><B
  25496. CLASS="function"
  25497. >require()</B
  25498. ></A
  25499. > bindet die angegebene Datei ein und fⁿhrt
  25500.     diese aus. Genaue Informationen wie die Einbindung funktioniert ist in
  25501.     der Dokumentation fⁿr <A
  25502. HREF="#function.include"
  25503. ><B
  25504. CLASS="function"
  25505. >include()</B
  25506. ></A
  25507. > beschrieben.
  25508.    </P
  25509. ><P
  25510. >     <A
  25511. HREF="#function.require"
  25512. ><B
  25513. CLASS="function"
  25514. >require()</B
  25515. ></A
  25516. > und <A
  25517. HREF="#function.include"
  25518. ><B
  25519. CLASS="function"
  25520. >include()</B
  25521. ></A
  25522. > sind in
  25523.     jeder Hinsicht gleichwertig mit der einen Ausnahme: der Umgang mit
  25524.     Fehlern. <A
  25525. HREF="#function.include"
  25526. ><B
  25527. CLASS="function"
  25528. >include()</B
  25529. ></A
  25530. > erzeugt ein
  25531.     <A
  25532. HREF="#internal.e-warning"
  25533. >Warning</A
  25534. > wΣhrend
  25535.     <A
  25536. HREF="#function.require"
  25537. ><B
  25538. CLASS="function"
  25539. >require()</B
  25540. ></A
  25541. > in einem <A
  25542. HREF="#internal.e-error"
  25543. >     Fatal Error</A
  25544. > endet. Mit anderen Worten: scheuen Sie sich nicht,
  25545.     <A
  25546. HREF="#function.require"
  25547. ><B
  25548. CLASS="function"
  25549. >require()</B
  25550. ></A
  25551. > zu benutzen, wenn Sie m÷chten, dass eine
  25552.     fehlende Datei die Ausfⁿhrung ihres Skripts beendet.
  25553.     <A
  25554. HREF="#function.include"
  25555. ><B
  25556. CLASS="function"
  25557. >include()</B
  25558. ></A
  25559. > verhΣlt sich anders, ihr Skript wird
  25560.     weiterhin ausgefⁿhrt. Stellen Sie au▀erdem sicher, dass Sie einen gⁿltigen
  25561.     <A
  25562. HREF="#ini.include-path"
  25563. >include_path</A
  25564. > gesetzt haben.
  25565.    </P
  25566. ><P
  25567. >     <TABLE
  25568. WIDTH="100%"
  25569. BORDER="0"
  25570. CELLPADDING="0"
  25571. CELLSPACING="0"
  25572. CLASS="EXAMPLE"
  25573. ><TR
  25574. ><TD
  25575. ><DIV
  25576. CLASS="example"
  25577. ><A
  25578. NAME="AEN4647"
  25579. ></A
  25580. ><P
  25581. ><B
  25582. >Beispiel 15-2. Grundlegende <A
  25583. HREF="#function.require"
  25584. ><B
  25585. CLASS="function"
  25586. >require()</B
  25587. ></A
  25588. > Beispiele</B
  25589. ></P
  25590. ><TABLE
  25591. BORDER="0"
  25592. BGCOLOR="#E0E0E0"
  25593. CELLPADDING="5"
  25594. ><TR
  25595. ><TD
  25596. ><PRE
  25597. CLASS="php"
  25598. ><?php
  25599.  
  25600. require 'prepend.php';
  25601.  
  25602. require $somefile;
  25603.  
  25604. require ('somefile.txt');
  25605.  
  25606. ?></PRE
  25607. ></TD
  25608. ></TR
  25609. ></TABLE
  25610. ></DIV
  25611. ></TD
  25612. ></TR
  25613. ></TABLE
  25614. >
  25615.    </P
  25616. ><P
  25617. >     Weitere Beispiele finden Sie in der Dokumentation zu
  25618.     <A
  25619. HREF="#function.include"
  25620. ><B
  25621. CLASS="function"
  25622. >include()</B
  25623. ></A
  25624. >.
  25625.    </P
  25626. ><P
  25627. >     <DIV
  25628. CLASS="note"
  25629. ><BLOCKQUOTE
  25630. CLASS="note"
  25631. ><P
  25632. ><B
  25633. >Anmerkung: </B
  25634. >
  25635.       Fⁿr frⁿhere Versionen als PHP 4.0.2 gilt folgendes:
  25636.       <A
  25637. HREF="#function.require"
  25638. ><B
  25639. CLASS="function"
  25640. >require()</B
  25641. ></A
  25642. > wird immer versuchen die Zieldatei zu lesen,
  25643.       selbst wenn die Zeile in der die Anweisung steht, nie ausgefⁿhrt wird.
  25644.       Eine bedingte Anweisung hat keine Auswirkungen auf
  25645.       <A
  25646. HREF="#function.require"
  25647. ><B
  25648. CLASS="function"
  25649. >require()</B
  25650. ></A
  25651. >. Wenn jedoch die Zeile in der
  25652.       <A
  25653. HREF="#function.require"
  25654. ><B
  25655. CLASS="function"
  25656. >require()</B
  25657. ></A
  25658. > steht, nie ausgefⁿhrt wird, wird auch der
  25659.       Code der Zieldatei nie ausgefⁿhrt werden. ─hnliches gilt fⁿr
  25660.       Schleifenstrukturen, diese beeinflussen das Verhalten von
  25661.       <A
  25662. HREF="#function.require"
  25663. ><B
  25664. CLASS="function"
  25665. >require()</B
  25666. ></A
  25667. > nicht. Obwohl der Code, der in der Zieldatei
  25668.       enthalten ist, zur Schleife geh÷rt, wird <A
  25669. HREF="#function.require"
  25670. ><B
  25671. CLASS="function"
  25672. >require()</B
  25673. ></A
  25674. >
  25675.       selbst nur einmal ausgefⁿhrt.
  25676.      </P
  25677. ></BLOCKQUOTE
  25678. ></DIV
  25679. >
  25680.    </P
  25681. ><DIV
  25682. CLASS="note"
  25683. ><BLOCKQUOTE
  25684. CLASS="note"
  25685. ><P
  25686. ><B
  25687. >Anmerkung: </B
  25688. >Da dies ein Sprachkonstrukt
  25689. und keine Funktion ist, deshalb k÷nnen Sie dieses nicht mit
  25690. <A
  25691. HREF="#functions.variable-functions"
  25692. >Variablenfunktionen</A
  25693. >
  25694. verwenden.</P
  25695. ></BLOCKQUOTE
  25696. ></DIV
  25697. ><DIV
  25698. CLASS="warning"
  25699. ><P
  25700. ></P
  25701. ><TABLE
  25702. CLASS="warning"
  25703. BORDER="1"
  25704. WIDTH="100%"
  25705. ><TR
  25706. ><TD
  25707. ALIGN="CENTER"
  25708. ><B
  25709. >Warnung</B
  25710. ></TD
  25711. ></TR
  25712. ><TR
  25713. ><TD
  25714. ALIGN="LEFT"
  25715. ><P
  25716. >PHP Versionen kleiner 4.3.0
  25717. fⁿr Windows, erlauben den Zugriff auf Remote-Dateien mit dieser Funktion nicht,
  25718. selbst wenn <A
  25719. HREF="#ini.allow-url-fopen"
  25720. >allow_url_fopen</A
  25721. > aktiviert
  25722. ist.</P
  25723. ></TD
  25724. ></TR
  25725. ></TABLE
  25726. ></DIV
  25727. ><P
  25728. >     Siehe auch <A
  25729. HREF="#function.include"
  25730. ><B
  25731. CLASS="function"
  25732. >include()</B
  25733. ></A
  25734. >, <A
  25735. HREF="#function.require-once"
  25736. ><B
  25737. CLASS="function"
  25738. >require_once()</B
  25739. ></A
  25740. >,
  25741.     <A
  25742. HREF="#function.include-once"
  25743. ><B
  25744. CLASS="function"
  25745. >include_once()</B
  25746. ></A
  25747. >, <A
  25748. HREF="#function.eval"
  25749. ><B
  25750. CLASS="function"
  25751. >eval()</B
  25752. ></A
  25753. >, 
  25754.     <A
  25755. HREF="#function.file"
  25756. ><B
  25757. CLASS="function"
  25758. >file()</B
  25759. ></A
  25760. >, <A
  25761. HREF="#function.readfile"
  25762. ><B
  25763. CLASS="function"
  25764. >readfile()</B
  25765. ></A
  25766. >, 
  25767.     <A
  25768. HREF="#function.virtual"
  25769. ><B
  25770. CLASS="function"
  25771. >virtual()</B
  25772. ></A
  25773. > und <A
  25774. HREF="#ini.include-path"
  25775. >include_path</A
  25776. >.
  25777.    </P
  25778. ></DIV
  25779. ><DIV
  25780. CLASS="sect1"
  25781. ><HR><H2
  25782. CLASS="sect1"
  25783. ><A
  25784. NAME="function.include"
  25785. ><A
  25786. HREF="#function.include"
  25787. ><B
  25788. CLASS="function"
  25789. >include()</B
  25790. ></A
  25791. ></A
  25792. ></H2
  25793. ><P
  25794. >     Die <A
  25795. HREF="#function.include"
  25796. ><B
  25797. CLASS="function"
  25798. >include()</B
  25799. ></A
  25800. > Anweisung bindet die angegebene Datei ein
  25801.     und wertet diese aus.
  25802.    </P
  25803. ><P
  25804. >     Die untenstehende Dokumentation gilt ebenso fⁿr
  25805.     <A
  25806. HREF="#function.require"
  25807. ><B
  25808. CLASS="function"
  25809. >require()</B
  25810. ></A
  25811. >. Diese beiden Konstrukte sind in jeder
  25812.     Hinsicht gleichwertig mit der einen Ausnahme: der Umgang mit Fehlern.
  25813.     <A
  25814. HREF="#function.include"
  25815. ><B
  25816. CLASS="function"
  25817. >include()</B
  25818. ></A
  25819. > erzeugt ein
  25820.     <A
  25821. HREF="#internal.e-warning"
  25822. >Warning</A
  25823. > wΣhrend 
  25824.     <A
  25825. HREF="#function.require"
  25826. ><B
  25827. CLASS="function"
  25828. >require()</B
  25829. ></A
  25830. > in einem <A
  25831. HREF="#internal.e-error"
  25832. >     Fatal Error</A
  25833. > endet. Mit anderen Worten, verwenden Sie
  25834.     <A
  25835. HREF="#function.require"
  25836. ><B
  25837. CLASS="function"
  25838. >require()</B
  25839. ></A
  25840. >, wenn Sie m÷chten, dass eine
  25841.     fehlende Datei die Ausfⁿhrung ihres Skripts beendet.
  25842.     <A
  25843. HREF="#function.include"
  25844. ><B
  25845. CLASS="function"
  25846. >include()</B
  25847. ></A
  25848. > verhΣlt sich anders, ihr Skript wird
  25849.     weiterhin ausgefⁿhrt. Stellen Sie au▀erdem sicher, dass Sie einen gⁿltigen
  25850.     <A
  25851. HREF="#ini.include-path"
  25852. >include_path</A
  25853. > gesetzt
  25854.     haben. Beachten Sie, dass eine Parse Error in einer Datei, die mit require
  25855.     eingebunden wurde, die Ausfⁿhrung ihre Skripts nicht unterbricht.
  25856.    </P
  25857. ><P
  25858. >     Dateien die mit include eingebunden werden, werden zuerst im include_path
  25859.     relativ zum gegenwΣrtigen Arbeitsverzeichnis gesucht und danach im
  25860.     include_path relativ zum Verzeichnis des ausgefⁿhrten Skripts. Zur
  25861.     Veranschaulichung: Falls Ihr include_path <VAR
  25862. CLASS="literal"
  25863. >.</VAR
  25864. > entspricht,
  25865.     ist das gegenwΣrtige Arbeitsverzeichnis
  25866.     <TT
  25867. CLASS="filename"
  25868. >/www/</TT
  25869. >. Sie haben ⁿber include
  25870.     <TT
  25871. CLASS="filename"
  25872. >include/a.php</TT
  25873. > eingebunden und in diesem Skript steht
  25874.     die Anweisung <VAR
  25875. CLASS="literal"
  25876. >include "b.php"</VAR
  25877. >. In diesem Fall wird
  25878.     <TT
  25879. CLASS="filename"
  25880. >b.php</TT
  25881. > zuerst im Verzeichnis
  25882.     <TT
  25883. CLASS="filename"
  25884. >/www/</TT
  25885. > gesucht und danach im
  25886.     Verzeichnis <TT
  25887. CLASS="filename"
  25888. >/www/include/</TT
  25889. >.
  25890.    </P
  25891. ><P
  25892. >     Wenn eine Datei eingebunden wird, erbt der enthaltene Code den
  25893.     <A
  25894. HREF="#language.variables.scope"
  25895. >Geltungsbereich von Variablen</A
  25896. >
  25897.     der Zeile in der die Anweisung steht. Ab dieser Zeile stehen alle verfⁿgbaren
  25898.     Variablen in der aufgerufenen Datei im aufrufenden Skript zur Verfⁿgung.
  25899.    </P
  25900. ><P
  25901. >      <TABLE
  25902. WIDTH="100%"
  25903. BORDER="0"
  25904. CELLPADDING="0"
  25905. CELLSPACING="0"
  25906. CLASS="EXAMPLE"
  25907. ><TR
  25908. ><TD
  25909. ><DIV
  25910. CLASS="example"
  25911. ><A
  25912. NAME="AEN4701"
  25913. ></A
  25914. ><P
  25915. ><B
  25916. >Beispiel 15-3. Grundlegendes <A
  25917. HREF="#function.include"
  25918. ><B
  25919. CLASS="function"
  25920. >include()</B
  25921. ></A
  25922. > Beispiel</B
  25923. ></P
  25924. ><TABLE
  25925. BORDER="0"
  25926. BGCOLOR="#E0E0E0"
  25927. CELLPADDING="5"
  25928. ><TR
  25929. ><TD
  25930. ><PRE
  25931. CLASS="php"
  25932. >vars.php
  25933. <?php
  25934.  
  25935. $color = 'grⁿn';
  25936. $fruit = 'Apfel';
  25937.  
  25938. ?>
  25939.  
  25940. test.php
  25941. <?php
  25942.  
  25943. echo "Ein $color $fruit"; // A
  25944.  
  25945. include 'vars.php';
  25946.  
  25947. echo "Ein $color $fruit"; // Ein grⁿner Apfel
  25948.  
  25949. ?></PRE
  25950. ></TD
  25951. ></TR
  25952. ></TABLE
  25953. ></DIV
  25954. ></TD
  25955. ></TR
  25956. ></TABLE
  25957. >
  25958.    </P
  25959. ><P
  25960. >     Steht include im aufrufenden Skript innerhalb einer Funktion, verhΣlt sich
  25961.     der gesamte Code der aufgerufenen Datei genau so, als ob Sie diesen Code
  25962.     innerhalb dieser Funktion definiert hΣtten. Aus diesem Grund hat dieser
  25963.     Code den Geltungsbereich der Variablen dieser Funktion.
  25964.    </P
  25965. ><P
  25966. >      <TABLE
  25967. WIDTH="100%"
  25968. BORDER="0"
  25969. CELLPADDING="0"
  25970. CELLSPACING="0"
  25971. CLASS="EXAMPLE"
  25972. ><TR
  25973. ><TD
  25974. ><DIV
  25975. CLASS="example"
  25976. ><A
  25977. NAME="AEN4707"
  25978. ></A
  25979. ><P
  25980. ><B
  25981. >Beispiel 15-4. Include innerhalb einer Funktion</B
  25982. ></P
  25983. ><TABLE
  25984. BORDER="0"
  25985. BGCOLOR="#E0E0E0"
  25986. CELLPADDING="5"
  25987. ><TR
  25988. ><TD
  25989. ><PRE
  25990. CLASS="php"
  25991. ><?php
  25992.  
  25993. function foo()
  25994. {
  25995. global $color;
  25996.  
  25997.     include 'vars.php';
  25998.  
  25999.     echo "Ein $color $fruit";
  26000. }
  26001.  
  26002. /* vars.php ist im Geltungsbereich von foo(),  *
  26003.  * d.h. $fruit steht au▀erhalb dieses Bereichs *
  26004.  * NICHT zur Verfⁿgung. $color schon, da wir   *
  26005.  * diese Variable als global definiert haben  */
  26006.  
  26007. foo();                    // Ein grⁿner Apfel
  26008. echo "Ein $color $fruit";   // Ein grⁿner
  26009.  
  26010. ?></PRE
  26011. ></TD
  26012. ></TR
  26013. ></TABLE
  26014. ></DIV
  26015. ></TD
  26016. ></TR
  26017. ></TABLE
  26018. >
  26019.    </P
  26020. ><P
  26021. >     Beim Einbinden einer Datei wechselt der Parser vom PHP-Modus zu Beginn
  26022.     der Zieldatei in den HTML-Modus und kehrt am Ende der eingebunden
  26023.     Datei wieder in den PHP-Modus zurⁿck. Deshalb muss jeglicher Code
  26024.     innerhalb der eingebundenen Datei, der als PHP-Code ausgefⁿhrt werden
  26025.     soll, von <A
  26026. HREF="#language.basic-syntax.phpmode"
  26027. >gⁿltigen
  26028.     PHP-Start- und Ende-Tags</A
  26029. > eingefa▀t sein.
  26030.    </P
  26031. ><P
  26032. >     Wenn "<A
  26033. HREF="#ini.allow-url-fopen"
  26034. >URL fopen wrappers</A
  26035. >"
  26036.     in PHP aktiviert sind (in der Standardkonfiguration ist das der Fall)
  26037.     k÷nnen Sie als Pfad der einzubindenden Datei auch eine URL (via HTTP oder
  26038.     anderen unterstⁿtzen Wrappern - eine Liste der unterstⁿtzen Protokolle
  26039.     finden Sie unter <A
  26040. HREF="#wrappers"
  26041. >Anhang L</A
  26042. >) statt einer lokalen
  26043.     Pfadangabe angeben. Falls der Zielserver die Zieldatei als PHP-Code
  26044.     interpretiert, k÷nnen Sie an die einzubindende Datei Variablen in einem
  26045.     Request-String ⁿbergeben, genauso wie bei HTTP GET. Streng genommen ist
  26046.     das nicht das Gleiche, wie diese Datei einzubinden und diesem den
  26047.     Geltungsbereich des Vater-Skripts zu vererben; das Skript wird auf dem
  26048.     Remote-Server ausgefⁿhrt und danach wird das Ergebnis in das lokale Skript
  26049.     eingebunden.
  26050.    </P
  26051. ><DIV
  26052. CLASS="warning"
  26053. ><P
  26054. ></P
  26055. ><TABLE
  26056. CLASS="warning"
  26057. BORDER="1"
  26058. WIDTH="100%"
  26059. ><TR
  26060. ><TD
  26061. ALIGN="CENTER"
  26062. ><B
  26063. >Warnung</B
  26064. ></TD
  26065. ></TR
  26066. ><TR
  26067. ><TD
  26068. ALIGN="LEFT"
  26069. ><P
  26070. >PHP Versionen kleiner 4.3.0
  26071. fⁿr Windows, erlauben den Zugriff auf Remote-Dateien mit dieser Funktion nicht,
  26072. selbst wenn <A
  26073. HREF="#ini.allow-url-fopen"
  26074. >allow_url_fopen</A
  26075. > aktiviert
  26076. ist.</P
  26077. ></TD
  26078. ></TR
  26079. ></TABLE
  26080. ></DIV
  26081. ><P
  26082. >     <TABLE
  26083. WIDTH="100%"
  26084. BORDER="0"
  26085. CELLPADDING="0"
  26086. CELLSPACING="0"
  26087. CLASS="EXAMPLE"
  26088. ><TR
  26089. ><TD
  26090. ><DIV
  26091. CLASS="example"
  26092. ><A
  26093. NAME="AEN4719"
  26094. ></A
  26095. ><P
  26096. ><B
  26097. >Beispiel 15-5. <A
  26098. HREF="#function.include"
  26099. ><B
  26100. CLASS="function"
  26101. >include()</B
  26102. ></A
  26103. > ⁿber HTTP</B
  26104. ></P
  26105. ><TABLE
  26106. BORDER="0"
  26107. BGCOLOR="#E0E0E0"
  26108. CELLPADDING="5"
  26109. ><TR
  26110. ><TD
  26111. ><PRE
  26112. CLASS="php"
  26113. ><?php
  26114.  
  26115. /* Dieses Beispiel geht davon aus, dass www.example.com so konfiguriert     *
  26116.  * ist, dass .php-Dateien geparst werden und keine .txt Dateien. Also meint *
  26117.  * 'Funkt' hier, dass die Variablen $foo und $bar innerhalb der             *
  26118.  * angeforderten Datei zur Verfⁿgung stehen                                 */
  26119.  
  26120. // Funkt nicht; file.txt wird von www.example.com nicht als PHP geparst
  26121.  
  26122. include 'http://www.example.com/file.txt?foo=1&bar=2';
  26123.  
  26124. // Funkt nicht; schaut nach einer lokalen Datei namens
  26125. // 'file.php?foo=1&bar=2' im lokalen Dateisystem
  26126.  
  26127. include 'file.php?foo=1&bar=2';
  26128.  
  26129. // Funkt
  26130. include 'http://www.example.com/file.php?foo=1&bar=2';
  26131.  
  26132. $foo = 1;
  26133. $bar = 2;
  26134. include 'file.txt';  // Funkt
  26135. include 'file.php';  // Funkt
  26136.  
  26137. ?></PRE
  26138. ></TD
  26139. ></TR
  26140. ></TABLE
  26141. ></DIV
  26142. ></TD
  26143. ></TR
  26144. ></TABLE
  26145. >
  26146.      Siehe auch <A
  26147. HREF="#features.remote-files"
  26148. >      Zugriff auf entfernte Dateien</A
  26149. >, <A
  26150. HREF="#function.fopen"
  26151. ><B
  26152. CLASS="function"
  26153. >fopen()</B
  26154. ></A
  26155. > und
  26156.      <A
  26157. HREF="#function.file"
  26158. ><B
  26159. CLASS="function"
  26160. >file()</B
  26161. ></A
  26162. > fⁿr verwandte Informationen.
  26163.    </P
  26164. ><P
  26165. >     Da <A
  26166. HREF="#function.include"
  26167. ><B
  26168. CLASS="function"
  26169. >include()</B
  26170. ></A
  26171. > und <A
  26172. HREF="#function.require"
  26173. ><B
  26174. CLASS="function"
  26175. >require()</B
  26176. ></A
  26177. >
  26178.     spezielle Sprachkonstrukte sind, mⁿssen Sie diese innerhalb einer
  26179.     bedingten Anweisung in einen Anweisungsblock setzen.
  26180.    </P
  26181. ><P
  26182. >     <TABLE
  26183. WIDTH="100%"
  26184. BORDER="0"
  26185. CELLPADDING="0"
  26186. CELLSPACING="0"
  26187. CLASS="EXAMPLE"
  26188. ><TR
  26189. ><TD
  26190. ><DIV
  26191. CLASS="example"
  26192. ><A
  26193. NAME="AEN4730"
  26194. ></A
  26195. ><P
  26196. ><B
  26197. >Beispiel 15-6. include() und bedingte Bl÷cke</B
  26198. ></P
  26199. ><TABLE
  26200. BORDER="0"
  26201. BGCOLOR="#E0E0E0"
  26202. CELLPADDING="5"
  26203. ><TR
  26204. ><TD
  26205. ><PRE
  26206. CLASS="php"
  26207. ><?php
  26208.  
  26209. // Das ist FALSCH und fⁿhrt nicht zum gewⁿnschten Ergebnis.
  26210.  
  26211.  
  26212. if ($bedingung)
  26213.     include $datei;
  26214. else
  26215.     include $andere_datei;
  26216.  
  26217.  
  26218. // Das ist KORREKT.
  26219. if ($bedingung) {
  26220.     include $datei;
  26221. } else {
  26222.     include $andere_datei;
  26223. }
  26224.  
  26225. ?></PRE
  26226. ></TD
  26227. ></TR
  26228. ></TABLE
  26229. ></DIV
  26230. ></TD
  26231. ></TR
  26232. ></TABLE
  26233. >
  26234.    </P
  26235. ><P
  26236. >     Der Umgang mit Returns: Es ist m÷glich eine <A
  26237. HREF="#function.return"
  26238. ><B
  26239. CLASS="function"
  26240. >return()</B
  26241. ></A
  26242. >
  26243.     -Anweisung innerhalb einer eingebunden Datei anzugeben, um die 
  26244.     Ausfⁿhrung innerhalb dieser Datei abzubrechen und zum aufrufenden Skript
  26245.     zurⁿckzukehren. Ebenso ist die Rⁿckgabe von Werten aus einer
  26246.     eingebunden Datei m÷glich. Sie k÷nnen den Wert eines include-Aufrufs auf
  26247.     die gleiche Art und Weise nutzen, wie Sie es bei einer Funktion machen
  26248.     wⁿrden. Allerdings besteht diese M÷glichkeit nicht, wenn Sie entfernte
  26249.     Dateien mittels include einbinden au▀er, wenn die Ausgabe der
  26250.     entfernten Datei <A
  26251. HREF="#language.basic-syntax.phpmode"
  26252. >     gⁿltige PHP Start- und Endetags</A
  26253. > beeinhaltet (wie jede lokale Datei auch).
  26254.     Innerhalb dieser Tags k÷nnen Sie die ben÷tigten Variablen deklarieren und
  26255.     diese werden dann an dem Punkt Ihres Skripts eingefⁿhrt, von wo aus der
  26256.     Aufruf mit include erfolgt ist.
  26257.    </P
  26258. ><DIV
  26259. CLASS="note"
  26260. ><BLOCKQUOTE
  26261. CLASS="note"
  26262. ><P
  26263. ><B
  26264. >Anmerkung: </B
  26265. >
  26266.      In PHP 3 darf eine return-Anweisung nicht innerhalb eines Blocks
  26267.      auftreten, es sei denn, es ist ein Funktionsblock. In diesem Fall gilt
  26268.      <A
  26269. HREF="#function.return"
  26270. ><B
  26271. CLASS="function"
  26272. >return()</B
  26273. ></A
  26274. > fⁿr diese Funktion und nicht fⁿr die ganze
  26275.      Datei.
  26276.     </P
  26277. ></BLOCKQUOTE
  26278. ></DIV
  26279. ><P
  26280. >     <TABLE
  26281. WIDTH="100%"
  26282. BORDER="0"
  26283. CELLPADDING="0"
  26284. CELLSPACING="0"
  26285. CLASS="EXAMPLE"
  26286. ><TR
  26287. ><TD
  26288. ><DIV
  26289. CLASS="example"
  26290. ><A
  26291. NAME="AEN4740"
  26292. ></A
  26293. ><P
  26294. ><B
  26295. >Beispiel 15-7. <A
  26296. HREF="#function.include"
  26297. ><B
  26298. CLASS="function"
  26299. >include()</B
  26300. ></A
  26301. > und die <A
  26302. HREF="#function.return"
  26303. ><B
  26304. CLASS="function"
  26305. >return()</B
  26306. ></A
  26307. > Anweisung</B
  26308. ></P
  26309. ><TABLE
  26310. BORDER="0"
  26311. BGCOLOR="#E0E0E0"
  26312. CELLPADDING="5"
  26313. ><TR
  26314. ><TD
  26315. ><PRE
  26316. CLASS="php"
  26317. >return.php
  26318. <?php
  26319.  
  26320. $var = 'PHP';
  26321.  
  26322. return $var;
  26323.  
  26324. ?>
  26325.  
  26326. noreturn.php
  26327. <?php
  26328.  
  26329. $var = 'PHP';
  26330.  
  26331. ?>
  26332.  
  26333. testreturns.php
  26334. <?php
  26335.  
  26336. $foo = include 'return.php';
  26337.  
  26338. echo $foo; // gibt 'PHP' aus
  26339.  
  26340. $bar = include 'noreturn.php';
  26341.  
  26342. echo $bar; // gibt 1 aus
  26343.  
  26344. ?></PRE
  26345. ></TD
  26346. ></TR
  26347. ></TABLE
  26348. ></DIV
  26349. ></TD
  26350. ></TR
  26351. ></TABLE
  26352. >
  26353.    </P
  26354. ><P
  26355. >     <VAR
  26356. CLASS="literal"
  26357. >$bar</VAR
  26358. > hat den Wert <VAR
  26359. CLASS="literal"
  26360. >1</VAR
  26361. >, weil include
  26362.     erfolgreich war. Beachten Sie die Unterschiede in den obigen Beispielen.
  26363.     Das erste nutzt <A
  26364. HREF="#function.return"
  26365. ><B
  26366. CLASS="function"
  26367. >return()</B
  26368. ></A
  26369. > innerhalb der eingebundenen
  26370.     Datei im Gegensatz zum zweiten Beispiel. Weitere M÷glichkeiten Dateien in
  26371.     Variablen "einzubinden" bieten ihnen die Funktionen
  26372.     <A
  26373. HREF="#function.fopen"
  26374. ><B
  26375. CLASS="function"
  26376. >fopen()</B
  26377. ></A
  26378. > und <A
  26379. HREF="#function.file"
  26380. ><B
  26381. CLASS="function"
  26382. >file()</B
  26383. ></A
  26384. > oder
  26385.     <A
  26386. HREF="#function.include"
  26387. ><B
  26388. CLASS="function"
  26389. >include()</B
  26390. ></A
  26391. > im Zusammenspiel mit den
  26392.     <A
  26393. HREF="#ref.outcontrol"
  26394. >Funktionen zur Ausgabesteuerung</A
  26395. >.
  26396.    </P
  26397. ><DIV
  26398. CLASS="note"
  26399. ><BLOCKQUOTE
  26400. CLASS="note"
  26401. ><P
  26402. ><B
  26403. >Anmerkung: </B
  26404. >Da dies ein Sprachkonstrukt
  26405. und keine Funktion ist, deshalb k÷nnen Sie dieses nicht mit
  26406. <A
  26407. HREF="#functions.variable-functions"
  26408. >Variablenfunktionen</A
  26409. >
  26410. verwenden.</P
  26411. ></BLOCKQUOTE
  26412. ></DIV
  26413. ><P
  26414. >     Siehe auch <A
  26415. HREF="#function.require"
  26416. ><B
  26417. CLASS="function"
  26418. >require()</B
  26419. ></A
  26420. >, <A
  26421. HREF="#function.require-once"
  26422. ><B
  26423. CLASS="function"
  26424. >require_once()</B
  26425. ></A
  26426. >,
  26427.     <A
  26428. HREF="#function.include-once"
  26429. ><B
  26430. CLASS="function"
  26431. >include_once()</B
  26432. ></A
  26433. >, <A
  26434. HREF="#function.readfile"
  26435. ><B
  26436. CLASS="function"
  26437. >readfile()</B
  26438. ></A
  26439. >,
  26440.     <A
  26441. HREF="#function.virtual"
  26442. ><B
  26443. CLASS="function"
  26444. >virtual()</B
  26445. ></A
  26446. >und
  26447.     <A
  26448. HREF="#ini.include-path"
  26449. >include_path</A
  26450. >.
  26451.    </P
  26452. ></DIV
  26453. ><DIV
  26454. CLASS="sect1"
  26455. ><HR><H2
  26456. CLASS="sect1"
  26457. ><A
  26458. NAME="function.require-once"
  26459. ><A
  26460. HREF="#function.require-once"
  26461. ><B
  26462. CLASS="function"
  26463. >require_once()</B
  26464. ></A
  26465. ></A
  26466. ></H2
  26467. ><P
  26468. >     Die <A
  26469. HREF="#function.require-once"
  26470. ><B
  26471. CLASS="function"
  26472. >require_once()</B
  26473. ></A
  26474. > Anweisung bindet eine Datei ein
  26475.     und wertet diese zur Laufzeit des Skripts aus.
  26476.     Das Verhalten ist Σhnlich der <A
  26477. HREF="#function.require"
  26478. ><B
  26479. CLASS="function"
  26480. >require()</B
  26481. ></A
  26482. > Anweisung mit
  26483.     dem einzigen Unterschied, dass einmal eingebundener Code aus einer Datei
  26484.     nicht nocht einmal eingebunden wird. Lesen Sie die Dokumentation zu
  26485.     <A
  26486. HREF="#function.require"
  26487. ><B
  26488. CLASS="function"
  26489. >require()</B
  26490. ></A
  26491. > um mehr Informationen ⁿber die Arbeitsweise
  26492.     dieser Anweisung zu erhalten.
  26493.    </P
  26494. ><P
  26495. >     <A
  26496. HREF="#function.require-once"
  26497. ><B
  26498. CLASS="function"
  26499. >require_once()</B
  26500. ></A
  26501. > sollten Sie in den FΣllen benutzen,
  26502.     wenn die gleiche Datei in einem bestimmten Bereich mehrmals eingebunden
  26503.     und interpretiert werden soll und Sie sicher stellen wollen, dass diese
  26504.     Datei nur exakt einmal eingebunden wird, um Probleme mit Wiederholungen
  26505.     bei Funktions-Definitionen und Wertzuweisungen zu Variablen zu vermeiden,
  26506.     usw.
  26507.    </P
  26508. ><P
  26509. >     Weitere Beispiele zu <A
  26510. HREF="#function.require-once"
  26511. ><B
  26512. CLASS="function"
  26513. >require_once()</B
  26514. ></A
  26515. > und
  26516.     <A
  26517. HREF="#function.include-once"
  26518. ><B
  26519. CLASS="function"
  26520. >include_once()</B
  26521. ></A
  26522. > k÷nnen Sie dem
  26523.     <A
  26524. HREF="http://pear.php.net/"
  26525. TARGET="_top"
  26526. >PEAR</A
  26527. >-Code entnehmen, welcher
  26528.     im aktuellsten PHP-Sourcecode enthalten ist.
  26529.    </P
  26530. ><DIV
  26531. CLASS="note"
  26532. ><BLOCKQUOTE
  26533. CLASS="note"
  26534. ><P
  26535. ><B
  26536. >Anmerkung: </B
  26537. >
  26538.     <A
  26539. HREF="#function.require-once"
  26540. ><B
  26541. CLASS="function"
  26542. >require_once()</B
  26543. ></A
  26544. > steht ab PHP 4.01pl2 zur
  26545.     Verfⁿgung.
  26546.    </P
  26547. ></BLOCKQUOTE
  26548. ></DIV
  26549. ><DIV
  26550. CLASS="note"
  26551. ><BLOCKQUOTE
  26552. CLASS="note"
  26553. ><P
  26554. ><B
  26555. >Anmerkung: </B
  26556. >
  26557.      Beachten Sie, dass auf auf einem Betriebssystem, das nicht zwischen
  26558.      Gro▀- und Kleinschreibung unterschiedet (wie z.B. Windows) das Verhalten
  26559.      von <A
  26560. HREF="#function.require-once"
  26561. ><B
  26562. CLASS="function"
  26563. >require_once()</B
  26564. ></A
  26565. > und
  26566.      <A
  26567. HREF="#function.include-once"
  26568. ><B
  26569. CLASS="function"
  26570. >include_once()</B
  26571. ></A
  26572. > nicht unbedingt ihren Erwartungen
  26573.      entspricht.
  26574.      <TABLE
  26575. WIDTH="100%"
  26576. BORDER="0"
  26577. CELLPADDING="0"
  26578. CELLSPACING="0"
  26579. CLASS="EXAMPLE"
  26580. ><TR
  26581. ><TD
  26582. ><DIV
  26583. CLASS="example"
  26584. ><A
  26585. NAME="AEN4783"
  26586. ></A
  26587. ><P
  26588. ><B
  26589. >Beispiel 15-8. 
  26590.        <A
  26591. HREF="#function.require-once"
  26592. ><B
  26593. CLASS="function"
  26594. >require_once()</B
  26595. ></A
  26596. > unterscheidet nicht zwischen
  26597.        Gro▀-/Kleinschreibung unter Windows
  26598.       </B
  26599. ></P
  26600. ><TABLE
  26601. BORDER="0"
  26602. BGCOLOR="#E0E0E0"
  26603. CELLPADDING="5"
  26604. ><TR
  26605. ><TD
  26606. ><PRE
  26607. CLASS="php"
  26608. ><?php
  26609. require_once("a.php"); // bindet a.php ein
  26610. require_once("A.php"); // bindet a.php auf Windows nochmal ein!
  26611. ?></PRE
  26612. ></TD
  26613. ></TR
  26614. ></TABLE
  26615. ></DIV
  26616. ></TD
  26617. ></TR
  26618. ></TABLE
  26619. >
  26620.     </P
  26621. ></BLOCKQUOTE
  26622. ></DIV
  26623. ><DIV
  26624. CLASS="warning"
  26625. ><P
  26626. ></P
  26627. ><TABLE
  26628. CLASS="warning"
  26629. BORDER="1"
  26630. WIDTH="100%"
  26631. ><TR
  26632. ><TD
  26633. ALIGN="CENTER"
  26634. ><B
  26635. >Warnung</B
  26636. ></TD
  26637. ></TR
  26638. ><TR
  26639. ><TD
  26640. ALIGN="LEFT"
  26641. ><P
  26642. >PHP Versionen kleiner 4.3.0
  26643. fⁿr Windows, erlauben den Zugriff auf Remote-Dateien mit dieser Funktion nicht,
  26644. selbst wenn <A
  26645. HREF="#ini.allow-url-fopen"
  26646. >allow_url_fopen</A
  26647. > aktiviert
  26648. ist.</P
  26649. ></TD
  26650. ></TR
  26651. ></TABLE
  26652. ></DIV
  26653. ><P
  26654. >     Siehe auch: <A
  26655. HREF="#function.require"
  26656. ><B
  26657. CLASS="function"
  26658. >require()</B
  26659. ></A
  26660. >,
  26661.     <A
  26662. HREF="#function.include"
  26663. ><B
  26664. CLASS="function"
  26665. >include()</B
  26666. ></A
  26667. >, <A
  26668. HREF="#function.include-once"
  26669. ><B
  26670. CLASS="function"
  26671. >include_once()</B
  26672. ></A
  26673. >,
  26674.     <A
  26675. HREF="#function.get-required-files"
  26676. ><B
  26677. CLASS="function"
  26678. >get_required_files()</B
  26679. ></A
  26680. >,
  26681.     <A
  26682. HREF="#function.get-included-files"
  26683. ><B
  26684. CLASS="function"
  26685. >get_included_files()</B
  26686. ></A
  26687. >, 
  26688.     <A
  26689. HREF="#function.readfile"
  26690. ><B
  26691. CLASS="function"
  26692. >readfile()</B
  26693. ></A
  26694. >
  26695.     und <A
  26696. HREF="#function.virtual"
  26697. ><B
  26698. CLASS="function"
  26699. >virtual()</B
  26700. ></A
  26701. >.
  26702.    </P
  26703. ></DIV
  26704. ><DIV
  26705. CLASS="sect1"
  26706. ><HR><H2
  26707. CLASS="sect1"
  26708. ><A
  26709. NAME="function.include-once"
  26710. ><A
  26711. HREF="#function.include-once"
  26712. ><B
  26713. CLASS="function"
  26714. >include_once()</B
  26715. ></A
  26716. ></A
  26717. ></H2
  26718. ><P
  26719. >     Die Anweisung <A
  26720. HREF="#function.include-once"
  26721. ><B
  26722. CLASS="function"
  26723. >include_once()</B
  26724. ></A
  26725. > schlie▀t zur
  26726.     Ausfⁿhrungszeit die angegebene Datei ein und wertet diese aus. Dies
  26727.     ist Σhnlich der <A
  26728. HREF="#function.include"
  26729. ><B
  26730. CLASS="function"
  26731. >include()</B
  26732. ></A
  26733. >-Anweisung; mit dem
  26734.     Unterschied, dass einmal eingebundener Code nicht nochmals 
  26735.     eingebunden wird. Wie der Name vermuten lΣsst, wird die Datei nur ein
  26736.     einziges Mal eingebunden.
  26737.    </P
  26738. ><P
  26739. >     <A
  26740. HREF="#function.include-once"
  26741. ><B
  26742. CLASS="function"
  26743. >include_once()</B
  26744. ></A
  26745. > sollten Sie in den FΣllen benutzen,
  26746.     wenn die gleiche Datei in einem bestimmten Bereich mehrmals eingebunden
  26747.     und interpretiert werden soll und Sie sicher stellen wollen, dass diese
  26748.     Datei nur exakt einmal eingebunden wird, um Probleme mit Wiederholungen
  26749.     von Funktionsdefinitionen und Wertzuweisungen an Variablen zu vermeiden,
  26750.     usw.
  26751.    </P
  26752. ><P
  26753. >     Weitere Beispiele zu <A
  26754. HREF="#function.require-once"
  26755. ><B
  26756. CLASS="function"
  26757. >require_once()</B
  26758. ></A
  26759. > und
  26760.     <A
  26761. HREF="#function.include-once"
  26762. ><B
  26763. CLASS="function"
  26764. >include_once()</B
  26765. ></A
  26766. > k÷nnen Sie dem
  26767.     <A
  26768. HREF="http://pear.php.net/"
  26769. TARGET="_top"
  26770. >PEAR</A
  26771. >-Code entnehmen, welcher
  26772.     im aktuellsten PHP-Source-Code enthalten ist.
  26773.    </P
  26774. ><DIV
  26775. CLASS="note"
  26776. ><BLOCKQUOTE
  26777. CLASS="note"
  26778. ><P
  26779. ><B
  26780. >Anmerkung: </B
  26781. >
  26782.     <A
  26783. HREF="#function.include-once"
  26784. ><B
  26785. CLASS="function"
  26786. >include_once()</B
  26787. ></A
  26788. > steht ab PHP 4.01pl2 zur
  26789.     Verfⁿgung.
  26790.    </P
  26791. ></BLOCKQUOTE
  26792. ></DIV
  26793. ><DIV
  26794. CLASS="note"
  26795. ><BLOCKQUOTE
  26796. CLASS="note"
  26797. ><P
  26798. ><B
  26799. >Anmerkung: </B
  26800. >
  26801.      Beachten Sie, dass auf auf einem Betriebssystem, das nicht zwischen
  26802.      Gro▀- und Kleinschreibung unterschiedet (wie z.B. Windows) das Verhalten
  26803.      von <A
  26804. HREF="#function.include-once"
  26805. ><B
  26806. CLASS="function"
  26807. >include_once()</B
  26808. ></A
  26809. > und
  26810.      <A
  26811. HREF="#function.require-once"
  26812. ><B
  26813. CLASS="function"
  26814. >require_once()</B
  26815. ></A
  26816. > nicht unbedingt ihren Erwartungen
  26817.      entspricht.
  26818.      <TABLE
  26819. WIDTH="100%"
  26820. BORDER="0"
  26821. CELLPADDING="0"
  26822. CELLSPACING="0"
  26823. CLASS="EXAMPLE"
  26824. ><TR
  26825. ><TD
  26826. ><DIV
  26827. CLASS="example"
  26828. ><A
  26829. NAME="AEN4817"
  26830. ></A
  26831. ><P
  26832. ><B
  26833. >Beispiel 15-9. 
  26834.        <A
  26835. HREF="#function.include-once"
  26836. ><B
  26837. CLASS="function"
  26838. >include_once()</B
  26839. ></A
  26840. > unterscheidet nicht zwischen
  26841.        Gro▀-/Kleinschreibung unter Windows
  26842.       </B
  26843. ></P
  26844. ><TABLE
  26845. BORDER="0"
  26846. BGCOLOR="#E0E0E0"
  26847. CELLPADDING="5"
  26848. ><TR
  26849. ><TD
  26850. ><PRE
  26851. CLASS="php"
  26852. ><?php
  26853. include_once("a.php"); // bindet a.php ein
  26854. include_once("A.php"); // bindet a.php auf Windows nochmal ein!
  26855. ?></PRE
  26856. ></TD
  26857. ></TR
  26858. ></TABLE
  26859. ></DIV
  26860. ></TD
  26861. ></TR
  26862. ></TABLE
  26863. >
  26864.     </P
  26865. ></BLOCKQUOTE
  26866. ></DIV
  26867. ><DIV
  26868. CLASS="warning"
  26869. ><P
  26870. ></P
  26871. ><TABLE
  26872. CLASS="warning"
  26873. BORDER="1"
  26874. WIDTH="100%"
  26875. ><TR
  26876. ><TD
  26877. ALIGN="CENTER"
  26878. ><B
  26879. >Warnung</B
  26880. ></TD
  26881. ></TR
  26882. ><TR
  26883. ><TD
  26884. ALIGN="LEFT"
  26885. ><P
  26886. >PHP Versionen kleiner 4.3.0
  26887. fⁿr Windows, erlauben den Zugriff auf Remote-Dateien mit dieser Funktion nicht,
  26888. selbst wenn <A
  26889. HREF="#ini.allow-url-fopen"
  26890. >allow_url_fopen</A
  26891. > aktiviert
  26892. ist.</P
  26893. ></TD
  26894. ></TR
  26895. ></TABLE
  26896. ></DIV
  26897. ><P
  26898. >     Siehe auch <A
  26899. HREF="#function.include"
  26900. ><B
  26901. CLASS="function"
  26902. >include()</B
  26903. ></A
  26904. >,
  26905.     <A
  26906. HREF="#function.require"
  26907. ><B
  26908. CLASS="function"
  26909. >require()</B
  26910. ></A
  26911. >, <A
  26912. HREF="#function.require-once"
  26913. ><B
  26914. CLASS="function"
  26915. >require_once()</B
  26916. ></A
  26917. >,
  26918.     <A
  26919. HREF="#function.get-required-files"
  26920. ><B
  26921. CLASS="function"
  26922. >get_required_files()</B
  26923. ></A
  26924. >,
  26925.     <A
  26926. HREF="#function.get-included-files"
  26927. ><B
  26928. CLASS="function"
  26929. >get_included_files()</B
  26930. ></A
  26931. >, <A
  26932. HREF="#function.readfile"
  26933. ><B
  26934. CLASS="function"
  26935. >readfile()</B
  26936. ></A
  26937. >
  26938.     und <A
  26939. HREF="#function.virtual"
  26940. ><B
  26941. CLASS="function"
  26942. >virtual()</B
  26943. ></A
  26944. >.
  26945.    </P
  26946. ></DIV
  26947. ></DIV
  26948. ><DIV
  26949. CLASS="chapter"
  26950. ><HR><H1
  26951. ><A
  26952. NAME="functions"
  26953. >Kapitel 16. Funktionen</A
  26954. ></H1
  26955. ><DIV
  26956. CLASS="sect1"
  26957. ><H2
  26958. CLASS="sect1"
  26959. ><A
  26960. NAME="functions.user-defined"
  26961. >Vom Nutzer definierte Funktionen</A
  26962. ></H2
  26963. ><P
  26964. >     Eine Funktion kann wie folgt definiert werden:
  26965.  
  26966.     <DIV
  26967. CLASS="informalexample"
  26968. ><P
  26969. ></P
  26970. ><A
  26971. NAME="AEN4837"
  26972. ></A
  26973. ><TABLE
  26974. BORDER="0"
  26975. BGCOLOR="#E0E0E0"
  26976. CELLPADDING="5"
  26977. ><TR
  26978. ><TD
  26979. ><PRE
  26980. CLASS="php"
  26981. >function foo ($arg_1, $arg_2, ..., $arg_n)
  26982. {
  26983.     echo "Beispielfunktion.\n";
  26984.     return $retval;
  26985. }</PRE
  26986. ></TD
  26987. ></TR
  26988. ></TABLE
  26989. ><P
  26990. ></P
  26991. ></DIV
  26992. >
  26993.    </P
  26994. ><P
  26995. >     Jeder beliebige korrekte PHP-Code kann in einer Funktion
  26996.     vorkommen, sogar andere Funktionen und <A
  26997. HREF="#keyword.class"
  26998. >Klassen-</A
  26999. > Definitionen.
  27000.    </P
  27001. ><P
  27002. >     In PHP 3 mⁿssen Funktionen definiert sein, bevor man auf sie
  27003.     verweist. In PHP4 ist das nicht mehr erforderlich,
  27004.     <SPAN
  27005. CLASS="emphasis"
  27006. ><I
  27007. CLASS="emphasis"
  27008. >au▀er</I
  27009. ></SPAN
  27010. > wenn eine Funktion nur bedingt definiert
  27011.     wird, wie in den beiden untenstehenden Beispielen gezeigt.
  27012.    </P
  27013. ><P
  27014. >     Wenn eine Funktion nur unter bestimmten Bedingungen definiert wird,
  27015.     mu▀ die Definition dieser Funktion noch <SPAN
  27016. CLASS="emphasis"
  27017. ><I
  27018. CLASS="emphasis"
  27019. >vor</I
  27020. ></SPAN
  27021. >
  27022.     deren Aufruf abgearbeitet werden.
  27023.     <TABLE
  27024. WIDTH="100%"
  27025. BORDER="0"
  27026. CELLPADDING="0"
  27027. CELLSPACING="0"
  27028. CLASS="EXAMPLE"
  27029. ><TR
  27030. ><TD
  27031. ><DIV
  27032. CLASS="example"
  27033. ><A
  27034. NAME="AEN4845"
  27035. ></A
  27036. ><P
  27037. ><B
  27038. >Beispiel 16-1. Bedingte Funktionen</B
  27039. ></P
  27040. ><TABLE
  27041. BORDER="0"
  27042. BGCOLOR="#E0E0E0"
  27043. CELLPADDING="5"
  27044. ><TR
  27045. ><TD
  27046. ><PRE
  27047. CLASS="php"
  27048. ><?php
  27049.  
  27050. $makefoo = true;
  27051.  
  27052. /* Wir k÷nnen foo() von her aus nicht
  27053.    aufrufen, da sie noch nicht existiert,
  27054.    aber wir k÷nnen bar() aufrufen */
  27055.  
  27056. bar();
  27057.  
  27058. if ($makefoo) {
  27059.   function foo ()
  27060.   {
  27061.     echo "Ich existiere nicht, bis mich die Programmausfⁿhrung erreicht hat.\n";
  27062.   }
  27063. }
  27064.  
  27065. /* Nun k÷nnen wir foo() sicher aufrufen,
  27066.    da $makefoo als true ausgewertet wurde */
  27067.  
  27068. if ($makefoo) foo();
  27069.  
  27070. function bar()
  27071. {
  27072.   echo "Ich existiere sofort nach Programmstart.\n";
  27073. }
  27074.  
  27075. ?></PRE
  27076. ></TD
  27077. ></TR
  27078. ></TABLE
  27079. ></DIV
  27080. ></TD
  27081. ></TR
  27082. ></TABLE
  27083. >
  27084.     <TABLE
  27085. WIDTH="100%"
  27086. BORDER="0"
  27087. CELLPADDING="0"
  27088. CELLSPACING="0"
  27089. CLASS="EXAMPLE"
  27090. ><TR
  27091. ><TD
  27092. ><DIV
  27093. CLASS="example"
  27094. ><A
  27095. NAME="AEN4848"
  27096. ></A
  27097. ><P
  27098. ><B
  27099. >Beispiel 16-2. Funktionen innerhalb von Funktionen</B
  27100. ></P
  27101. ><TABLE
  27102. BORDER="0"
  27103. BGCOLOR="#E0E0E0"
  27104. CELLPADDING="5"
  27105. ><TR
  27106. ><TD
  27107. ><PRE
  27108. CLASS="php"
  27109. ><?php
  27110. function foo() 
  27111. {
  27112.   function bar() 
  27113.   {
  27114.     echo "Ich existiere nicht, bis foo() aufgerufen wurde.\n";
  27115.   }
  27116. }
  27117.  
  27118. /* Wir k÷nnen bar() noch nicht
  27119.    aufrufen, da es nicht existiert */
  27120.  
  27121. foo();
  27122.  
  27123. /* Nun k÷nnen wir auch bar() aufrufen,
  27124.    da sie durch die Abarbeitung von
  27125.    foo() verfⁿgbar gemacht wurde */
  27126.  
  27127. bar();
  27128.  
  27129. ?></PRE
  27130. ></TD
  27131. ></TR
  27132. ></TABLE
  27133. ></DIV
  27134. ></TD
  27135. ></TR
  27136. ></TABLE
  27137. >
  27138.    </P
  27139. ><P
  27140. >     PHP unterstⁿtzt weder das ▄berladen von Funktionen, noch ist es
  27141.     m÷glich, zuvor deklarierte Funktionen neu zu definieren oder die
  27142.     Definition zu l÷schen.
  27143.    </P
  27144. ><P
  27145. >     PHP 3 unterstⁿtzt keine variable Anzahl von Parametern,
  27146.     obwohl Vorgabewerte fⁿr Parameter unterstⁿtzt werden
  27147.     (weitere Informationen finden Sie unter
  27148.     <A
  27149. HREF="#functions.arguments.default"
  27150. >Vorgabewerte
  27151.     fⁿr Parameter</A
  27152. >). PHP 4 unterstⁿtzt beides: siehe
  27153.     <A
  27154. HREF="#functions.variable-arg-list"
  27155. >Variable
  27156.     Parameteranzahl</A
  27157. > und die Funktionsreferenzen fⁿr
  27158.     <A
  27159. HREF="#function.func-num-args"
  27160. ><B
  27161. CLASS="function"
  27162. >func_num_args()</B
  27163. ></A
  27164. >,
  27165.     <A
  27166. HREF="#function.func-get-arg"
  27167. ><B
  27168. CLASS="function"
  27169. >func_get_arg()</B
  27170. ></A
  27171. > und
  27172.     <A
  27173. HREF="#function.func-get-args"
  27174. ><B
  27175. CLASS="function"
  27176. >func_get_args()</B
  27177. ></A
  27178. > fⁿr weitere Informationen.
  27179.    </P
  27180. ></DIV
  27181. ><DIV
  27182. CLASS="sect1"
  27183. ><HR><H2
  27184. CLASS="sect1"
  27185. ><A
  27186. NAME="functions.arguments"
  27187. >Funktionsparameter</A
  27188. ></H2
  27189. ><P
  27190. >     Mit einer Parameterliste kann man Informationen an eine Funktion 
  27191.     ⁿbergeben. Die Parameterliste ist eine durch Kommas getrennte
  27192.     Liste von Variablen und/oder Konstanten.
  27193.    </P
  27194. ><P
  27195. >     PHP unterstⁿtzt die Weitergabe von Parametern als Werte (das ist
  27196.     der Standard), als <A
  27197. HREF="#functions.arguments.by-reference"
  27198. >Verweise</A
  27199. >, und
  27200.     als <A
  27201. HREF="#functions.arguments.default"
  27202. >Vorgabewerte</A
  27203. >.
  27204.     Die ▄bergabe einer variablen Anzahl von Parametern wird nur von
  27205.     PHP 4 und h÷her unterstⁿtzt, siehe <A
  27206. HREF="#functions.variable-arg-list"
  27207. >Variable
  27208.     Parameteranzahl</A
  27209. > und die Funktionsreferenzen fⁿr
  27210.     <A
  27211. HREF="#function.func-num-args"
  27212. ><B
  27213. CLASS="function"
  27214. >func_num_args()</B
  27215. ></A
  27216. >,
  27217.     <A
  27218. HREF="#function.func-get-arg"
  27219. ><B
  27220. CLASS="function"
  27221. >func_get_arg()</B
  27222. ></A
  27223. > und
  27224.     <A
  27225. HREF="#function.func-get-args"
  27226. ><B
  27227. CLASS="function"
  27228. >func_get_args()</B
  27229. ></A
  27230. > fⁿr weitere Informationen. 
  27231.     Durch die ▄bergabe eines Arrays mit Parametern kann man auch
  27232.     in PHP 3 einen Σhnlichen Effekt erreichen:
  27233.  
  27234.     <DIV
  27235. CLASS="informalexample"
  27236. ><P
  27237. ></P
  27238. ><A
  27239. NAME="AEN4868"
  27240. ></A
  27241. ><TABLE
  27242. BORDER="0"
  27243. BGCOLOR="#E0E0E0"
  27244. CELLPADDING="5"
  27245. ><TR
  27246. ><TD
  27247. ><PRE
  27248. CLASS="php"
  27249. >function rechne_array($eingabe)
  27250. {
  27251.     echo "$eingabe[0] + $eingabe[1] = ", $eingabe[0]+$eingabe[1];
  27252. }</PRE
  27253. ></TD
  27254. ></TR
  27255. ></TABLE
  27256. ><P
  27257. ></P
  27258. ></DIV
  27259. >
  27260.    </P
  27261. ><DIV
  27262. CLASS="sect2"
  27263. ><HR><H3
  27264. CLASS="sect2"
  27265. ><A
  27266. NAME="functions.arguments.by-reference"
  27267. >Verweise als Parameter ⁿbergeben</A
  27268. ></H3
  27269. ><P
  27270. >      Normalerweise werden den Funktionen Werte als Parameter
  27271.      ⁿbermittelt. Wenn man den Wert dieses Parameters innerhalb der
  27272.      Funktion Σndert, bleibt der Parameter au▀erhalb der Funktion
  27273.      unverΣndert. Wollen Sie aber genau das erreichen, dann mⁿssen
  27274.      Sie die Parameter als Verweise (Referenzen) ⁿbergeben. 
  27275.     </P
  27276. ><P
  27277. >      Wenn eine Funktion einen Parameter generell als Verweis behandeln
  27278.      soll, setzt man in der Funktionsdefinition ein kaufmΣnnisches Und
  27279.      (&) vor den Parameternamen:
  27280.  
  27281.      <DIV
  27282. CLASS="informalexample"
  27283. ><P
  27284. ></P
  27285. ><A
  27286. NAME="AEN4874"
  27287. ></A
  27288. ><TABLE
  27289. BORDER="0"
  27290. BGCOLOR="#E0E0E0"
  27291. CELLPADDING="5"
  27292. ><TR
  27293. ><TD
  27294. ><PRE
  27295. CLASS="php"
  27296. >function fuege_etwas_anderes_an (&$string)
  27297. {
  27298.     $string .= 'und nun zu etwas anderem.';
  27299. }
  27300. $str = 'Dies ist ein String, ';
  27301. fuege_etwas_anderes_an ($str);
  27302. echo $str; // Ausgabe: 'Dies ist ein String, und nun zu etwas anderem.'</PRE
  27303. ></TD
  27304. ></TR
  27305. ></TABLE
  27306. ><P
  27307. ></P
  27308. ></DIV
  27309. >
  27310.     </P
  27311. ></DIV
  27312. ><DIV
  27313. CLASS="sect2"
  27314. ><HR><H3
  27315. CLASS="sect2"
  27316. ><A
  27317. NAME="functions.arguments.default"
  27318. >Vorgabewerte fⁿr Parameter</A
  27319. ></H3
  27320. ><P
  27321. >      Eine Funktion kann C++-artige Vorgabewerte fⁿr skalare Parameter
  27322.      wie folgt definieren:
  27323.  
  27324.      <DIV
  27325. CLASS="informalexample"
  27326. ><P
  27327. ></P
  27328. ><A
  27329. NAME="AEN4879"
  27330. ></A
  27331. ><TABLE
  27332. BORDER="0"
  27333. BGCOLOR="#E0E0E0"
  27334. CELLPADDING="5"
  27335. ><TR
  27336. ><TD
  27337. ><PRE
  27338. CLASS="php"
  27339. >function machkaffee ($typ = "Cappucino")
  27340. {
  27341.     return "Ich mache eine Tasse $typ.\n";
  27342. }
  27343. echo machkaffee ();
  27344. echo machkaffee ("Espresso");</PRE
  27345. ></TD
  27346. ></TR
  27347. ></TABLE
  27348. ><P
  27349. ></P
  27350. ></DIV
  27351. >
  27352.     </P
  27353. ><P
  27354. >      Die Ausgabe von diesem kleinen Skript ist:
  27355.  
  27356.      <TABLE
  27357. BORDER="0"
  27358. BGCOLOR="#E0E0E0"
  27359. CELLPADDING="5"
  27360. ><TR
  27361. ><TD
  27362. ><PRE
  27363. CLASS="screen"
  27364. >Ich mache eine Tasse Cappucino.
  27365. Ich mache eine Tasse Espresso.</PRE
  27366. ></TD
  27367. ></TR
  27368. ></TABLE
  27369. >
  27370.     </P
  27371. ><P
  27372. >      Der Vorgabewert muss ein konstanter Ausdruck sein, darf also (zum
  27373.      Beispiel) keine Variable oder Element einer Klasse sein.
  27374.     </P
  27375. ><P
  27376. >      Bitte beachten Sie, dass alle Vorgabewerte rechts von den 
  27377.      Nicht-Vorgabeparametern stehen sollten; - sonst wird es nicht 
  27378.      funktionieren. Betrachten Sie folgendes Beispiel:
  27379.  
  27380.      <DIV
  27381. CLASS="informalexample"
  27382. ><P
  27383. ></P
  27384. ><A
  27385. NAME="AEN4885"
  27386. ></A
  27387. ><TABLE
  27388. BORDER="0"
  27389. BGCOLOR="#E0E0E0"
  27390. CELLPADDING="5"
  27391. ><TR
  27392. ><TD
  27393. ><PRE
  27394. CLASS="php"
  27395. >function mach_joghurt ($typ = "rechtsdrehendes", $geschmack)
  27396. {
  27397.     return "Mache einen Becher $typ $geschmack-joghurt.\n";
  27398. }
  27399.  
  27400. echo mach_joghurt ("Brombeer");   // arbeitet nicht wie erwartet</PRE
  27401. ></TD
  27402. ></TR
  27403. ></TABLE
  27404. ><P
  27405. ></P
  27406. ></DIV
  27407. >
  27408.     </P
  27409. ><P
  27410. >      Die Ausgabe dieses Beispiels ist::
  27411.  
  27412.      <TABLE
  27413. BORDER="0"
  27414. BGCOLOR="#E0E0E0"
  27415. CELLPADDING="5"
  27416. ><TR
  27417. ><TD
  27418. ><PRE
  27419. CLASS="screen"
  27420. >Warning: Missing argument 2 in call to makeyogurt() in 
  27421. /usr/local/etc/httpd/htdocs/php3test/functest.html on line 41
  27422. Mache einen Becher Brombeer-joghurt.</PRE
  27423. ></TD
  27424. ></TR
  27425. ></TABLE
  27426. ></P
  27427. ><P
  27428. >      Nun vergleichen Sie bitte oberes Beispiel mit folgendem:
  27429.  
  27430.      <DIV
  27431. CLASS="informalexample"
  27432. ><P
  27433. ></P
  27434. ><A
  27435. NAME="AEN4890"
  27436. ></A
  27437. ><TABLE
  27438. BORDER="0"
  27439. BGCOLOR="#E0E0E0"
  27440. CELLPADDING="5"
  27441. ><TR
  27442. ><TD
  27443. ><PRE
  27444. CLASS="php"
  27445. >function mach_joghurt ($geschmack, $typ = "rechtsdrehendes")
  27446. {
  27447.     return "Mache einen Becher $typ $geschmack-joghurt.\n";
  27448. }
  27449.  
  27450. echo mach_joghurt ("Brombeer");   // arbeitet wie erwartet.</PRE
  27451. ></TD
  27452. ></TR
  27453. ></TABLE
  27454. ><P
  27455. ></P
  27456. ></DIV
  27457. >
  27458.     </P
  27459. ><P
  27460. >      ... und jetzt ist die Ausgabe:
  27461.  
  27462.      <TABLE
  27463. BORDER="0"
  27464. BGCOLOR="#E0E0E0"
  27465. CELLPADDING="5"
  27466. ><TR
  27467. ><TD
  27468. ><PRE
  27469. CLASS="screen"
  27470. >Mache einen Becher rechtsdrehendes Brombeer-Joghurt.</PRE
  27471. ></TD
  27472. ></TR
  27473. ></TABLE
  27474. >
  27475.     </P
  27476. ></DIV
  27477. ><DIV
  27478. CLASS="sect2"
  27479. ><HR><H3
  27480. CLASS="sect2"
  27481. ><A
  27482. NAME="functions.variable-arg-list"
  27483. >Variable Anzahl von Parametern</A
  27484. ></H3
  27485. ><P
  27486. >      PHP 4 unterstⁿtzt eine variable Anzahl von Parametern in
  27487.      benutzerdefinierten Funktionen. Das Handling dieser Parameter
  27488.      fΣllt mittels der Funktionen <A
  27489. HREF="#function.func-num-args"
  27490. ><B
  27491. CLASS="function"
  27492. >func_num_args()</B
  27493. ></A
  27494. >,
  27495.      <A
  27496. HREF="#function.func-get-arg"
  27497. ><B
  27498. CLASS="function"
  27499. >func_get_arg()</B
  27500. ></A
  27501. > und
  27502.      <A
  27503. HREF="#function.func-get-args"
  27504. ><B
  27505. CLASS="function"
  27506. >func_get_args()</B
  27507. ></A
  27508. > sehr leicht.
  27509.     </P
  27510. ><P
  27511. >      Es ist keine spezielle Syntax erforderlich. Die Parameter k÷nnen
  27512.      wie gehabt explizit in den Funktionsdeklarationen angegeben
  27513.      werden, und werden sich wie gewohnt verhalten.
  27514.     </P
  27515. ></DIV
  27516. ></DIV
  27517. ><DIV
  27518. CLASS="sect1"
  27519. ><HR><H2
  27520. CLASS="sect1"
  27521. ><A
  27522. NAME="functions.returning-values"
  27523. >Rⁿckgabewerte</A
  27524. ></H2
  27525. ><P
  27526. >     Sie k÷nnen Werte mit dem optionalen Befehl "return" zurⁿckgeben.
  27527.     Es k÷nnen Variablen jedes Typs zurⁿckgegeben werden, auch Listen
  27528.     oder Objekte. Die beendet sofort die Funktion, und die Kontrolle
  27529.     wird wieder an die aufrufende Zeile zurⁿckgegeben. Weitere
  27530.     Informationen finden Sie unter <A
  27531. HREF="#function.return"
  27532. ><B
  27533. CLASS="function"
  27534. >return()</B
  27535. ></A
  27536. >.
  27537.     <DIV
  27538. CLASS="informalexample"
  27539. ><P
  27540. ></P
  27541. ><A
  27542. NAME="AEN4905"
  27543. ></A
  27544. ><TABLE
  27545. BORDER="0"
  27546. BGCOLOR="#E0E0E0"
  27547. CELLPADDING="5"
  27548. ><TR
  27549. ><TD
  27550. ><PRE
  27551. CLASS="php"
  27552. >function quadrat ($zahl)
  27553. {
  27554.     return $zahl * $zahl;
  27555. }
  27556. echo quadrat (4);   // gibt '16' aus.</PRE
  27557. ></TD
  27558. ></TR
  27559. ></TABLE
  27560. ><P
  27561. ></P
  27562. ></DIV
  27563. >
  27564.    </P
  27565. ><P
  27566. >     Es ist nicht m÷glich, mehrere Werte von einer Funktion zurⁿckzugeben.
  27567.     Ein Σhnliches Resultat kann man aber durch die Rⁿckgabe von Listen
  27568.     erreichen.
  27569.  
  27570.     <DIV
  27571. CLASS="informalexample"
  27572. ><P
  27573. ></P
  27574. ><A
  27575. NAME="AEN4908"
  27576. ></A
  27577. ><TABLE
  27578. BORDER="0"
  27579. BGCOLOR="#E0E0E0"
  27580. CELLPADDING="5"
  27581. ><TR
  27582. ><TD
  27583. ><PRE
  27584. CLASS="php"
  27585. >function kleine_zahlen()
  27586. {
  27587.    return array (0, 1, 2);
  27588. }
  27589. list ($null, $eins, $zwei) = kleine_zahlen();</PRE
  27590. ></TD
  27591. ></TR
  27592. ></TABLE
  27593. ><P
  27594. ></P
  27595. ></DIV
  27596. >
  27597.    </P
  27598. ><P
  27599. >     Um von einer Funktion eine Referenz zurⁿckzugeben, mⁿssen Sie
  27600.     den Referenz-Operator & sowohl in der Funktionsdeklaration,
  27601.     als auch bei der Zuweisung des zurⁿckgegebenen Wertes verwenden: 
  27602.     <DIV
  27603. CLASS="informalexample"
  27604. ><P
  27605. ></P
  27606. ><A
  27607. NAME="AEN4911"
  27608. ></A
  27609. ><TABLE
  27610. BORDER="0"
  27611. BGCOLOR="#E0E0E0"
  27612. CELLPADDING="5"
  27613. ><TR
  27614. ><TD
  27615. ><PRE
  27616. CLASS="php"
  27617. >function &returniere_referenz()
  27618. {
  27619.     return $einereferenz;
  27620. }
  27621.  
  27622. $neuereferenz =& returniere_referenz();</PRE
  27623. ></TD
  27624. ></TR
  27625. ></TABLE
  27626. ><P
  27627. ></P
  27628. ></DIV
  27629. >
  27630.    </P
  27631. ><P
  27632. >     Weitere Informationen ⁿber Referenzen finden Sie im Kapitel
  27633.     <A
  27634. HREF="#language.references"
  27635. >Referenzen in PHP</A
  27636. >.
  27637.    </P
  27638. ></DIV
  27639. ><DIV
  27640. CLASS="sect1"
  27641. ><HR><H2
  27642. CLASS="sect1"
  27643. ><A
  27644. NAME="functions.old-syntax"
  27645. ><VAR
  27646. CLASS="literal"
  27647. >old_function</VAR
  27648. ></A
  27649. ></H2
  27650. ><P
  27651. >     Der Befehl <VAR
  27652. CLASS="literal"
  27653. >old_function</VAR
  27654. > erlaubt es, eine
  27655.     Funktion genauso wie bei PHP/FI2 zu definieren (nur "function"
  27656.     wird durch "old_function" ersetzt.
  27657.    </P
  27658. ><P
  27659. >     Dieser Befehl sollte nur vom PHP/FI2->PHP3-Konverter genutzt
  27660.     werden.
  27661.    </P
  27662. ><DIV
  27663. CLASS="warning"
  27664. ><P
  27665. ></P
  27666. ><TABLE
  27667. CLASS="warning"
  27668. BORDER="1"
  27669. WIDTH="100%"
  27670. ><TR
  27671. ><TD
  27672. ALIGN="CENTER"
  27673. ><B
  27674. >Warnung</B
  27675. ></TD
  27676. ></TR
  27677. ><TR
  27678. ><TD
  27679. ALIGN="LEFT"
  27680. ><P
  27681. >      Funktionen, die durch <VAR
  27682. CLASS="literal"
  27683. >old_function</VAR
  27684. > definiert
  27685.      werden, k÷nnen nicht von PHP selbst aufgerufen werden. Das hei▀t
  27686.      unter anderem, dass sie nicht in Funktionen wie <B
  27687. CLASS="function"
  27688. >usort
  27689.      ()</B
  27690. >, <A
  27691. HREF="#function.array-walk"
  27692. ><B
  27693. CLASS="function"
  27694. >array_walk()</B
  27695. ></A
  27696. > und <B
  27697. CLASS="function"
  27698. >      register_shutdown_function()</B
  27699. > benutzt werden k÷nnen.
  27700.      Dieses Manko k÷nnen Sie umgehen, indem Sie eine Adapterfunktion
  27701.      (in normalem PHP3) schreiben, welche die
  27702.      <VAR
  27703. CLASS="literal"
  27704. >old_function</VAR
  27705. > aufruft.
  27706.     </P
  27707. ></TD
  27708. ></TR
  27709. ></TABLE
  27710. ></DIV
  27711. ></DIV
  27712. ><DIV
  27713. CLASS="sect1"
  27714. ><HR><H2
  27715. CLASS="sect1"
  27716. ><A
  27717. NAME="functions.variable-functions"
  27718. >Variablenfunktionen</A
  27719. ></H2
  27720. ><P
  27721. >     PHP unterstⁿtzt das Konzept der Variablenfunktionen. Wenn Sie an
  27722.     das Ende einer Variablen Klammern hΣngen, versucht PHP eine
  27723.     Funktion aufzurufen, deren Name der aktuelle Wert der Variable
  27724.     ist. Dies kann unter anderem fⁿr Callbacks, Funktionstabellen,
  27725.     usw. genutzt werden.
  27726.    </P
  27727. ><P
  27728. >     Variablenfunktionen funktionieren nicht mit Sprachkonstrukten
  27729.     wie <A
  27730. HREF="#function.echo"
  27731. ><B
  27732. CLASS="function"
  27733. >echo()</B
  27734. ></A
  27735. >, <A
  27736. HREF="#function.print"
  27737. ><B
  27738. CLASS="function"
  27739. >print()</B
  27740. ></A
  27741. >,
  27742.     <A
  27743. HREF="#function.unset"
  27744. ><B
  27745. CLASS="function"
  27746. >unset()</B
  27747. ></A
  27748. >, <A
  27749. HREF="#function.isset"
  27750. ><B
  27751. CLASS="function"
  27752. >isset()</B
  27753. ></A
  27754. >,
  27755.     <A
  27756. HREF="#function.empty"
  27757. ><B
  27758. CLASS="function"
  27759. >empty()</B
  27760. ></A
  27761. >, <A
  27762. HREF="#function.include"
  27763. ><B
  27764. CLASS="function"
  27765. >include()</B
  27766. ></A
  27767. > und
  27768.     <A
  27769. HREF="#function.require"
  27770. ><B
  27771. CLASS="function"
  27772. >require()</B
  27773. ></A
  27774. >. Sie mⁿssen Ihre eigenen Wrapperfunktionen
  27775.     verwenden, um diese Konstrukte als variable Funktionen benutzen zu
  27776.     k÷nnen.
  27777.    </P
  27778. ><P
  27779. >     <TABLE
  27780. WIDTH="100%"
  27781. BORDER="0"
  27782. CELLPADDING="0"
  27783. CELLSPACING="0"
  27784. CLASS="EXAMPLE"
  27785. ><TR
  27786. ><TD
  27787. ><DIV
  27788. CLASS="example"
  27789. ><A
  27790. NAME="AEN4940"
  27791. ></A
  27792. ><P
  27793. ><B
  27794. >Beispiel 16-3. Beispiel fⁿr Variablenfunktionen</B
  27795. ></P
  27796. ><TABLE
  27797. BORDER="0"
  27798. BGCOLOR="#E0E0E0"
  27799. CELLPADDING="5"
  27800. ><TR
  27801. ><TD
  27802. ><PRE
  27803. CLASS="php"
  27804. ><?php
  27805. function foo()
  27806. {
  27807.     echo "In foo()<br>\n";
  27808. }
  27809.  
  27810. function bar($arg = '')
  27811. {
  27812.     echo "In bar(); der Parameter ist '$arg'.<br>\n";
  27813. }
  27814.  
  27815. // Dies ist eine Wrapperfunkiton fⁿr echo
  27816. function echoit($string)
  27817. {
  27818.     echo $string;
  27819. }
  27820.  
  27821. $func = 'foo';
  27822. $func();        // Dies ruft foo() auf
  27823.  
  27824. $func = 'bar';
  27825. $func('test');  // Dies ruft bar() auf
  27826.  
  27827. $func = 'echoit';
  27828. $func('test');  // Dies ruft echoit() auf
  27829. ?></PRE
  27830. ></TD
  27831. ></TR
  27832. ></TABLE
  27833. ></DIV
  27834. ></TD
  27835. ></TR
  27836. ></TABLE
  27837. >
  27838.    </P
  27839. ><P
  27840. >     Sie k÷nnen auch die Methode eines Objektes mittels der variablen
  27841.     Funktionen aufrufen.
  27842.     <TABLE
  27843. WIDTH="100%"
  27844. BORDER="0"
  27845. CELLPADDING="0"
  27846. CELLSPACING="0"
  27847. CLASS="EXAMPLE"
  27848. ><TR
  27849. ><TD
  27850. ><DIV
  27851. CLASS="example"
  27852. ><A
  27853. NAME="AEN4944"
  27854. ></A
  27855. ><P
  27856. ><B
  27857. >Beispiel 16-4. Variable Methode</B
  27858. ></P
  27859. ><TABLE
  27860. BORDER="0"
  27861. BGCOLOR="#E0E0E0"
  27862. CELLPADDING="5"
  27863. ><TR
  27864. ><TD
  27865. ><PRE
  27866. CLASS="php"
  27867. ><?php
  27868. class Foo
  27869. {
  27870.     function Var()
  27871.     {
  27872.         $name = 'Bar';
  27873.         $this->$name(); // Dies ruft die Bar() Methode auf
  27874.     }
  27875.     
  27876.     function Bar()
  27877.     {
  27878.         echo "Das ist Bar";
  27879.     }
  27880. }
  27881.  
  27882. $foo = new Foo();
  27883. $funcname = "Var";
  27884. $foo->$funcname();   // Dies ruft $foo->Var() auf
  27885.  
  27886. ?></PRE
  27887. ></TD
  27888. ></TR
  27889. ></TABLE
  27890. ></DIV
  27891. ></TD
  27892. ></TR
  27893. ></TABLE
  27894. >
  27895.    </P
  27896. ><P
  27897. >     Siehe auch <A
  27898. HREF="#function.call-user-func"
  27899. ><B
  27900. CLASS="function"
  27901. >call_user_func()</B
  27902. ></A
  27903. >,
  27904.     <A
  27905. HREF="#language.variables.variable"
  27906. >     Variable Variablen</A
  27907. > und <A
  27908. HREF="#function.function-exists"
  27909. ><B
  27910. CLASS="function"
  27911. >function_exists()</B
  27912. ></A
  27913. >.
  27914.    </P
  27915. ></DIV
  27916. ></DIV
  27917. ><DIV
  27918. CLASS="chapter"
  27919. ><HR><H1
  27920. ><A
  27921. NAME="language.oop"
  27922. >Kapitel 17. Klassen und Objekte</A
  27923. ></H1
  27924. ><DIV
  27925. CLASS="sect1"
  27926. ><H2
  27927. CLASS="sect1"
  27928. ><A
  27929. NAME="keyword.class"
  27930. ><VAR
  27931. CLASS="literal"
  27932. >Klassen</VAR
  27933. ></A
  27934. ></H2
  27935. ><P
  27936. >     Eine Klasse ist eine Sammlung von Variablen und Funktionen, die
  27937.     mit diesen Variablen arbeiten. Eine Klasse wird folgenderma▀en
  27938.     definiert:
  27939.     <DIV
  27940. CLASS="informalexample"
  27941. ><P
  27942. ></P
  27943. ><A
  27944. NAME="AEN4957"
  27945. ></A
  27946. ><TABLE
  27947. BORDER="0"
  27948. BGCOLOR="#E0E0E0"
  27949. CELLPADDING="5"
  27950. ><TR
  27951. ><TD
  27952. ><PRE
  27953. CLASS="php"
  27954. ><?php
  27955. class Cart
  27956. {
  27957.     var $items;  // Artikel in unserem Einkaufswagen
  27958.    
  27959.     // Fⁿge dem Einkaufswagen $num Artikel der Sorte $artnr zu
  27960.  
  27961.     function add_item ($artnr, $num)
  27962.     {
  27963.         $this->items[$artnr] += $num;
  27964.     }
  27965.    
  27966.     // Nimm $num Artikel von $artnr aus dem Einkaufswagen
  27967.  
  27968.     function remove_item ($artnr, $num)
  27969.     {
  27970.         if ($this->items[$artnr] > $num) {
  27971.             $this->items[$artnr] -= $num;
  27972.             return true;
  27973.         } else {
  27974.             return false;
  27975.         }   
  27976.     }
  27977. }
  27978. ?></PRE
  27979. ></TD
  27980. ></TR
  27981. ></TABLE
  27982. ><P
  27983. ></P
  27984. ></DIV
  27985. >
  27986.    </P
  27987. ><P
  27988. >     In diesem Beispiel wird eine Klasse "Cart" definiert. Sie
  27989.     besteht aus einem assoziativen Array von Produkten im
  27990.     Einkaufswagen und zwei Funktionen zum Hinzufⁿgen und Entfernen von
  27991.     Artikeln.
  27992.    </P
  27993. ><DIV
  27994. CLASS="caution"
  27995. ><P
  27996. ></P
  27997. ><TABLE
  27998. CLASS="caution"
  27999. BORDER="1"
  28000. WIDTH="100%"
  28001. ><TR
  28002. ><TD
  28003. ALIGN="CENTER"
  28004. ><B
  28005. >Achtung</B
  28006. ></TD
  28007. ></TR
  28008. ><TR
  28009. ><TD
  28010. ALIGN="LEFT"
  28011. ><P
  28012. >      Die folgenden warnenden Bemerkungen gelten fⁿr PHP 4.
  28013.     </P
  28014. ><P
  28015. >      Der Name <VAR
  28016. CLASS="literal"
  28017. >stdClass</VAR
  28018. > ist reserviert, da er intern
  28019.      von Zend benutzt wird. Sie k÷nnen in PHP keine Klasse mit dem
  28020.      Namen <VAR
  28021. CLASS="literal"
  28022. >stdClass</VAR
  28023. > haben.
  28024.     </P
  28025. ><P
  28026. >       Die Funktionsnamen <VAR
  28027. CLASS="literal"
  28028. >__sleep</VAR
  28029. > und
  28030.       <VAR
  28031. CLASS="literal"
  28032. >__wakeup</VAR
  28033. > sind in PHP Klassen "magisch". Sie
  28034.       k÷nnen in Ihren Klassen keine Funktionen mit diesen Namen haben,
  28035.       au▀er Sie wollen sie mit dieser "magischen" FunktionalitΣt
  28036.       assoziieren. Mehr Informationen dazu finden Sie weiter unten.
  28037.     </P
  28038. ><P
  28039. >       SΣmtliche mit __ beginnende Funktionsnamen sind PHP als "magisch"
  28040.       vorbehalten. Es wird empfohlen, in PHP keine Funktionsnamen mit
  28041.       __ zu verwenden, au▀er Sie m÷chten dokumentierte "magische"
  28042.       FunktionalitΣt.
  28043.     </P
  28044. ></TD
  28045. ></TR
  28046. ></TABLE
  28047. ></DIV
  28048. ><DIV
  28049. CLASS="note"
  28050. ><BLOCKQUOTE
  28051. CLASS="note"
  28052. ><P
  28053. ><B
  28054. >Anmerkung: </B
  28055. >
  28056.      In PHP 4 sind nur konstante Initialisierungen fⁿr
  28057.      <VAR
  28058. CLASS="literal"
  28059. >var</VAR
  28060. > Variablen erlaubt. Um Variablen mit nicht
  28061.      konstanten Werten zu initialisieren, ben÷tigen Sie eine Funktion
  28062.      zur Initialisierung, welche beim Erstellen eines Objektes
  28063.      automatisch von der Klasse aufgerufen wird. Eine solche Funktion
  28064.      wird Konstruktor genannt (siehe unten).
  28065.     </P
  28066. ><DIV
  28067. CLASS="informalexample"
  28068. ><P
  28069. ></P
  28070. ><A
  28071. NAME="AEN4972"
  28072. ></A
  28073. ><TABLE
  28074. BORDER="0"
  28075. BGCOLOR="#E0E0E0"
  28076. CELLPADDING="5"
  28077. ><TR
  28078. ><TD
  28079. ><PRE
  28080. CLASS="php"
  28081. ><?php
  28082. /* Keine wird in PHP 4 funktionieren */
  28083. class Cart
  28084. {
  28085.     var $todays_date = date("Y-m-d");
  28086.     var $name = $firstname;
  28087.     var $owner = 'Fred ' . 'Jones';
  28088.     var $items = array("VCR", "TV");
  28089. }
  28090.  
  28091. /* So sollte es gemacht werden */
  28092. class Cart
  28093. {
  28094.     var $todays_date;
  28095.     var $name;
  28096.     var $owner;
  28097.     var $items;
  28098.  
  28099.     function Cart()
  28100.     {
  28101.         $this->todays_date = date("Y-m-d");
  28102.         $this->name = $GLOBALS['firstname'];
  28103.         /* etc. . . */
  28104.     }
  28105. }
  28106. ?></PRE
  28107. ></TD
  28108. ></TR
  28109. ></TABLE
  28110. ><P
  28111. ></P
  28112. ></DIV
  28113. ></BLOCKQUOTE
  28114. ></DIV
  28115. ><P
  28116. >     Klassen sind Typen, das hei▀t sie sind die Blaupausen fⁿr reale
  28117.     Variablen. Um sie zu nutzen, muss zunΣchst eine Variable mit dem
  28118.     Operator <VAR
  28119. CLASS="literal"
  28120. >new</VAR
  28121. > angelegt werden.
  28122.    </P
  28123. ><DIV
  28124. CLASS="informalexample"
  28125. ><P
  28126. ></P
  28127. ><A
  28128. NAME="AEN4976"
  28129. ></A
  28130. ><TABLE
  28131. BORDER="0"
  28132. BGCOLOR="#E0E0E0"
  28133. CELLPADDING="5"
  28134. ><TR
  28135. ><TD
  28136. ><PRE
  28137. CLASS="php"
  28138. ><?php
  28139. $cart = new Cart;
  28140. $cart->add_item("10", 1);
  28141.  
  28142. $another_cart = new Cart;
  28143. $another_cart->add_item("0815", 3);</PRE
  28144. ></TD
  28145. ></TR
  28146. ></TABLE
  28147. ><P
  28148. ></P
  28149. ></DIV
  28150. ><P
  28151. >     Dies erstellt die Objekte $cart und $another_cart aus der Klasse
  28152.     Cart. Dann wird die Funktion add_item() des $cart Objektes
  28153.     aufgerufen, um $cart einen Artikel mit der Artikelnummer 10
  28154.     hinzuzufⁿgen. 3 Artikel mit der Artikelnummer 0815 werden
  28155.     $another_cart hinzugefⁿgt.
  28156.    </P
  28157. ><P
  28158. >     Sowohl $cart als auch $another_cart haben die Funktionen
  28159.     add_item(), remove_item() und die Variable items. Dies sind
  28160.     verschiedene Funktionen und Variablen. Sie k÷nnen sich Objekte
  28161.     Σhnlich den Verzeichnissen in einem Dateisystem vorstellen. Sie
  28162.     k÷nnen in einem Dateisystem zwei verschiedene Dateien README.TXT
  28163.     haben, solange sie sich in verschiedenen Verzeichnissen befinden.
  28164.     So wie Sie in Verzeichnissen den vollen Pfadnamen eingeben mⁿssen,
  28165.     um jede Datei von dem obersten Verzeichnis aus zu erreichen, mⁿssen
  28166.     Sie auch den vollen Namen der aufzurufenden Funktion angeben: Das
  28167.     hei▀t fⁿr PHP, dass das Hauptverzeichnis der globale Namensbereich,
  28168.     und der Separator des Pfadnamens -> wΣre. Deshalb benennen die
  28169.     Namen $cart->items und $another_cart->items auch zwei
  28170.     verschiedene Variablen. Beachten Sie, dass die Variable
  28171.     $cart->items, und nicht $cart->$items genannt wird, da
  28172.     ein Variablenname in PHP nur ein einziges Dollarzeichen hat.
  28173.    </P
  28174. ><DIV
  28175. CLASS="informalexample"
  28176. ><P
  28177. ></P
  28178. ><A
  28179. NAME="AEN4980"
  28180. ></A
  28181. ><TABLE
  28182. BORDER="0"
  28183. BGCOLOR="#E0E0E0"
  28184. CELLPADDING="5"
  28185. ><TR
  28186. ><TD
  28187. ><PRE
  28188. CLASS="php"
  28189. >// korrekt, einfaches $
  28190. $cart->items = array("10" => 1); 
  28191.  
  28192. // falsch, denn $cart->$items wird zu $cart->""
  28193. $cart->$items = array("10" => 1);
  28194.  
  28195. // richtig aber fraglich, ob dies erwⁿnscht war:
  28196. // $cart->$myvar wird zu $cart->items
  28197. $myvar = 'items';
  28198. $cart->$myvar = array("10" => 1);</PRE
  28199. ></TD
  28200. ></TR
  28201. ></TABLE
  28202. ><P
  28203. ></P
  28204. ></DIV
  28205. ><P
  28206. >     Innerhalb einer Klassendefinition ist nicht bekannt, unter welchem
  28207.     Namen das Objekt in Ihrem Programm erreichbar sein wird: Als die
  28208.     Klasse Cart geschrieben wurde war nicht bekannt, dass das Objekt
  28209.     spΣter $cart oder $another_cart genannt wird. Deshalb k÷nnen Sie
  28210.     innerhalb der Klasse Cart selbst auch nicht $cart->items schreiben.
  28211.     Um nun die eigenen Funktionen und Variablen innerhalb einer Klasse
  28212.     anzusprechen, k÷nnen Sie die Pseudo-Variable $this verwenden, welche
  28213.     Sie auch als 'meine eigene' oder 'aktuelles Objekt' verstehen k÷nnen.
  28214.     Deshalb kann '$this->items[$artnr] += $num' auch als 'addiere $num
  28215.     zu $artnr in meinem eigenen Array items', oder 'addiere $num zu
  28216.     $artnr im Array items innerhalb des aktuellen Objektes' lesen.
  28217.    </P
  28218. ><DIV
  28219. CLASS="note"
  28220. ><BLOCKQUOTE
  28221. CLASS="note"
  28222. ><P
  28223. ><B
  28224. >Anmerkung: </B
  28225. >
  28226.     Es gibt ein paar angenehme Funktionen, um mit Klassen und Objekten umzugehen.
  28227.     Mehr darⁿber erfahren Sie im Kapitel <A
  28228. HREF="#ref.classobj"
  28229. >Klassen- 
  28230.     und Objekt-Funktionen</A
  28231. >.
  28232.     </P
  28233. ></BLOCKQUOTE
  28234. ></DIV
  28235. ></DIV
  28236. ><DIV
  28237. CLASS="sect1"
  28238. ><HR><H2
  28239. CLASS="sect1"
  28240. ><A
  28241. NAME="keyword.extends"
  28242. ><VAR
  28243. CLASS="literal"
  28244. >extends</VAR
  28245. ></A
  28246. ></H2
  28247. ><P
  28248. >     Oft braucht man Klassen mit in einer anderen Klasse Σhnlichen Variablen
  28249.     und Funktionen. So ist es eine gute Vorgehensweise, eine in allen Ihren
  28250.     Projekten verwendbare Oberklasse zu definieren, und diese dann den
  28251.     Bedⁿrfnissen Ihrer einzelnen Projekte anzupassen. Um dies zu erleichtern,
  28252.     k÷nnen Klassen andere Klassen erweitern. Die erweiterte bzw. abgeleitete
  28253.     Klasse verfⁿgt ⁿber alle Variablen und Funktionen der Basisklasse (dies
  28254.     wird 'Vererbung' genannt, obwohl niemand gestorben ist), und was Sie in
  28255.     der erweiterten Definition hinzufⁿgen. Es ist nicht m÷glich, etwas von
  28256.     einer Klasse wegzunehmen, d.h. Sie k÷nnen keine existierenden Variablen
  28257.     oder Funktionen 'wegdefinieren'. Eine Unterklasse ist immer von einer
  28258.     einzigen Oberklasse abhΣngig, d.h. Mehrfachvererbung wird nicht
  28259.     unterstⁿtzt. Klassen werden mittels dem Schlⁿsselwort 'extends' erweitert.
  28260.    </P
  28261. ><DIV
  28262. CLASS="informalexample"
  28263. ><P
  28264. ></P
  28265. ><A
  28266. NAME="AEN4990"
  28267. ></A
  28268. ><TABLE
  28269. BORDER="0"
  28270. BGCOLOR="#E0E0E0"
  28271. CELLPADDING="5"
  28272. ><TR
  28273. ><TD
  28274. ><PRE
  28275. CLASS="php"
  28276. >class Named_Cart extends Cart
  28277. {
  28278.     var $owner;
  28279.   
  28280.     function set_owner ($name)
  28281.     {
  28282.         $this->owner = $name;
  28283.     }
  28284. }</PRE
  28285. ></TD
  28286. ></TR
  28287. ></TABLE
  28288. ><P
  28289. ></P
  28290. ></DIV
  28291. ><P
  28292. >     Hier wird die Klasse Named_Cart definiert, die ⁿber alle Variablen
  28293.     und Funktionen von Cart, plus der Variable $owner und der Funktion
  28294.     set_owner() verfⁿgt. Sie k÷nnen einen bestimmten Einkaufswagen
  28295.     (Named_Cart) auf dem ⁿblichen Weg erstellen, und nun auch den
  28296.     Besitzer (owner) bestimmen und erfragen. Sie k÷nnen noch immer
  28297.     die normalen Cart Funktionen an Named_Cart anwenden:
  28298.    </P
  28299. ><DIV
  28300. CLASS="informalexample"
  28301. ><P
  28302. ></P
  28303. ><A
  28304. NAME="AEN4993"
  28305. ></A
  28306. ><TABLE
  28307. BORDER="0"
  28308. BGCOLOR="#E0E0E0"
  28309. CELLPADDING="5"
  28310. ><TR
  28311. ><TD
  28312. ><PRE
  28313. CLASS="php"
  28314. >$ncart = new Named_Cart;    // Erstellt einen bestimmten Einkaufwagen
  28315. $ncart->set_owner("kris");  // den Besitzer festlegen
  28316. print $ncart->owner;        // den Besitzer ausgeben
  28317. $ncart->add_item("10", 1);  // (vererbte FunktionalitΣt von Cart)</PRE
  28318. ></TD
  28319. ></TR
  28320. ></TABLE
  28321. ><P
  28322. ></P
  28323. ></DIV
  28324. ><P
  28325. >     Dies wird auch eine "Eltern-Kind" Beziehung genannt. Sie erstellen eine
  28326.     Klasse ("Eltern"), und erstellen mittels <VAR
  28327. CLASS="literal"
  28328. >extends</VAR
  28329. > eine
  28330.     neue Klasse, die auf der "Eltern"-Klasse <SPAN
  28331. CLASS="emphasis"
  28332. ><I
  28333. CLASS="emphasis"
  28334. >basiert</I
  28335. ></SPAN
  28336. >:
  28337.     die "Kind"-Klasse. Sie k÷nnen auch diese neue Unterklasse verwenden und
  28338.     eine neue, auf dieser Klasse basierenden Klasse erstellen.
  28339.    </P
  28340. ><DIV
  28341. CLASS="note"
  28342. ><BLOCKQUOTE
  28343. CLASS="note"
  28344. ><P
  28345. ><B
  28346. >Anmerkung: </B
  28347. >
  28348.      Bevor Sie Klassen verwenden k÷nnen, mⁿssen Sie diese definieren. Wenn
  28349.      Sie wollen, dass <VAR
  28350. CLASS="literal"
  28351. >Named_Cart</VAR
  28352. > die Klasse
  28353.      <VAR
  28354. CLASS="literal"
  28355. >Cart</VAR
  28356. > erweitert, mⁿssen Sie <VAR
  28357. CLASS="literal"
  28358. >Cart</VAR
  28359. >
  28360.      erst definieren. Wenn Sie eine andere Klasse, z.B.
  28361.      <VAR
  28362. CLASS="literal"
  28363. >Yellow_named_cart</VAR
  28364. > erstellen wollen, welche
  28365.      auf <VAR
  28366. CLASS="literal"
  28367. >Named_Cart</VAR
  28368. > basiert, mⁿssen Sie zuerst 
  28369.      <VAR
  28370. CLASS="literal"
  28371. >Named_Cart</VAR
  28372. > definieren. Kurz gesagt ist die
  28373.      Reihenfolge, in der die Klassen definiert werden, sehr wichtig.
  28374.     </P
  28375. ></BLOCKQUOTE
  28376. ></DIV
  28377. ></DIV
  28378. ><DIV
  28379. CLASS="sect1"
  28380. ><HR><H2
  28381. CLASS="sect1"
  28382. ><A
  28383. NAME="language.oop.constructor"
  28384. ><VAR
  28385. CLASS="literal"
  28386. >Konstruktoren</VAR
  28387. ></A
  28388. ></H2
  28389. ><DIV
  28390. CLASS="caution"
  28391. ><P
  28392. ></P
  28393. ><TABLE
  28394. CLASS="caution"
  28395. BORDER="1"
  28396. WIDTH="100%"
  28397. ><TR
  28398. ><TD
  28399. ALIGN="CENTER"
  28400. ><B
  28401. >Achtung</B
  28402. ></TD
  28403. ></TR
  28404. ><TR
  28405. ><TD
  28406. ALIGN="LEFT"
  28407. ><P
  28408. >      In PHP 3 und PHP 4 verhalten sich die Konstruktoren
  28409.      unterschiedlich. Die PHP 4 Semantik wird dringend empfohlen.
  28410.     </P
  28411. ></TD
  28412. ></TR
  28413. ></TABLE
  28414. ></DIV
  28415. ><P
  28416. >     Konstruktoren sind Funktionen innerhalb einer Klasse, die
  28417.     automatisch aufgerufen wird, sobald Sie mittels
  28418.     <VAR
  28419. CLASS="literal"
  28420. >new</VAR
  28421. > eine neue Instanz erstellen. In PHP 3
  28422.     wird eine Funktion zum Konstruktor, wenn sie den gleichen Namen
  28423.     wie die Klasse hat. In PHP 4 wird eine Funktion zum Konstruktor,
  28424.     wenn sie den gleichen Namen wie die Klasse hat, in der sie
  28425.     definiert ist. Der Unterschied ist subtil, aber entscheidend
  28426.     (siehe unten).
  28427.    </P
  28428. ><DIV
  28429. CLASS="informalexample"
  28430. ><P
  28431. ></P
  28432. ><A
  28433. NAME="AEN5013"
  28434. ></A
  28435. ><TABLE
  28436. BORDER="0"
  28437. BGCOLOR="#E0E0E0"
  28438. CELLPADDING="5"
  28439. ><TR
  28440. ><TD
  28441. ><PRE
  28442. CLASS="php"
  28443. >// Funktioniert sowohl in PHP 3, als auch in PHP 4.
  28444. class Auto_Cart extends Cart
  28445. {
  28446.     function Auto_Cart()
  28447.     {
  28448.         $this->add_item ("10", 1);
  28449.     }
  28450. }</PRE
  28451. ></TD
  28452. ></TR
  28453. ></TABLE
  28454. ><P
  28455. ></P
  28456. ></DIV
  28457. ><P
  28458. >     Die Klasse Auto_Cart entspricht der Klasse Cart und hat einen
  28459.     Konstruktor, der Cart bereits mit einem Artikel der Nummer "10"
  28460.     initialisiert, sobald ein neuer Auto_Cart mittels "new" erstellt
  28461.     wird. Konstruktoren k÷nnen Argumente ⁿbernehmen, die optional
  28462.     sein k÷nnen, was sie sehr praktisch macht. Um eine Klasse auch
  28463.     ohne Parameter verwenden zu k÷nnen, sollten alle Parameter fⁿr
  28464.     Konstruktoren optional sein, indem sie mit Standardwerten
  28465.     ausgestattet werden.
  28466.    </P
  28467. ><DIV
  28468. CLASS="informalexample"
  28469. ><P
  28470. ></P
  28471. ><A
  28472. NAME="AEN5016"
  28473. ></A
  28474. ><TABLE
  28475. BORDER="0"
  28476. BGCOLOR="#E0E0E0"
  28477. CELLPADDING="5"
  28478. ><TR
  28479. ><TD
  28480. ><PRE
  28481. CLASS="php"
  28482. >// Funktioniert sowohl in PHP 3, als auch in PHP 4.
  28483. class Constructor_Cart extends Cart
  28484. {
  28485.     function Constructor_Cart($item = "10", $num = 1)
  28486.     {
  28487.         $this->add_item ($item, $num);
  28488.     }
  28489. }
  28490.  
  28491. // Kaufe das gleiche alte Zeug ein.
  28492.  
  28493. $default_cart = new Constructor_Cart;
  28494.  
  28495. // Kaufe etwas anderes...
  28496.  
  28497. $different_cart = new Constructor_Cart("20", 17);</PRE
  28498. ></TD
  28499. ></TR
  28500. ></TABLE
  28501. ><P
  28502. ></P
  28503. ></DIV
  28504. ><P
  28505. >     Sie k÷nnen auch den Operator <VAR
  28506. CLASS="literal"
  28507. >@</VAR
  28508. > verwenden, um
  28509.     Fehlermeldungen innerhalb des Konstruktors zu unterdrⁿcken, z.B.
  28510.     <VAR
  28511. CLASS="literal"
  28512. >@new</VAR
  28513. >.
  28514.    </P
  28515. ><DIV
  28516. CLASS="caution"
  28517. ><P
  28518. ></P
  28519. ><TABLE
  28520. CLASS="caution"
  28521. BORDER="1"
  28522. WIDTH="100%"
  28523. ><TR
  28524. ><TD
  28525. ALIGN="CENTER"
  28526. ><B
  28527. >Achtung</B
  28528. ></TD
  28529. ></TR
  28530. ><TR
  28531. ><TD
  28532. ALIGN="LEFT"
  28533. ><P
  28534. >      In PHP 3 haben abgeleitete Klassen und Konstruktoren ein paar
  28535.      EinschrΣnkungen. Sie sollten das folgende Beispiel sorgfΣltig
  28536.      lesen, um diese EinschrΣnkungen zu verstehen.
  28537.     </P
  28538. ></TD
  28539. ></TR
  28540. ></TABLE
  28541. ></DIV
  28542. ><DIV
  28543. CLASS="informalexample"
  28544. ><P
  28545. ></P
  28546. ><A
  28547. NAME="AEN5023"
  28548. ></A
  28549. ><TABLE
  28550. BORDER="0"
  28551. BGCOLOR="#E0E0E0"
  28552. CELLPADDING="5"
  28553. ><TR
  28554. ><TD
  28555. ><PRE
  28556. CLASS="php"
  28557. >class A
  28558. {
  28559.     function A()
  28560.     {
  28561.       echo "I am the constructor of A.<br>\n";
  28562.     }
  28563. }
  28564.  
  28565. class B extends A
  28566. {
  28567.     function C()
  28568.     {
  28569.         echo "I am a regular function.<br>\n";
  28570.     }
  28571. }
  28572.  
  28573. // In PHP 3 wurde kein Konstruktor aufgerufen.
  28574. $b = new B;</PRE
  28575. ></TD
  28576. ></TR
  28577. ></TABLE
  28578. ><P
  28579. ></P
  28580. ></DIV
  28581. ><P
  28582. >     In PHP 3 wird bei dem obigen Beispiel kein Konstruktor aufgerufen.
  28583.     Die Regel in PHP 3 besagt: 'Ein Konstruktor ist eine Funktion mit
  28584.     dem selben Namen wie die Klasse'. Der Name der Klasse ist B, und
  28585.     nachdem in Klasse B keine Funktion namens B() existiert, passiert
  28586.     nichts.
  28587.    </P
  28588. ><P
  28589. >     Dies ist in PHP 4 mit der Einfⁿhrung einer anderen Regel behoben:
  28590.     Wenn eine Klasse keinen Konstruktor hat, wird der Konstruktor der
  28591.     Basisklasse aufgerufen, so dieser existiert. Das obige Beispiel
  28592.     hΣtte in PHP 4 also 'I am the constructor of A.<br>' ausgegeben.
  28593.    </P
  28594. ><DIV
  28595. CLASS="informalexample"
  28596. ><P
  28597. ></P
  28598. ><A
  28599. NAME="AEN5027"
  28600. ></A
  28601. ><TABLE
  28602. BORDER="0"
  28603. BGCOLOR="#E0E0E0"
  28604. CELLPADDING="5"
  28605. ><TR
  28606. ><TD
  28607. ><PRE
  28608. CLASS="php"
  28609. >class A
  28610. {
  28611.     function A()
  28612.     {
  28613.         echo "I am the constructor of A.<br>\n";
  28614.     }
  28615.  
  28616.     function B()
  28617.     {
  28618.         echo "I am a regular function named B in class A.<br>\n";
  28619.         echo "I am not a constructor in A.<br>\n";
  28620.     }
  28621. }
  28622.  
  28623. class B extends A
  28624. {
  28625.     function C()
  28626.     {
  28627.         echo "I am a regular function.<br>\n";
  28628.     }
  28629. }
  28630.  
  28631. // Dies ruft B() als Konstruktor auf.
  28632. $b = new B;</PRE
  28633. ></TD
  28634. ></TR
  28635. ></TABLE
  28636. ><P
  28637. ></P
  28638. ></DIV
  28639. ><P
  28640. >     In PHP 3 wird die Funktion B() in der Klasse A pl÷tzlich zum
  28641.     Konstruktor in Klasse B, auch wenn dies nie beabsichtigt war.
  28642.     Die Regel in PHP 3 lautet: 'Ein Konstruktor ist eine Funktion
  28643.     mit dem gleichen Namen wie die Klasse'. PHP 3 kⁿmmert sich nicht
  28644.     darum, ob die Funktion in Klasse B definiert, oder ob sie nur
  28645.     vererbt wurde.
  28646.    </P
  28647. ><P
  28648. >     Dies ist in PHP 4 mit einer modifizierten Regel behoben: 'Ein
  28649.     Konstruktor ist eine Funktion mit dem selben Namen wie die Klasse,
  28650.     in der sie definiert wurde'. So hΣtte die Klasse B in dem obigen
  28651.     Beispiel keinen eigenen Konstruktor, und wⁿrde der Konstruktor
  28652.     der Basisklasse aufgerufen, welcher 'I am the constructor of
  28653.     A.<br>' ausgeben wⁿrde.
  28654.    </P
  28655. ><DIV
  28656. CLASS="caution"
  28657. ><P
  28658. ></P
  28659. ><TABLE
  28660. CLASS="caution"
  28661. BORDER="1"
  28662. WIDTH="100%"
  28663. ><TR
  28664. ><TD
  28665. ALIGN="CENTER"
  28666. ><B
  28667. >Achtung</B
  28668. ></TD
  28669. ></TR
  28670. ><TR
  28671. ><TD
  28672. ALIGN="LEFT"
  28673. ><P
  28674. >      Weder PHP 3, noch PHP 4 rufen vom Konstruktor der abgeleiteten
  28675.      Klasse aus automatisch Konstruktoren der Basisklasse auf. Wenn
  28676.      angebracht, ist der Aufruf von Konstruktoren aufwΣrts Ihre
  28677.      Aufgabe.
  28678.     </P
  28679. ></TD
  28680. ></TR
  28681. ></TABLE
  28682. ></DIV
  28683. ><DIV
  28684. CLASS="note"
  28685. ><BLOCKQUOTE
  28686. CLASS="note"
  28687. ><P
  28688. ><B
  28689. >Anmerkung: </B
  28690. >
  28691.      In PHP 3 und PHP 4 gibt es keine Destruktoren. Stattdessen k÷nnen
  28692.      Sie <A
  28693. HREF="#function.register-shutdown-function"
  28694. ><B
  28695. CLASS="function"
  28696. >register_shutdown_function()</B
  28697. ></A
  28698. > verwenden, um
  28699.      die meisten Effekte von Destruktoren zu simulieren.
  28700.     </P
  28701. ></BLOCKQUOTE
  28702. ></DIV
  28703. ><P
  28704. >     Destruktoren sind Funktionen die automatisch aufgerufen werden, wenn
  28705.     ein Objekt entweder mittels <A
  28706. HREF="#function.unset"
  28707. ><B
  28708. CLASS="function"
  28709. >unset()</B
  28710. ></A
  28711. >, oder durch
  28712.     Verlassen des Gⁿltigkeitsbereiches zerst÷rt wird. Es gibt in PHP
  28713.     keine Destruktoren.
  28714.    </P
  28715. ></DIV
  28716. ><DIV
  28717. CLASS="sect1"
  28718. ><HR><H2
  28719. CLASS="sect1"
  28720. ><A
  28721. NAME="keyword.paamayim-nekudotayim"
  28722. ><VAR
  28723. CLASS="literal"
  28724. >::</VAR
  28725. ></A
  28726. ></H2
  28727. ><DIV
  28728. CLASS="caution"
  28729. ><P
  28730. ></P
  28731. ><TABLE
  28732. CLASS="caution"
  28733. BORDER="1"
  28734. WIDTH="100%"
  28735. ><TR
  28736. ><TD
  28737. ALIGN="CENTER"
  28738. ><B
  28739. >Achtung</B
  28740. ></TD
  28741. ></TR
  28742. ><TR
  28743. ><TD
  28744. ALIGN="LEFT"
  28745. ><P
  28746. >      Die folgende Beschreibung ist nur fⁿr PHP 4 gⁿltig.
  28747.     </P
  28748. ></TD
  28749. ></TR
  28750. ></TABLE
  28751. ></DIV
  28752. ><P
  28753. >     Manchmal ist es hilfreich, auf Funktionen in Basisklassen bzw.
  28754.     auf Funktionen in Klassen zuzugreifen, die noch keine Instanzen
  28755.     haben. Dafⁿr wird der :: Operator verwendet. 
  28756.    </P
  28757. ><DIV
  28758. CLASS="informalexample"
  28759. ><P
  28760. ></P
  28761. ><A
  28762. NAME="AEN5044"
  28763. ></A
  28764. ><TABLE
  28765. BORDER="0"
  28766. BGCOLOR="#E0E0E0"
  28767. CELLPADDING="5"
  28768. ><TR
  28769. ><TD
  28770. ><PRE
  28771. CLASS="php"
  28772. >class A
  28773. {
  28774.     function example()
  28775.     {
  28776.         echo "I am the original function A::example().<br>\n";
  28777.     }
  28778. }
  28779.  
  28780. class B extends A
  28781. {
  28782.     function example()
  28783.     {
  28784.         echo "I am the redefined function B::example().<br>\n";
  28785.         A::example();
  28786.     }
  28787. }
  28788.  
  28789. // Es gibt kein Objekt der Klasse A.
  28790. // Dies wird folgendes ausgeben
  28791. //   I am the original function A::example().<br>
  28792. A::example();
  28793.  
  28794. // Erstellt ein Objekt der Klasse B.
  28795. $b = new B;
  28796.  
  28797. // Dies wird folgendes ausgeben
  28798. //   I am the redefined function B::example().<br>
  28799. //   I am the original function A::example().<br>
  28800. $b->example();</PRE
  28801. ></TD
  28802. ></TR
  28803. ></TABLE
  28804. ><P
  28805. ></P
  28806. ></DIV
  28807. ><P
  28808. >     Das obige Beispiel ruft die Funktion example() der Klasse A auf.
  28809.     Nachdem noch kein Objekt der Klasse A existiert, k÷nnen wir nicht
  28810.     $a->example() oder Σhnliches schreiben. Stattdessen rufen wir
  28811.     example() als 'Klassenfunktion' auf, d.h. als Funktion der Klasse
  28812.     selbst, und nicht irgendein Objekt dieser Klasse.
  28813.    </P
  28814. ><P
  28815. >     Es gibt Klassenfunktionen, aber keine Klassenvariablen. TatsΣchlich
  28816.     gibt es zur Zeit des Aufrufs kein Objekt. Deshalb darf eine
  28817.     Klassenfunktion keine Objektvariablen benutzen (aber sie kann lokale
  28818.     und globale Variablen verwenden), und sie darf $this ebenfalls nicht
  28819.     benutzen.
  28820.    </P
  28821. ><P
  28822. >     In dem obigen Beispiel definiert Klasse B die Funktion example() neu.
  28823.     Die ursprⁿngliche Definition in Klasse A ist ⁿberschattet und nicht
  28824.     lΣnger verfⁿgbar, au▀er Sie verweisen mittels des ::-Operators
  28825.     speziell auf example() in Klasse A. Schreiben Sie A::example(), um
  28826.     dies zu tun (TatsΣchlich sollten Sie parent::example() schreiben,
  28827.     wie im nΣchsten Abschnitt beschrieben).
  28828.    </P
  28829. ><P
  28830. >     In diesem Kontext besteht ein Objekt, das Objektvariablen haben
  28831.     kann. Deshalb k÷nnen Sie auch $this und Objektvariablen verwenden,
  28832.     wenn sie von innerhalb einer Objektfunktion verwendet werden.
  28833.    </P
  28834. ></DIV
  28835. ><DIV
  28836. CLASS="sect1"
  28837. ><HR><H2
  28838. CLASS="sect1"
  28839. ><A
  28840. NAME="keyword.parent"
  28841. ><VAR
  28842. CLASS="literal"
  28843. >parent</VAR
  28844. ></A
  28845. ></H2
  28846. ><P
  28847. >    Wahrscheinlich wollen Sie auch Code schreiben, der sich auch auf
  28848.    Variablen und Funktionen in Basisklassen bezieht. Dies gilt
  28849.    speziell dann, wenn Ihre abgeleitete Klasse eine Verfeinerung
  28850.    oder Spezialisierung von Code in Ihrer Basisklasse ist.
  28851.   </P
  28852. ><P
  28853. >    Anstatt in Ihrem Code den w÷rtlichen Namen der Basisklasse zu
  28854.    verwenden, sollten Sie den speziellen Namen
  28855.    <VAR
  28856. CLASS="literal"
  28857. >parent</VAR
  28858. > verwenden, welcher sich auf den in
  28859.    der Deklaration Ihrer Klasse mittels <VAR
  28860. CLASS="literal"
  28861. >extends</VAR
  28862. >
  28863.    gegebenen Namen Ihrer Basisklasse bezieht. So vermeiden Sie
  28864.    die mehrfache Verwendung des Namens der Basisklasse. Sollte
  28865.    sich Ihr Vererbungsbaum wΣhrend der Implementation Σndern,
  28866.    brauchen Sie nur mehr die <VAR
  28867. CLASS="literal"
  28868. >extends</VAR
  28869. > Deklaration
  28870.    Ihrer Klasse zu Σndern.
  28871.   </P
  28872. ><DIV
  28873. CLASS="informalexample"
  28874. ><P
  28875. ></P
  28876. ><A
  28877. NAME="AEN5058"
  28878. ></A
  28879. ><TABLE
  28880. BORDER="0"
  28881. BGCOLOR="#E0E0E0"
  28882. CELLPADDING="5"
  28883. ><TR
  28884. ><TD
  28885. ><PRE
  28886. CLASS="php"
  28887. >class A
  28888. {
  28889.     function example()
  28890.     {
  28891.         echo "I am A::example() and provide basic functionality.<br>\n";
  28892.     }
  28893. }
  28894.  
  28895. class B extends A
  28896. {
  28897.     function example()
  28898.     {
  28899.         echo "I am B::example() and provide additional functionality.<br>\n";
  28900.         parent::example();
  28901.     }
  28902. }
  28903.  
  28904. $b = new B;
  28905.  
  28906. // Dies ruft B::example() auf, welches wiederum A::example() aufruft.
  28907. $b->example();</PRE
  28908. ></TD
  28909. ></TR
  28910. ></TABLE
  28911. ><P
  28912. ></P
  28913. ></DIV
  28914. ></DIV
  28915. ><DIV
  28916. CLASS="sect1"
  28917. ><HR><H2
  28918. CLASS="sect1"
  28919. ><A
  28920. NAME="language.oop.serialization"
  28921. >Objekte serialisieren - Objekte in Sessions</A
  28922. ></H2
  28923. ><DIV
  28924. CLASS="note"
  28925. ><BLOCKQUOTE
  28926. CLASS="note"
  28927. ><P
  28928. ><B
  28929. >Anmerkung: </B
  28930. >
  28931.     In PHP 3 verlieren Objekte wΣhrend des Prozesses der Serialisierung
  28932.     und Deserialisierung ihre Assoziation zur Klasse. Die resultierende
  28933.     Variable ist vom Typ Objekt, hat aber keine Klasse und keine Methoden,
  28934.     weshalb sie ziemlich unbrauchbar ist (Sie wurde wie ein Array, jedoch
  28935.     mit einer ziemlich komischen Syntax).
  28936.    </P
  28937. ></BLOCKQUOTE
  28938. ></DIV
  28939. ><DIV
  28940. CLASS="caution"
  28941. ><P
  28942. ></P
  28943. ><TABLE
  28944. CLASS="caution"
  28945. BORDER="1"
  28946. WIDTH="100%"
  28947. ><TR
  28948. ><TD
  28949. ALIGN="CENTER"
  28950. ><B
  28951. >Achtung</B
  28952. ></TD
  28953. ></TR
  28954. ><TR
  28955. ><TD
  28956. ALIGN="LEFT"
  28957. ><P
  28958. >     Die folgende Information ist nur fⁿr PHP 4 gⁿltig.
  28959.    </P
  28960. ></TD
  28961. ></TR
  28962. ></TABLE
  28963. ></DIV
  28964. ><P
  28965. >    <A
  28966. HREF="#function.serialize"
  28967. ><B
  28968. CLASS="function"
  28969. >serialize()</B
  28970. ></A
  28971. > gibt eine Zeichenkette zurⁿck, die
  28972.    eine Byte-Strom-ReprΣsentation irgendeines in PHP speicherbaren
  28973.    Wertes enthΣlt. <A
  28974. HREF="#function.unserialize"
  28975. ><B
  28976. CLASS="function"
  28977. >unserialize()</B
  28978. ></A
  28979. > kann diese
  28980.    Zeichenkette verwenden, um die ursprⁿnglichen Variablenwerte
  28981.    wieder herzustellen. Die Verwendung von serialize zum Speichern
  28982.    eines Objektes wird alle Variablen innerhalb eines Objektes
  28983.    speichern. Die Funktionen in einem Objekt werden nicht gespeichert,
  28984.    sondern nur der Name der Klasse.
  28985.   </P
  28986. ><P
  28987. >    Um ein Objekt wieder deserialisieren zu k÷nnen, muss die Klasse
  28988.    dieses Objektes definiert werden. Das hei▀t, wenn Sie ein Objekt
  28989.    $a der Klasse A in page1.php haben und dieses serialisieren,
  28990.    erhalten Sie eine Zeichenkette, die sich auf die Klasse A bezieht,
  28991.    und alle Werte der in $a enthaltenen Variablen enthΣlt. Wenn Sie
  28992.    $a der Klasse A in page2.php mittels unserialize wiederherstellen
  28993.    m÷chten, muss die Definition von Klasse A in page2.php vorhanden
  28994.    sein. Dies kann zum Beispiel durch das Speichern der
  28995.    Klassendefiniton von Klasse A in einer Include-Datei, und das
  28996.    Einbinden dieser Datei sowohl in page1.php und page2.php realisiert
  28997.    werden.
  28998.   </P
  28999. ><DIV
  29000. CLASS="informalexample"
  29001. ><P
  29002. ></P
  29003. ><A
  29004. NAME="AEN5070"
  29005. ></A
  29006. ><TABLE
  29007. BORDER="0"
  29008. BGCOLOR="#E0E0E0"
  29009. CELLPADDING="5"
  29010. ><TR
  29011. ><TD
  29012. ><PRE
  29013. CLASS="php"
  29014. >classa.inc:
  29015.   class A 
  29016.   {
  29017.       var $one = 1;
  29018.     
  29019.       function show_one()
  29020.       {
  29021.           echo $this->one;
  29022.       }
  29023.   }
  29024.   
  29025. page1.php:
  29026.   include("classa.inc");
  29027.   
  29028.   $a = new A;
  29029.   $s = serialize($a);
  29030.   // speichere $s irgendwo, wo sie page2.php finden kann.
  29031.   $fp = fopen("store", "w");
  29032.   fputs($fp, $s);
  29033.   fclose($fp);
  29034.  
  29035. page2.php:
  29036.   // Dies ist fⁿr das korrekte Arbeiten von unserialize n÷tig.
  29037.   include("classa.inc");
  29038.  
  29039.   $s = implode("", @file("store"));
  29040.   $a = unserialize($s);
  29041.  
  29042.   // Nun verwenden wir die Funktion show_one() des Objektes $a.  
  29043.   $a->show_one();</PRE
  29044. ></TD
  29045. ></TR
  29046. ></TABLE
  29047. ><P
  29048. ></P
  29049. ></DIV
  29050. ><P
  29051. >    Wenn Sie mit Sessions arbeiten und <A
  29052. HREF="#function.session-register"
  29053. ><B
  29054. CLASS="function"
  29055. >session_register()</B
  29056. ></A
  29057. >
  29058.    verwenden, um Objekte zu registrieren, so werden diese Objekte am Ende
  29059.    der PHP Seite serialisiert, und in jeder folgenden Seite automatisch
  29060.    via unserialize wiederhergestellt. Das hei▀t, dass diese Objekte auf
  29061.    jeder Ihrer Seite auftauchen k÷nnen, sobald sie Teil Ihrer Session sind.
  29062.   </P
  29063. ><P
  29064. >    Es wird ausdrⁿcklich empfohlen, dass Sie die Klassendefinitionen der
  29065.    so registrierten Objekte in allen Ihren Seiten einbinden, auch wenn
  29066.    Sie diese Klassen eigentlich nicht auf allen Ihren Seiten ben÷tigen.
  29067.    Tun Sie es nicht und wird ein Objekt ohne einer vorhandenen
  29068.    Klassendefinition deserialisiert, verliert es seine Assoziation zur
  29069.    Klasse, und wird zu einem Objekt der Klasse <VAR
  29070. CLASS="literal"
  29071. >stdClass</VAR
  29072. >,
  29073.    ohne irgendwelchen Funktionen. Das bedeutet, dass es ziemlich nutzlos
  29074.    wird.
  29075.   </P
  29076. ><P
  29077. >    Wⁿrde also $a in dem obigen Beispiel mittels 
  29078.    <VAR
  29079. CLASS="literal"
  29080. >session_register("a")</VAR
  29081. > ein Teil einer Session,
  29082.    sollten Sie die Datei <VAR
  29083. CLASS="literal"
  29084. >classa.inc</VAR
  29085. > nicht nur in
  29086.    page1.php und page2.php, sondern in all Ihre Seiten einbinden.
  29087.   </P
  29088. ></DIV
  29089. ><DIV
  29090. CLASS="sect1"
  29091. ><HR><H2
  29092. CLASS="sect1"
  29093. ><A
  29094. NAME="language.oop.magic-functions"
  29095. >Die "magischen" Funktionen <VAR
  29096. CLASS="literal"
  29097. >__sleep</VAR
  29098. > und <VAR
  29099. CLASS="literal"
  29100. >__wakeup</VAR
  29101. ></A
  29102. ></H2
  29103. ><P
  29104. >    <A
  29105. HREF="#function.serialize"
  29106. ><B
  29107. CLASS="function"
  29108. >serialize()</B
  29109. ></A
  29110. > prⁿft, ob Ihre Klasse eine Funktion mit
  29111.    dem magischen Namen <VAR
  29112. CLASS="literal"
  29113. >__sleep</VAR
  29114. > enthΣlt. Wenn dem so ist,
  29115.    wird diese Funktion vor einer Serialisierung ausgefⁿhrt. Sie kann das
  29116.    Objekt aufrΣumen und soll ein Array mit den Namen aller Variablen des
  29117.    zu serialisierenden Objektes zurⁿckgeben.
  29118.   </P
  29119. ><P
  29120. >    Die beabsichtigte Verwendung von <VAR
  29121. CLASS="literal"
  29122. >__sleep</VAR
  29123. > ist,
  29124.    eventuelle Datenbankverbindungen des Objektes zu schlie▀en, noch
  29125.    offene Daten zu committen, oder Σhnliche SΣuberungsaktionen
  29126.    durchzufⁿhren. Weiters ist diese Funktion hilfreich, wenn Sie
  29127.    sehr gro▀e Objekte haben, die nicht komplett gespeichert werden 
  29128.    mⁿssen.
  29129.   </P
  29130. ><P
  29131. >    Umgekehrt prⁿft <A
  29132. HREF="#function.unserialize"
  29133. ><B
  29134. CLASS="function"
  29135. >unserialize()</B
  29136. ></A
  29137. > die Existenz einer
  29138.    Funktion mit dem magischen Namen <VAR
  29139. CLASS="literal"
  29140. >__wakeup</VAR
  29141. >. Ist
  29142.    diese vorhanden, kann sie Ressourcen des Objektes rekonstruieren.
  29143.   </P
  29144. ><P
  29145. >     Die vorgesehene Verwendung von <VAR
  29146. CLASS="literal"
  29147. >__wakeup</VAR
  29148. > ist die
  29149.     Wiederherstellung von Datenbankverbindungen, welche wΣhrend der
  29150.     Serialisierung verloren gegangen sein k÷nnten, sowie andere
  29151.     Neuinitialisierungen.
  29152.   </P
  29153. ></DIV
  29154. ><DIV
  29155. CLASS="sect1"
  29156. ><HR><H2
  29157. CLASS="sect1"
  29158. ><A
  29159. NAME="language.oop.newref"
  29160. >Referenzen innherhalb des Konstruktors</A
  29161. ></H2
  29162. ><P
  29163. >     Referenzen innerhalb des Konstruktors k÷nnen zu verwirrenden
  29164.     Resultaten fⁿhren. Dieser Abschnitt hilft, Probleme zu vermeiden.
  29165.  
  29166.     <DIV
  29167. CLASS="informalexample"
  29168. ><P
  29169. ></P
  29170. ><A
  29171. NAME="AEN5096"
  29172. ></A
  29173. ><TABLE
  29174. BORDER="0"
  29175. BGCOLOR="#E0E0E0"
  29176. CELLPADDING="5"
  29177. ><TR
  29178. ><TD
  29179. ><PRE
  29180. CLASS="php"
  29181. >class Foo
  29182. {
  29183.     function Foo($name)
  29184.     {
  29185.         // eine Referenz innerhalb des globalen Arrays  $globalref erstellen
  29186.         global $globalref;
  29187.         $globalref[] = &$this;
  29188.         // setze den Namen auf den ⁿbergebenen Wert
  29189.         $this->setName($name);
  29190.         // und gib' ihn aus
  29191.         $this->echoName();
  29192.     }
  29193.  
  29194.     function echoName()
  29195.     {
  29196.         echo "<br>",$this->name;
  29197.     }
  29198.     
  29199.     function setName($name)
  29200.     {
  29201.         $this->name = $name;
  29202.     }
  29203. }</PRE
  29204. ></TD
  29205. ></TR
  29206. ></TABLE
  29207. ><P
  29208. ></P
  29209. ></DIV
  29210. >
  29211.   </P
  29212. ><P
  29213. >     Prⁿfen wir, ob zwischen <VAR
  29214. CLASS="varname"
  29215. >$bar1</VAR
  29216. >, die mittels
  29217.     dem Operator zum Kopieren  <VAR
  29218. CLASS="literal"
  29219. >=</VAR
  29220. > erstellt wurde,
  29221.     und <VAR
  29222. CLASS="varname"
  29223. >$bar2</VAR
  29224. >, die mittels dem Referenzoperator
  29225.     <VAR
  29226. CLASS="literal"
  29227. >=&</VAR
  29228. > erstellt wurde, besteht...
  29229.  
  29230.     <DIV
  29231. CLASS="informalexample"
  29232. ><P
  29233. ></P
  29234. ><A
  29235. NAME="AEN5103"
  29236. ></A
  29237. ><TABLE
  29238. BORDER="0"
  29239. BGCOLOR="#E0E0E0"
  29240. CELLPADDING="5"
  29241. ><TR
  29242. ><TD
  29243. ><PRE
  29244. CLASS="php"
  29245. >$bar1 = new Foo('set in constructor');
  29246. $bar1->echoName();
  29247. $globalref[0]->echoName();
  29248.  
  29249. /* Ausgabe:
  29250. set in constructor
  29251. set in constructor
  29252. set in constructor */
  29253.  
  29254. $bar2 =& new Foo('set in constructor');
  29255. $bar2->echoName();
  29256. $globalref[1]->echoName();
  29257.  
  29258. /* Ausgabe:
  29259. set in constructor
  29260. set in constructor
  29261. set in constructor */</PRE
  29262. ></TD
  29263. ></TR
  29264. ></TABLE
  29265. ><P
  29266. ></P
  29267. ></DIV
  29268. >
  29269.    </P
  29270. ><P
  29271. >     Scheinbar besteht kein Unterschied, aber tatsΣchlich existiert ein
  29272.     signifikanter: <VAR
  29273. CLASS="varname"
  29274. >$bar1</VAR
  29275. > und
  29276.     <VAR
  29277. CLASS="varname"
  29278. >$globalref[0]</VAR
  29279. > sind NICHT referenziert, d.h. sie
  29280.     sind NICHT die selbe Variable. Das kommt daher, dass "new" nicht
  29281.     automatisch eine Referenz, sondern eine Kopie zurⁿckgibt.
  29282.     <DIV
  29283. CLASS="note"
  29284. ><BLOCKQUOTE
  29285. CLASS="note"
  29286. ><P
  29287. ><B
  29288. >Anmerkung: </B
  29289. >
  29290.       Das zurⁿckgeben von Kopien anstatt von Referenzen stellt keinen
  29291.       Performanceverlust dar (da PHP 4 und h÷her Reference Counting
  29292.       verwendet). Andererseits ist es sehr oft besser, einfach mit Kopien
  29293.       anstatt mit Referenzen zu arbeiten, da die Erstellung von Referenzen
  29294.       etwas Zeit in Anspruch nimmt, wΣhrend das Erstellen von Kopien so gut
  29295.       wie keine Zeit braucht (sofern keine von ihnen ein gro▀es Array oder
  29296.       Objekt ist, und eines davon geΣndert wird und das/die andere/n
  29297.       nachtrΣglich. In diesem Fall wΣre es besser, Referenzen zu verwenden,
  29298.       um sie alle gleichzeitig zu Σndern).
  29299.      </P
  29300. ></BLOCKQUOTE
  29301. ></DIV
  29302. >
  29303.     Um das zuvor geschriebene zu beweisen, sehen wir uns den folgenden Code an.
  29304.  
  29305.     <DIV
  29306. CLASS="informalexample"
  29307. ><P
  29308. ></P
  29309. ><A
  29310. NAME="AEN5110"
  29311. ></A
  29312. ><TABLE
  29313. BORDER="0"
  29314. BGCOLOR="#E0E0E0"
  29315. CELLPADDING="5"
  29316. ><TR
  29317. ><TD
  29318. ><PRE
  29319. CLASS="php"
  29320. >// nun werden wir den Namen Σndern. Was erwarten Sie?
  29321. // ...dass sowohl $bar1, als auch $globalref[0] ihre Namen Σndern...
  29322. $bar1->setName('set from outside');
  29323.  
  29324. // wie bereits zuvor erwΣhnt, ist dies nicht der Fall
  29325. $bar1->echoName();
  29326. $globalref[0]->echoName();
  29327.  
  29328. /* Ausgabe:
  29329. set from outside
  29330. set in constructor */
  29331.  
  29332. // lassen Sie uns den Unterschied zwischen $bar2 and $globalref[1] ansehen
  29333. $bar2->setName('set from outside');
  29334.  
  29335. // glⁿcklicherweise sind sie nicht nur nicht gleich, sondern auch die selbe
  29336. // Variable; demnach sind $bar2->name und $globalref[1]->name ebenfalls gleich
  29337. $bar2->echoName();
  29338. $globalref[1]->echoName();
  29339.  
  29340. /* Ausgabe:
  29341. set from outside
  29342. set from outside */</PRE
  29343. ></TD
  29344. ></TR
  29345. ></TABLE
  29346. ><P
  29347. ></P
  29348. ></DIV
  29349. >   
  29350.    </P
  29351. ><P
  29352. >    Ein anderes, letztes Beispiel zum VerstΣndnis:
  29353.    
  29354.     <DIV
  29355. CLASS="informalexample"
  29356. ><P
  29357. ></P
  29358. ><A
  29359. NAME="AEN5113"
  29360. ></A
  29361. ><TABLE
  29362. BORDER="0"
  29363. BGCOLOR="#E0E0E0"
  29364. CELLPADDING="5"
  29365. ><TR
  29366. ><TD
  29367. ><PRE
  29368. CLASS="php"
  29369. >class A
  29370. {
  29371.     function A($i)
  29372.     {
  29373.         $this->value = $i;
  29374.         // finden Sie heraus, warum wir hier keine Referenz ben÷tigen
  29375.         $this->b = new B($this);
  29376.     }
  29377.  
  29378.     function createRef()
  29379.     {
  29380.         $this->c = new B($this);
  29381.     }
  29382.  
  29383.     function echoValue()
  29384.     {
  29385.         echo "<br>","class ",get_class($this),': ',$this->value;
  29386.     }
  29387. }
  29388.  
  29389.  
  29390. class B
  29391. {
  29392.     function B(&$a)
  29393.     {
  29394.         $this->a = &$a;
  29395.     }
  29396.  
  29397.     function echoValue()
  29398.     {
  29399.         echo "<br>","class ",get_class($this),': ',$this->a->value;
  29400.     }
  29401. }
  29402.  
  29403. // ⁿberlegen Sie, warum hier die Verwendung einer einfachen Kopie in der
  29404. // mit * markierten Zeile zu einem unerwⁿnschten Ergebnis fⁿhren wⁿrde
  29405. $a =& new A(10);
  29406. $a->createRef();
  29407.  
  29408. $a->echoValue();
  29409. $a->b->echoValue();
  29410. $a->c->echoValue();
  29411.  
  29412. $a->value = 11;
  29413.  
  29414. $a->echoValue();
  29415. $a->b->echoValue(); // *
  29416. $a->c->echoValue();
  29417.  
  29418. /*
  29419. Ausgabe:
  29420. class A: 10
  29421. class B: 10
  29422. class B: 10
  29423. class A: 11
  29424. class B: 11
  29425. class B: 11
  29426. */</PRE
  29427. ></TD
  29428. ></TR
  29429. ></TABLE
  29430. ><P
  29431. ></P
  29432. ></DIV
  29433. >
  29434.    </P
  29435. ></DIV
  29436. ></DIV
  29437. ><DIV
  29438. CLASS="chapter"
  29439. ><HR><H1
  29440. ><A
  29441. NAME="language.oop5"
  29442. >Kapitel 18. Classes and Objects (PHP 5)</A
  29443. ></H1
  29444. ><DIV
  29445. CLASS="sect1"
  29446. ><H2
  29447. CLASS="sect1"
  29448. ><A
  29449. NAME="op5.intro"
  29450. >Introduction</A
  29451. ></H2
  29452. ><P
  29453. >      Intro to oop5 for php
  29454.     </P
  29455. ></DIV
  29456. ><DIV
  29457. CLASS="sect1"
  29458. ><HR><H2
  29459. CLASS="sect1"
  29460. ><A
  29461. NAME="language.oop5.decon"
  29462. >Constructors and Destructors</A
  29463. ></H2
  29464. ><DIV
  29465. CLASS="sect2"
  29466. ><H3
  29467. CLASS="sect2"
  29468. ><A
  29469. NAME="oop5-decon-constructor"
  29470. >Constructor</A
  29471. ></H3
  29472. >void <B
  29473. CLASS="methodname"
  29474. >__construct</B
  29475. > ( [mixed args [, ...]])<BR
  29476. ></BR
  29477. ><P
  29478. >     PHP 5 allows developers to declare constructor methods for classes.
  29479.     Classes which have a constructor method call this method on each
  29480.     newly-created object, so it is suitable for any initialization that the
  29481.     object may need before it is used.
  29482.    </P
  29483. ><DIV
  29484. CLASS="note"
  29485. ><BLOCKQUOTE
  29486. CLASS="note"
  29487. ><P
  29488. ><B
  29489. >Anmerkung: </B
  29490. >
  29491.      Parent constructors are not called implicitly.  In order to run
  29492.      a parent constructor, a call to
  29493.      <B
  29494. CLASS="function"
  29495. >parent::__construct()</B
  29496. > is required.
  29497.     </P
  29498. ></BLOCKQUOTE
  29499. ></DIV
  29500. ><TABLE
  29501. WIDTH="100%"
  29502. BORDER="0"
  29503. CELLPADDING="0"
  29504. CELLSPACING="0"
  29505. CLASS="EXAMPLE"
  29506. ><TR
  29507. ><TD
  29508. ><DIV
  29509. CLASS="example"
  29510. ><A
  29511. NAME="AEN5136"
  29512. ></A
  29513. ><P
  29514. ><B
  29515. >Beispiel 18-1. using new unified constructors</B
  29516. ></P
  29517. ><TABLE
  29518. BORDER="0"
  29519. BGCOLOR="#E0E0E0"
  29520. CELLPADDING="5"
  29521. ><TR
  29522. ><TD
  29523. ><PRE
  29524. CLASS="php"
  29525. ><?php
  29526. class BaseClass {
  29527.    function __construct() {
  29528.        print "In BaseClass constructor\n";
  29529.    }
  29530. }
  29531.  
  29532. class SubClass extends BaseClass {
  29533.    function __construct() {
  29534.        parent::__construct();
  29535.        print "In SubClass constructor\n";
  29536.    }
  29537. }
  29538.  
  29539. $obj = new BaseClass();
  29540. $obj = new SubClass();
  29541. ?></PRE
  29542. ></TD
  29543. ></TR
  29544. ></TABLE
  29545. ></DIV
  29546. ></TD
  29547. ></TR
  29548. ></TABLE
  29549. ><P
  29550. >     For backwards compatibility, if PHP 5 cannot find a 
  29551.     <B
  29552. CLASS="function"
  29553. >__construct()</B
  29554. > function for a given class, it will
  29555.     search for the old-style constructor function, by the name of the class.
  29556.     Effectively, it means that the only case that would have compatibility
  29557.     issues is if the class had a method named 
  29558.     <B
  29559. CLASS="function"
  29560. >__construct()</B
  29561. > which was used for different semantics.
  29562.    </P
  29563. ></DIV
  29564. ><DIV
  29565. CLASS="sect2"
  29566. ><HR><H3
  29567. CLASS="sect2"
  29568. ><A
  29569. NAME="oop5-decon-destructor"
  29570. >Destructor</A
  29571. ></H3
  29572. >void <B
  29573. CLASS="methodname"
  29574. >__destruct</B
  29575. > ( void )<BR
  29576. ></BR
  29577. ><P
  29578. >     PHP 5 introduces a destructor concept similar to that of other
  29579.     object-oriented languages, such as Java.  The destructor method will be
  29580.     called as soon as all references to a paticular object are removed or when
  29581.     the object is explicitly destroyed.
  29582.    </P
  29583. ><TABLE
  29584. WIDTH="100%"
  29585. BORDER="0"
  29586. CELLPADDING="0"
  29587. CELLSPACING="0"
  29588. CLASS="EXAMPLE"
  29589. ><TR
  29590. ><TD
  29591. ><DIV
  29592. CLASS="example"
  29593. ><A
  29594. NAME="AEN5149"
  29595. ></A
  29596. ><P
  29597. ><B
  29598. >Beispiel 18-2. Destructor Example</B
  29599. ></P
  29600. ><TABLE
  29601. BORDER="0"
  29602. BGCOLOR="#E0E0E0"
  29603. CELLPADDING="5"
  29604. ><TR
  29605. ><TD
  29606. ><PRE
  29607. CLASS="php"
  29608. ><?php
  29609. class MyDestructableClass {
  29610.    function __construct() {
  29611.        print "In constructor\n";
  29612.        $this->name = "MyDestructableClass";
  29613.    }
  29614.  
  29615.    function __destruct() {
  29616.        print "Destroying " . $this->name . "\n";
  29617.    }
  29618. }
  29619.  
  29620. $obj = new MyDestructableClass();
  29621. ?></PRE
  29622. ></TD
  29623. ></TR
  29624. ></TABLE
  29625. ></DIV
  29626. ></TD
  29627. ></TR
  29628. ></TABLE
  29629. ><P
  29630. >     Like constructors, parent destructors will not be called implicitly by
  29631.     the engine. In order to run a parent destructor, one would have to
  29632.     explicitly call <B
  29633. CLASS="function"
  29634. >parent::__destruct()</B
  29635. > in the destructor
  29636.     body.
  29637.    </P
  29638. ></DIV
  29639. ></DIV
  29640. ><DIV
  29641. CLASS="sect1"
  29642. ><HR><H2
  29643. CLASS="sect1"
  29644. ><A
  29645. NAME="language.oop5.visibility"
  29646. >Visibility</A
  29647. ></H2
  29648. ><P
  29649. >    The visibility of a property or method can be defined by prefixing the
  29650.    declaration with the keywords: public, protected or private. Public
  29651.    declared items can be acessed everywhere. Protected limits access to
  29652.    inherited classes (and to the class that defines the item). Private limits
  29653.    visiblity only to the class that defines the item.
  29654.   </P
  29655. ><DIV
  29656. CLASS="sect2"
  29657. ><HR><H3
  29658. CLASS="sect2"
  29659. ><A
  29660. NAME="language.oop5.visiblity-members"
  29661. >Members Visibility</A
  29662. ></H3
  29663. ><P
  29664. >    Class members must be defined with public, private, or protected.
  29665.    </P
  29666. ><TABLE
  29667. WIDTH="100%"
  29668. BORDER="0"
  29669. CELLPADDING="0"
  29670. CELLSPACING="0"
  29671. CLASS="EXAMPLE"
  29672. ><TR
  29673. ><TD
  29674. ><DIV
  29675. CLASS="example"
  29676. ><A
  29677. NAME="AEN5160"
  29678. ></A
  29679. ><P
  29680. ><B
  29681. >Beispiel 18-3. Member declaration</B
  29682. ></P
  29683. ><TABLE
  29684. BORDER="0"
  29685. BGCOLOR="#E0E0E0"
  29686. CELLPADDING="5"
  29687. ><TR
  29688. ><TD
  29689. ><PRE
  29690. CLASS="php"
  29691. ><?php
  29692.  
  29693. class MyClass {
  29694.    public    $public     = "MyClass::public!\n";
  29695.    protected $protected  = "MyClass::Protected!\n";
  29696.    protected $protected2 = "MyClass::Protected2!\n";
  29697.    private   $private    = "MyClass::private!\n";
  29698.  
  29699.    function printHello() {
  29700.       print "MyClass::printHello() " . $this->private;
  29701.       print "MyClass::printHello() " . $this->protected;
  29702.       print "MyClass::printHello() " . $this->protected2;
  29703.    }
  29704. }
  29705.  
  29706. class MyClass2 extends MyClass {
  29707.    protected $protected = "MyClass2::protected!\n";
  29708.  
  29709.    function printHello() {
  29710.  
  29711.       MyClass::printHello();    
  29712.  
  29713.       print "MyClass2::printHello() " . $this->public; 
  29714.       print "MyClass2::printHello() " . $this->protected; 
  29715.       print "MyClass2::printHello() " . $this->protected2;
  29716.  
  29717.       /* Will result in a Fatal Error: */
  29718.       //print "MyClass2::printHello() " . $this->private; /* Fatal Error */
  29719.  
  29720.    }
  29721. }
  29722.  
  29723. $obj = new MyClass();
  29724.  
  29725. print "Main:: " . $obj->public;
  29726. //print $obj->private; /* Fatal Error */
  29727. //print $obj->protected;  /* Fatal Error */
  29728. //print $obj->protected2;  /* Fatal Error */
  29729.  
  29730. $obj->printHello(); /* Should print */
  29731.  
  29732. $obj2 = new MyClass2();
  29733. print "Main:: " . $obj2->private; /* Undefined */ 
  29734.  
  29735. //print $obj2->protected;   /* Fatal Error */ 
  29736. //print $obj2->protected2;  /* Fatal Error */ 
  29737.  
  29738. $obj2->printHello();
  29739. ?></PRE
  29740. ></TD
  29741. ></TR
  29742. ></TABLE
  29743. ></DIV
  29744. ></TD
  29745. ></TR
  29746. ></TABLE
  29747. ><DIV
  29748. CLASS="note"
  29749. ><BLOCKQUOTE
  29750. CLASS="note"
  29751. ><P
  29752. ><B
  29753. >Anmerkung: </B
  29754. >
  29755.      The use PHP 4 use of declaring a variable with the keyword 'var' is
  29756.      no longer valid for PHP 5 objects. For compatiblity a variable declared
  29757.      in php will be assumed with public visiblity, and a
  29758.      <TT
  29759. CLASS="constant"
  29760. ><B
  29761. >E_STRICT</B
  29762. ></TT
  29763. > warning will be issued.
  29764.     </P
  29765. ></BLOCKQUOTE
  29766. ></DIV
  29767. ></DIV
  29768. ><DIV
  29769. CLASS="sect2"
  29770. ><HR><H3
  29771. CLASS="sect2"
  29772. ><A
  29773. NAME="language.oop5.visiblity-methods"
  29774. >Method Visibility</A
  29775. ></H3
  29776. ><P
  29777. >     .
  29778.    </P
  29779. ></DIV
  29780. ></DIV
  29781. ><DIV
  29782. CLASS="sect1"
  29783. ><HR><H2
  29784. CLASS="sect1"
  29785. ><A
  29786. NAME="language.oop5.paamayim-nekudotayim"
  29787. >::</A
  29788. ></H2
  29789. ><P
  29790. >    The Paamayim Nekudotayim, or in simpler terms, the double colon.
  29791.    This token provides a way to access <A
  29792. HREF="#language.oop5.static"
  29793. >static</A
  29794. >, <A
  29795. HREF="#language.oop5.constants"
  29796. >constant</A
  29797. > or overridden members
  29798.    or methods of a class. 
  29799.   </P
  29800. ><P
  29801. >    When referencing these items from outside the class definition, you use
  29802.    name of the class.
  29803.   </P
  29804. ><P
  29805. >    Paamayim Nekudotayim would, at first, seem a strange choice for a
  29806.    double-colon. However, at the time of writing of Zend Engine 0.5
  29807.    (which powered PHP3), that is what Andi and Zeev decided to call it.
  29808.    It actually does mean double-colon - in Hebrew! As PHP has progressed
  29809.    with its development it has just never changed.
  29810.   </P
  29811. ><TABLE
  29812. WIDTH="100%"
  29813. BORDER="0"
  29814. CELLPADDING="0"
  29815. CELLSPACING="0"
  29816. CLASS="EXAMPLE"
  29817. ><TR
  29818. ><TD
  29819. ><DIV
  29820. CLASS="example"
  29821. ><A
  29822. NAME="AEN5176"
  29823. ></A
  29824. ><P
  29825. ><B
  29826. >Beispiel 18-4. :: from outside class definition</B
  29827. ></P
  29828. ><TABLE
  29829. BORDER="0"
  29830. BGCOLOR="#E0E0E0"
  29831. CELLPADDING="5"
  29832. ><TR
  29833. ><TD
  29834. ><PRE
  29835. CLASS="php"
  29836. ><?php
  29837. class MyClass {
  29838.   const CONST_VALUE = 'A constant value';
  29839. }
  29840. echo MyClass::CONST_VALUE;
  29841. ?></PRE
  29842. ></TD
  29843. ></TR
  29844. ></TABLE
  29845. ></DIV
  29846. ></TD
  29847. ></TR
  29848. ></TABLE
  29849. ><P
  29850. >    Two special keywords <VAR
  29851. CLASS="varname"
  29852. >self</VAR
  29853. > and <VAR
  29854. CLASS="varname"
  29855. >parent</VAR
  29856. >
  29857.    are used to access members or methods from inside the class definition.
  29858.   </P
  29859. ><TABLE
  29860. WIDTH="100%"
  29861. BORDER="0"
  29862. CELLPADDING="0"
  29863. CELLSPACING="0"
  29864. CLASS="EXAMPLE"
  29865. ><TR
  29866. ><TD
  29867. ><DIV
  29868. CLASS="example"
  29869. ><A
  29870. NAME="AEN5182"
  29871. ></A
  29872. ><P
  29873. ><B
  29874. >Beispiel 18-5. :: from inside the class definition</B
  29875. ></P
  29876. ><TABLE
  29877. BORDER="0"
  29878. BGCOLOR="#E0E0E0"
  29879. CELLPADDING="5"
  29880. ><TR
  29881. ><TD
  29882. ><PRE
  29883. CLASS="php"
  29884. ><?php
  29885. class OtherClass extends MyClass {
  29886.   public static $my_static = 'static var';
  29887.  
  29888.   public static function doubleColon() {
  29889.      echo parent::CONST_VALUE . "\n";
  29890.      echo self::$my_static . "\n";
  29891.   }
  29892. }
  29893.  
  29894. OtherClass::doubleColon();
  29895. ?></PRE
  29896. ></TD
  29897. ></TR
  29898. ></TABLE
  29899. ></DIV
  29900. ></TD
  29901. ></TR
  29902. ></TABLE
  29903. ><P
  29904. >    When an extending class overrides the parents definition of a method,
  29905.    php will not call the parent's method.  It is up to the extending class
  29906.    to call the parent method or not, this also applies to <A
  29907. HREF="#language.oop5.decon"
  29908. >Constructors and Destructors</A
  29909. >, <A
  29910. HREF="#language.oop5.overloading"
  29911. >Overloading</A
  29912. > and <A
  29913. HREF="#language.oop5.magic"
  29914. >Magic</A
  29915. > method defintions as well.
  29916.   </P
  29917. ><TABLE
  29918. WIDTH="100%"
  29919. BORDER="0"
  29920. CELLPADDING="0"
  29921. CELLSPACING="0"
  29922. CLASS="EXAMPLE"
  29923. ><TR
  29924. ><TD
  29925. ><DIV
  29926. CLASS="example"
  29927. ><A
  29928. NAME="AEN5189"
  29929. ></A
  29930. ><P
  29931. ><B
  29932. >Beispiel 18-6. Calling a parent's method</B
  29933. ></P
  29934. ><TABLE
  29935. BORDER="0"
  29936. BGCOLOR="#E0E0E0"
  29937. CELLPADDING="5"
  29938. ><TR
  29939. ><TD
  29940. ><PRE
  29941. CLASS="php"
  29942. ><?php
  29943. class MyClass {
  29944.  
  29945.   protected function myFunc() {
  29946.     echo "MyClass::myFunc()\n";
  29947.   }
  29948. }
  29949.  
  29950. class OtherClass extends MyClass {
  29951.  
  29952.   /* Override parent's definition */
  29953.   public function myFunc() {
  29954.  
  29955.     /* But still call the parent function */
  29956.     parent::myFunc();
  29957.     echo "OtherClass::myFunc()\n";
  29958.   }
  29959. }
  29960.  
  29961. $class = new OtherClass();
  29962. $class->myFunc();
  29963. ?></PRE
  29964. ></TD
  29965. ></TR
  29966. ></TABLE
  29967. ></DIV
  29968. ></TD
  29969. ></TR
  29970. ></TABLE
  29971. ></DIV
  29972. ><DIV
  29973. CLASS="sect1"
  29974. ><HR><H2
  29975. CLASS="sect1"
  29976. ><A
  29977. NAME="language.oop5.static"
  29978. >Static Keyword</A
  29979. ></H2
  29980. ><P
  29981. >    Declaring class members or methods as static, makes them callable
  29982.    from outside the object context. A member or method declared
  29983.    with static can not be accessed with a variable that is an instance
  29984.    of the object and cannot be re-defined in an extending class.
  29985.   </P
  29986. ><P
  29987. >    The static declaration must be after the visibilty declaration. For 
  29988.    compatibility with PHP 4, if no <A
  29989. HREF="#language.oop5.visibility"
  29990. >visibility</A
  29991. >
  29992.    declaration is used, then the member or method will be treated
  29993.    as if it was declared as <VAR
  29994. CLASS="literal"
  29995. >public static</VAR
  29996. >.
  29997.   </P
  29998. ><P
  29999. >    Because static methods are callable without an instance of
  30000.    the object created, the pseudo variable <VAR
  30001. CLASS="varname"
  30002. >$this</VAR
  30003. > is
  30004.    not available inside the method declared as static.
  30005.   </P
  30006. ><TABLE
  30007. WIDTH="100%"
  30008. BORDER="0"
  30009. CELLPADDING="0"
  30010. CELLSPACING="0"
  30011. CLASS="EXAMPLE"
  30012. ><TR
  30013. ><TD
  30014. ><DIV
  30015. CLASS="example"
  30016. ><A
  30017. NAME="AEN5200"
  30018. ></A
  30019. ><P
  30020. ><B
  30021. >Beispiel 18-7. Static member example</B
  30022. ></P
  30023. ><TABLE
  30024. BORDER="0"
  30025. BGCOLOR="#E0E0E0"
  30026. CELLPADDING="5"
  30027. ><TR
  30028. ><TD
  30029. ><PRE
  30030. CLASS="php"
  30031. ><?php
  30032. class Foo {
  30033.   public static $my_static = 'foo';
  30034.  
  30035.   public function staticValue() {
  30036.     return self::$my_static;
  30037.   }
  30038. }
  30039.  
  30040. class Bar extends Foo {
  30041.  
  30042.   public function fooStatic() {
  30043.     return parent::$my_static;
  30044.   }
  30045. }
  30046.  
  30047.  
  30048. print Foo::$my_static . "\n";
  30049.  
  30050. $foo = new Foo();
  30051. print $foo->staticValue() . "\n";
  30052. print $foo->my_static . "\n";      // Undefined my_static 
  30053.  
  30054. print Bar::$my_static . "\n";
  30055. $bar = new Bar();
  30056. print $bar->fooStatic() . "\n";
  30057. ?></PRE
  30058. ></TD
  30059. ></TR
  30060. ></TABLE
  30061. ></DIV
  30062. ></TD
  30063. ></TR
  30064. ></TABLE
  30065. ><TABLE
  30066. WIDTH="100%"
  30067. BORDER="0"
  30068. CELLPADDING="0"
  30069. CELLSPACING="0"
  30070. CLASS="EXAMPLE"
  30071. ><TR
  30072. ><TD
  30073. ><DIV
  30074. CLASS="example"
  30075. ><A
  30076. NAME="AEN5203"
  30077. ></A
  30078. ><P
  30079. ><B
  30080. >Beispiel 18-8. Static method example</B
  30081. ></P
  30082. ><TABLE
  30083. BORDER="0"
  30084. BGCOLOR="#E0E0E0"
  30085. CELLPADDING="5"
  30086. ><TR
  30087. ><TD
  30088. ><PRE
  30089. CLASS="php"
  30090. ><?php
  30091. class Foo {
  30092.   public static function aStaticMethod() {
  30093.     // ...
  30094.   }
  30095. }
  30096.  
  30097. Foo::aStaticMethod();
  30098. ?></PRE
  30099. ></TD
  30100. ></TR
  30101. ></TABLE
  30102. ></DIV
  30103. ></TD
  30104. ></TR
  30105. ></TABLE
  30106. ></DIV
  30107. ><DIV
  30108. CLASS="sect1"
  30109. ><HR><H2
  30110. CLASS="sect1"
  30111. ><A
  30112. NAME="language.oop5.constants"
  30113. >Object Constants</A
  30114. ></H2
  30115. ><P
  30116. >    It is possible to define constant values on a per-class basis remaining the
  30117.    same and unchangeable. Constants differ from normal variables in that you
  30118.    don't use the <VAR
  30119. CLASS="varname"
  30120. >$</VAR
  30121. > symbol to declare or use them.  Like
  30122.    <A
  30123. HREF="#language.oop5.static"
  30124. >static</A
  30125. > members, constant values
  30126.    can not be accessed from an instance of the object.
  30127.   </P
  30128. ><TABLE
  30129. WIDTH="100%"
  30130. BORDER="0"
  30131. CELLPADDING="0"
  30132. CELLSPACING="0"
  30133. CLASS="EXAMPLE"
  30134. ><TR
  30135. ><TD
  30136. ><DIV
  30137. CLASS="example"
  30138. ><A
  30139. NAME="AEN5211"
  30140. ></A
  30141. ><P
  30142. ><B
  30143. >Beispiel 18-9. Defining and using a constant</B
  30144. ></P
  30145. ><TABLE
  30146. BORDER="0"
  30147. BGCOLOR="#E0E0E0"
  30148. CELLPADDING="5"
  30149. ><TR
  30150. ><TD
  30151. ><PRE
  30152. CLASS="php"
  30153. ><?php
  30154. class MyClass {
  30155.   const constant = 'constant value';
  30156.  
  30157.   function showConstant() {
  30158.     echo  self::constant . "\n";
  30159.   }
  30160. }
  30161.  
  30162. echo MyClass::constant . "\n";
  30163.  
  30164. $class = new MyClass();
  30165. $class->showConstant();
  30166. /* echo $class::constant;  is not allowed */
  30167. ?></PRE
  30168. ></TD
  30169. ></TR
  30170. ></TABLE
  30171. ></DIV
  30172. ></TD
  30173. ></TR
  30174. ></TABLE
  30175. ></DIV
  30176. ><DIV
  30177. CLASS="sect1"
  30178. ><HR><H2
  30179. CLASS="sect1"
  30180. ><A
  30181. NAME="language.oop5.abstract"
  30182. >Object Abstraction</A
  30183. ></H2
  30184. ><P
  30185. >    PHP 5 introduces abstract classes and methods. It is not allowed to create
  30186.    an instance of a class that has been defined as abstract.  Any class that
  30187.    contains at least one abstract method must also be abstract.  Methods
  30188.    defined as abstract simply declare the method's signature they cannot
  30189.    define the implementation.
  30190.   </P
  30191. ><P
  30192. >    The class that implements the abstract method must define with the same
  30193.    <A
  30194. HREF="#language.oop5.visibility"
  30195. >visibillity</A
  30196. > or weaker. If the
  30197.    abstract method is defined as protected, the function implenetation must be
  30198.    defined as either protected or public.
  30199.   </P
  30200. ><TABLE
  30201. WIDTH="100%"
  30202. BORDER="0"
  30203. CELLPADDING="0"
  30204. CELLSPACING="0"
  30205. CLASS="EXAMPLE"
  30206. ><TR
  30207. ><TD
  30208. ><DIV
  30209. CLASS="example"
  30210. ><A
  30211. NAME="AEN5219"
  30212. ></A
  30213. ><P
  30214. ><B
  30215. >Beispiel 18-10. Abstract class example</B
  30216. ></P
  30217. ><TABLE
  30218. BORDER="0"
  30219. BGCOLOR="#E0E0E0"
  30220. CELLPADDING="5"
  30221. ><TR
  30222. ><TD
  30223. ><PRE
  30224. CLASS="php"
  30225. ><?php
  30226.  
  30227. abstract class AbstractClass {
  30228.  
  30229.    /* Force Extending class to define this method */
  30230.    abstract protected function getValue();
  30231.  
  30232.    /* Common method */
  30233.    public function print() {
  30234.      print $this->getValue();
  30235.    }
  30236.  
  30237. }
  30238.  
  30239. class ConcreteClass1 extends AbstractClass {
  30240.  
  30241.    protected function getValue() {
  30242.      return "ConcreteClass1";
  30243.    }
  30244.  
  30245. }
  30246.  
  30247. class ConcreteClass2 extends AbstractClass {
  30248.  
  30249.    protected function getValue() {
  30250.      return "ConcreteClass2";
  30251.    }
  30252.  
  30253. }
  30254.  
  30255. $class1 = new ConcreteClass1;
  30256. $class1->print();
  30257.  
  30258. $class2 = new ConcreteClass2;
  30259. $class2->print();
  30260. ?></PRE
  30261. ></TD
  30262. ></TR
  30263. ></TABLE
  30264. ></DIV
  30265. ></TD
  30266. ></TR
  30267. ></TABLE
  30268. ><P
  30269. >     Old code that has no user-defined classes or functions named
  30270.     'abstract' should run without modifications.
  30271.    </P
  30272. ></DIV
  30273. ><DIV
  30274. CLASS="sect1"
  30275. ><HR><H2
  30276. CLASS="sect1"
  30277. ><A
  30278. NAME="language.oop5.interfaces"
  30279. >Object Interfaces</A
  30280. ></H2
  30281. ><P
  30282. >    Object interfaces allow you to create code which specifies which methods 
  30283.    and variables a class must implement, without having to define how these 
  30284.    methods are handled.
  30285.   </P
  30286. ><P
  30287. >    Interfaces are defined using the interface keyword, in the same way as a
  30288.    standard class, but without any of the methods having their contents
  30289.    defined. Classes which implement an interface should do so using the
  30290.    implements keyword, and must have definitions for all the methods listed
  30291.    in the interface. Classes may implement more than one interface if desired
  30292.    by listing each interface split by a space.
  30293.   </P
  30294. ><P
  30295. >    Stating that a class implements an interface, and then not implementing all
  30296.    the methods in the interface will result in a fatal error telling you which
  30297.    methods have not been implemented.
  30298.   </P
  30299. ><TABLE
  30300. WIDTH="100%"
  30301. BORDER="0"
  30302. CELLPADDING="0"
  30303. CELLSPACING="0"
  30304. CLASS="EXAMPLE"
  30305. ><TR
  30306. ><TD
  30307. ><DIV
  30308. CLASS="example"
  30309. ><A
  30310. NAME="AEN5228"
  30311. ></A
  30312. ><P
  30313. ><B
  30314. >Beispiel 18-11. Interface example</B
  30315. ></P
  30316. ><TABLE
  30317. BORDER="0"
  30318. BGCOLOR="#E0E0E0"
  30319. CELLPADDING="5"
  30320. ><TR
  30321. ><TD
  30322. ><PRE
  30323. CLASS="php"
  30324. ><?php
  30325. interface ITemplate
  30326. {
  30327.   public function setVariable($name, $var);
  30328.   public function getHtml($template);
  30329. }
  30330.  
  30331. class Template implements ITemplate
  30332. {
  30333.   private $vars = array();
  30334.   
  30335.   public function setVariable($name, $var)
  30336.   {
  30337.     $this->vars[$name] = $var;
  30338.   }
  30339.   
  30340.   public function getHtml($template)
  30341.   {
  30342.     foreach($this->vars as $name => $value) {
  30343.       $template = str_replace('{'.$name.'}', $value, $template);
  30344.     }
  30345.     
  30346.     return $template;
  30347.   }
  30348. }
  30349. ?></PRE
  30350. ></TD
  30351. ></TR
  30352. ></TABLE
  30353. ></DIV
  30354. ></TD
  30355. ></TR
  30356. ></TABLE
  30357. ></DIV
  30358. ><DIV
  30359. CLASS="sect1"
  30360. ><HR><H2
  30361. CLASS="sect1"
  30362. ><A
  30363. NAME="language.oop5.overloading"
  30364. >Overloading</A
  30365. ></H2
  30366. ><P
  30367. >    Both method calls and member accesses can be overloaded via the
  30368.    __call, __get and __set methods. These methods will only be
  30369.    triggered when your object or inherited object doesn't contain the 
  30370.    member or method you're trying to access.
  30371.   </P
  30372. ><DIV
  30373. CLASS="sect2"
  30374. ><HR><H3
  30375. CLASS="sect2"
  30376. ><A
  30377. NAME="language.oop5.overloading.members"
  30378. >Member overloading</A
  30379. ></H3
  30380. >void <B
  30381. CLASS="methodname"
  30382. >__set</B
  30383. > ( string name, mixed value)<BR
  30384. ></BR
  30385. >void <B
  30386. CLASS="methodname"
  30387. >__get</B
  30388. > ( mixed name)<BR
  30389. ></BR
  30390. ><P
  30391. >     Class members can be overloaded to run custom code defined in your class
  30392.     by defining these specially named methods. The <VAR
  30393. CLASS="varname"
  30394. >$name</VAR
  30395.     parameter used is the name of the variable that should be set or retrieved.
  30396.     The __set() method's <VAR
  30397. CLASS="varname"
  30398. >$value</VAR
  30399. > parameter specifies the 
  30400.     value that the object should set set the <VAR
  30401. CLASS="varname"
  30402. >$name</VAR
  30403. >.
  30404.    </P
  30405. ><TABLE
  30406. WIDTH="100%"
  30407. BORDER="0"
  30408. CELLPADDING="0"
  30409. CELLSPACING="0"
  30410. CLASS="EXAMPLE"
  30411. ><TR
  30412. ><TD
  30413. ><DIV
  30414. CLASS="example"
  30415. ><A
  30416. NAME="AEN5255"
  30417. ></A
  30418. ><P
  30419. ><B
  30420. >Beispiel 18-12. overloading with __get and __set example</B
  30421. ></P
  30422. ><TABLE
  30423. BORDER="0"
  30424. BGCOLOR="#E0E0E0"
  30425. CELLPADDING="5"
  30426. ><TR
  30427. ><TD
  30428. ><PRE
  30429. CLASS="php"
  30430. ><?php
  30431. class Setter {
  30432.   public $n;
  30433.   private $x = array("a" => 1, "b" => 2, "c" => 3);
  30434.  
  30435.   function __get($nm) {
  30436.     print "Getting [$nm]\n";
  30437.  
  30438.     if (isset($this->x[$nm])) {
  30439.       $r = $this->x[$nm];
  30440.       print "Returning: $r\n";
  30441.       return $r;
  30442.     } else {
  30443.       print "Nothing!\n";
  30444.     }
  30445.   }
  30446.  
  30447.   function __set($nm, $val) {
  30448.     print "Setting [$nm] to $val\n";
  30449.  
  30450.     if (isset($this->x[$nm])) {
  30451.       $this->x[$nm] = $val;
  30452.       print "OK!\n";
  30453.     } else {
  30454.       print "Not OK!\n";
  30455.     }
  30456.   }
  30457. }
  30458.  
  30459. $foo = new Setter();
  30460. $foo->n = 1;
  30461. $foo->a = 100;
  30462. $foo->a++;
  30463. $foo->z++;
  30464. var_dump($foo);
  30465. ?></PRE
  30466. ></TD
  30467. ></TR
  30468. ></TABLE
  30469. ><P
  30470. >      Will output:
  30471.     </P
  30472. ><TABLE
  30473. BORDER="0"
  30474. BGCOLOR="#E0E0E0"
  30475. CELLPADDING="5"
  30476. ><TR
  30477. ><TD
  30478. ><PRE
  30479. CLASS="php"
  30480. >Setting [a] to 100
  30481. OK!
  30482. Getting [a]
  30483. Returning: 100
  30484. Setting [a] to 101
  30485. OK!
  30486. Getting [z]
  30487. Nothing!
  30488. Setting [z] to 1
  30489. Not OK!
  30490. object(Setter)#1 (2) {
  30491.   ["n"]=>
  30492.   int(1)
  30493.   ["x:private"]=>
  30494.   array(3) {
  30495.     ["a"]=>
  30496.     int(101)
  30497.     ["b"]=>
  30498.     int(2)
  30499.     ["c"]=>
  30500.     int(3)
  30501.   }
  30502. }</PRE
  30503. ></TD
  30504. ></TR
  30505. ></TABLE
  30506. ></DIV
  30507. ></TD
  30508. ></TR
  30509. ></TABLE
  30510. ></DIV
  30511. ><DIV
  30512. CLASS="sect2"
  30513. ><HR><H3
  30514. CLASS="sect2"
  30515. ><A
  30516. NAME="language.oop5.overloading.methods"
  30517. >Method overloading</A
  30518. ></H3
  30519. >mixed <B
  30520. CLASS="methodname"
  30521. >__call</B
  30522. > ( string name, array arguments)<BR
  30523. ></BR
  30524. ><P
  30525. >     Class methods can be overloaded to run custom code defined in your class
  30526.     by defining this specially named method. The <VAR
  30527. CLASS="varname"
  30528. >$name</VAR
  30529.     parameter used is the name as the function name that was requested 
  30530.     to be used. The arguments that were passed in the function will be 
  30531.     defined as an array in the <VAR
  30532. CLASS="varname"
  30533. >$arguments</VAR
  30534. > parameter.
  30535.     The value returned from the __call() method will be returned to the
  30536.     caller of the method.
  30537.    </P
  30538. ><TABLE
  30539. WIDTH="100%"
  30540. BORDER="0"
  30541. CELLPADDING="0"
  30542. CELLSPACING="0"
  30543. CLASS="EXAMPLE"
  30544. ><TR
  30545. ><TD
  30546. ><DIV
  30547. CLASS="example"
  30548. ><A
  30549. NAME="AEN5274"
  30550. ></A
  30551. ><P
  30552. ><B
  30553. >Beispiel 18-13. overloading with __call example</B
  30554. ></P
  30555. ><TABLE
  30556. BORDER="0"
  30557. BGCOLOR="#E0E0E0"
  30558. CELLPADDING="5"
  30559. ><TR
  30560. ><TD
  30561. ><PRE
  30562. CLASS="php"
  30563. ><?php
  30564. class Caller {
  30565.   private $x = array(1, 2, 3);
  30566.  
  30567.   function __call($m, $a) {
  30568.     print "Method $m called:\n";
  30569.     var_dump($a);
  30570.     return $this->x;
  30571.   }
  30572. }
  30573.  
  30574. $foo = new Caller();
  30575. $a = $foo->test(1, "2", 3.4, true);
  30576. var_dump($a);
  30577. ?></PRE
  30578. ></TD
  30579. ></TR
  30580. ></TABLE
  30581. ><P
  30582. >      Will Output:
  30583.     </P
  30584. ><TABLE
  30585. BORDER="0"
  30586. BGCOLOR="#E0E0E0"
  30587. CELLPADDING="5"
  30588. ><TR
  30589. ><TD
  30590. ><PRE
  30591. CLASS="php"
  30592. >Method test called:
  30593. array(4) {
  30594.   [0]=>
  30595.   int(1)
  30596.   [1]=>
  30597.   string(1) "2"
  30598.   [2]=>
  30599.   float(3.4)
  30600.   [3]=>
  30601.   bool(true)
  30602. }
  30603. array(3) {
  30604.   [0]=>
  30605.   int(1)
  30606.   [1]=>
  30607.   int(2)
  30608.   [2]=>
  30609.   int(3)
  30610. }</PRE
  30611. ></TD
  30612. ></TR
  30613. ></TABLE
  30614. ></DIV
  30615. ></TD
  30616. ></TR
  30617. ></TABLE
  30618. ></DIV
  30619. ></DIV
  30620. ><DIV
  30621. CLASS="sect1"
  30622. ><HR><H2
  30623. CLASS="sect1"
  30624. ><A
  30625. NAME="language.oop5.iterations"
  30626. >Object Iteration</A
  30627. ></H2
  30628. ><P
  30629. >    PHP 5 provides a way for objects to be defined so it is possible
  30630.    to iterate through a list of items, with, for example a <A
  30631. HREF="#control-structures.foreach"
  30632. >Abschnitt namens <I
  30633. ><VAR
  30634. CLASS="literal"
  30635. >foreach</VAR
  30636. ></I
  30637. > in Kapitel 15</A
  30638. > statement. By default, all
  30639.    public properties will be used for the iteration.
  30640.   </P
  30641. ><TABLE
  30642. WIDTH="100%"
  30643. BORDER="0"
  30644. CELLPADDING="0"
  30645. CELLSPACING="0"
  30646. CLASS="EXAMPLE"
  30647. ><TR
  30648. ><TD
  30649. ><DIV
  30650. CLASS="example"
  30651. ><A
  30652. NAME="AEN5283"
  30653. ></A
  30654. ><P
  30655. ><B
  30656. >Beispiel 18-14. Simple Object Iteration</B
  30657. ></P
  30658. ><TABLE
  30659. BORDER="0"
  30660. BGCOLOR="#E0E0E0"
  30661. CELLPADDING="5"
  30662. ><TR
  30663. ><TD
  30664. ><PRE
  30665. CLASS="php"
  30666. ><?php
  30667.  
  30668. class MyClass {
  30669.   public $var1 = 'value 1';
  30670.   public $var2 = 'value 2';
  30671.   public $var3 = 'value 3';
  30672.  
  30673.   protected $protected = 'protected';
  30674.   private   $private   = 'private';
  30675.  
  30676. }
  30677.  
  30678. $class = new MyClass();
  30679.  
  30680. foreach($class as $key => $value) {
  30681.   print "$key => $value\n";
  30682. }</PRE
  30683. ></TD
  30684. ></TR
  30685. ></TABLE
  30686. ><P
  30687. >      Will output:
  30688.    </P
  30689. ><TABLE
  30690. BORDER="0"
  30691. BGCOLOR="#E0E0E0"
  30692. CELLPADDING="5"
  30693. ><TR
  30694. ><TD
  30695. ><PRE
  30696. CLASS="php"
  30697. >var1 => value 1
  30698. var2 => value 2
  30699. var3 => value 3</PRE
  30700. ></TD
  30701. ></TR
  30702. ></TABLE
  30703. ></DIV
  30704. ></TD
  30705. ></TR
  30706. ></TABLE
  30707. ><P
  30708. >   As the output shows, the <A
  30709. HREF="#control-structures.foreach"
  30710. >Abschnitt namens <I
  30711. ><VAR
  30712. CLASS="literal"
  30713. >foreach</VAR
  30714. ></I
  30715. > in Kapitel 15</A
  30716. >
  30717.   iterated through each public variable that is defined. To take it 
  30718.   a step further you can <VAR
  30719. CLASS="varname"
  30720. >implement</VAR
  30721. > one of PHP 5's 
  30722.   internal <A
  30723. HREF="#language.oop5.interfaces"
  30724. >Abschnitt namens <I
  30725. >Object Interfaces</I
  30726. ></A
  30727. > named
  30728.   <VAR
  30729. CLASS="varname"
  30730. >Iterator</VAR
  30731. >. This allows the object to decide what
  30732.   and how the object will be iterated.
  30733.  </P
  30734. ><TABLE
  30735. WIDTH="100%"
  30736. BORDER="0"
  30737. CELLPADDING="0"
  30738. CELLSPACING="0"
  30739. CLASS="EXAMPLE"
  30740. ><TR
  30741. ><TD
  30742. ><DIV
  30743. CLASS="example"
  30744. ><A
  30745. NAME="AEN5293"
  30746. ></A
  30747. ><P
  30748. ><B
  30749. >Beispiel 18-15. Object Iteration implenting Iterator</B
  30750. ></P
  30751. ><TABLE
  30752. BORDER="0"
  30753. BGCOLOR="#E0E0E0"
  30754. CELLPADDING="5"
  30755. ><TR
  30756. ><TD
  30757. ><PRE
  30758. CLASS="php"
  30759. ><?php
  30760. class MyIterator implements Iterator {
  30761.  
  30762.   private $var = array();
  30763.  
  30764.   public function __construct($array) {
  30765.     if (is_array($array) ) {
  30766.       $this->var = $array;
  30767.     }
  30768.   }
  30769.  
  30770.   public function rewind() {
  30771.     echo "rewinding\n";
  30772.     reset($this->var);
  30773.   }
  30774.  
  30775.   public function current() {
  30776.     $var = current($this->var);
  30777.     echo "current: $var\n";
  30778.     return $var;
  30779.   }
  30780.  
  30781.   public function key() {
  30782.     $var = key($this->var);
  30783.     echo "key: $var\n";
  30784.     return $var;
  30785.   }
  30786.  
  30787.   public function next() {
  30788.     $var = next($this->var);
  30789.     echo "next: $var\n";
  30790.     return $var;
  30791.   }
  30792.  
  30793.   public function valid() {
  30794.     $var = $this->current() !== false;
  30795.     echo "valid: {$var}\n";
  30796.     return $var;
  30797.   }
  30798.  
  30799. }
  30800.  
  30801. $values = array(1,2,3);
  30802. $it = new MyIterator($values);
  30803.  
  30804. foreach ($it as $a => $b) {
  30805.   print "$a: $b\n";
  30806. }</PRE
  30807. ></TD
  30808. ></TR
  30809. ></TABLE
  30810. ><P
  30811. >      Will output:
  30812.    </P
  30813. ><TABLE
  30814. BORDER="0"
  30815. BGCOLOR="#E0E0E0"
  30816. CELLPADDING="5"
  30817. ><TR
  30818. ><TD
  30819. ><PRE
  30820. CLASS="php"
  30821. >rewinding
  30822. current: 1
  30823. valid: 1
  30824. current: 1
  30825. key: 0
  30826. 0: 1
  30827. next: 2
  30828. current: 2
  30829. valid: 1
  30830. current: 2
  30831. key: 1
  30832. 1: 2
  30833. next: 3
  30834. current: 3
  30835. valid: 1
  30836. current: 3
  30837. key: 2
  30838. 2: 3
  30839. next:
  30840. current:
  30841. valid:</PRE
  30842. ></TD
  30843. ></TR
  30844. ></TABLE
  30845. ></DIV
  30846. ></TD
  30847. ></TR
  30848. ></TABLE
  30849. ><P
  30850. >    You can also define your class so that it doesn't have to define
  30851.    all the <VAR
  30852. CLASS="varname"
  30853. >Iterator</VAR
  30854. > functions by simply implementing
  30855.    the PHP 5 <VAR
  30856. CLASS="varname"
  30857. >IteratorAggregate</VAR
  30858. > interface.
  30859.   </P
  30860. ><TABLE
  30861. WIDTH="100%"
  30862. BORDER="0"
  30863. CELLPADDING="0"
  30864. CELLSPACING="0"
  30865. CLASS="EXAMPLE"
  30866. ><TR
  30867. ><TD
  30868. ><DIV
  30869. CLASS="example"
  30870. ><A
  30871. NAME="AEN5301"
  30872. ></A
  30873. ><P
  30874. ><B
  30875. >Beispiel 18-16. Object Iteration implenting IteratorAggregate</B
  30876. ></P
  30877. ><TABLE
  30878. BORDER="0"
  30879. BGCOLOR="#E0E0E0"
  30880. CELLPADDING="5"
  30881. ><TR
  30882. ><TD
  30883. ><PRE
  30884. CLASS="php"
  30885. ><?php
  30886. class MyCollection implements IteratorAggregate {
  30887.   private $items = array();
  30888.   private $count = 0;
  30889.  
  30890.   /* Required definition of interface IteratorAggregate */
  30891.   public function getIterator() {
  30892.     return new MyIterator($this->items);
  30893.   }
  30894.  
  30895.   public function add($value) {
  30896.     $this->items[$this->count++] = $value;
  30897.   }
  30898.  
  30899. }
  30900.  
  30901. $coll = new MyCollection();
  30902. $coll->add('value 1');
  30903. $coll->add('value 2');
  30904. $coll->add('value 3');
  30905.  
  30906. foreach ($coll as $key => $val) {
  30907.   echo "key/value: [$key -> $val]\n\n";
  30908. }
  30909.  
  30910. ?>
  30911. </pre></PRE
  30912. ></TD
  30913. ></TR
  30914. ></TABLE
  30915. ><P
  30916. >      Will output:
  30917.    </P
  30918. ><TABLE
  30919. BORDER="0"
  30920. BGCOLOR="#E0E0E0"
  30921. CELLPADDING="5"
  30922. ><TR
  30923. ><TD
  30924. ><PRE
  30925. CLASS="php"
  30926. >rewinding
  30927. current: value 1
  30928. valid: 1
  30929. current: value 1
  30930. key: 0
  30931. key/value: [0 -> value 1]
  30932.  
  30933. next: value 2
  30934. current: value 2
  30935. valid: 1
  30936. current: value 2
  30937. key: 1
  30938. key/value: [1 -> value 2]
  30939.  
  30940. next: value 3
  30941. current: value 3
  30942. valid: 1
  30943. current: value 3
  30944. key: 2
  30945. key/value: [2 -> value 3]
  30946.  
  30947. next:
  30948. current:
  30949. valid:</PRE
  30950. ></TD
  30951. ></TR
  30952. ></TABLE
  30953. ></DIV
  30954. ></TD
  30955. ></TR
  30956. ></TABLE
  30957. ></DIV
  30958. ><DIV
  30959. CLASS="sect1"
  30960. ><HR><H2
  30961. CLASS="sect1"
  30962. ><A
  30963. NAME="language.oop5.magic"
  30964. >Magic Methods</A
  30965. ></H2
  30966. ><P
  30967. >    .
  30968.   </P
  30969. ></DIV
  30970. ><DIV
  30971. CLASS="sect1"
  30972. ><HR><H2
  30973. CLASS="sect1"
  30974. ><A
  30975. NAME="language.oop5.final"
  30976. >Final Keyword</A
  30977. ></H2
  30978. ><P
  30979. >    PHP 5 introduces the final keyword, which prevents child classes from
  30980.    overriding a method or variable by prefixing the definition with final.
  30981.   </P
  30982. ><TABLE
  30983. WIDTH="100%"
  30984. BORDER="0"
  30985. CELLPADDING="0"
  30986. CELLSPACING="0"
  30987. CLASS="EXAMPLE"
  30988. ><TR
  30989. ><TD
  30990. ><DIV
  30991. CLASS="example"
  30992. ><A
  30993. NAME="AEN5312"
  30994. ></A
  30995. ><P
  30996. ><B
  30997. >Beispiel 18-17. Final methods example</B
  30998. ></P
  30999. ><TABLE
  31000. BORDER="0"
  31001. BGCOLOR="#E0E0E0"
  31002. CELLPADDING="5"
  31003. ><TR
  31004. ><TD
  31005. ><PRE
  31006. CLASS="php"
  31007. ><?php
  31008. class BaseClass {
  31009.    public function test() {
  31010.        echo "BaseClass::test() called\n";
  31011.    }
  31012.    
  31013.    final public function moreTesting() {
  31014.        echo "BaseClass::moreTesting() called\n";
  31015.    }
  31016. }
  31017.  
  31018. class ChildClass extends BaseClass {
  31019.    public function moreTesting() {
  31020.        echo "ChildClass::moreTesting() called\n";
  31021.    }
  31022. }
  31023. // Results in Fatal error: Cannot override final method BaseClass::moreTesting()
  31024. ?></PRE
  31025. ></TD
  31026. ></TR
  31027. ></TABLE
  31028. ></DIV
  31029. ></TD
  31030. ></TR
  31031. ></TABLE
  31032. ></DIV
  31033. ><DIV
  31034. CLASS="sect1"
  31035. ><HR><H2
  31036. CLASS="sect1"
  31037. ><A
  31038. NAME="language.oop5.cloning"
  31039. >Object cloning</A
  31040. ></H2
  31041. ><P
  31042. >    Creating a copy of an object with fully replicated properties is not
  31043.    always the wanted behavior. A good example of the need for copy
  31044.    constructors, is if you have an object which represents a GTK window and the
  31045.    object holds the resource of this GTK window, when you create a duplicate
  31046.    you might want to create a new window with the same properties and have the
  31047.    new object hold the resource of the new window. Another example is if your
  31048.    object holds a reference to another object which it uses and when you
  31049.    replicate the parent object you want to create a new instance of this other
  31050.    object so that the replica has its own separate copy.
  31051.   </P
  31052. ><P
  31053. >    An object copy is created by using the clone keyword (which calls the
  31054.    object's __clone() method if possible). An object's __clone()  method
  31055.    cannot be called directly.
  31056.   </P
  31057. ><DIV
  31058. CLASS="informalexample"
  31059. ><P
  31060. ></P
  31061. ><A
  31062. NAME="AEN5319"
  31063. ></A
  31064. ><TABLE
  31065. BORDER="0"
  31066. BGCOLOR="#E0E0E0"
  31067. CELLPADDING="5"
  31068. ><TR
  31069. ><TD
  31070. ><PRE
  31071. CLASS="programlisting"
  31072. >$copy_of_object = clone $object;</PRE
  31073. ></TD
  31074. ></TR
  31075. ></TABLE
  31076. ><P
  31077. ></P
  31078. ></DIV
  31079. ><P
  31080. >
  31081.    When an object is cloned, PHP 5 will perform a shallow copy of all of the
  31082.    object's properties. Any properties that are references to other variables,
  31083.    will remain references. If a __clone() method is defined, then the newly
  31084.    created  object's __clone() method will be called, to allow any necessary
  31085.    properties that need to be changed.
  31086.  
  31087.   </P
  31088. ><TABLE
  31089. WIDTH="100%"
  31090. BORDER="0"
  31091. CELLPADDING="0"
  31092. CELLSPACING="0"
  31093. CLASS="EXAMPLE"
  31094. ><TR
  31095. ><TD
  31096. ><DIV
  31097. CLASS="example"
  31098. ><A
  31099. NAME="AEN5322"
  31100. ></A
  31101. ><P
  31102. ><B
  31103. >Beispiel 18-18. Cloning an object</B
  31104. ></P
  31105. ><TABLE
  31106. BORDER="0"
  31107. BGCOLOR="#E0E0E0"
  31108. CELLPADDING="5"
  31109. ><TR
  31110. ><TD
  31111. ><PRE
  31112. CLASS="php"
  31113. ><?php
  31114.  
  31115. class SubObject {
  31116.   static $instances = 0;
  31117.   public $instance;
  31118.  
  31119.   public function __construct() {
  31120.     $this->instance = ++self::$instances;
  31121.   }
  31122.  
  31123.   public function __clone() {
  31124.     $this->instance = ++self::$instances;
  31125.   }
  31126. }
  31127.  
  31128. class MyCloneable {
  31129.  
  31130.   public $object1;
  31131.   public $object2;
  31132.  
  31133.   function __clone() {
  31134.     
  31135.     // Force a copy of this->object, otherwise
  31136.     // it will point to same object.
  31137.     $this->object1 = clone($this->object1);
  31138.   }
  31139. }
  31140.  
  31141. $obj = new MyCloneable();
  31142.  
  31143. $obj->object1 = new SubObject();
  31144. $obj->object2 = new SubObject();
  31145.  
  31146. $obj2 = clone $obj;
  31147.  
  31148.  
  31149. print("Original Object:\n");
  31150. print_r($obj);
  31151.  
  31152. print("Cloned Object:\n");
  31153. print_r($obj2);
  31154.  
  31155. ?></PRE
  31156. ></TD
  31157. ></TR
  31158. ></TABLE
  31159. ><P
  31160. >The above example will output:</P
  31161. ><TABLE
  31162. BORDER="0"
  31163. BGCOLOR="#E0E0E0"
  31164. CELLPADDING="5"
  31165. ><TR
  31166. ><TD
  31167. ><PRE
  31168. CLASS="php"
  31169. >Original Object:
  31170. MyCloneable Object
  31171. (
  31172.     [object1] => SubObject Object
  31173.         (
  31174.             [instance] => 1
  31175.         )
  31176.  
  31177.     [object2] => SubObject Object
  31178.         (
  31179.             [instance] => 2
  31180.         )
  31181.  
  31182. )
  31183. Cloned Object:
  31184. MyCloneable Object
  31185. (
  31186.     [object1] => SubObject Object
  31187.         (
  31188.             [instance] => 3
  31189.         )
  31190.  
  31191.     [object2] => SubObject Object
  31192.         (
  31193.             [instance] => 2
  31194.         )
  31195.  
  31196. )</PRE
  31197. ></TD
  31198. ></TR
  31199. ></TABLE
  31200. ></DIV
  31201. ></TD
  31202. ></TR
  31203. ></TABLE
  31204. ></DIV
  31205. ><DIV
  31206. CLASS="sect1"
  31207. ><HR><H2
  31208. CLASS="sect1"
  31209. ><A
  31210. NAME="language.oop5.object-comparison"
  31211. >Comparing objects</A
  31212. ></H2
  31213. ><P
  31214. >     In PHP 5, object comparison is more complicated than in PHP 4 and more
  31215.     in accordance to what one will expect from an Object Oriented Language
  31216.     (not that PHP 5 is such a language).
  31217.    </P
  31218. ><P
  31219. >     When using the comparison operator (<VAR
  31220. CLASS="literal"
  31221. >==</VAR
  31222. >), 
  31223.     object variables are compared in a simple manner, namely: Two object
  31224.     instances are equal if they have the same attributes and values, and are
  31225.     instances of the same class.
  31226.    </P
  31227. ><P
  31228. >     On the other hand, when using the identity operator (<VAR
  31229. CLASS="literal"
  31230. >===</VAR
  31231. >),
  31232.     object variables are identical if and only if they refer to the same
  31233.     instance of the same class.
  31234.    </P
  31235. ><P
  31236. >     An example will clarify these rules.
  31237.     <TABLE
  31238. WIDTH="100%"
  31239. BORDER="0"
  31240. CELLPADDING="0"
  31241. CELLSPACING="0"
  31242. CLASS="EXAMPLE"
  31243. ><TR
  31244. ><TD
  31245. ><DIV
  31246. CLASS="example"
  31247. ><A
  31248. NAME="AEN5335"
  31249. ></A
  31250. ><P
  31251. ><B
  31252. >Beispiel 18-19. Example of object comparison in PHP 5</B
  31253. ></P
  31254. ><TABLE
  31255. BORDER="0"
  31256. BGCOLOR="#E0E0E0"
  31257. CELLPADDING="5"
  31258. ><TR
  31259. ><TD
  31260. ><PRE
  31261. CLASS="php"
  31262. ><?php
  31263. function bool2str($bool) {
  31264.     if ($bool === false) {
  31265.             return 'FALSE';
  31266.     } else {
  31267.             return 'TRUE';
  31268.     }
  31269. }
  31270.  
  31271. function compareObjects(&$o1, &$o2) {
  31272.     echo 'o1 == o2 : '.bool2str($o1 == $o2)."\n";
  31273.     echo 'o1 != o2 : '.bool2str($o1 != $o2)."\n";
  31274.     echo 'o1 === o2 : '.bool2str($o1 === $o2)."\n";
  31275.     echo 'o1 !== o2 : '.bool2str($o1 !== $o2)."\n";
  31276. }
  31277.  
  31278. class Flag {
  31279.     var $flag;
  31280.  
  31281.     function Flag($flag=true) {
  31282.             $this->flag = $flag;
  31283.     }
  31284. }
  31285.  
  31286. class OtherFlag {
  31287.     var $flag;
  31288.  
  31289.     function OtherFlag($flag=true) {
  31290.             $this->flag = $flag;
  31291.     }
  31292. }
  31293.  
  31294. $o = new Flag();
  31295. $p = new Flag();
  31296. $q = $o;
  31297. $r = new OtherFlag();
  31298.  
  31299. echo "Two instances of the same class\n";
  31300. compareObjects($o, $p);
  31301.  
  31302. echo "\nTwo references to the same instance\n";
  31303. compareObjects($o, $q);
  31304.  
  31305. echo "\nInstances of two different classes\n";
  31306. compareObjects($o, $r);
  31307. ?></PRE
  31308. ></TD
  31309. ></TR
  31310. ></TABLE
  31311. ></DIV
  31312. ></TD
  31313. ></TR
  31314. ></TABLE
  31315. >
  31316.     This example will output:
  31317.     <TABLE
  31318. BORDER="0"
  31319. BGCOLOR="#E0E0E0"
  31320. CELLPADDING="5"
  31321. ><TR
  31322. ><TD
  31323. ><PRE
  31324. CLASS="screen"
  31325. >Two instances of the same class
  31326. o1 == o2 : TRUE
  31327. o1 != o2 : FALSE
  31328. o1 === o2 : FALSE
  31329. o1 !== o2 : TRUE
  31330.  
  31331. Two references to the same instance
  31332. o1 == o2 : TRUE
  31333. o1 != o2 : FALSE
  31334. o1 === o2 : TRUE
  31335. o1 !== o2 : FALSE
  31336.  
  31337. Instances of two different classes
  31338. o1 == o2 : FALSE
  31339. o1 != o2 : TRUE
  31340. o1 === o2 : FALSE
  31341. o1 !== o2 : TRUE</PRE
  31342. ></TD
  31343. ></TR
  31344. ></TABLE
  31345. >
  31346.    </P
  31347. ></DIV
  31348. ><DIV
  31349. CLASS="sect1"
  31350. ><HR><H2
  31351. CLASS="sect1"
  31352. ><A
  31353. NAME="language.oop5.reflection"
  31354. >Reflection</A
  31355. ></H2
  31356. ><DIV
  31357. CLASS="sect2"
  31358. ><H3
  31359. CLASS="sect2"
  31360. ><A
  31361. NAME="language.oop5.reflection.introduction"
  31362. >Introduction</A
  31363. ></H3
  31364. ><P
  31365. >     PHP 5 comes with a complete reflection API that adds the ability to
  31366.     reverse-engineer classes, interfaces, functions and methods as well
  31367.     as extensions. Additionally, the reflection API also offers ways of 
  31368.     retrieving doc comments for functions, classes and methods.
  31369.    </P
  31370. ><P
  31371. >     The reflection API is an object-oriented extension to the Zend Engine,
  31372.     consisting of the following classes:
  31373.    </P
  31374. ><DIV
  31375. CLASS="informalexample"
  31376. ><P
  31377. ></P
  31378. ><A
  31379. NAME="AEN5345"
  31380. ></A
  31381. ><TABLE
  31382. BORDER="0"
  31383. BGCOLOR="#E0E0E0"
  31384. CELLPADDING="5"
  31385. ><TR
  31386. ><TD
  31387. ><PRE
  31388. CLASS="php"
  31389. ><?php
  31390.   class Reflection { }
  31391.   interface Reflector { }
  31392.   class ReflectionException extends Exception { }
  31393.   class ReflectionFunction implements Reflector { }
  31394.   class ReflectionParameter implements Reflector { }
  31395.   class ReflectionMethod extends ReflectionFunction { }
  31396.   class ReflectionClass implements Reflector { }
  31397.   class ReflectionObject extends ReflectionClass { }
  31398.   class ReflectionProperty implements Reflector { }
  31399.   class ReflectionExtension implements Reflector { }
  31400. ?></PRE
  31401. ></TD
  31402. ></TR
  31403. ></TABLE
  31404. ><P
  31405. ></P
  31406. ></DIV
  31407. ><DIV
  31408. CLASS="note"
  31409. ><BLOCKQUOTE
  31410. CLASS="note"
  31411. ><P
  31412. ><B
  31413. >Anmerkung: </B
  31414. >
  31415.      For details on these classes, have a look at the next chapters.
  31416.     </P
  31417. ></BLOCKQUOTE
  31418. ></DIV
  31419. ><P
  31420. >     If we were to execute the code in the example below:
  31421.     <TABLE
  31422. WIDTH="100%"
  31423. BORDER="0"
  31424. CELLPADDING="0"
  31425. CELLSPACING="0"
  31426. CLASS="EXAMPLE"
  31427. ><TR
  31428. ><TD
  31429. ><DIV
  31430. CLASS="example"
  31431. ><A
  31432. NAME="AEN5350"
  31433. ></A
  31434. ><P
  31435. ><B
  31436. >Beispiel 18-20. Basic usage of the reflection API</B
  31437. ></P
  31438. ><TABLE
  31439. BORDER="0"
  31440. BGCOLOR="#E0E0E0"
  31441. CELLPADDING="5"
  31442. ><TR
  31443. ><TD
  31444. ><PRE
  31445. CLASS="php"
  31446. ><?php
  31447.   Reflection::export(new ReflectionClass('Exception'));
  31448. ?></PRE
  31449. ></TD
  31450. ></TR
  31451. ></TABLE
  31452. ></DIV
  31453. ></TD
  31454. ></TR
  31455. ></TABLE
  31456. >
  31457.     We will see:
  31458.     <TABLE
  31459. BORDER="0"
  31460. BGCOLOR="#E0E0E0"
  31461. CELLPADDING="5"
  31462. ><TR
  31463. ><TD
  31464. ><PRE
  31465. CLASS="screen"
  31466. >Class [ <internal> class Exception ] {
  31467.  
  31468.   - Constants [0] {
  31469.   }
  31470.  
  31471.   - Static properties [0] {
  31472.   }
  31473.  
  31474.   - Static methods [0] {
  31475.   }
  31476.  
  31477.   - Properties [6] {
  31478.     Property [ <default> protected $message ]
  31479.     Property [ <default> private $string ]
  31480.     Property [ <default> protected $code ]
  31481.     Property [ <default> protected $file ]
  31482.     Property [ <default> protected $line ]
  31483.     Property [ <default> private $trace ]
  31484.   }
  31485.  
  31486.   - Methods [9] {
  31487.     Method [ <internal> final private method __clone ] {
  31488.     }
  31489.  
  31490.     Method [ <internal> <ctor> method __construct ] {
  31491.     }
  31492.  
  31493.     Method [ <internal> final public method getMessage ] {
  31494.     }
  31495.  
  31496.     Method [ <internal> final public method getCode ] {
  31497.     }
  31498.  
  31499.     Method [ <internal> final public method getFile ] {
  31500.     }
  31501.  
  31502.     Method [ <internal> final public method getLine ] {
  31503.     }
  31504.  
  31505.     Method [ <internal> final public method getTrace ] {
  31506.     }
  31507.  
  31508.     Method [ <internal> final public method getTraceAsString ] {
  31509.     }
  31510.  
  31511.     Method [ <internal> public method __toString ] {
  31512.     }
  31513.   }
  31514. }</PRE
  31515. ></TD
  31516. ></TR
  31517. ></TABLE
  31518. >
  31519.    </P
  31520. ></DIV
  31521. ><DIV
  31522. CLASS="sect2"
  31523. ><HR><H3
  31524. CLASS="sect2"
  31525. ><A
  31526. NAME="language.oop5.reflection.reflectionfunction"
  31527. ><B
  31528. CLASS="classname"
  31529. >ReflectionFunction</B
  31530. ></A
  31531. ></H3
  31532. ><P
  31533. >     The <B
  31534. CLASS="classname"
  31535. >ReflectionFunction</B
  31536. > class lets you
  31537.     reverse-engineer functions.
  31538.    </P
  31539. ><DIV
  31540. CLASS="informalexample"
  31541. ><P
  31542. ></P
  31543. ><A
  31544. NAME="AEN5359"
  31545. ></A
  31546. ><TABLE
  31547. BORDER="0"
  31548. BGCOLOR="#E0E0E0"
  31549. CELLPADDING="5"
  31550. ><TR
  31551. ><TD
  31552. ><PRE
  31553. CLASS="php"
  31554. ><?php
  31555.   class ReflectionFunction implements Reflector {
  31556.       public object __construct(string name)
  31557.       public string __toString()
  31558.       public static string export()
  31559.       public string getName()
  31560.       public bool isInternal()
  31561.       public bool isUserDefined()
  31562.       public string getFileName()
  31563.       public int getStartLine()
  31564.       public int getEndLine()
  31565.       public string getDocComment()
  31566.       public array getStaticVariables()
  31567.       public mixed invoke(mixed* args)
  31568.       public bool returnsReference()
  31569.       public ReflectionParameter[] getParameters()
  31570.   }
  31571. ?></PRE
  31572. ></TD
  31573. ></TR
  31574. ></TABLE
  31575. ><P
  31576. ></P
  31577. ></DIV
  31578. ><P
  31579. >     To introspect a function, you will first have to create an instance
  31580.     of the <B
  31581. CLASS="classname"
  31582. >ReflectionFunction</B
  31583. > class. You can then call
  31584.     any of the above methods on this instance.
  31585.    </P
  31586. ><TABLE
  31587. WIDTH="100%"
  31588. BORDER="0"
  31589. CELLPADDING="0"
  31590. CELLSPACING="0"
  31591. CLASS="EXAMPLE"
  31592. ><TR
  31593. ><TD
  31594. ><DIV
  31595. CLASS="example"
  31596. ><A
  31597. NAME="AEN5363"
  31598. ></A
  31599. ><P
  31600. ><B
  31601. >Beispiel 18-21. Using the <B
  31602. CLASS="classname"
  31603. >ReflectionFunction</B
  31604. > class</B
  31605. ></P
  31606. ><TABLE
  31607. BORDER="0"
  31608. BGCOLOR="#E0E0E0"
  31609. CELLPADDING="5"
  31610. ><TR
  31611. ><TD
  31612. ><PRE
  31613. CLASS="php"
  31614. ><?php
  31615. /**
  31616.  * A simple counter
  31617.  *
  31618.  * @return    int
  31619.  */
  31620. function counter() 
  31621. {
  31622.     static $c = 0;
  31623.  
  31624.     return $c++;
  31625. }
  31626.  
  31627. // Create an instance of the Reflection_Function class
  31628. $func = new ReflectionFunction('counter');
  31629.  
  31630. // Print out basic information
  31631. printf(
  31632.     "===> The %s function '%s'\n".
  31633.     "     declared in %s\n".
  31634.     "     lines %d to %d\n",
  31635.     $func->isInternal() ? 'internal' : 'user-defined',
  31636.     $func->getName(),
  31637.     $func->getFileName(),
  31638.     $func->getStartLine(),
  31639.     $func->getEndline()
  31640. );
  31641.  
  31642. // Print documentation comment
  31643. printf("---> Documentation:\n %s\n", var_export($func->getDocComment(), 1));
  31644.  
  31645. // Print static variables if existant
  31646. if ($statics = $func->getStaticVariables())
  31647. {
  31648.     printf("---> Static variables: %s\n", var_export($statics, 1));
  31649. }
  31650.  
  31651. // Invoke the function
  31652. printf("---> Invokation results in: ");
  31653. var_dump($func->invoke());
  31654.  
  31655.  
  31656. // you may prefer to use the export() method
  31657. echo "\nReflectionFunction::export() results:\n";
  31658. echo ReflectionFunction::export('counter');
  31659. ?></PRE
  31660. ></TD
  31661. ></TR
  31662. ></TABLE
  31663. ></DIV
  31664. ></TD
  31665. ></TR
  31666. ></TABLE
  31667. ><DIV
  31668. CLASS="note"
  31669. ><BLOCKQUOTE
  31670. CLASS="note"
  31671. ><P
  31672. ><B
  31673. >Anmerkung: </B
  31674. >
  31675.      The method <B
  31676. CLASS="function"
  31677. >invoke()</B
  31678. > accepts a variable number of
  31679.      arguments which are passed to the function just as in
  31680.      <A
  31681. HREF="#function.call-user-func"
  31682. ><B
  31683. CLASS="function"
  31684. >call_user_func()</B
  31685. ></A
  31686. >.
  31687.     </P
  31688. ></BLOCKQUOTE
  31689. ></DIV
  31690. ></DIV
  31691. ><DIV
  31692. CLASS="sect2"
  31693. ><HR><H3
  31694. CLASS="sect2"
  31695. ><A
  31696. NAME="language.oop5.reflection.reflectionparameter"
  31697. ><B
  31698. CLASS="classname"
  31699. >ReflectionParameter</B
  31700. ></A
  31701. ></H3
  31702. ><P
  31703. >     The <B
  31704. CLASS="classname"
  31705. >ReflectionParameter</B
  31706. > class retrieves
  31707.     information about a function's or method's parameters.
  31708.    </P
  31709. ><DIV
  31710. CLASS="informalexample"
  31711. ><P
  31712. ></P
  31713. ><A
  31714. NAME="AEN5376"
  31715. ></A
  31716. ><TABLE
  31717. BORDER="0"
  31718. BGCOLOR="#E0E0E0"
  31719. CELLPADDING="5"
  31720. ><TR
  31721. ><TD
  31722. ><PRE
  31723. CLASS="php"
  31724. ><?php
  31725.   class ReflectionParameter implements Reflector {
  31726.       public object __construct(string name)
  31727.       public string __toString()
  31728.       public static string export()
  31729.       public string getName()
  31730.       public ReflectionClass getClass()
  31731.       public bool allowsNull()
  31732.       public bool isPassedByReference()
  31733.       public bool isOptional()
  31734.   }
  31735. ?></PRE
  31736. ></TD
  31737. ></TR
  31738. ></TABLE
  31739. ><P
  31740. ></P
  31741. ></DIV
  31742. ><DIV
  31743. CLASS="note"
  31744. ><BLOCKQUOTE
  31745. CLASS="note"
  31746. ><P
  31747. ><B
  31748. >Anmerkung: </B
  31749. >
  31750.      <B
  31751. CLASS="function"
  31752. >isOptional()</B
  31753. > was added in PHP 5.1.0.
  31754.     </P
  31755. ></BLOCKQUOTE
  31756. ></DIV
  31757. ><P
  31758. >     To introspect function parameters, you will first have to create an instance
  31759.     of the <B
  31760. CLASS="classname"
  31761. >ReflectionFunction</B
  31762. > or 
  31763.     <B
  31764. CLASS="classname"
  31765. >ReflectionMethod</B
  31766. > classes and then use their 
  31767.     <B
  31768. CLASS="function"
  31769. >getParameters()</B
  31770. > method to retrieve an array of parameters.
  31771.    </P
  31772. ><TABLE
  31773. WIDTH="100%"
  31774. BORDER="0"
  31775. CELLPADDING="0"
  31776. CELLSPACING="0"
  31777. CLASS="EXAMPLE"
  31778. ><TR
  31779. ><TD
  31780. ><DIV
  31781. CLASS="example"
  31782. ><A
  31783. NAME="AEN5385"
  31784. ></A
  31785. ><P
  31786. ><B
  31787. >Beispiel 18-22. Using the <B
  31788. CLASS="classname"
  31789. >ReflectionParameter</B
  31790. > class</B
  31791. ></P
  31792. ><TABLE
  31793. BORDER="0"
  31794. BGCOLOR="#E0E0E0"
  31795. CELLPADDING="5"
  31796. ><TR
  31797. ><TD
  31798. ><PRE
  31799. CLASS="php"
  31800. ><?php
  31801.     function foo($a, $b, $c) { }
  31802.     function bar(Exception $a, &$b, $c) { }
  31803.     function baz(ReflectionFunction $a, $b = 1, $c = null) { }
  31804.     function abc() { }
  31805.  
  31806.     // Create an instance of Reflection_Function with the
  31807.     // parameter given from the command line.    
  31808.     $reflect = new ReflectionFunction($argv[1]);
  31809.  
  31810.     echo $reflect;
  31811.  
  31812.     foreach ($reflect->getParameters() as $i => $param) 
  31813.     {
  31814.         printf(
  31815.             "-- Parameter #%d: %s {\n".
  31816.             "   Class: %s\n".
  31817.             "   Allows NULL: %s\n".
  31818.             "   Passed to by reference: %s\n".
  31819.             "   Is optional?: %s\n".
  31820.             "}\n",
  31821.             $i, 
  31822.             $param->getName(),
  31823.             var_export($param->getClass(), 1),
  31824.             var_export($param->allowsNull(), 1),
  31825.             var_export($param->isPassedByReference(), 1),
  31826.             $param->isOptional() ? 'yes' : 'no'
  31827.         );
  31828.     }
  31829. ?></PRE
  31830. ></TD
  31831. ></TR
  31832. ></TABLE
  31833. ></DIV
  31834. ></TD
  31835. ></TR
  31836. ></TABLE
  31837. ></DIV
  31838. ><DIV
  31839. CLASS="sect2"
  31840. ><HR><H3
  31841. CLASS="sect2"
  31842. ><A
  31843. NAME="language.oop5.reflection.reflectionclass"
  31844. ><B
  31845. CLASS="classname"
  31846. >ReflectionClass</B
  31847. ></A
  31848. ></H3
  31849. ><P
  31850. >     The <B
  31851. CLASS="classname"
  31852. >ReflectionClass</B
  31853. > class lets
  31854.     you reverse-engineer classes.
  31855.    </P
  31856. ><DIV
  31857. CLASS="informalexample"
  31858. ><P
  31859. ></P
  31860. ><A
  31861. NAME="AEN5394"
  31862. ></A
  31863. ><TABLE
  31864. BORDER="0"
  31865. BGCOLOR="#E0E0E0"
  31866. CELLPADDING="5"
  31867. ><TR
  31868. ><TD
  31869. ><PRE
  31870. CLASS="php"
  31871. ><?php
  31872.   class ReflectionClass implements Reflector {
  31873.       public __construct(string name)
  31874.       public string __toString()
  31875.       public static string export()
  31876.       public string getName()
  31877.       public bool isInternal()
  31878.       public bool isUserDefined()
  31879.       public string getFileName()
  31880.       public int getStartLine()
  31881.       public int getEndLine()
  31882.       public string getDocComment()
  31883.       public ReflectionMethod getConstructor()
  31884.       public ReflectionMethod getMethod(string name)
  31885.       public ReflectionMethod[] getMethods()
  31886.       public ReflectionProperty getProperty(string name)
  31887.       public ReflectionProperty[] getProperties()
  31888.       public array getConstants()
  31889.       public mixed getConstant(string name)
  31890.       public bool isInstantiable()
  31891.       public bool isInterface()
  31892.       public bool isFinal()
  31893.       public bool isAbstract()
  31894.       public int getModifiers()
  31895.       public bool isInstance(stdclass object)
  31896.       public stdclass newInstance(mixed* args)
  31897.       public ReflectionClass[] getInterfaces()
  31898.       public ReflectionClass getParentClass()
  31899.       public bool isSubclassOf(ReflectionClass class)
  31900.   }
  31901. ?></PRE
  31902. ></TD
  31903. ></TR
  31904. ></TABLE
  31905. ><P
  31906. ></P
  31907. ></DIV
  31908. ><P
  31909. >     To introspect a class, you will first have to create an instance
  31910.     of the <B
  31911. CLASS="classname"
  31912. >ReflectionClass</B
  31913. > class. You can then
  31914.     call any of the above methods on this instance.
  31915.    </P
  31916. ><TABLE
  31917. WIDTH="100%"
  31918. BORDER="0"
  31919. CELLPADDING="0"
  31920. CELLSPACING="0"
  31921. CLASS="EXAMPLE"
  31922. ><TR
  31923. ><TD
  31924. ><DIV
  31925. CLASS="example"
  31926. ><A
  31927. NAME="AEN5398"
  31928. ></A
  31929. ><P
  31930. ><B
  31931. >Beispiel 18-23. Using the <B
  31932. CLASS="classname"
  31933. >ReflectionClass</B
  31934. > class</B
  31935. ></P
  31936. ><TABLE
  31937. BORDER="0"
  31938. BGCOLOR="#E0E0E0"
  31939. CELLPADDING="5"
  31940. ><TR
  31941. ><TD
  31942. ><PRE
  31943. CLASS="php"
  31944. ><?php
  31945.   interface Serializable
  31946.   {
  31947.       // ...
  31948.   }
  31949.  
  31950.   class Object
  31951.   {
  31952.       // ...
  31953.   }
  31954.  
  31955.   /**
  31956.    * A counter class
  31957.    *
  31958.    */
  31959.   class Counter extends Object implements Serializable 
  31960.   {
  31961.       const START = 0;
  31962.       private static $c = Counter::START;
  31963.  
  31964.       /**
  31965.        * Invoke counter
  31966.        *
  31967.        * @access  public
  31968.        * @return  int
  31969.        */
  31970.       public function count()
  31971.       {
  31972.           return self::$c++;
  31973.       }
  31974.   }
  31975.  
  31976.   // Create an instance of the ReflectionClass class
  31977.   $class= new ReflectionClass('Counter');
  31978.  
  31979.   // Print out basic information
  31980.   printf(
  31981.       "===> The %s%s%s %s '%s' [extends %s]\n".
  31982.       "     declared in %s\n".
  31983.       "     lines %d to %d\n".
  31984.       "     having the modifiers %d [%s]\n",
  31985.       $class->isInternal() ? 'internal' : 'user-defined',
  31986.       $class->isAbstract() ? ' abstract' : '',
  31987.       $class->isFinal() ? ' final' : '',
  31988.       $class->isInterface() ? 'interface' : 'class',
  31989.       $class->getName(),
  31990.       var_export($class->getParentClass(), 1),
  31991.       $class->getFileName(),
  31992.       $class->getStartLine(),
  31993.       $class->getEndline(),
  31994.       $class->getModifiers(),
  31995.       implode(' ', Reflection::getModifierNames($class->getModifiers()))
  31996.   );
  31997.  
  31998.   // Print documentation comment
  31999.   printf("---> Documentation:\n %s\n", var_export($class->getDocComment(), 1));
  32000.  
  32001.   // Print which interfaces are implemented by this class
  32002.   printf("---> Implements:\n %s\n", var_export($class->getInterfaces(), 1));
  32003.  
  32004.   // Print class constants
  32005.   printf("---> Constants: %s\n", var_export($class->getConstants(), 1));
  32006.  
  32007.   // Print class properties
  32008.   printf("---> Properties: %s\n", var_export($class->getProperties(), 1));
  32009.  
  32010.   // Print class methods
  32011.   printf("---> Methods: %s\n", var_export($class->getMethods(), 1));
  32012.  
  32013.   // If this class is instantiable, create an instance
  32014.   if ($class->isInstantiable()) 
  32015.   {
  32016.       $counter= $class->newInstance();
  32017.  
  32018.       echo '---> $counter is instance? '; 
  32019.       echo $class->isInstance($counter) ? 'yes' : 'no';
  32020.  
  32021.       echo "\n---> new Object() is instance? ";
  32022.       echo $class->isInstance(new Object()) ? 'yes' : 'no';
  32023.   }
  32024. ?></PRE
  32025. ></TD
  32026. ></TR
  32027. ></TABLE
  32028. ></DIV
  32029. ></TD
  32030. ></TR
  32031. ></TABLE
  32032. ><DIV
  32033. CLASS="note"
  32034. ><BLOCKQUOTE
  32035. CLASS="note"
  32036. ><P
  32037. ><B
  32038. >Anmerkung: </B
  32039. >
  32040.      The method <B
  32041. CLASS="function"
  32042. >newInstance()</B
  32043. > accepts a variable number of
  32044.      arguments which are passed to the function just as in
  32045.      <A
  32046. HREF="#function.call-user-func"
  32047. ><B
  32048. CLASS="function"
  32049. >call_user_func()</B
  32050. ></A
  32051. >.
  32052.     </P
  32053. ></BLOCKQUOTE
  32054. ></DIV
  32055. ><DIV
  32056. CLASS="note"
  32057. ><BLOCKQUOTE
  32058. CLASS="note"
  32059. ><P
  32060. ><B
  32061. >Anmerkung: </B
  32062. >
  32063.      <VAR
  32064. CLASS="literal"
  32065. >$class = new ReflectionClass('Foo'); $class->isInstance($arg)</VAR
  32066. >
  32067.      is equivalent to <VAR
  32068. CLASS="literal"
  32069. >$arg instanceof Foo</VAR
  32070. > or 
  32071.      <VAR
  32072. CLASS="literal"
  32073. >is_a($arg, 'Foo')</VAR
  32074. >.
  32075.     </P
  32076. ></BLOCKQUOTE
  32077. ></DIV
  32078. ></DIV
  32079. ><DIV
  32080. CLASS="sect2"
  32081. ><HR><H3
  32082. CLASS="sect2"
  32083. ><A
  32084. NAME="language.oop5.reflection.reflectionmethod"
  32085. ><B
  32086. CLASS="classname"
  32087. >ReflectionMethod</B
  32088. ></A
  32089. ></H3
  32090. ><P
  32091. >     The <B
  32092. CLASS="classname"
  32093. >ReflectionMethod</B
  32094. > class lets you
  32095.     reverse-engineer class methods.
  32096.    </P
  32097. ><DIV
  32098. CLASS="informalexample"
  32099. ><P
  32100. ></P
  32101. ><A
  32102. NAME="AEN5416"
  32103. ></A
  32104. ><TABLE
  32105. BORDER="0"
  32106. BGCOLOR="#E0E0E0"
  32107. CELLPADDING="5"
  32108. ><TR
  32109. ><TD
  32110. ><PRE
  32111. CLASS="php"
  32112. ><?php
  32113.   class ReflectionMethod extends ReflectionFunction {
  32114.       public __construct(mixed class, string name)
  32115.       public static string export()
  32116.       public mixed invoke(stdclass object, mixed* args)
  32117.       public bool isFinal()
  32118.       public bool isAbstract()
  32119.       public bool isPublic()
  32120.       public bool isPrivate()
  32121.       public bool isProtected()
  32122.       public bool isStatic()
  32123.       public bool isConstructor()
  32124.       public int getModifiers()
  32125.       public ReflectionClass getDeclaringClass()
  32126.  
  32127.       /* Inherited from ReflectionFunction */
  32128.       public string __toString()
  32129.       public string getName()
  32130.       public bool isInternal()
  32131.       public bool isUserDefined()
  32132.       public string getFileName()
  32133.       public int getStartLine()
  32134.       public int getEndLine()
  32135.       public string getDocComment()
  32136.       public array getStaticVariables()
  32137.       public bool returnsReference()
  32138.       public ReflectionParameter[] getParameters()
  32139.   }
  32140. ?></PRE
  32141. ></TD
  32142. ></TR
  32143. ></TABLE
  32144. ><P
  32145. ></P
  32146. ></DIV
  32147. ><P
  32148. >     To introspect a method, you will first have to create an instance
  32149.     of the <B
  32150. CLASS="classname"
  32151. >ReflectionMethod</B
  32152. > class. You can then call
  32153.     any of the above methods on this instance.
  32154.    </P
  32155. ><TABLE
  32156. WIDTH="100%"
  32157. BORDER="0"
  32158. CELLPADDING="0"
  32159. CELLSPACING="0"
  32160. CLASS="EXAMPLE"
  32161. ><TR
  32162. ><TD
  32163. ><DIV
  32164. CLASS="example"
  32165. ><A
  32166. NAME="AEN5420"
  32167. ></A
  32168. ><P
  32169. ><B
  32170. >Beispiel 18-24. Using the <B
  32171. CLASS="classname"
  32172. >ReflectionMethod</B
  32173. > class</B
  32174. ></P
  32175. ><TABLE
  32176. BORDER="0"
  32177. BGCOLOR="#E0E0E0"
  32178. CELLPADDING="5"
  32179. ><TR
  32180. ><TD
  32181. ><PRE
  32182. CLASS="php"
  32183. ><?php
  32184.   class Counter {
  32185.       private static $c = 0;
  32186.  
  32187.       /**
  32188.        * Increment counter
  32189.        *
  32190.        * @final
  32191.        * @static
  32192.        * @access  public
  32193.        * @return  int
  32194.        */
  32195.       final public static function increment()
  32196.       {
  32197.           self::$c++;
  32198.           return self::$c;
  32199.       }
  32200.   }
  32201.  
  32202.   // Create an instance of the Reflection_Method class
  32203.   $method= new ReflectionMethod('Counter', 'increment');
  32204.  
  32205.   // Print out basic information
  32206.   printf(
  32207.     "===> The %s%s%s%s%s%s%s method '%s' (which is %s)\n".
  32208.     "     declared in %s\n".
  32209.     "     lines %d to %d\n".
  32210.     "     having the modifiers %d[%s]\n",
  32211.     $method->isInternal() ? 'internal' : 'user-defined',
  32212.     $method->isAbstract() ? ' abstract' : '',
  32213.     $method->isFinal() ? ' final' : '',
  32214.     $method->isPublic() ? ' public' : '',
  32215.     $method->isPrivate() ? ' private' : '',
  32216.     $method->isProtected() ? ' protected' : '',
  32217.     $method->isStatic() ? ' static' : '',
  32218.     $method->getName(),
  32219.     $method->isConstructor() ? 'the constructor' : 'a regular method',
  32220.     $method->getFileName(),
  32221.     $method->getStartLine(),
  32222.     $method->getEndline(),
  32223.     $method->getModifiers(),
  32224.     implode(' ', Reflection::getModifierNames($method->getModifiers()))
  32225.   );
  32226.  
  32227.   // Print documentation comment
  32228.   printf("---> Documentation:\n %s\n", var_export($method->getDocComment(), 1));
  32229.  
  32230.   // Print static variables if existant
  32231.   if ($statics= $method->getStaticVariables())
  32232.   {
  32233.       printf("---> Static variables: %s\n", var_export($statics, 1));
  32234.   }
  32235.  
  32236.   // Invoke the method
  32237.   printf("---> Invokation results in: ");
  32238.   var_dump($method->invoke(NULL));
  32239. ?></PRE
  32240. ></TD
  32241. ></TR
  32242. ></TABLE
  32243. ></DIV
  32244. ></TD
  32245. ></TR
  32246. ></TABLE
  32247. ><DIV
  32248. CLASS="note"
  32249. ><BLOCKQUOTE
  32250. CLASS="note"
  32251. ><P
  32252. ><B
  32253. >Anmerkung: </B
  32254. >
  32255.      Trying to invoke private, protected or abstract methods will result
  32256.      in an exception being thrown from the <B
  32257. CLASS="function"
  32258. >invoke()</B
  32259. >
  32260.      method.
  32261.     </P
  32262. ></BLOCKQUOTE
  32263. ></DIV
  32264. ><DIV
  32265. CLASS="note"
  32266. ><BLOCKQUOTE
  32267. CLASS="note"
  32268. ><P
  32269. ><B
  32270. >Anmerkung: </B
  32271. >
  32272.      For static methods as seen above, you should pass NULL as the first
  32273.      argument to <B
  32274. CLASS="function"
  32275. >invoke()</B
  32276. >. For non-static methods, pass 
  32277.      an instance of the class.
  32278.     </P
  32279. ></BLOCKQUOTE
  32280. ></DIV
  32281. ></DIV
  32282. ><DIV
  32283. CLASS="sect2"
  32284. ><HR><H3
  32285. CLASS="sect2"
  32286. ><A
  32287. NAME="language.oop5.reflection.reflectionproperty"
  32288. ><B
  32289. CLASS="classname"
  32290. >ReflectionProperty</B
  32291. ></A
  32292. ></H3
  32293. ><P
  32294. >     The <B
  32295. CLASS="classname"
  32296. >ReflectionProperty</B
  32297. > class lets you
  32298.     reverse-engineer class properties.
  32299.    </P
  32300. ><DIV
  32301. CLASS="informalexample"
  32302. ><P
  32303. ></P
  32304. ><A
  32305. NAME="AEN5435"
  32306. ></A
  32307. ><TABLE
  32308. BORDER="0"
  32309. BGCOLOR="#E0E0E0"
  32310. CELLPADDING="5"
  32311. ><TR
  32312. ><TD
  32313. ><PRE
  32314. CLASS="php"
  32315. ><?php
  32316.   class ReflectionProperty implements Reflector {
  32317.       public __construct(mixed class, string name)
  32318.       public string __toString()
  32319.       public static string export()
  32320.       public string getName()
  32321.       public bool isPublic()
  32322.       public bool isPrivate()
  32323.       public bool isProtected()
  32324.       public bool isStatic()
  32325.       public bool isDefault()
  32326.       public int getModifiers()
  32327.       public mixed getValue(stdclass object)
  32328.       public void setValue(stdclass object, mixed value)
  32329.       public ReflectionClass getDeclaringClass()
  32330.   }
  32331. ?></PRE
  32332. ></TD
  32333. ></TR
  32334. ></TABLE
  32335. ><P
  32336. ></P
  32337. ></DIV
  32338. ><P
  32339. >     To introspect a method, you will first have to create an instance
  32340.     of the <B
  32341. CLASS="classname"
  32342. >ReflectionProperty</B
  32343. > class. You can then
  32344.     call any of the above methods on this instance.
  32345.    </P
  32346. ><TABLE
  32347. WIDTH="100%"
  32348. BORDER="0"
  32349. CELLPADDING="0"
  32350. CELLSPACING="0"
  32351. CLASS="EXAMPLE"
  32352. ><TR
  32353. ><TD
  32354. ><DIV
  32355. CLASS="example"
  32356. ><A
  32357. NAME="AEN5439"
  32358. ></A
  32359. ><P
  32360. ><B
  32361. >Beispiel 18-25. Using the <B
  32362. CLASS="classname"
  32363. >ReflectionProperty</B
  32364. > class</B
  32365. ></P
  32366. ><TABLE
  32367. BORDER="0"
  32368. BGCOLOR="#E0E0E0"
  32369. CELLPADDING="5"
  32370. ><TR
  32371. ><TD
  32372. ><PRE
  32373. CLASS="php"
  32374. ><?php
  32375.   class String
  32376.   {
  32377.       public $length  = 5;
  32378.   }
  32379.  
  32380.   // Create an instance of the ReflectionProperty class
  32381.   $prop = new ReflectionProperty('String', 'length');
  32382.  
  32383.   // Print out basic information
  32384.   printf(
  32385.       "===> The%s%s%s%s property '%s' (which was %s)\n".
  32386.       "     having the modifiers %s\n",
  32387.       $prop->isPublic() ? ' public' : '',
  32388.       $prop->isPrivate() ? ' private' : '',
  32389.       $prop->isProtected() ? ' protected' : '',
  32390.       $prop->isStatic() ? ' static' : '',
  32391.       $prop->getName(),
  32392.       $prop->isDefault() ? 'declared at compile-time' : 'created at run-time',
  32393.       var_export(Reflection::getModifierNames($prop->getModifiers()), 1)
  32394.   );
  32395.  
  32396.   // Create an instance of String
  32397.   $obj= new String();
  32398.  
  32399.   // Get current value
  32400.   printf("---> Value is: ");
  32401.   var_dump($prop->getValue($obj));
  32402.  
  32403.   // Change value
  32404.   $prop->setValue($obj, 10);
  32405.   printf("---> Setting value to 10, new value is: ");
  32406.   var_dump($prop->getValue($obj));
  32407.  
  32408.   // Dump object
  32409.   var_dump($obj);
  32410. ?></PRE
  32411. ></TD
  32412. ></TR
  32413. ></TABLE
  32414. ></DIV
  32415. ></TD
  32416. ></TR
  32417. ></TABLE
  32418. ><DIV
  32419. CLASS="note"
  32420. ><BLOCKQUOTE
  32421. CLASS="note"
  32422. ><P
  32423. ><B
  32424. >Anmerkung: </B
  32425. >
  32426.      Trying to get or set private or protected class property's values
  32427.      will result in an exception being thrown.
  32428.     </P
  32429. ></BLOCKQUOTE
  32430. ></DIV
  32431. ></DIV
  32432. ><DIV
  32433. CLASS="sect2"
  32434. ><HR><H3
  32435. CLASS="sect2"
  32436. ><A
  32437. NAME="language.oop5.reflection.reflectionextension"
  32438. ><B
  32439. CLASS="classname"
  32440. >ReflectionExtension</B
  32441. ></A
  32442. ></H3
  32443. ><P
  32444. >     The <B
  32445. CLASS="classname"
  32446. >ReflectionExtension</B
  32447. > class lets you
  32448.     reverse-engineer extensions. You can retrieve all loaded extensions
  32449.     at runtime using the <A
  32450. HREF="#function.get-loaded-extensions"
  32451. ><B
  32452. CLASS="function"
  32453. >get_loaded_extensions()</B
  32454. ></A
  32455. >.
  32456.    </P
  32457. ><DIV
  32458. CLASS="informalexample"
  32459. ><P
  32460. ></P
  32461. ><A
  32462. NAME="AEN5451"
  32463. ></A
  32464. ><TABLE
  32465. BORDER="0"
  32466. BGCOLOR="#E0E0E0"
  32467. CELLPADDING="5"
  32468. ><TR
  32469. ><TD
  32470. ><PRE
  32471. CLASS="php"
  32472. ><?php
  32473.   class ReflectionExtension implements Reflector {
  32474.       public __construct(string name)
  32475.       public string __toString()
  32476.       public static string export()
  32477.       public string getName()
  32478.       public string getVersion()
  32479.       public ReflectionFunction[] getFunctions()
  32480.       public array getConstants()
  32481.       public array getINIEntries()
  32482.   }
  32483. ?></PRE
  32484. ></TD
  32485. ></TR
  32486. ></TABLE
  32487. ><P
  32488. ></P
  32489. ></DIV
  32490. ><P
  32491. >     To introspect a method, you will first have to create an instance
  32492.     of the <B
  32493. CLASS="classname"
  32494. >ReflectionProperty</B
  32495. > class. You can then call
  32496.     any of the above methods on this instance.
  32497.    </P
  32498. ><TABLE
  32499. WIDTH="100%"
  32500. BORDER="0"
  32501. CELLPADDING="0"
  32502. CELLSPACING="0"
  32503. CLASS="EXAMPLE"
  32504. ><TR
  32505. ><TD
  32506. ><DIV
  32507. CLASS="example"
  32508. ><A
  32509. NAME="AEN5455"
  32510. ></A
  32511. ><P
  32512. ><B
  32513. >Beispiel 18-26. Using the <B
  32514. CLASS="classname"
  32515. >ReflectionExtension</B
  32516. > class</B
  32517. ></P
  32518. ><TABLE
  32519. BORDER="0"
  32520. BGCOLOR="#E0E0E0"
  32521. CELLPADDING="5"
  32522. ><TR
  32523. ><TD
  32524. ><PRE
  32525. CLASS="php"
  32526. ><?php
  32527.   // Create an instance of the ReflectionProperty class
  32528.   $ext = new ReflectionExtension('standard');
  32529.  
  32530.   // Print out basic information
  32531.   printf(
  32532.       "Name        : %s\n".
  32533.       "Version     : %s\n".
  32534.       "Functions   : [%d] %s\n".
  32535.       "Constants   : [%d] %s\n".
  32536.       "INI entries : [%d] %s\n",
  32537.       $ext->getName(),
  32538.       $ext->getVersion() ? $ext->getVersion() : 'NO_VERSION',
  32539.       sizeof($ext->getFunctions()),
  32540.       var_export($ext->getFunctions(), 1),
  32541.       sizeof($ext->getConstants()),
  32542.       var_export($ext->getConstants(), 1),
  32543.       sizeof($ext->getINIEntries()),
  32544.       var_export($ext->getINIEntries(), 1)
  32545.   );
  32546. ?></PRE
  32547. ></TD
  32548. ></TR
  32549. ></TABLE
  32550. ></DIV
  32551. ></TD
  32552. ></TR
  32553. ></TABLE
  32554. ></DIV
  32555. ><DIV
  32556. CLASS="sect2"
  32557. ><HR><H3
  32558. CLASS="sect2"
  32559. ><A
  32560. NAME="language.oop5.reflection.extending"
  32561. >Extending the reflection classes</A
  32562. ></H3
  32563. ><P
  32564. >     In case you want to create specialized versions of the built-in
  32565.     classes (say, for creating colorized HTML when being exported,
  32566.     having easy-access member variables instead of methods or
  32567.     having utility methods), you may go ahead and extend them.
  32568.    </P
  32569. ><TABLE
  32570. WIDTH="100%"
  32571. BORDER="0"
  32572. CELLPADDING="0"
  32573. CELLSPACING="0"
  32574. CLASS="EXAMPLE"
  32575. ><TR
  32576. ><TD
  32577. ><DIV
  32578. CLASS="example"
  32579. ><A
  32580. NAME="AEN5462"
  32581. ></A
  32582. ><P
  32583. ><B
  32584. >Beispiel 18-27. Extending the built-in classes</B
  32585. ></P
  32586. ><TABLE
  32587. BORDER="0"
  32588. BGCOLOR="#E0E0E0"
  32589. CELLPADDING="5"
  32590. ><TR
  32591. ><TD
  32592. ><PRE
  32593. CLASS="php"
  32594. ><?php
  32595.   /**
  32596.    * My Reflection_Method class
  32597.    *
  32598.    */
  32599.   class My_Reflection_Method extends ReflectionMethod {
  32600.     public $visibility= '';
  32601.  
  32602.     public function __construct($o, $m) {
  32603.       parent::__construct($o, $m);
  32604.       $this->visibility= Reflection::getModifierNames($this->getModifiers());
  32605.     }
  32606.   }
  32607.  
  32608.   /**
  32609.    * Demo class #1
  32610.    *
  32611.    */
  32612.   class T {
  32613.     protected function x() {}
  32614.   }
  32615.  
  32616.   /**
  32617.    * Demo class #2
  32618.    *
  32619.    */
  32620.   class U extends T {
  32621.     function x() {}
  32622.   }
  32623.  
  32624.   // Print out information
  32625.   var_dump(new My_Reflection_Method('U', 'x'));
  32626. ?></PRE
  32627. ></TD
  32628. ></TR
  32629. ></TABLE
  32630. ></DIV
  32631. ></TD
  32632. ></TR
  32633. ></TABLE
  32634. ><DIV
  32635. CLASS="note"
  32636. ><BLOCKQUOTE
  32637. CLASS="note"
  32638. ><P
  32639. ><B
  32640. >Anmerkung: </B
  32641. >
  32642.      Caution: If you're overwriting the constructor, remember to call
  32643.      the parent's constructor _before_ any code you insert. Failing to
  32644.      do so will result in the following:
  32645.      <VAR
  32646. CLASS="literal"
  32647. >       Fatal error: Internal error: Failed to retrieve the reflection object
  32648.      </VAR
  32649. >
  32650.     </P
  32651. ></BLOCKQUOTE
  32652. ></DIV
  32653. ></DIV
  32654. ></DIV
  32655. ></DIV
  32656. ><DIV
  32657. CLASS="chapter"
  32658. ><HR><H1
  32659. ><A
  32660. NAME="language.references"
  32661. >Kapitel 19. Referenzen in PHP</A
  32662. ></H1
  32663. ><DIV
  32664. CLASS="sect1"
  32665. ><H2
  32666. CLASS="sect1"
  32667. ><A
  32668. NAME="language.references.whatare"
  32669. >Was Referenzen sind</A
  32670. ></H2
  32671. ><P
  32672. >  
  32673.     Referenzen sind in PHP ein Mechanismus um verschiedene Namen
  32674.     fⁿr den gleichen Inhalt von Variablen zu erm÷glichen. 
  32675.     Sie sind nicht mit Zeigern in C zu vergleichen, sondern 
  32676.     Aliasdefinitionen fⁿr die Symboltabelle. 
  32677.     PHP unterscheidet zwischen Variablenname und Variableninhalt, 
  32678.     wobei der gleiche Variableninhalt unterschiedliche Namen besitzen kann. 
  32679.     Der bestm÷gliche Vergleich ist der mit Dateinamen und Dateien 
  32680.     im Dateisystem von Unix - Variablennamen sind VerzeichniseintrΣge, 
  32681.     wΣhrend der Variableninhalt die eigentliche Datei darstellt. 
  32682.     Referenzen k÷nnen nun als Hardlinks im Dateisystem verstanden werden.
  32683.    </P
  32684. ></DIV
  32685. ><DIV
  32686. CLASS="sect1"
  32687. ><HR><H2
  32688. CLASS="sect1"
  32689. ><A
  32690. NAME="language.references.whatdo"
  32691. >Was Referenzen leisten</A
  32692. ></H2
  32693. ><P
  32694. >     PHP Referenzen erlauben es, zwei Variablennamen sich auf den
  32695.     gleichen Variableninhalt beziehen zu lassen. Das heisst im
  32696.     folgenden Beispiel, dass sich <VAR
  32697. CLASS="varname"
  32698. >$a</VAR
  32699. > und
  32700.     <VAR
  32701. CLASS="varname"
  32702. >$b</VAR
  32703. > auf dieselbe Variable beziehen:
  32704.  
  32705.     <DIV
  32706. CLASS="informalexample"
  32707. ><P
  32708. ></P
  32709. ><A
  32710. NAME="AEN5478"
  32711. ></A
  32712. ><TABLE
  32713. BORDER="0"
  32714. BGCOLOR="#E0E0E0"
  32715. CELLPADDING="5"
  32716. ><TR
  32717. ><TD
  32718. ><PRE
  32719. CLASS="php"
  32720. >$a =& $b</PRE
  32721. ></TD
  32722. ></TR
  32723. ></TABLE
  32724. ><P
  32725. ></P
  32726. ></DIV
  32727. >
  32728.  
  32729.     <DIV
  32730. CLASS="note"
  32731. ><BLOCKQUOTE
  32732. CLASS="note"
  32733. ><P
  32734. ><B
  32735. >Anmerkung: </B
  32736. >
  32737.       <VAR
  32738. CLASS="varname"
  32739. >$a</VAR
  32740. > und <VAR
  32741. CLASS="varname"
  32742. >$b</VAR
  32743. > sind hier
  32744.       gleichwertig, und <VAR
  32745. CLASS="varname"
  32746. >$a</VAR
  32747. > ist nicht nur ein
  32748.       Zeiger auf <VAR
  32749. CLASS="varname"
  32750. >$b</VAR
  32751. > oder umgekehrt, sondern
  32752.       <VAR
  32753. CLASS="varname"
  32754. >$a</VAR
  32755. > und <VAR
  32756. CLASS="varname"
  32757. >$b</VAR
  32758. > zeigen auf
  32759.       den selben Inhalt.
  32760.      </P
  32761. ></BLOCKQUOTE
  32762. ></DIV
  32763. >
  32764.    </P
  32765. ><P
  32766. >    Seit PHP 4.0.4 kann <VAR
  32767. CLASS="literal"
  32768. >&</VAR
  32769. > auch in Verbindung mit
  32770.    <VAR
  32771. CLASS="literal"
  32772. >new</VAR
  32773. > verwendet werden.
  32774.    <DIV
  32775. CLASS="informalexample"
  32776. ><P
  32777. ></P
  32778. ><A
  32779. NAME="AEN5491"
  32780. ></A
  32781. ><TABLE
  32782. BORDER="0"
  32783. BGCOLOR="#E0E0E0"
  32784. CELLPADDING="5"
  32785. ><TR
  32786. ><TD
  32787. ><PRE
  32788. CLASS="php"
  32789. >$bar =& new fooclass();
  32790. $foo =& find_var ($bar);</PRE
  32791. ></TD
  32792. ></TR
  32793. ></TABLE
  32794. ><P
  32795. ></P
  32796. ></DIV
  32797. >
  32798.     </P
  32799. ><DIV
  32800. CLASS="note"
  32801. ><BLOCKQUOTE
  32802. CLASS="note"
  32803. ><P
  32804. ><B
  32805. >Anmerkung: </B
  32806. >
  32807.      Wenn der <VAR
  32808. CLASS="literal"
  32809. >&</VAR
  32810. > Operator nicht verwendet wird, erzeugt
  32811.      PHP eine Kopie des Objekts. Wenn nun <VAR
  32812. CLASS="literal"
  32813. >$this</VAR
  32814. > innerhalb 
  32815.      der Klasse verwendet wird, bezieht es sich auf die aktuelle Instanz der 
  32816.      Klasse. Die Zuordnung ohne <VAR
  32817. CLASS="literal"
  32818. >&</VAR
  32819. > erzeugt eine Kopie der 
  32820.      Instanz (d.h. des Objekts) und <VAR
  32821. CLASS="literal"
  32822. >$this</VAR
  32823. > wird sich auf 
  32824.      die Kopie beziehen. In der Regel will man aus Performance- und 
  32825.      Speicherverbrausgrⁿnden nur eine einzige Instanz einer Klasse
  32826.      erzeugen. Dafⁿr stellt PHP den <VAR
  32827. CLASS="literal"
  32828. >&</VAR
  32829. > bereit. 
  32830.      </P
  32831. ></BLOCKQUOTE
  32832. ></DIV
  32833. ><P
  32834. >     Eine weitere Einsatzm÷glichkeit von Referenzen ist die ▄bergabe 
  32835.     von Parametern an eine Funktion mit pass-by-reference. Hierbei 
  32836.     beziehen sich der lokale Variablenname als auch der Variablenname 
  32837.     der aufrufenden Instanz auf denselben Variableninhalt:
  32838.     <DIV
  32839. CLASS="informalexample"
  32840. ><P
  32841. ></P
  32842. ><A
  32843. NAME="AEN5501"
  32844. ></A
  32845. ><TABLE
  32846. BORDER="0"
  32847. BGCOLOR="#E0E0E0"
  32848. CELLPADDING="5"
  32849. ><TR
  32850. ><TD
  32851. ><PRE
  32852. CLASS="php"
  32853. >function foo (&$var) {
  32854.     $var++;
  32855. }
  32856.  
  32857. $a=5;
  32858. foo ($a);</PRE
  32859. ></TD
  32860. ></TR
  32861. ></TABLE
  32862. ><P
  32863. ></P
  32864. ></DIV
  32865. >
  32866.     Nach der Ausfⁿhrung hat <VAR
  32867. CLASS="varname"
  32868. >$a</VAR
  32869. > den Wert 6, da sich 
  32870.     in der Funktion <VAR
  32871. CLASS="varname"
  32872. >foo</VAR
  32873. > der Variablenname 
  32874.     <VAR
  32875. CLASS="varname"
  32876. >$var</VAR
  32877. > auf denselben Variableninhalt bezieht wie 
  32878.     <VAR
  32879. CLASS="varname"
  32880. >$a</VAR
  32881. > in der aufrufenden Instanz (hier das Hauptprogramm).
  32882.    </P
  32883. ><P
  32884. >     Daneben besteht die M÷glichkeit aus Funktionen heraus Werte mit 
  32885.     <A
  32886. HREF="#language.references.return"
  32887. >return by-reference</A
  32888.     zurⁿckzugeben.
  32889.    </P
  32890. ></DIV
  32891. ><DIV
  32892. CLASS="sect1"
  32893. ><HR><H2
  32894. CLASS="sect1"
  32895. ><A
  32896. NAME="language.references.arent"
  32897. >Was Referenzen nicht sind</A
  32898. ></H2
  32899. ><P
  32900. >     Wie bereits gesagt: Referenzen sind keine Zeiger. Das bedeutet, 
  32901.     der folgende Code tut nicht, was zum Beispiel ein C Programmierer 
  32902.     erwarten wⁿrde:
  32903.     <DIV
  32904. CLASS="informalexample"
  32905. ><P
  32906. ></P
  32907. ><A
  32908. NAME="AEN5512"
  32909. ></A
  32910. ><TABLE
  32911. BORDER="0"
  32912. BGCOLOR="#E0E0E0"
  32913. CELLPADDING="5"
  32914. ><TR
  32915. ><TD
  32916. ><PRE
  32917. CLASS="php"
  32918. >function foo (&$var) {
  32919.     $var =& $GLOBALS["baz"];
  32920. }
  32921. foo($bar);</PRE
  32922. ></TD
  32923. ></TR
  32924. ></TABLE
  32925. ><P
  32926. ></P
  32927. ></DIV
  32928. >
  32929.    </P
  32930. ><P
  32931. >     Folgendes wird passieren: <VAR
  32932. CLASS="varname"
  32933. >$var</VAR
  32934. > in foo wird zunΣchst 
  32935.     an  <VAR
  32936. CLASS="varname"
  32937. >$bar</VAR
  32938. > aus der aufrufenden Instanz, dann 
  32939.     aber an <VAR
  32940. CLASS="varname"
  32941. >$GLOBALS["baz"]</VAR
  32942. >, gebunden.
  32943.     Es gibt keine M÷glichkeit, <VAR
  32944. CLASS="varname"
  32945. >$bar</VAR
  32946. > aus der aufrufenden 
  32947.     Instanz mittels Referenz-Mechanismen an etwas anderes zu binden, da 
  32948.     <VAR
  32949. CLASS="varname"
  32950. >$bar</VAR
  32951. > in der Funktion foo nicht zur Verfⁿgung steht 
  32952.     (<VAR
  32953. CLASS="varname"
  32954. >$bar</VAR
  32955. > wird durch <VAR
  32956. CLASS="varname"
  32957. >$var</VAR
  32958. > reprΣsentiert; 
  32959.     <VAR
  32960. CLASS="varname"
  32961. >$var</VAR
  32962. > verfⁿgt nur ⁿber Variableninhalt, besitzt 
  32963.     aber keinen name-to-value Eintrag in der Symboltabelle der aufrufenden 
  32964.     Instanz).
  32965.    </P
  32966. ></DIV
  32967. ><DIV
  32968. CLASS="sect1"
  32969. ><HR><H2
  32970. CLASS="sect1"
  32971. ><A
  32972. NAME="language.references.return"
  32973. >Referenzen zurⁿckgeben</A
  32974. ></H2
  32975. ><P
  32976. >     Das Zurⁿckgeben von Ergebnissen per Referenz aus Funktionen 
  32977.     heraus kann manchmal recht nⁿzlich sein. Hierbei ist folgende
  32978.     Syntax zu beachten:
  32979.     <DIV
  32980. CLASS="informalexample"
  32981. ><P
  32982. ></P
  32983. ><A
  32984. NAME="AEN5526"
  32985. ></A
  32986. ><TABLE
  32987. BORDER="0"
  32988. BGCOLOR="#E0E0E0"
  32989. CELLPADDING="5"
  32990. ><TR
  32991. ><TD
  32992. ><PRE
  32993. CLASS="php"
  32994. >function &find_var ($param) {
  32995.     ...code...
  32996.     return $found_var;
  32997. }
  32998.  
  32999. $foo =& find_var ($bar);
  33000. $foo->x = 2;</PRE
  33001. ></TD
  33002. ></TR
  33003. ></TABLE
  33004. ><P
  33005. ></P
  33006. ></DIV
  33007. >
  33008.     In diesem Beispiel wird also die Eigenschaft des von 
  33009.     <VAR
  33010. CLASS="varname"
  33011. >find_var</VAR
  33012. > gelieferten Objektes gesetzt, nicht die der Kopie, 
  33013.     wie es der Fall wΣre, wenn die Funktion <VAR
  33014. CLASS="varname"
  33015. >find_var</VAR
  33016.     ihr Ergebnis nicht per Referenz liefern wⁿrde.
  33017.    </P
  33018. ><DIV
  33019. CLASS="note"
  33020. ><BLOCKQUOTE
  33021. CLASS="note"
  33022. ><P
  33023. ><B
  33024. >Anmerkung: </B
  33025. >
  33026.      Im Gegensatz zur Parameterⁿbergabe per Referenz ist bei der 
  33027.      Rⁿckgabe mittels Referenz an beiden Stellen die Angabe des 
  33028.      <VAR
  33029. CLASS="literal"
  33030. >&</VAR
  33031. > notwendig.
  33032.     </P
  33033. ></BLOCKQUOTE
  33034. ></DIV
  33035. ></DIV
  33036. ><DIV
  33037. CLASS="sect1"
  33038. ><HR><H2
  33039. CLASS="sect1"
  33040. ><A
  33041. NAME="language.references.unset"
  33042. >Referenzen aufheben</A
  33043. ></H2
  33044. ><P
  33045. >     Wird eine Referenz aufgehoben, so wird nur die Bindung zwischen einem 
  33046.     Variablennamen und dem Variableninhalt entfernt. Der Inhalt der Variablen 
  33047.     wird hierbei nicht gel÷scht. Betrachten wir folgendes Beispiel:
  33048.     <DIV
  33049. CLASS="informalexample"
  33050. ><P
  33051. ></P
  33052. ><A
  33053. NAME="AEN5536"
  33054. ></A
  33055. ><TABLE
  33056. BORDER="0"
  33057. BGCOLOR="#E0E0E0"
  33058. CELLPADDING="5"
  33059. ><TR
  33060. ><TD
  33061. ><PRE
  33062. CLASS="php"
  33063. >$a = 1;
  33064. $b =& $a;
  33065. unset ($a);</PRE
  33066. ></TD
  33067. ></TR
  33068. ></TABLE
  33069. ><P
  33070. ></P
  33071. ></DIV
  33072. >
  33073.     Die Variable <VAR
  33074. CLASS="varname"
  33075. >$b</VAR
  33076. > wird nicht gel÷scht, sondern es 
  33077.     wird nur die Bindung des Variablennamen <VAR
  33078. CLASS="varname"
  33079. >$a</VAR
  33080. > an den 
  33081.     Variableninhalt aufgehoben. Dieser Variableninhalt ist immer noch 
  33082.     ⁿber <VAR
  33083. CLASS="varname"
  33084. >$b</VAR
  33085. > verfⁿgbar.
  33086.    </P
  33087. ><P
  33088. >     Wiederum sieht man die Analogie zwischen Unix und den Referenzen: Das 
  33089.     Aufheben einer Referenz entspricht einem Aufruf von 
  33090.     <B
  33091. CLASS="command"
  33092. >unlink</B
  33093. > unter Unix.
  33094.    </P
  33095. ></DIV
  33096. ><DIV
  33097. CLASS="sect1"
  33098. ><HR><H2
  33099. CLASS="sect1"
  33100. ><A
  33101. NAME="language.references.spot"
  33102. >Referenzen entdecken</A
  33103. ></H2
  33104. ><P
  33105. >     Viele Sprachelemente von PHP sind intern mit der Benutzung von Referenzen 
  33106.     implementiert, daher gilt alles bisher gesagte auch fⁿr diese 
  33107.     Konstrukte:
  33108.    </P
  33109. ><DIV
  33110. CLASS="sect2"
  33111. ><HR><H3
  33112. CLASS="sect2"
  33113. ><A
  33114. NAME="references.global"
  33115. ><VAR
  33116. CLASS="literal"
  33117. >global</VAR
  33118. > References</A
  33119. ></H3
  33120. ><P
  33121. >      Die Verwendung von <B
  33122. CLASS="command"
  33123. >global $var</B
  33124. > erzeugt im aktuellen 
  33125.      Scope eine Referenz auf die globale Variable <VAR
  33126. CLASS="varname"
  33127. >$var</VAR
  33128. >, 
  33129.      sie ist also Σquivalent zu folgendem:
  33130.      <DIV
  33131. CLASS="informalexample"
  33132. ><P
  33133. ></P
  33134. ><A
  33135. NAME="AEN5552"
  33136. ></A
  33137. ><TABLE
  33138. BORDER="0"
  33139. BGCOLOR="#E0E0E0"
  33140. CELLPADDING="5"
  33141. ><TR
  33142. ><TD
  33143. ><PRE
  33144. CLASS="php"
  33145. >$var =& $GLOBALS["var"];</PRE
  33146. ></TD
  33147. ></TR
  33148. ></TABLE
  33149. ><P
  33150. ></P
  33151. ></DIV
  33152. >
  33153.     </P
  33154. ><P
  33155. >      Dies hat zur Folge, dass das Anwenden von unset() auf <VAR
  33156. CLASS="varname"
  33157. >$var</VAR
  33158.      keinen Einfluss auf die globale Variable hat.
  33159.     </P
  33160. ></DIV
  33161. ><DIV
  33162. CLASS="sect2"
  33163. ><HR><H3
  33164. CLASS="sect2"
  33165. ><A
  33166. NAME="references.this"
  33167. ><VAR
  33168. CLASS="literal"
  33169. >$this</VAR
  33170. ></A
  33171. ></H3
  33172. ><P
  33173. >      In einer Objektmethode ist <VAR
  33174. CLASS="varname"
  33175. >$this</VAR
  33176. > immer eine Referenz 
  33177.      auf die aufrufende Objektinstanz.
  33178.     </P
  33179. ></DIV
  33180. ></DIV
  33181. ></DIV
  33182. ></DIV
  33183. ><DIV
  33184. CLASS="PART"
  33185. ><A
  33186. NAME="security"
  33187. ></A
  33188. ><DIV
  33189. CLASS="TITLEPAGE"
  33190. ><H1
  33191. CLASS="title"
  33192. >IV. Sicherheit</H1
  33193. ><DIV
  33194. CLASS="TOC"
  33195. ><DL
  33196. ><DT
  33197. ><B
  33198. >Inhaltsverzeichnis</B
  33199. ></DT
  33200. ><DT
  33201. >20. <A
  33202. HREF="#security.intro"
  33203. >Einfⁿhrung</A
  33204. ></DT
  33205. ><DT
  33206. >21. <A
  33207. HREF="#security.general"
  33208. >Allgemeine ▄berlegungen</A
  33209. ></DT
  33210. ><DT
  33211. >22. <A
  33212. HREF="#security.cgi-bin"
  33213. >CGI-Version</A
  33214. ></DT
  33215. ><DT
  33216. >23. <A
  33217. HREF="#security.apache"
  33218. >Apache-Modul</A
  33219. ></DT
  33220. ><DT
  33221. >24. <A
  33222. HREF="#security.filesystem"
  33223. >Dateisystem - Sicherheit</A
  33224. ></DT
  33225. ><DT
  33226. >25. <A
  33227. HREF="#security.database"
  33228. >Datenbank - Sicherheit</A
  33229. ></DT
  33230. ><DT
  33231. >26. <A
  33232. HREF="#security.errors"
  33233. >Fehlerbehandlung</A
  33234. ></DT
  33235. ><DT
  33236. >27. <A
  33237. HREF="#security.globals"
  33238. >Verwendung von Register Globals</A
  33239. ></DT
  33240. ><DT
  33241. >28. <A
  33242. HREF="#security.variables"
  33243. >Vom Nutzer ⁿbermittelte Daten</A
  33244. ></DT
  33245. ><DT
  33246. >29. <A
  33247. HREF="#security.hiding"
  33248. >Verstecken von PHP</A
  33249. ></DT
  33250. ><DT
  33251. >30. <A
  33252. HREF="#security.current"
  33253. >Aktuell bleiben</A
  33254. ></DT
  33255. ></DL
  33256. ></DIV
  33257. ></DIV
  33258. ><DIV
  33259. CLASS="chapter"
  33260. ><HR><H1
  33261. ><A
  33262. NAME="security.intro"
  33263. >Kapitel 20. Einfⁿhrung</A
  33264. ></H1
  33265. ><P
  33266. >    PHP ist eine mΣchtige Sprache, und der Interpreter, der in einen
  33267.    Webserver als Modul oder als separate <ACRONYM
  33268. CLASS="acronym"
  33269. >CGI</ACRONYM
  33270. >-Version
  33271.    eingebunden werden kann, kann auf Dateien zugreifen, Befehle
  33272.    ausfⁿhren und Netzwerkverbindungen zu einem Server herstellen.
  33273.    Diese Eigenschaften k÷nnen einen Webserver unsicher machen, wenn man
  33274.    es bei den Voreinstellungen belΣsst.
  33275.    PHP wurde besonders dafⁿr entwickelt, um eine sicherere Sprache als
  33276.    Perl oder C fⁿr die Erstellung von CGI-Programmen bereitzustellen.
  33277.    Mit der richtigen Wahl der Einstellungen beim Kompilieren und
  33278.    zur Laufzeit bietet PHP genau die Kombination aus Freiheit und
  33279.    Sicherheit, die gerade ben÷tigt wird.
  33280.   </P
  33281. ><P
  33282. >    Da es sehr viele verschiedene M÷glichkeiten gibt, PHP zu nutzen,
  33283.    gibt es viele Konfigurationseinstellungen, die das Verhalten von
  33284.    PHP beeinflussen. Eine gro▀e Auswahl an Einstellungen garantiert,
  33285.    dass man PHP fⁿr viele Zwecke einsetzen kann. Allerdings
  33286.    bedeutet das auch, dass es Kombinationen gibt, die eine Installation
  33287.    mit nur ungenⁿgender Sicherheit zur Folge haben.
  33288.   </P
  33289. ><P
  33290. >    Die FlexibilitΣt der Konfiguration konkurriert mit der FlexibilitΣt
  33291.    in der Programmierung. Mit PHP k÷nnen komplette Server Applikationen
  33292.    mit allen M÷glichkeiten eines Shell Benutzers erstellt werden, oder
  33293.    auch nur einfache Server Side Includes mit einem minimalen Risiko in
  33294.    einer streng kontrollierten Umgebung. Wie die Umgebung erstellt wird,
  33295.    und wie sicher diese ist, ist zu einem gro▀en Teil die Sache des PHP
  33296.    Entwicklers.
  33297.   </P
  33298. ><P
  33299. >    Dieses Kapitel beginnt mit einigen generellen RatschlΣgen zur Sicherheit,
  33300.    erklΣrt die verschiedenen Kombinationen der Konfigurationseinstellungen
  33301.    und unter welchen Gegebenheiten sie sicher genutzt werden k÷nnen, und
  33302.    beschreibt verschiedene ▄berlegungen zur Programmierung fⁿr verschiedene
  33303.    Sicherheitsstufen.
  33304.   </P
  33305. ></DIV
  33306. ><DIV
  33307. CLASS="chapter"
  33308. ><HR><H1
  33309. ><A
  33310. NAME="security.general"
  33311. >Kapitel 21. Allgemeine ▄berlegungen</A
  33312. ></H1
  33313. ><P
  33314. >     Ein komplett sicheres System ist praktisch ein Ding der Unm÷glichkeit,
  33315.     weshalb ein unter Sicherheitsprofis oft genutzter Ansatz ist, einen
  33316.     Mittelweg zwischen Risiko und Verwendbarkeit zu finden.
  33317.     Wenn jede von einem Benutzer ⁿbermittelte Variable zwei Formen von
  33318.     biometrischer Prⁿfung (wie z.B. ein Scan der Netzhaut und ein
  33319.     Fingerabdruck) verlangen wⁿrde, wΣre eine extrem hohe Ebene der
  33320.     Verantwortlichkeit erreicht. Ein sehr komplexes Formular auszufⁿllen
  33321.     wⁿrde auch eine halbe Stunde in Anspruch nehmen, die Benutzer dazu
  33322.     ermuntern k÷nnte, Wege zur Umgehung der Sicherheitsma▀nahmen zu suchen.
  33323.    </P
  33324. ><P
  33325. >     Die beste Sicherheit ist oft unaufdringlich genug um den Anforderungen
  33326.     zu entsprechen, ohne den Benutzer an seiner Arbeit zu hindern oder den
  33327.     Code-Autor mit ⁿbertriebener KomplexitΣt zu ⁿberlasten. TatsΣchlich
  33328.     sind einige Sicherheitsangriffe nur die Folge von allzu strengen
  33329.     Sicherheitsma▀nahmen, was mit der Zeit nur zu deren Unterminierung
  33330.     fⁿhrt.
  33331.    </P
  33332. ><P
  33333. >     Eine Phrase die es wert ist, sich an sie zu erinnern: Ein System ist nur
  33334.     so gut wie das schwΣchste Glied in der Kette. Wenn alle Transaktionen
  33335.     mittels Zeit, Ort, Transaktionstyp, etc. streng mitprotokolliert werden,
  33336.     der Benutzer aber nur mittels einem einzigen Cookie verifiziert wird,
  33337.     lΣsst die ZuverlΣssigkeit fⁿr die Bindung des Benutzers an das
  33338.     Transaktions-Log bedrohlich nach.
  33339.    </P
  33340. ><P
  33341. >     Denken Sie wΣhrend der Tests daran, dass Sie selbst fⁿr die einfachsten
  33342.     Seiten nicht alle M÷glichkeiten testen k÷nnen. Der von Ihnen vielleicht
  33343.     erwartete Input wird zu dem eines verstimmten Mitarbeiters oder eines
  33344.     Crackers der Monate Zeit hat, oder einer Katze, die ⁿber die Tastatur
  33345.     lΣuft in keinerlei Zusammenhang stehen. Deshalb betrachten Sie Ihren
  33346.     Code am Besten aus der logischen Perspektive um zu erkennen, wo
  33347.     unerwartete Daten eingebracht werden k÷nnen und fragen sich dann,
  33348.     wie diese modifiziert, reduziert, oder weiter ausgefⁿhrt werden.
  33349.    </P
  33350. ><P
  33351. >     Das Internet ist voll von Leuten die versuchen, sich durch
  33352.     Entschlⁿsseln/zerst÷ren Ihres Codes, den Zusammenbruch Ihres
  33353.     Systems, Einsetzen von unangebrachten Inhalten, und anderen, Ihren
  33354.     Tag interessant gestaltenden Ma▀nahmen, einen Namen zu machen.
  33355.     Es ist egal, ob Sie eine kleine oder gro▀e Site haben, Sie sind
  33356.     einfach ein Ziel wenn Sie online sind oder wenn Sie einen Server
  33357.     haben, zu dem man eine Verbindung aufbauen kann. Viele
  33358.     Cracker-Programme erkennen nicht die Gr÷▀e, sondern durchsieben
  33359.     einfach gewaltige IP Bl÷cke im Netz, um Opfer zu finden. Versuchen
  33360.     Sie, keines zu werden.
  33361.    </P
  33362. ></DIV
  33363. ><DIV
  33364. CLASS="chapter"
  33365. ><HR><H1
  33366. ><A
  33367. NAME="security.cgi-bin"
  33368. >Kapitel 22. CGI-Version</A
  33369. ></H1
  33370. ><DIV
  33371. CLASS="sect1"
  33372. ><H2
  33373. CLASS="sect1"
  33374. ><A
  33375. NAME="security.cgi-bin.attacks"
  33376. >M÷gliche Angriffe</A
  33377. ></H2
  33378. ><P
  33379. >     PHP als <ACRONYM
  33380. CLASS="acronym"
  33381. >CGI</ACRONYM
  33382. > zu nutzen, ist eine M÷glichkeit
  33383.     fⁿr Installationen, bei denen aus irgendwelchen Grⁿnden kein Modul in
  33384.     die Serversoftware eingebunden werden soll (wie beim Apache) oder fⁿr
  33385.     Systeme, bei denen verschiedene CGI-Wrapper genutzt werden sollen,
  33386.     um sichere chroot- und setuid-Umgebungen fⁿrr Skripte zu schaffen.
  33387.     Bei dieser Konfiguration wird das ausfⁿhrbare PHP-Binary ⁿblicherweise
  33388.     im cgi-bin Verzeichnis des Webservers installiert.
  33389.     CERT advisory <A
  33390. HREF="http://www.cert.org/advisories/CA-1996-11.html"
  33391. TARGET="_top"
  33392. >CA-96.11</A
  33393. >
  33394.     spricht sich gegen die Platzierung von Interpretern im cgi-bin
  33395.     Verzeichnis aus. Obwohl das PHP-Binary als eigenstΣndiger Interpreter
  33396.     verwendet werden kann, wurde PHP so entwickelt, um den durch diese
  33397.     Konfiguration m÷glich werdenden Angriffe vorzubeugen:
  33398.    </P
  33399. ><P
  33400. ></P
  33401. ><UL
  33402. ><LI
  33403. ><P
  33404. >Zugriff auf Systemdateien:
  33405.         <TT
  33406. CLASS="filename"
  33407. >http://my.host/cgi-bin/php?/etc/passwd</TT
  33408. >
  33409.       </P
  33410. ><P
  33411. >        Die auf ein Fragezeichen (?) folgende Abfrageinformation in einer
  33412.        URL wird durch das CGI-Interface als Kommandozeilenargument an den
  33413.        Interpreter weitergereicht. In der Kommandozeile wird ⁿblicherweise
  33414.        die im ersten Argument angegebene Datei von Interpretern ge÷ffnet
  33415.        und ausgefⁿhrt.
  33416.       </P
  33417. ><P
  33418. >        Beim Aufruf als CGI-Binary verweigert PHP die Interpretation der
  33419.        Kommandozeilenargumente.
  33420.       </P
  33421. ></LI
  33422. ><LI
  33423. ><P
  33424. >        Zugriff auf beliebige Web-Dokumente auf dem Server: <TT
  33425. CLASS="filename"
  33426. >http://my.host/cgi-bin/php/secret/doc.html</TT
  33427. >
  33428.       </P
  33429. ><P
  33430. >        Der Teil der URL-Pfadinformation nach dem Namen der PHP BinΣrdatei,
  33431.        <TT
  33432. CLASS="filename"
  33433. >/secret/doc.html</TT
  33434. > wird im
  33435.        allgemeinen benutzt, um den Namen der Datei zu ⁿbergeben,
  33436.        die durch das <ACRONYM
  33437. CLASS="acronym"
  33438. >CGI</ACRONYM
  33439. >-Programm ge÷ffnet und
  33440.        interpretiert werden soll.
  33441.        Normalerweise werden einige EintrΣge in der Konfigurationsdatei
  33442.        des Webservers benutzt (Apache: Action), um Aufrufe von Dokumenten
  33443.        wie <TT
  33444. CLASS="filename"
  33445. >http://my.host/secret/script.php</TT
  33446. >
  33447.        an den PHP-Interpreter umzuleiten. Bei dieser Konfiguration
  33448.        ⁿberprⁿft der Webserver zuerst die Zugriffsrechte im Verzeichnis
  33449.        <TT
  33450. CLASS="filename"
  33451. >/secret</TT
  33452. > und erstellt anschlie▀end
  33453.        den umgeleiteten Aufruf <TT
  33454. CLASS="filename"
  33455. >http://my.host/cgi-bin/php/secret/script.php</TT
  33456. >.
  33457.        Unglⁿcklicherweise wird, wenn der Aufruf bereits in dieser Form
  33458.        geschieht, vom Webserver keine Zugriffsⁿberprⁿfung der Datei
  33459.        <TT
  33460. CLASS="filename"
  33461. >/secret/script.php</TT
  33462. >, sondern
  33463.        lediglich der Datei <TT
  33464. CLASS="filename"
  33465. >/cgi-bin/php</TT
  33466. >
  33467.        vorgenommen. So ist
  33468.        jeder Benutzer, der auf <TT
  33469. CLASS="filename"
  33470. >/cgi-bin/php</TT
  33471. >
  33472.        zugreifen darf in der Lage, sich zu jedem geschⁿtzten Dokument
  33473.        auf dem Webserver Zugriff zu verschaffen.
  33474.       </P
  33475. ><P
  33476. >        Bei PHP k÷nnen beim Kompilieren die Konfigurationsoption <A
  33477. HREF="#configure.enable-force-cgi-redirect"
  33478. >--enable-force-cgi-redirect</A
  33479. >
  33480.        und zur Laufzeit die Konfigurationsdirektiven <A
  33481. HREF="#ini.doc-root"
  33482. >doc_root</A
  33483. > und <A
  33484. HREF="#ini.user-dir"
  33485. >user_dir</A
  33486. >
  33487.        benutzt werden, um diesen Angriff zu verhindern, falls
  33488.        der Verzeichnisbaum des Servers Verzeichnisse mit
  33489.        ZugriffsbeschrΣnkungen beinhaltet.
  33490.        Ausfⁿhrliche Informationen ⁿber die verschiedenen Kombinationen
  33491.        siehe weiter unten.
  33492.       </P
  33493. ></LI
  33494. ></UL
  33495. ></DIV
  33496. ><DIV
  33497. CLASS="sect1"
  33498. ><HR><H2
  33499. CLASS="sect1"
  33500. ><A
  33501. NAME="security.cgi-bin.default"
  33502. >Fall 1: Nur ÷ffentliche Dateien vorhanden</A
  33503. ></H2
  33504. ><P
  33505. >      Wenn der Server keine Inhalte hat, die durch Passwort oder
  33506.      IP-basierte Zugriffskontrolle geschⁿtzt sind, werden diese
  33507.      Konfigurationsoptionen nicht ben÷tigt.
  33508.      Wenn der Webserver keine Redirects erlaubt oder keine M÷glichkeit
  33509.      hat, dem PHP-Binary mitzuteilen dass es sich um eine sicher umgeleitete
  33510.      Anfrage handelt, kann die Option <A
  33511. HREF="#configure.enable-force-cgi-redirect"
  33512. >--enable-force-cgi-redirect</A
  33513. >
  33514.      im configure-Script angegeben werden. Nichtsdestotrotz mⁿssen
  33515.      Sie sicherstellen, dass Ihre PHP-Skripte nicht auf die eine oder
  33516.      andere Art des Aufrufs angewiesen sind, weder direkt durch
  33517.      <TT
  33518. CLASS="filename"
  33519. >http://my.host/cgi-bin/php/dir/script.php</TT
  33520. >
  33521.      noch durch einen Redirect <TT
  33522. CLASS="filename"
  33523. >http://my.host/dir/script.php</TT
  33524. >.
  33525.     </P
  33526. ><P
  33527. >      Beim Apache kann der Redirect durch den Gebrauch von
  33528.      AddHandler und Action konfiguriert werden (siehe unten).
  33529.     </P
  33530. ></DIV
  33531. ><DIV
  33532. CLASS="sect1"
  33533. ><HR><H2
  33534. CLASS="sect1"
  33535. ><A
  33536. NAME="security.cgi-bin.force-redirect"
  33537. >Fall 2: --enable-force-cgi-redirect benutzen</A
  33538. ></H2
  33539. ><P
  33540. >      Diese beim Kompilieren verwendete Option verhindert grundsΣtzlich
  33541.      den Aufruf von PHP mit einer URL wie <TT
  33542. CLASS="filename"
  33543. >http://my.host/cgi-bin/php/secretdir/script.php</TT
  33544. >.
  33545.      Stattdessen parst PHP in diesem Modus nur dann, wenn der Aufruf
  33546.      durch einen korrekten Redirect des Webservers erfolgte.
  33547.     </P
  33548. ><P
  33549. >      Normalerweise wird der Redirect in der Apache-Konfiguration mit den
  33550.      folgenden EintrΣgen festgelegt:</P
  33551. ><TABLE
  33552. BORDER="0"
  33553. BGCOLOR="#E0E0E0"
  33554. CELLPADDING="5"
  33555. ><TR
  33556. ><TD
  33557. ><PRE
  33558. CLASS="apache-conf"
  33559. >Action php-script /cgi-bin/php
  33560. AddHandler php-script .php</PRE
  33561. ></TD
  33562. ></TR
  33563. ></TABLE
  33564. ><P
  33565. >      Diese Option wurde nur mit dem Apache Webserver getestet und
  33566.      ist abhΣngig davon, wie Apache die nicht standardmΣ▀ige
  33567.      CGI-Umgebungsvariable <VAR
  33568. CLASS="envar"
  33569. >REDIRECT_STATUS</VAR
  33570. > bei
  33571.      Redirect-Anfragen setzt.
  33572.      Sollte Ihr Webserver keine M÷glichkeit unterstⁿtzen, zu ⁿbermitteln,
  33573.      ob es sich um einen direkte Aufruf oder einen Redirect handelt,
  33574.      k÷nnen Sie diese Option nicht verwenden und mⁿssen einen der
  33575.      anderen hier beschriebenen Wege gehen, die CGI-Version zu
  33576.      nutzen.
  33577.     </P
  33578. ></DIV
  33579. ><DIV
  33580. CLASS="sect1"
  33581. ><HR><H2
  33582. CLASS="sect1"
  33583. ><A
  33584. NAME="security.cgi-bin.doc-root"
  33585. >Fall 3: doc_root oder user_dir festlegen</A
  33586. ></H2
  33587. ><P
  33588. >      Aktiven Inhalt, wie beispielsweise Skripts und ausfⁿhrbare
  33589.      Dateien, in den Dokumentverzeichnissen des Webservers abzulegen,
  33590.      wird manchmal als unsichere Methode angesehen.
  33591.      Wenn, beispielsweise aufgrund von Konfigurationsfehlern, die
  33592.      Skripte nicht ausgefⁿhrt, sondern als regulΣre HTML-Dokumente
  33593.      angezeigt werden kann dies ein Durchsickern von geistigem Eigentum
  33594.      und sicherheitsrelevanter Informationen (Passw÷rter!) zur Folge
  33595.      haben. Deshalb ziehen es viele Systemadministratoren vor, eine
  33596.      zweite Verzeichnisstruktur fⁿr Skripte einzurichten, auf die nur
  33597.      durch das PHP-CGI zugegriffen werden kann. Diese werden dann stets
  33598.      interpretiert und nicht angezeigt.
  33599.     </P
  33600. ><P
  33601. >      Auch wenn die Methode zum sichergestellten Verhindern einer Umleitung
  33602.      von Anfragen (wie im vorangegangenen Kapitel beschrieben) nicht
  33603.      verfⁿgbar ist, ist es notwendig, ein doc_root fⁿr Skripte  zusΣtzlich
  33604.      zum Web-Dokumentenverzeichnis einzurichten.
  33605.     </P
  33606. ><P
  33607. >      Sie k÷nnen das PHP-Skriptverzeichnis durch die Direktive
  33608.      <A
  33609. HREF="#ini.doc-root"
  33610. >doc_root</A
  33611. > in der
  33612.      <A
  33613. HREF="#configuration.file"
  33614. >Konfigurationsdatei</A
  33615. >
  33616.      festlegen, oder Sie setzen die Umgebungsvariable
  33617.      <VAR
  33618. CLASS="envar"
  33619. >PHP_DOCUMENT_ROOT</VAR
  33620. >. Wenn sie gesetzt ist, wird die
  33621.      CGI-Version von PHP den Namen der zu ÷ffnenden Datei stets aus
  33622.      <VAR
  33623. CLASS="parameter"
  33624. >doc_root</VAR
  33625. > und der Pfadinformation der Anfrage
  33626.      zusammensetzen, sodass man sicher sein kann, dass au▀erhalb dieses
  33627.      Verzeichnisses keine Skripte ausgefⁿhrt werden (au▀er
  33628.      <VAR
  33629. CLASS="parameter"
  33630. >user_dir</VAR
  33631. >, siehe unten).
  33632.     </P
  33633. ><P
  33634. >      Eine weitere hier nⁿtzliche Option ist <A
  33635. HREF="#ini.user-dir"
  33636. >user_dir</A
  33637. >. Wenn das
  33638.      <VAR
  33639. CLASS="parameter"
  33640. >user_dir</VAR
  33641. > nicht gesetzt ist, hat nur
  33642.      <VAR
  33643. CLASS="parameter"
  33644. >doc_root</VAR
  33645. > Einfluss auf die zu ÷ffnende Datei.
  33646.      Der Aufruf einer URL wie <TT
  33647. CLASS="filename"
  33648. >http://my.host/~user/doc.php</TT
  33649. > hat nicht zum
  33650.      Ergebnis, dass eine Datei im Home-Verzeichnis des Benutzers ge÷ffnet
  33651.      wird, sondern eine Datei namens <TT
  33652. CLASS="filename"
  33653. >~user/doc.php</TT
  33654. >
  33655.      unterhalb des doc_root (Ja, ein Verzeichnisname, der mit einer Tilde anfΣngt
  33656.      [<VAR
  33657. CLASS="literal"
  33658. >~</VAR
  33659. >]).
  33660.     </P
  33661. ><P
  33662. >      Ist das user_dir beispielsweise auf <TT
  33663. CLASS="filename"
  33664. >public_php</TT
  33665. > gesetzt,
  33666.      wird eine Anfrage wie <TT
  33667. CLASS="filename"
  33668. >http://my.host/~user/doc.php</TT
  33669. >
  33670.      eine Datei namens <TT
  33671. CLASS="filename"
  33672. >doc.php</TT
  33673. > im Verzeichnis
  33674.      <TT
  33675. CLASS="filename"
  33676. >public_php</TT
  33677. > im Heimatverzeichnis
  33678.      des Benutzers ÷ffnen.  Wenn das Heimatverzeichnis des Benutzers
  33679.      <TT
  33680. CLASS="filename"
  33681. >/home/user</TT
  33682. > ist, so ist die ausgefⁿhrte
  33683.      Datei <TT
  33684. CLASS="filename"
  33685. >/home/user/public_php/doc.php</TT
  33686. >.
  33687.     </P
  33688. ><P
  33689. >      Die <VAR
  33690. CLASS="parameter"
  33691. >user_dir</VAR
  33692. >-Expansion erfolgt ohne Berⁿcksichtigung
  33693.      der <VAR
  33694. CLASS="parameter"
  33695. >doc_root</VAR
  33696. > Einstellung. So k÷nnen Zugriffe
  33697.      auf die Dokumenten- und Benutzerverzeichnisse separat gesteuert werden.
  33698.     </P
  33699. ></DIV
  33700. ><DIV
  33701. CLASS="sect1"
  33702. ><HR><H2
  33703. CLASS="sect1"
  33704. ><A
  33705. NAME="security.cgi-bin.shell"
  33706. >Fall 4: PHP-Parser au▀erhalb des Webverzeichnisbaums</A
  33707. ></H2
  33708. ><P
  33709. >      Eine sehr sichere Sache ist es, das PHP-Parser-Binary irgendwo
  33710.      au▀erhalb des Webverzeichnisbaums zu platzieren, beispielsweise
  33711.      in <TT
  33712. CLASS="filename"
  33713. >/usr/local/bin</TT
  33714. >.  Der einzige
  33715.      Nachteil dieses Verfahrens ist, dass eine Zeile Σhnlich der folgenden:
  33716.      <DIV
  33717. CLASS="informalexample"
  33718. ><P
  33719. ></P
  33720. ><A
  33721. NAME="AEN5652"
  33722. ></A
  33723. ><TABLE
  33724. BORDER="0"
  33725. BGCOLOR="#E0E0E0"
  33726. CELLPADDING="5"
  33727. ><TR
  33728. ><TD
  33729. ><PRE
  33730. CLASS="programlisting"
  33731. >#!/usr/local/bin/php</PRE
  33732. ></TD
  33733. ></TR
  33734. ></TABLE
  33735. ><P
  33736. ></P
  33737. ></DIV
  33738. >
  33739.      als erste Zeile in jeder Datei, die PHP-Tags enthΣlt, stehen muss.
  33740.      Au▀erdem muss die Datei ausfⁿhrbar sein. Ansonsten ist sie genauso
  33741.      zu behandeln wie ein beliebiges CGI-Script in Perl oder sh oder
  33742.      anderen gebrΣuchlichen Scriptsprachen, die den
  33743.      <VAR
  33744. CLASS="literal"
  33745. >#!</VAR
  33746. > shell-escape-Mechanismus nutzen, um sich
  33747.      selbst aufzurufen.
  33748.     </P
  33749. ><P
  33750. >      Damit PHP bei dieser Konfiguration die <VAR
  33751. CLASS="envar"
  33752. >PATH_INFO</VAR
  33753. >- und
  33754.      <VAR
  33755. CLASS="envar"
  33756. >PATH_TRANSLATED</VAR
  33757. >-Informationen korrekt auswertet,
  33758.      sollte der PHP-Parser mit der Option <A
  33759. HREF="#configure.enable-discard-path"
  33760. >--enable-discard-path</A
  33761. >
  33762.      kompiliert werden.
  33763.     </P
  33764. ></DIV
  33765. ></DIV
  33766. ><DIV
  33767. CLASS="chapter"
  33768. ><HR><H1
  33769. ><A
  33770. NAME="security.apache"
  33771. >Kapitel 23. Apache-Modul</A
  33772. ></H1
  33773. ><P
  33774. >     Wenn PHP als Apache-Modul eingesetzt wird, ⁿbernimmt es die
  33775.     Benutzerrechte des Apache (ⁿblicherweise user "nobody"). Das hat
  33776.     verschiedene Auswirkungen auf Sicherheit und Authentifizierung, z.B.:
  33777.     Wenn Sie PHP zum Zugriff auf eine Datenbank benutzen, es sei denn
  33778.     diese Datenbank hat eine integrierte Zugriffskontrolle, mⁿssen Sie
  33779.     dem Benutzer "nobody" Zugriffsrechte auf die Datenbank erteilen. Das
  33780.     hei▀t, dass ein b÷swilliges Skript auch Benutzerkennung und Passwort
  33781.     auf die Datenbank zugreifen, und sie verΣndern k÷nnte. Es ist durchaus
  33782.     m÷glich, dass ein Web-Spider ⁿber die Webseite eines
  33783.     Datenbankadministrators stolpert, und alle Ihre Datenbanken l÷scht.
  33784.     Sie k÷nnen sich dagegen mit Apache Authentifizierung schⁿtzen, oder
  33785.     ein eigenes Zugangsmodell unter Verwendung von LDAP, .htaccess Dateien,
  33786.     etc. entwerfen, und diesen Code als Teil Ihrer PHP Skripte einbinden.
  33787.    </P
  33788. ><P
  33789. >     Es wurde festgestellt, dass wenn einmal die Sicherheitsma▀nahmen so
  33790.     weit eingerichtet sind dass dem PHP User (in diesem Fall ein Apache
  33791.     User) nur mehr ein geringes Risiko bleibt, PHP daran gehindert wird,
  33792.     virenverseuchte Dateien in das Benutzerverzeichnis zu schreiben. Oder
  33793.     vielleicht wurde es auch daran gehindert, auf Datenbanken zuzugreifen
  33794.     oder diese gar zu verΣndern. In gleicher Weise wird auch davor
  33795.     abgehalten, "gute" oder "b÷sartige" Dateien zu schreiben, oder "gute"
  33796.     bzw. "b÷sartige" Datenbanktransaktionen durchzufⁿhren.
  33797.    </P
  33798. ><P
  33799. >     Ein hΣufig gemachter Fehler in Punkto Sicherheit ist Apache Root-Rechte
  33800.     zu erteilen, oder die M÷glichkeiten von Apache in einer anderen Weise
  33801.     auszuweiten.
  33802.    </P
  33803. ><P
  33804. >     Die Ausweitung der Benutzerrechte fⁿr Apache auf root ist sehr
  33805.     gefΣhrlich, und kann dem gesamten System schaden, denn mit sudo,
  33806.     chroot, oder anderwΣrtig als root zu arbeiten sollte niemand anders
  33807.     als den Sicherheitsprofis ⁿberlassen werden.
  33808.    </P
  33809. ><P
  33810. >     Es gibt auch ein paar einfachere L÷sungen. Mit
  33811.     <A
  33812. HREF="#ini.open-basedir"
  33813. >open_basedir()</A
  33814. > k÷nnen Sie
  33815.     kontrollieren, welche Verzeichnisse PHP benutzen darf oder nicht. Sie
  33816.     k÷nnen auch einen Bereich nur fⁿr Apache einrichten, um alle
  33817.     webbasierten AktivitΣten auf nicht-Benutzer- bzw. nicht-System-Dateien
  33818.     einzuschrΣnken.
  33819.    </P
  33820. ></DIV
  33821. ><DIV
  33822. CLASS="chapter"
  33823. ><HR><H1
  33824. ><A
  33825. NAME="security.filesystem"
  33826. >Kapitel 24. Dateisystem - Sicherheit</A
  33827. ></H1
  33828. ><P
  33829. >     PHP ist von den in den meisten Serversystemen implementierten
  33830.     Sicherheitseinstellungen hinsichtlich der Berechtigungen auf Datei-
  33831.     und Verzeichnisebene abhΣngig. Dies verleiht Ihnen Kontrolle darⁿber,
  33832.     welche Dateien in dem Dateisystem gelesen werden dⁿrfen. Vorsicht ist
  33833.     bei weltweit lesbaren Dateien geboten um sicherzustellen, dass diese
  33834.     sicher von allen Usern mit Zugriff auf dieses Dateisystem (nur) gelesen
  33835.     werden k÷nnen.
  33836.    </P
  33837. ><P
  33838. >     Da PHP entwickelt wurde um Zugriffe auf das Dateisystem auf Benutzebene
  33839.     zu erlauben, ist es natⁿrlich auch m÷glich ein PHP Skript zu schreiben
  33840.     das Ihnen erlaubt Systemdateien wie /etc/passwd zu lesen,
  33841.     Ethernetverbindungen zu modifizieren, enorme DruckauftrΣge zu senden,
  33842.     etc. Dies hat offensichtliche Implikationen, indem Sie sicherstellen
  33843.     mⁿssen, dass alle von Ihnen zu lesenden bzw. zu schreibenden Dateien
  33844.     auch die richtigen sind.
  33845.    </P
  33846. ><P
  33847. >     Stellen Sie sich folgendes Skript vor, in dem ein User zum Ausdruck
  33848.     bringt, dass gerne eine Datei in seinem Heimatverzeichnis l÷schen
  33849.     m÷chte. Dies geht von einer Situation aus, in der ein PHP Web-Interface
  33850.     regelmΣ▀ig zum Dateimanagement verwendet wird, und der Apache User
  33851.     ist auch berechtigt, in seinem Heimatverzeichnis Dateien zu l÷schen.
  33852.    </P
  33853. ><P
  33854. >     <TABLE
  33855. WIDTH="100%"
  33856. BORDER="0"
  33857. CELLPADDING="0"
  33858. CELLSPACING="0"
  33859. CLASS="EXAMPLE"
  33860. ><TR
  33861. ><TD
  33862. ><DIV
  33863. CLASS="example"
  33864. ><A
  33865. NAME="AEN5673"
  33866. ></A
  33867. ><P
  33868. ><B
  33869. >Beispiel 24-1. Schlechte Variablenprⁿfung fⁿhrt zu....</B
  33870. ></P
  33871. ><TABLE
  33872. BORDER="0"
  33873. BGCOLOR="#E0E0E0"
  33874. CELLPADDING="5"
  33875. ><TR
  33876. ><TD
  33877. ><PRE
  33878. CLASS="php"
  33879. ><?php
  33880. // L÷schen einer Datei aus dem Heimatverzeichnis des Users
  33881. $username = $_POST['user_submitted_name'];
  33882. $homedir = "/home/$username";
  33883. $file_to_delete = "$userfile";
  33884. unlink ("$homedir/$userfile");
  33885. echo "$file_to_delete wurde gel÷scht!";
  33886. ?></PRE
  33887. ></TD
  33888. ></TR
  33889. ></TABLE
  33890. ></DIV
  33891. ></TD
  33892. ></TR
  33893. ></TABLE
  33894. >
  33895.    Da der Benutzername ⁿber ein User-Formular zu posten ist, kann
  33896.    jeder einen Benutzer- und Dateinamen von jemand anderen ⁿbertragen,
  33897.    und Dateien l÷schen. In diesem Fall empfiehlt es sich, eine andere
  33898.    Form der Authentifizierung zu verwenden. Stellen Sie sich vor was
  33899.    passieren wⁿrde, wenn die ⁿbertragenen Variablen "../etc/" und
  33900.    "passwd" beinhalten wⁿrden. Der Code wⁿrde dann effektiv lesen:
  33901.     <TABLE
  33902. WIDTH="100%"
  33903. BORDER="0"
  33904. CELLPADDING="0"
  33905. CELLSPACING="0"
  33906. CLASS="EXAMPLE"
  33907. ><TR
  33908. ><TD
  33909. ><DIV
  33910. CLASS="example"
  33911. ><A
  33912. NAME="AEN5676"
  33913. ></A
  33914. ><P
  33915. ><B
  33916. >Beispiel 24-2. ... Ein Angriff auf das Dateisystem</B
  33917. ></P
  33918. ><TABLE
  33919. BORDER="0"
  33920. BGCOLOR="#E0E0E0"
  33921. CELLPADDING="5"
  33922. ><TR
  33923. ><TD
  33924. ><PRE
  33925. CLASS="php"
  33926. ><?php
  33927. // l÷scht eine Datei irgendwo auf der Festplatte, wo der
  33928. // Benutzer die n÷tigen Rechte besitzt. Wenn PHP root hat:
  33929. $username = "../etc/";
  33930. $homedir = "/home/../etc/";
  33931. $file_to_delete = "passwd";
  33932. unlink ("/home/../etc/passwd");
  33933. echo "/home/../etc/passwd wurde gel÷scht!";
  33934. ?></PRE
  33935. ></TD
  33936. ></TR
  33937. ></TABLE
  33938. ></DIV
  33939. ></TD
  33940. ></TR
  33941. ></TABLE
  33942. >
  33943.     Es gibt zwei wichtige Kriterien die Sie beachten sollten, um diese
  33944.     Dinge zu vermeiden:
  33945.     <P
  33946. ></P
  33947. ><UL
  33948. ><LI
  33949. ><P
  33950. >        Erteilen Sie dem PHP Web-user (BinΣrdatei) nur eingeschrΣnkte Rechte.
  33951.       </P
  33952. ></LI
  33953. ><LI
  33954. ><P
  33955. >        Prⁿfen Sie alle ⁿbertragenen Variablen.
  33956.       </P
  33957. ></LI
  33958. ></UL
  33959. >
  33960.     Hier ist ein verbessertes Skript:
  33961.     <TABLE
  33962. WIDTH="100%"
  33963. BORDER="0"
  33964. CELLPADDING="0"
  33965. CELLSPACING="0"
  33966. CLASS="EXAMPLE"
  33967. ><TR
  33968. ><TD
  33969. ><DIV
  33970. CLASS="example"
  33971. ><A
  33972. NAME="AEN5684"
  33973. ></A
  33974. ><P
  33975. ><B
  33976. >Beispiel 24-3. Etwas sicherere Prⁿfung des Dateinamens</B
  33977. ></P
  33978. ><TABLE
  33979. BORDER="0"
  33980. BGCOLOR="#E0E0E0"
  33981. CELLPADDING="5"
  33982. ><TR
  33983. ><TD
  33984. ><PRE
  33985. CLASS="php"
  33986. ><?php
  33987. // l÷scht eine Datei von der Festplatte, auf die
  33988. // der PHP user Zugriff hat.
  33989. $username = $_SERVER['REMOTE_USER']; // verwendet eine
  33990.                                      // Authentifizierungsmethode
  33991. $homedir = "/home/$username";
  33992.  
  33993. $file_to_delete = basename("$userfile"); // den Pfad entfernen
  33994. unlink ($homedir/$file_to_delete);
  33995.  
  33996. $fp = fopen("/home/logging/filedelete.log","+a"); //logge die L÷schung
  33997. $logstring = "$username $homedir $file_to_delete";
  33998. fputs ($fp, $logstring);
  33999. fclose($fp);
  34000.  
  34001. echo "$file_to_delete wurde gel÷scht!";
  34002. ?></PRE
  34003. ></TD
  34004. ></TR
  34005. ></TABLE
  34006. ></DIV
  34007. ></TD
  34008. ></TR
  34009. ></TABLE
  34010. >
  34011.     Auch dies nicht v÷llig makellos. Wenn Ihr Authentifizierungssystem
  34012.     Benutzern erlauben sollte, deren eigene Logins zu kreieren, und ein
  34013.     Benutzer wΣhlt den Login "../etc", ist das System wieder aufgedeckt.
  34014.     Aus diesem Grund ziehen Sie es vielleicht vor, einen besseren Check
  34015.     zu schreiben:
  34016.     <TABLE
  34017. WIDTH="100%"
  34018. BORDER="0"
  34019. CELLPADDING="0"
  34020. CELLSPACING="0"
  34021. CLASS="EXAMPLE"
  34022. ><TR
  34023. ><TD
  34024. ><DIV
  34025. CLASS="example"
  34026. ><A
  34027. NAME="AEN5687"
  34028. ></A
  34029. ><P
  34030. ><B
  34031. >Beispiel 24-4. Sicherere Dateinamensprⁿfung</B
  34032. ></P
  34033. ><TABLE
  34034. BORDER="0"
  34035. BGCOLOR="#E0E0E0"
  34036. CELLPADDING="5"
  34037. ><TR
  34038. ><TD
  34039. ><PRE
  34040. CLASS="php"
  34041. ><?php
  34042. $username = $HTTP_SERVER_VARS['REMOTE_USER']; // verwendet eine
  34043.                                               // Authentifizierungsmethode
  34044. $homedir = "/home/$username";
  34045.  
  34046. if (!ereg('^[^./][^/]*$', $userfile))
  34047.     die('bad filename'); // "DIE", gehen Sie nicht weiter
  34048.  
  34049. if (!ereg('^[^./][^/]*$', $username))
  34050.      die('bad username'); // "DIE", gehen Sie nicht weiter
  34051. //etc...
  34052. ?></PRE
  34053. ></TD
  34054. ></TR
  34055. ></TABLE
  34056. ></DIV
  34057. ></TD
  34058. ></TR
  34059. ></TABLE
  34060. >
  34061.    </P
  34062. ><P
  34063. >     AbhΣngig vom Betriebssystem gibt es eine gro▀e Anzahl Dateien mit der
  34064.     Sie sich befassen sollten, inklusive EintrΣge fⁿr GerΣte (/dev/ oder
  34065.     com1), Konfigurationsdateien (/etc/ Dateien und die .ini Dateien), gut
  34066.     bekannte Verzeichnisse (/home/, My Documents), etc. Aus diesem Grund
  34067.     ist es gew÷hnlich einfacher eine Vorgangsweise einzufⁿhren, bei der
  34068.     au▀er den von Ihnen explizit erlaubten Dingen alles verboten ist.
  34069.    </P
  34070. ></DIV
  34071. ><DIV
  34072. CLASS="chapter"
  34073. ><HR><H1
  34074. ><A
  34075. NAME="security.database"
  34076. >Kapitel 25. Datenbank - Sicherheit</A
  34077. ></H1
  34078. ><P
  34079. >     Heutzutage sind Datenbanken die Hauptkomponenten jeder Webbasierten
  34080.     Applikation, aufgrund welcher Websites verschiedene dynamische Inhalte
  34081.     anbieten k÷nnen. Nachdem heikle oder geheime Informationen in solch einer
  34082.     Datenbank gespeichert werden k÷nnen, sollten Sie deren Schutz ernsthaft
  34083.     bedenken.
  34084.    </P
  34085. ><P
  34086. >     Um Informationen zu bekommen oder zu speichern, mⁿssen Sie eine legitime
  34087.     Abfrage senden, das Ergebnis holen, und die Verbindung schlie▀en.
  34088.     Heutzutage ist die allgemein verwendete Abfragesprache fⁿr solche
  34089.     Interaktionen die Structured Query Language (SQL). Sehen Sie, wie sich ein
  34090.     Angreifer <A
  34091. HREF="#security.database.sql-injection"
  34092. >an einer SQL
  34093.     Abfrage zu schaffen machen</A
  34094. > kann.
  34095.    </P
  34096. ><P
  34097. >     Sie werden merken, dass PHP Ihre Datenbank alleine nicht schⁿtzen kann.
  34098.     Die folgenden Abschnitte sind eine Einfⁿhrung in die Grundlagen, wie man
  34099.     innerhalb von PHP Skripten auf Datenbanken zugreift und diese manipuliert.
  34100.    </P
  34101. ><P
  34102. >     Denken Sie an diese einfache Regel: tief gestaffelte Verteidigung. Je mehr
  34103.     Platz Sie den Ma▀nahmen zum Schutz Ihrer Datenbank geben, desto geringer
  34104.     ist die Wahrscheinlichkeit, dass ein Angreifer Erfolg hat, und gespeicherte
  34105.     Geheiminformationen aufdeckt oder missbraucht. Gutes Design des
  34106.     Datenbankschemas und die Applikation wird mit Ihren gr÷▀ten Befⁿrchtungen
  34107.     fertig.
  34108.    </P
  34109. ><DIV
  34110. CLASS="sect1"
  34111. ><HR><H2
  34112. CLASS="sect1"
  34113. ><A
  34114. NAME="security.database.design"
  34115. >Datenbanken designen</A
  34116. ></H2
  34117. ><P
  34118. >       Der Erste Schritt liegt immer im Erstellen der Datenbank, au▀er Sie wollen
  34119.       eine bereits existierende Dritter verwenden. Ist eine Datenbank erstellt,
  34120.       ist sie einem Eigentⁿmer zugewiesen, welcher das Kommando zum Erstellen
  34121.       ausgefⁿhrt hat. Gew÷hnlich kann nur der Eigentⁿmer (oder ein Superuser)
  34122.       alles mit den Objekten in dieser Datenbank machen, und um anderen Benutzern
  34123.       die Verwendung zu erlauben, mⁿssen Rechte vergeben werden.
  34124.      </P
  34125. ><P
  34126. >       Applikationen sollten sich mit der Datenbank nie als deren Eigentⁿmer
  34127.       oder als ein Superuser verbinden, da diese Benutzer jede gewollte Abfrage
  34128.       ausfⁿhren k÷nnen, um z.B. das Schema zu modifizieren (z.B. Tabellen
  34129.       l÷schen) oder den gesamten Inhalt l÷schen.
  34130.      </P
  34131. ><P
  34132. >       Sie k÷nnen verschiedene Datenbanknutzer mit sehr limitierten Rechten auf
  34133.       Datenbankobjekte fⁿr jeden Aspekt Ihrer Applikation anlegen. Nur die
  34134.       wirklich ben÷tigten Rechte sollten gewΣhrt werden, und vermeiden Sie, dass
  34135.       der gleiche Benutzer in verschiedenen AnwendungsfΣllen mit der Datenbank
  34136.       interagieren kann. Das hei▀t, dass Eindringlinge, welche unter Verwendung
  34137.       einer dieser Referenzen Zugriff auf Ihre Datenbank erlangt haben, nur so
  34138.       viele ─nderungen durchfⁿhren k÷nnen, wie es Ihre Applikation kann.
  34139.      </P
  34140. ><P
  34141. >       Implementieren Sie nicht alle GeschΣftslogik in die Webapplikation (z.B.
  34142.       Ihr Skript), sondern tun Sie das im Datenbankschema unter Verwendung von
  34143.       Sichten, Triggern, oder Regeln. Wenn sich das System entwickelt, werden
  34144.       neu zu ÷ffnende Ports zu der Datenbank vorgesehen, und Sie mⁿssen die
  34145.       Logik in jedem Datenbank-Client neu implementieren. ▄berdies k÷nnen
  34146.       Trigger verwendet werden, um transparent und automatisch mit Feldern
  34147.       umzugehen, welche beim debuggen Ihrer Applikation oder beim
  34148.       Zurⁿckverfolgen von Transaktionen oft einen Einblick gewΣhren.
  34149.      </P
  34150. ></DIV
  34151. ><DIV
  34152. CLASS="sect1"
  34153. ><HR><H2
  34154. CLASS="sect1"
  34155. ><A
  34156. NAME="security.database.connection"
  34157. >Zur Datenbank verbinden</A
  34158. ></H2
  34159. ><P
  34160. >      Vielleicht wollen Sie die Verbindungen ⁿber SSL herstellen, um die
  34161.      Client/Server Kommunikation fⁿr eine erh÷hte Sicherheit zu verschlⁿsseln,
  34162.      oder aber auch ssh verwenden, um die Netzwerkverbindung zwischen den
  34163.      Clients und dem Datenbankserver zu verschlⁿsseln. Ist eines davon
  34164.      realisiert, wird ein Monitoring Ihres Verkehrs und das Erlangen von
  34165.      Informationen zu harter Arbeit.
  34166.     </P
  34167. ></DIV
  34168. ><DIV
  34169. CLASS="sect1"
  34170. ><HR><H2
  34171. CLASS="sect1"
  34172. ><A
  34173. NAME="security.database.storage"
  34174. >Verschlⁿsseltes Speichermodell</A
  34175. ></H2
  34176. ><P
  34177. >      SSL/SSH schⁿtzt zwar die gerade auf dem Weg befindlichen Daten vom Client
  34178.      zum Server, jedoch nicht die dauernd in einer Datenbank gespeicherten
  34179.      Daten. SSL ist ein "auf-der-Leitung" Protokoll.
  34180.     </P
  34181. ><P
  34182. >      Hat ein Angreifer direkten Zugriff auf Ihre Datenbank (den Webserver
  34183.      umgehend), k÷nnen die gespeicherten heiklen Daten aufgedeckt oder
  34184.      zweckentfremdet werden, au▀er wenn die Information von der Datenbank selbst
  34185.      geschⁿtzt ist. Die Daten zu verschlⁿsseln ist ein guter Weg, diese Gefahr
  34186.      zu mildern, doch bieten nur wenige Datenbanken diese Art der
  34187.      Verschlⁿsselung von Daten.
  34188.     </P
  34189. ><P
  34190. >      Der einfachste Weg, dieses Problem zu umgehen ist, erst einmal Ihr eigenes
  34191.      Verschlⁿsselungspaket zu erstellen, und dieses dann in Ihren PHP Skripten
  34192.      zu nutzen. PHP kann Ihnen in diesem Fall mit seinen verschiedenen
  34193.      Erweiterungen helfen, wie z.B. <A
  34194. HREF="#ref.mcrypt"
  34195. >Mcrypt</A
  34196. >
  34197.      and <A
  34198. HREF="#ref.mhash"
  34199. >Mhash</A
  34200. >, welche eine gro▀e Auswahl an
  34201.      Verschlⁿsselungsalgorhythmen abdecken. Das Skript verschlⁿsselt die Daten
  34202.      vor dem Speichern, und entschlⁿsselt diese wieder beim Erhalt. Siehe die
  34203.      Verweise fⁿr weitere Beispiele, wie Verschlⁿsselung arbeitet.
  34204.     </P
  34205. ><P
  34206. >      Im Fall von wirklich versteckten Daten, wenn deren unverfΣlschte
  34207.      ReprΣsentation nicht n÷tig ist (z.B. keine Anzeige), ist hashing ebenfalls
  34208.      ⁿberlegenswert. Das bekannte Beispiel fⁿr das Hashing ist das Speichern des
  34209.      MD5 hash eines Passwortes in einer Datenbank, anstatt des Passwortes selbst.
  34210.      Siehe auch <A
  34211. HREF="#function.crypt"
  34212. ><B
  34213. CLASS="function"
  34214. >crypt()</B
  34215. ></A
  34216. > und <A
  34217. HREF="#function.md5"
  34218. ><B
  34219. CLASS="function"
  34220. >md5()</B
  34221. ></A
  34222. >.
  34223.     </P
  34224. ><TABLE
  34225. WIDTH="100%"
  34226. BORDER="0"
  34227. CELLPADDING="0"
  34228. CELLSPACING="0"
  34229. CLASS="EXAMPLE"
  34230. ><TR
  34231. ><TD
  34232. ><DIV
  34233. CLASS="example"
  34234. ><A
  34235. NAME="AEN5717"
  34236. ></A
  34237. ><P
  34238. ><B
  34239. >Beispiel 25-1. Verwenden eines hashed Passwortfeldes</B
  34240. ></P
  34241. ><TABLE
  34242. BORDER="0"
  34243. BGCOLOR="#E0E0E0"
  34244. CELLPADDING="5"
  34245. ><TR
  34246. ><TD
  34247. ><PRE
  34248. CLASS="php"
  34249. >// Speichern des Passwort hash
  34250. $query  = sprintf("INSERT INTO users(name,pwd) VALUES('%s','%s');",
  34251.             addslashes($username), md5($password));
  34252. $result = pg_exec($connection, $query);
  34253.  
  34254. // Afragen, ob der User das richtige Passwort ⁿbermittelt hat
  34255. $query = sprintf("SELECT 1 FROM users WHERE name='%s' AND pwd='%s';",
  34256.             addslashes($username), md5($password));
  34257. $result = pg_exec($connection, $query);
  34258.  
  34259. if (pg_numrows($result) > 0) {
  34260.     echo "Welcome, $username!";
  34261. }
  34262. else {
  34263.     echo "Authentication failed for $username.";
  34264. }</PRE
  34265. ></TD
  34266. ></TR
  34267. ></TABLE
  34268. ></DIV
  34269. ></TD
  34270. ></TR
  34271. ></TABLE
  34272. ></DIV
  34273. ><DIV
  34274. CLASS="sect1"
  34275. ><HR><H2
  34276. CLASS="sect1"
  34277. ><A
  34278. NAME="security.database.sql-injection"
  34279. >SQL Injection</A
  34280. ></H2
  34281. ><P
  34282. >      Viele Entwickler sind sich nicht bewusst, wie man sich an SQL Abfragen
  34283.      zu schaffen machen kann und nehmen an, dass eine SQL Abfrage ein
  34284.      vertrauenswⁿrdiges Kommando ist. Das hei▀t, dass SQL Abfragen
  34285.      Zugriffskontrollen hinters Licht fⁿhren, und dadurch Standard
  34286.      Authentifizierungs- und Authorisationschecks umgehen k÷nnen, und
  34287.      manchmal k÷nnen SQL Abfragen sogar Zugriff zu Kommandos auf
  34288.      Betriebssystemebene erlauben.
  34289.     </P
  34290. ><P
  34291. >      Direkt SQL Command Injection ist eine Technik, wo ein Angreifer SQL
  34292.      Kommandos erstellt oder existierende verΣndert, um versteckte Daten
  34293.      sichtbar zu machen, wertvolle Daten zu ⁿberschreiben, oder sogar
  34294.      gefΣhrliche Kommandos auf Systemebene des Datenbank-Hosts auszufⁿhren.
  34295.      Dies wird durch die Applikation erreicht, welche den Input des Benutzers
  34296.      mit statischen Parametern kombiniert, um eine SQL Abfrage zu erstellen.
  34297.      Die folgenden Beispiele basieren - leider - auf wahren Begebenheiten.
  34298.     </P
  34299. ><P
  34300. >      Dank dem Mangel an Input Validierungen, und dem Verbinden zum
  34301.      Datenbankserver als ein Superuser oder jemand der Benutzer anlegen kann,
  34302.      kann ein Angreifer einen Superuser in Ihrer Datenbank anlegen.
  34303.      <TABLE
  34304. WIDTH="100%"
  34305. BORDER="0"
  34306. CELLPADDING="0"
  34307. CELLSPACING="0"
  34308. CLASS="EXAMPLE"
  34309. ><TR
  34310. ><TD
  34311. ><DIV
  34312. CLASS="example"
  34313. ><A
  34314. NAME="AEN5725"
  34315. ></A
  34316. ><P
  34317. ><B
  34318. >Beispiel 25-2. 
  34319.        Die Ergebnisliste in mehrere Seiten aufsplitten ... und Superuser anlegen
  34320.        (PostgreSQL and MySQL)
  34321.       </B
  34322. ></P
  34323. ><TABLE
  34324. BORDER="0"
  34325. BGCOLOR="#E0E0E0"
  34326. CELLPADDING="5"
  34327. ><TR
  34328. ><TD
  34329. ><PRE
  34330. CLASS="php"
  34331. >$offset = argv[0]; // Vorsicht, keine Validierung des Input !
  34332. $query  = "SELECT id, name FROM products ORDER BY name LIMIT 20 OFFSET $offset;";
  34333. // mit PostgreSQL
  34334. $result = pg_exec($conn, $query);
  34335. // mit MySQL
  34336. $result = mysql_query($query);</PRE
  34337. ></TD
  34338. ></TR
  34339. ></TABLE
  34340. ></DIV
  34341. ></TD
  34342. ></TR
  34343. ></TABLE
  34344. >
  34345.       Normale Benutzer klicken auf die 'nΣchste' bzw. 'vorige' Links, wo
  34346.       <VAR
  34347. CLASS="varname"
  34348. >$offset</VAR
  34349. > in der URL enthalten ist. Das Skript erwartet,
  34350.       dass die ankommende <VAR
  34351. CLASS="varname"
  34352. >$offset</VAR
  34353. > einen Dezimalwert enthΣlt.
  34354.       Ganz gleich, jemand versucht einzubrechen, indem er das folgende in einer
  34355.       <A
  34356. HREF="#function.urlencode"
  34357. ><B
  34358. CLASS="function"
  34359. >urlencode()</B
  34360. ></A
  34361. >'d Form an die URL anhΣngt
  34362.       <DIV
  34363. CLASS="informalexample"
  34364. ><P
  34365. ></P
  34366. ><A
  34367. NAME="AEN5731"
  34368. ></A
  34369. ><TABLE
  34370. BORDER="0"
  34371. BGCOLOR="#E0E0E0"
  34372. CELLPADDING="5"
  34373. ><TR
  34374. ><TD
  34375. ><PRE
  34376. CLASS="programlisting"
  34377. >// Im Fall von PostgreSQL
  34378. 0;
  34379. insert into pg_shadow(usename,usesysid,usesuper,usecatupd,passwd)
  34380.     select 'crack', usesysid, 't','t','crack'
  34381.     from pg_shadow where usename='postgres';
  34382. --
  34383.  
  34384. // Im Fall von MySQL
  34385. 0;
  34386. UPDATE user SET Password=PASSWORD('crack') WHERE user='root';
  34387. FLUSH PRIVILEGES;</PRE
  34388. ></TD
  34389. ></TR
  34390. ></TABLE
  34391. ><P
  34392. ></P
  34393. ></DIV
  34394. >
  34395.       Wenn es passiert ist, wⁿrde ihm das Skript einen Zugriff als Superuser
  34396.       prΣsentieren. Beachten Sie, dass <VAR
  34397. CLASS="literal"
  34398. >0;</VAR
  34399. > ein gⁿltiges
  34400.       Offset zur ursprⁿnglichen Abfrage liefert, und sie beendet.
  34401.     </P
  34402. ><DIV
  34403. CLASS="note"
  34404. ><BLOCKQUOTE
  34405. CLASS="note"
  34406. ><P
  34407. ><B
  34408. >Anmerkung: </B
  34409. >
  34410.       Es ist eine ⁿbliche Technik, den SQL Parser mittels dem Kommentarzeichen
  34411.       in SQL <VAR
  34412. CLASS="literal"
  34413. >--</VAR
  34414. > zu zwingen, den Rest der vom Entwickler
  34415.       geschriebenen Abfrage zu ignorieren.
  34416.      </P
  34417. ></BLOCKQUOTE
  34418. ></DIV
  34419. ><P
  34420. >      Ein gangbarer Weg um Passw÷rter zu finden ist, Ihre Seiten mit den
  34421.      Suchergebnissen hinters Licht zu fⁿhren. Der Angreifer braucht nur zu
  34422.      probieren, ob irgendeine ⁿbertragene Variable, die in dem SQL Statement
  34423.      verwendet wird, nicht richtig gehandhabt wird. Diese Filter k÷nnen
  34424.      gew÷hnlich in einer vorausgehenden Form gesetzt werden, indem
  34425.      <VAR
  34426. CLASS="literal"
  34427. >WHERE, ORDER BY, LIMIT</VAR
  34428. > und <VAR
  34429. CLASS="literal"
  34430. >OFFSET</VAR
  34431. >
  34432.      Klauseln in <VAR
  34433. CLASS="literal"
  34434. >SELECT</VAR
  34435. > Statements umgebaut werden. Wenn
  34436.      Ihre Datenbank das <VAR
  34437. CLASS="literal"
  34438. >UNION</VAR
  34439. > Konstrukt unterstⁿtzt, kann
  34440.      der Angreifer versuchen, eine komplette Abfrage an das Original anzuhΣngen,
  34441.      um Pa▀w÷rter aus einer willkⁿrlichen Tabelle aufzulisten. Die Verwendung
  34442.      von verschlⁿsselten Passwortfeldern wird ausdrⁿcklich empfohlen.
  34443.      <TABLE
  34444. WIDTH="100%"
  34445. BORDER="0"
  34446. CELLPADDING="0"
  34447. CELLSPACING="0"
  34448. CLASS="EXAMPLE"
  34449. ><TR
  34450. ><TD
  34451. ><DIV
  34452. CLASS="example"
  34453. ><A
  34454. NAME="AEN5742"
  34455. ></A
  34456. ><P
  34457. ><B
  34458. >Beispiel 25-3. 
  34459.        Artikel auflisten ... und ein paar Passw÷rter (irgendein Datenbankserver)
  34460.       </B
  34461. ></P
  34462. ><TABLE
  34463. BORDER="0"
  34464. BGCOLOR="#E0E0E0"
  34465. CELLPADDING="5"
  34466. ><TR
  34467. ><TD
  34468. ><PRE
  34469. CLASS="php"
  34470. >$query  = "SELECT id, name, inserted, size FROM products
  34471.                   WHERE size = '$size'
  34472.                   ORDER BY $order LIMIT $limit, $offset;";
  34473. $result = odbc_exec($conn, $query);</PRE
  34474. ></TD
  34475. ></TR
  34476. ></TABLE
  34477. ></DIV
  34478. ></TD
  34479. ></TR
  34480. ></TABLE
  34481. >
  34482.      Der statische Teil der Abfrage kann mit einem anderen
  34483.      <VAR
  34484. CLASS="literal"
  34485. >SELECT</VAR
  34486. > Statement kombiniert werden, welches alle
  34487.      Passw÷rter preisgibt
  34488.      <DIV
  34489. CLASS="informalexample"
  34490. ><P
  34491. ></P
  34492. ><A
  34493. NAME="AEN5746"
  34494. ></A
  34495. ><TABLE
  34496. BORDER="0"
  34497. BGCOLOR="#E0E0E0"
  34498. CELLPADDING="5"
  34499. ><TR
  34500. ><TD
  34501. ><PRE
  34502. CLASS="programlisting"
  34503. >'
  34504. union select '1', concat(uname||'-'||passwd) as name, '1971-01-01', '0' from usertable;
  34505. --</PRE
  34506. ></TD
  34507. ></TR
  34508. ></TABLE
  34509. ><P
  34510. ></P
  34511. ></DIV
  34512. >
  34513.      Wenn diese Abfrage (mit dem <VAR
  34514. CLASS="literal"
  34515. >'</VAR
  34516. > und
  34517.      <VAR
  34518. CLASS="literal"
  34519. >--</VAR
  34520. >) einer der in <VAR
  34521. CLASS="varname"
  34522. >$query</VAR
  34523. > verwendeten
  34524.      Variablen zugewiesen wⁿrde, wΣre das "Abfragebiest" erwacht.
  34525.     </P
  34526. ><P
  34527. >      SQL UPDATEs sind ebenfalls ein Anlass, Ihre Datenbank anzugreifen. Diese
  34528.      Abfragen sind auch durch das ─ndern und AnhΣngen einer komplett neuen
  34529.      Abfrage gefΣhrdet. Aber der Angreifer k÷nnte auch mit der
  34530.      <VAR
  34531. CLASS="literal"
  34532. >SET</VAR
  34533. > Klausel herumspielen. In diesem Fall muss eine
  34534.      Schemainformation vorhanden sein, um die Abfrage erfolgreich manipulieren
  34535.      zu k÷nnen. Diese kann durch Untersuchen der Variablennamen im Formular,
  34536.      oder simpel mittels brute force gesammelt werden. Es gibt nicht so viele
  34537.      Namenskonventionen fⁿr Felder, welche Passw÷rter oder Benutzernamen
  34538.      speichern.
  34539.      <TABLE
  34540. WIDTH="100%"
  34541. BORDER="0"
  34542. CELLPADDING="0"
  34543. CELLSPACING="0"
  34544. CLASS="EXAMPLE"
  34545. ><TR
  34546. ><TD
  34547. ><DIV
  34548. CLASS="example"
  34549. ><A
  34550. NAME="AEN5753"
  34551. ></A
  34552. ><P
  34553. ><B
  34554. >Beispiel 25-4. 
  34555.       Vom Zurⁿcksetzen eines Passwortes ... zum Erlangen von mehr Rechten
  34556.       (irgendein Datenbankserver)
  34557.      </B
  34558. ></P
  34559. ><TABLE
  34560. BORDER="0"
  34561. BGCOLOR="#E0E0E0"
  34562. CELLPADDING="5"
  34563. ><TR
  34564. ><TD
  34565. ><PRE
  34566. CLASS="php"
  34567. >$query = "UPDATE usertable SET pwd='$pwd' WHERE uid='$uid';";</PRE
  34568. ></TD
  34569. ></TR
  34570. ></TABLE
  34571. ></DIV
  34572. ></TD
  34573. ></TR
  34574. ></TABLE
  34575. >
  34576.      Aber ein b÷swilliger Benutzer ⁿbermittelt den Wert
  34577.      <VAR
  34578. CLASS="literal"
  34579. >' or uid like'%admin%'; --</VAR
  34580. > zu <VAR
  34581. CLASS="varname"
  34582. >$uid</VAR
  34583. >,
  34584.      um das Administrator Passwort zu Σndern, oder setzt einfach
  34585.      <VAR
  34586. CLASS="varname"
  34587. >$pwd</VAR
  34588. > auf <VAR
  34589. CLASS="literal"
  34590. >"hehehe', admin='yes', trusted=100
  34591.      "</VAR
  34592. > (mit dem hinteren Leerzeichen), um mehr Rechte zu erhalten.
  34593.      Dann wird die Abfrage verdreht:
  34594.      <DIV
  34595. CLASS="informalexample"
  34596. ><P
  34597. ></P
  34598. ><A
  34599. NAME="AEN5760"
  34600. ></A
  34601. ><TABLE
  34602. BORDER="0"
  34603. BGCOLOR="#E0E0E0"
  34604. CELLPADDING="5"
  34605. ><TR
  34606. ><TD
  34607. ><PRE
  34608. CLASS="php"
  34609. >// $uid == ' or uid like'%admin%'; --
  34610. $query = "UPDATE usertable SET pwd='...' WHERE uid='' or uid like '%admin%'; --";
  34611.  
  34612. // $pwd == "hehehe', admin='yes', trusted=100 "
  34613. $query = "UPDATE usertable SET pwd='hehehe', admin='yes', trusted=100 WHERE ...;"</PRE
  34614. ></TD
  34615. ></TR
  34616. ></TABLE
  34617. ><P
  34618. ></P
  34619. ></DIV
  34620. >
  34621.     </P
  34622. ><P
  34623. >      Ein furchterregendes Beispiel, wie der Zugriff auf Kommandos auf
  34624.      Betriebssystemebene bei manchen Datenbankservern erfolgen kann.
  34625.      <TABLE
  34626. WIDTH="100%"
  34627. BORDER="0"
  34628. CELLPADDING="0"
  34629. CELLSPACING="0"
  34630. CLASS="EXAMPLE"
  34631. ><TR
  34632. ><TD
  34633. ><DIV
  34634. CLASS="example"
  34635. ><A
  34636. NAME="AEN5763"
  34637. ></A
  34638. ><P
  34639. ><B
  34640. >Beispiel 25-5. Angriff auf das Betriebssystem des Datenbank Hosts (MSSQL Server)</B
  34641. ></P
  34642. ><TABLE
  34643. BORDER="0"
  34644. BGCOLOR="#E0E0E0"
  34645. CELLPADDING="5"
  34646. ><TR
  34647. ><TD
  34648. ><PRE
  34649. CLASS="php"
  34650. >$query  = "SELECT * FROM products WHERE id LIKE '%$prod%'";
  34651. $result = mssql_query($query);</PRE
  34652. ></TD
  34653. ></TR
  34654. ></TABLE
  34655. ></DIV
  34656. ></TD
  34657. ></TR
  34658. ></TABLE
  34659. >
  34660.      Wenn ein Angreifer den Wert
  34661.      <VAR
  34662. CLASS="literal"
  34663. >a%' exec master..xp_cmdshell 'net user test testpass /ADD' --</VAR
  34664. >
  34665.      zu <VAR
  34666. CLASS="varname"
  34667. >$prod</VAR
  34668. > ⁿbertrΣgt, wird <VAR
  34669. CLASS="varname"
  34670. >$query</VAR
  34671. > zu:
  34672.      <DIV
  34673. CLASS="informalexample"
  34674. ><P
  34675. ></P
  34676. ><A
  34677. NAME="AEN5769"
  34678. ></A
  34679. ><TABLE
  34680. BORDER="0"
  34681. BGCOLOR="#E0E0E0"
  34682. CELLPADDING="5"
  34683. ><TR
  34684. ><TD
  34685. ><PRE
  34686. CLASS="php"
  34687. >$query  = "SELECT * FROM products
  34688.                     WHERE id LIKE '%a%'
  34689.                     exec master..xp_cmdshell 'net user test testpass /ADD'--";
  34690. $result = mssql_query($query);</PRE
  34691. ></TD
  34692. ></TR
  34693. ></TABLE
  34694. ><P
  34695. ></P
  34696. ></DIV
  34697. >
  34698.      Der MSSQL Server fⁿhrt die SQL Statements in dem Batch aus, inklusive einem
  34699.      Kommando zum Anlegen eines neuen Benutzers in der Datenbank Accounts. Wⁿrde
  34700.      diese Applikation als <VAR
  34701. CLASS="literal"
  34702. >sa</VAR
  34703. > und der MSSQLSERVER Service
  34704.      mit genⁿgend Rechten laufen, hΣtte der Angreifer nun ein Konto, mit welchem
  34705.      er Zugriff auf diese Maschine hΣtte.
  34706.     </P
  34707. ><DIV
  34708. CLASS="note"
  34709. ><BLOCKQUOTE
  34710. CLASS="note"
  34711. ><P
  34712. ><B
  34713. >Anmerkung: </B
  34714. >
  34715.       Manche der obigen Beispiele sind an einen spezifischen Datenbankserver
  34716.       gebunden. Das hei▀t jedoch nicht, dass nicht ein Σhnlicher Angriff auf
  34717.       andere Produkte m÷glich wΣre. Ihr Datenbankserver k÷nnte auf andere
  34718.       Weise genauso verwundbar sein.
  34719.      </P
  34720. ></BLOCKQUOTE
  34721. ></DIV
  34722. ><DIV
  34723. CLASS="sect2"
  34724. ><HR><H3
  34725. CLASS="sect2"
  34726. ><A
  34727. NAME="security.database.avoiding"
  34728. >Techniken zur Vermeidung</A
  34729. ></H3
  34730. ><P
  34731. >       Sie k÷nnten sich nun darauf berufen, dass der Angreifer in den meisten
  34732.       Beispielen ein Stⁿck Information ⁿber das Datenbankschema haben muss. Sie
  34733.       haben recht, aber Sie wissen nie, wann und wie es genommen werden kann,
  34734.       und wenn es passiert, kann Ihre Datenbank entbl÷▀t werden. Wenn Sie ein
  34735.       Open Source, oder ÷ffentlich verfⁿgbares Paket zur Handhabung von
  34736.       Datenbanken verwenden, welches vielleicht zu einem Content Management
  34737.       System oder Forum geh÷rt, k÷nnen Eindringlinge leicht eine Kopie eines
  34738.       Stⁿcks Ihres Codes erstellen. Es kann auch ein Sicherheitsrisiko sein,
  34739.       wenn es sich um ein schlecht designtes Paket handelt.
  34740.      </P
  34741. ><P
  34742. >       Diese Angriffe basieren hauptsΣchlich auf dem Ausnutzen des Codes, welcher
  34743.       ohne Bedenken auf die Sicherheit geschrieben wurde. Vertrauen Sie nie auf
  34744.       irgendeine Art von Input, speziell wenn er von der Clientseite kommt,
  34745.       selbst wenn er von einer Auswahlbox, einem versteckten Eingabefeld, oder
  34746.       einem Cookie kommt. Das erste Beispiel zeigt, dass solch eine untadelige
  34747.       Abfrage ein Disaster anrichten kann.
  34748.      </P
  34749. ><P
  34750. ></P
  34751. ><UL
  34752. ><LI
  34753. ><P
  34754. >         Stellen Sie nie als Superuser oder Owner einer Datenbank eine Verbindung
  34755.         zur Datenbank her. Verwenden Sie immer speziell angelegte Benutzer mit
  34756.         sehr limitierten Rechten.
  34757.        </P
  34758. ></LI
  34759. ><LI
  34760. ><P
  34761. >         Prⁿfen Sie, ob der gegebene Input dem erwarteten Datentyp entspricht.
  34762.         PHP bietet eine gro▀e Auswahl an Funktionen zum Validieren des Input,
  34763.         von den einfachsten unter <A
  34764. HREF="#ref.variables"
  34765. >Variablenfunktionen</A
  34766. > und <A
  34767. HREF="#ref.ctype"
  34768. >Character Type Functions</A
  34769. > (z.B.
  34770.         <A
  34771. HREF="#function.is-numeric"
  34772. ><B
  34773. CLASS="function"
  34774. >is_numeric()</B
  34775. ></A
  34776. > bzw. <A
  34777. HREF="#function.ctype-digit"
  34778. ><B
  34779. CLASS="function"
  34780. >ctype_digit()</B
  34781. ></A
  34782. >),
  34783.         bis hin zu den <A
  34784. HREF="#ref.pcre"
  34785. >Perl kompatiblen RegulΣren
  34786.         Ausdrⁿcken</A
  34787. >.
  34788.        </P
  34789. ></LI
  34790. ><LI
  34791. ><P
  34792. >         Wenn die Applikation numerischen Input erwartet, erwΣgen Sie die Prⁿfung
  34793.         der Daten mit <A
  34794. HREF="#function.is-numeric"
  34795. ><B
  34796. CLASS="function"
  34797. >is_numeric()</B
  34798. ></A
  34799. >, oder die ─nderung des
  34800.         Typs mit <A
  34801. HREF="#function.settype"
  34802. ><B
  34803. CLASS="function"
  34804. >settype()</B
  34805. ></A
  34806. >, oder verwenden Sie die numerische
  34807.         ReprΣsentation mittels <A
  34808. HREF="#function.sprintf"
  34809. ><B
  34810. CLASS="function"
  34811. >sprintf()</B
  34812. ></A
  34813. >.
  34814.         <TABLE
  34815. WIDTH="100%"
  34816. BORDER="0"
  34817. CELLPADDING="0"
  34818. CELLSPACING="0"
  34819. CLASS="EXAMPLE"
  34820. ><TR
  34821. ><TD
  34822. ><DIV
  34823. CLASS="example"
  34824. ><A
  34825. NAME="AEN5793"
  34826. ></A
  34827. ><P
  34828. ><B
  34829. >Beispiel 25-6. Ein sicherer Weg, eine Abfrage zu erstellen</B
  34830. ></P
  34831. ><TABLE
  34832. BORDER="0"
  34833. BGCOLOR="#E0E0E0"
  34834. CELLPADDING="5"
  34835. ><TR
  34836. ><TD
  34837. ><PRE
  34838. CLASS="php"
  34839. >settype($offset, 'integer');
  34840. $query = "SELECT id, name FROM products ORDER BY name LIMIT 20 OFFSET $offset;";
  34841.  
  34842. // Beachten Sie %d im Formatstring, %s zu verwenden wΣre sinnlos
  34843. $query = sprintf("SELECT id, name FROM products ORDER BY name LIMIT 20 OFFSET %d;",
  34844.                  $offset);</PRE
  34845. ></TD
  34846. ></TR
  34847. ></TABLE
  34848. ></DIV
  34849. ></TD
  34850. ></TR
  34851. ></TABLE
  34852. >
  34853.        </P
  34854. ></LI
  34855. ><LI
  34856. ><P
  34857. >         Escapen Sie jeden nicht numerischen Input, welcher zur Datenbank
  34858.         weitergereicht werden soll mit <A
  34859. HREF="#function.addslashes"
  34860. ><B
  34861. CLASS="function"
  34862. >addslashes()</B
  34863. ></A
  34864. >
  34865.         oder <A
  34866. HREF="#function.addcslashes"
  34867. ><B
  34868. CLASS="function"
  34869. >addcslashes()</B
  34870. ></A
  34871. >. Siehe auch <A
  34872. HREF="#security.database.storage"
  34873. >das erste Beispiel</A
  34874. >. Wie
  34875.         dieses Beispiel zeigt, sind in den statischen Teil der Abfrage
  34876.         eingebrachten Escapes nicht genug, und k÷nnen leicht gehacked werden.
  34877.        </P
  34878. ></LI
  34879. ><LI
  34880. ><P
  34881. >         Geben Sie keinerlei datenbankspezifische Informationen aus, speziell
  34882.         ⁿber das Schema, egal wie (auf ehrliche oder unehrliche Weise). Siehe
  34883.         auch <A
  34884. HREF="#security.errors"
  34885. >Fehlerbehandlung</A
  34886. > und
  34887.         <A
  34888. HREF="#ref.errorfunc"
  34889. >Error Handling and Logging
  34890.         Functions</A
  34891. >.
  34892.        </P
  34893. ></LI
  34894. ><LI
  34895. ><P
  34896. >         Sie k÷nnen stored procedures und vorher definierte Cursor verwenden,
  34897.         um den Datenzugriff zu abstrahieren, sodass Benutzer nicht direkt auf
  34898.         Tabellen oder Views zugreifen, aber diese L÷sung hat andere
  34899.         Auswirkungen.
  34900.        </P
  34901. ></LI
  34902. ></UL
  34903. ><P
  34904. >       Abgesehen davon profitieren Sie von einer Protokollierung der Abfragen
  34905.       entweder in Ihrem Skript, oder durch die Datenbank selbst, wenn es hilft.
  34906.       Klar, die Protokollierung kann nicht irgendeinen schΣdlichen Versuch
  34907.       verhindern, aber es kann helfen herauszufinden, welche Applikation
  34908.       umgangen wurde. Das Log ist durch die in ihm enthaltene Information
  34909.       nⁿtzlich, und je mehr Details es enthΣlt, desto besser ist es im
  34910.       Allgemeinen.
  34911.      </P
  34912. ></DIV
  34913. ></DIV
  34914. ></DIV
  34915. ><DIV
  34916. CLASS="chapter"
  34917. ><HR><H1
  34918. ><A
  34919. NAME="security.errors"
  34920. >Kapitel 26. Fehlerbehandlung</A
  34921. ></H1
  34922. ><P
  34923. >     PHP Security hat zwei Seiten der Fehlerbehandlung. Eine ist fⁿr die
  34924.     Erh÷hung der Sicherheit vorteilhaft, die andere ist schΣdlich.
  34925.    </P
  34926. ><P
  34927. >     Eine Standard-Angriffstaktik beinhaltet die Erstellung eines Profils
  34928.     des anzugreifenden Systems, indem die aufgrund der Einspeisung von
  34929.     unzulΣssigen Daten zurⁿckgegebenen Fehlermeldungen anhand deren
  34930.     Art und des Kontextes ausgewertet werden. Wenn z.B. ein Angreifer
  34931.     Informationen ⁿber eine auf einem eingesendeten Formular basierte
  34932.     Seite zusammengetragen hat, kann er versuchen, Variablen zu
  34933.     ⁿberschreiben bzw. zu modifizieren:
  34934.     <TABLE
  34935. WIDTH="100%"
  34936. BORDER="0"
  34937. CELLPADDING="0"
  34938. CELLSPACING="0"
  34939. CLASS="EXAMPLE"
  34940. ><TR
  34941. ><TD
  34942. ><DIV
  34943. CLASS="example"
  34944. ><A
  34945. NAME="AEN5812"
  34946. ></A
  34947. ><P
  34948. ><B
  34949. >Beispiel 26-1. Variablen mit einer eigenen HTML Seite angreifen</B
  34950. ></P
  34951. ><TABLE
  34952. BORDER="0"
  34953. BGCOLOR="#E0E0E0"
  34954. CELLPADDING="5"
  34955. ><TR
  34956. ><TD
  34957. ><PRE
  34958. CLASS="html"
  34959. ><form method="post" action="attacktarget?username=badfoo&password=badfoo">
  34960. <input type="hidden" name="username" value="badfoo">
  34961. <input type="hidden" name="password" value="badfoo">
  34962. </form></PRE
  34963. ></TD
  34964. ></TR
  34965. ></TABLE
  34966. ></DIV
  34967. ></TD
  34968. ></TR
  34969. ></TABLE
  34970. >
  34971.    </P
  34972. ><P
  34973. >     Die normalerweise zurⁿckgegebenen PHP Fehler k÷nnen fⁿr den Entwickler
  34974.     hilfreich sein, wenn dieser ein Skript debuggen m÷chte, Hinweise auf
  34975.     eine nicht korrekt arbeitende Funktion oder Datei, oder die PHP Datei
  34976.     und die Zeilennummer des aufgetretenen Fehlers anzeigen lassen m÷chte.
  34977.     Das sind alles Informationen, die ausgenutzt werden k÷nnen. Es ist fⁿr
  34978.     einen PHP Entwickler nicht unⁿblich, <A
  34979. HREF="#function.show-source"
  34980. ><B
  34981. CLASS="function"
  34982. >show_source()</B
  34983. ></A
  34984. >,
  34985.     <A
  34986. HREF="#function.highlight-string"
  34987. ><B
  34988. CLASS="function"
  34989. >highlight_string()</B
  34990. ></A
  34991. >, oder
  34992.     <A
  34993. HREF="#function.highlight-file"
  34994. ><B
  34995. CLASS="function"
  34996. >highlight_file()</B
  34997. ></A
  34998. > zur Fehlersuche zu verwenden,
  34999.     jedoch kann dies in einem lebenden System auch versteckte Variablen,
  35000.     ungeprⁿfte Syntax und andere gefΣhrliche Informationen aufdecken.
  35001.     Speziell gefΣhrlich ist es, Code von bekannten Quellen mit integrierten
  35002.     Debugging Handlern auszufⁿhren, oder weit verbreitete Debuggingtechniken
  35003.     zu verwenden. Wenn ein Angreifer die von Ihnen benutzte generelle
  35004.     Technik herausfindet, kann er versuchen, mit Brute-Force Ihre Seite zu
  35005.     knacken, indem er verschiedene allgemein gebrΣuchliche Debug Strings
  35006.     sendet:
  35007.     <TABLE
  35008. WIDTH="100%"
  35009. BORDER="0"
  35010. CELLPADDING="0"
  35011. CELLSPACING="0"
  35012. CLASS="EXAMPLE"
  35013. ><TR
  35014. ><TD
  35015. ><DIV
  35016. CLASS="example"
  35017. ><A
  35018. NAME="AEN5819"
  35019. ></A
  35020. ><P
  35021. ><B
  35022. >Beispiel 26-2. Ausnutzen von gebrΣuchlichen Debugging Variablen</B
  35023. ></P
  35024. ><TABLE
  35025. BORDER="0"
  35026. BGCOLOR="#E0E0E0"
  35027. CELLPADDING="5"
  35028. ><TR
  35029. ><TD
  35030. ><PRE
  35031. CLASS="html"
  35032. ><form method="post" action="attacktarget?errors=Y&amp;showerrors=1"&debug=1">
  35033. <input type="hidden" name="errors" value="Y">
  35034. <input type="hidden" name="showerrors" value="1">
  35035. <input type="hidden" name="debug" value="1">
  35036. </form></PRE
  35037. ></TD
  35038. ></TR
  35039. ></TABLE
  35040. ></DIV
  35041. ></TD
  35042. ></TR
  35043. ></TABLE
  35044. >
  35045.    </P
  35046. ><P
  35047. >     Ungeachtet der Fehlerbehandlungsmethode fⁿhrt die M÷glichkeit ein
  35048.     System nach Fehlermeldungen zu sondieren dazu, dass einem Angreifer mehr
  35049.     Informationen geboten werden.
  35050.    </P
  35051. ><P
  35052. >     Zum Beispiel weist schon alleine der Stil einer Fehlermeldung darauf
  35053.     hin, dass auf einem System PHP lΣuft. Wenn der Angreifer auf eine
  35054.     .html Seite kommt und untersuchen m÷chte welches System im Hintergrund
  35055.     lΣuft (um nach bekannten SystemschwΣchen zu suchen), k÷nnte dieser
  35056.     mittels der Einspeisung von falschen Daten herausfinden, dass ein
  35057.     System mit PHP aufgebaut ist.
  35058.    </P
  35059. ><P
  35060. >     Ein Fehler einer Funktion gibt Aufschluss darⁿber, ob ein System eine
  35061.     bestimmte Datenbankapplikation benutzt, oder gibt Hinweise darauf,
  35062.     wie eine Webseite programmiert bzw. entworfen wurde. Dies erlaubt
  35063.     eine tiefere ▄berprⁿfung von offenen Datenbank-Ports, oder die Suche
  35064.     nach spezifischen Bugs bzw. SchwΣchen einer Webseite. Mit der
  35065.     Einspeisung von falschen Daten kann ein Angreifer z.B. die Reihenfolge
  35066.     der Authentifizierung in einem Skript bestimmen (anhand der
  35067.     Zeilennummern in den Fehlermeldungen), wie auch durch "Herumstochern"
  35068.     Missbrauchsm÷glichkeiten an verschiedenen Stellen im Script herausfinden.
  35069.    </P
  35070. ><P
  35071. >     Eine Fehlermeldung des Dateisystems oder eines generellen PHP-Errors
  35072.     welche Rechte der Server hat, wie auch die Struktur und Organisation
  35073.     der Dateien auf dem Webserver. Vom Entwickler geschriebene
  35074.     Fehlermeldungen k÷nnen das Problem verschlimmern, bis hin zum Preisgeben
  35075.     von zuvor "versteckten" Informationen.
  35076.    </P
  35077. ><P
  35078. >     Es gibt drei bedeutende L÷sungen zu diesem Thema. Die erste ist, alle
  35079.     Funktionen zu ⁿberprⁿfen und zu versuchen, die Menge an Fehlermeldungen
  35080.     zu ersetzen. Die zweite ist, die Ausgabe von Fehlermeldungen am laufenden
  35081.     Code generell zu deaktivieren. Die dritte ist, sich unter Verwendung der
  35082.     PHP Funktionen zur Fehlerbehandlung seinen eigenen Error-handler zu
  35083.     schreiben. AbhΣngig von Ihrer Sicherheitspolitik k÷nnte jede der drei
  35084.     L÷sungen fⁿr Sie geeignet sein.
  35085.    </P
  35086. ><P
  35087. >     Ein Weg, diesen Punkt vorzeitig zu behandeln ist, das PHP eigene
  35088.     <A
  35089. HREF="#function.error-reporting"
  35090. ><B
  35091. CLASS="function"
  35092. >error_reporting()</B
  35093. ></A
  35094. > zu benutzen, um Ihren Code
  35095.     sicherer zu gestalten und m÷glicherweise gefΣhrliche Nutzungen von
  35096.     Variablen zu entdecken. Wenn Sie Ihren Code noch vor dem Einsatz
  35097.     mit E_ALL testen, k÷nnen Sie Bereiche entdecken, in denen Ihre Variablen
  35098.     eventuell fⁿr Verseuchung oder andere Modifikationen offen sind.
  35099.     Sind Sie bereit zum Einsatz, k÷nnen Sie Ihren Code mit E_NONE vor
  35100.     Sondierungen schⁿtzen.
  35101.     <TABLE
  35102. WIDTH="100%"
  35103. BORDER="0"
  35104. CELLPADDING="0"
  35105. CELLSPACING="0"
  35106. CLASS="EXAMPLE"
  35107. ><TR
  35108. ><TD
  35109. ><DIV
  35110. CLASS="example"
  35111. ><A
  35112. NAME="AEN5829"
  35113. ></A
  35114. ><P
  35115. ><B
  35116. >Beispiel 26-3. GefΣhrliche Variablen mit E_ALL finden</B
  35117. ></P
  35118. ><TABLE
  35119. BORDER="0"
  35120. BGCOLOR="#E0E0E0"
  35121. CELLPADDING="5"
  35122. ><TR
  35123. ><TD
  35124. ><PRE
  35125. CLASS="php"
  35126. ><?php
  35127. if ($username) {  // Vor Verwendung nicht initialisiert oder geprⁿft
  35128.     $good_login = 1;
  35129. }
  35130. if ($good_login == 1) { // Wenn der obige Test fehlschlΣgt, ist vor der
  35131.                         // Verwendung nicht initialisiert oder geprⁿft
  35132.     fpassthru ("/highly/sensitive/data/index.html");
  35133. }
  35134. ?></PRE
  35135. ></TD
  35136. ></TR
  35137. ></TABLE
  35138. ></DIV
  35139. ></TD
  35140. ></TR
  35141. ></TABLE
  35142. >
  35143.    </P
  35144. ></DIV
  35145. ><DIV
  35146. CLASS="chapter"
  35147. ><HR><H1
  35148. ><A
  35149. NAME="security.globals"
  35150. >Kapitel 27. Verwendung von Register Globals</A
  35151. ></H1
  35152. ><P
  35153. >     Ein Feature von PHP zur Erh÷hung der Sicherheit ist die Konfiguration von
  35154.     PHP mit <A
  35155. HREF="#ini.register-globals"
  35156. >register_globals</A
  35157. > = off.
  35158.     Mit Deaktivierung der M÷glichkeit, irgendeine vom Benutzer ⁿbertragenen
  35159.     Variable in den PHP Code zu injizieren, k÷nnen Sie die Anzahl "vergifteter"
  35160.     Variablen reduzieren, welche ein potentieller Angreifer zufⁿgen k÷nnte.
  35161.     Dieser ben÷tigt mehr Zeit, um sich ▄bermittlungen auszudenken, und Ihre
  35162.     internen Variablen sind effektiv von den ⁿbergebenen Benutzervariablen
  35163.     isoliert.
  35164.    </P
  35165. ><P
  35166. >     WΣhrend dies den ben÷tigten Aufwand mit PHP zu arbeiten leicht erh÷ht
  35167.     ist dargelegt, dass die Vorteile gegenⁿber dem Aufwand klar ⁿberwiegen.
  35168.     <TABLE
  35169. WIDTH="100%"
  35170. BORDER="0"
  35171. CELLPADDING="0"
  35172. CELLSPACING="0"
  35173. CLASS="EXAMPLE"
  35174. ><TR
  35175. ><TD
  35176. ><DIV
  35177. CLASS="example"
  35178. ><A
  35179. NAME="AEN5837"
  35180. ></A
  35181. ><P
  35182. ><B
  35183. >Beispiel 27-1. Mit register_globals=on arbeiten</B
  35184. ></P
  35185. ><TABLE
  35186. BORDER="0"
  35187. BGCOLOR="#E0E0E0"
  35188. CELLPADDING="5"
  35189. ><TR
  35190. ><TD
  35191. ><PRE
  35192. CLASS="php"
  35193. ><?php
  35194. if ($username) {  // kann vom User mit get/post/cookies ⁿbermittelt werden
  35195.     $good_login = 1;
  35196. }
  35197.  
  35198. if ($good_login == 1) { // kann vom User mit get/post/cookies ⁿbermittelt werden
  35199.     fpassthru ("/highly/sensitive/data/index.html");
  35200. }
  35201. ?></PRE
  35202. ></TD
  35203. ></TR
  35204. ></TABLE
  35205. ></DIV
  35206. ></TD
  35207. ></TR
  35208. ></TABLE
  35209. >
  35210.     <TABLE
  35211. WIDTH="100%"
  35212. BORDER="0"
  35213. CELLPADDING="0"
  35214. CELLSPACING="0"
  35215. CLASS="EXAMPLE"
  35216. ><TR
  35217. ><TD
  35218. ><DIV
  35219. CLASS="example"
  35220. ><A
  35221. NAME="AEN5840"
  35222. ></A
  35223. ><P
  35224. ><B
  35225. >Beispiel 27-2. Mit register_globals = off arbeiten</B
  35226. ></P
  35227. ><TABLE
  35228. BORDER="0"
  35229. BGCOLOR="#E0E0E0"
  35230. CELLPADDING="5"
  35231. ><TR
  35232. ><TD
  35233. ><PRE
  35234. CLASS="php"
  35235. ><?php
  35236. if($_COOKIE['username']){
  35237.     // kann nur von einem Cookie kommen
  35238.     $good_login = 1;
  35239.     fpassthru ("/highly/sensitive/data/index.html");
  35240. }
  35241. ?></PRE
  35242. ></TD
  35243. ></TR
  35244. ></TABLE
  35245. ></DIV
  35246. ></TD
  35247. ></TR
  35248. ></TABLE
  35249. >
  35250.     Dies weise genutzt ist es auch m÷glich, prΣventive Messungen
  35251.     durchzufⁿhren, um bei versuchten Vorst÷▀en zu warnen. Wenn Sie
  35252.     im Voraus wissen, woher eine Variable kommen soll, k÷nnen Sie
  35253.     prⁿfen, ob die ⁿbermittelten Daten nicht einen unpassenden Weg
  35254.     genommen haben. Obwohl dies nicht garantiert, dass Daten nicht
  35255.     nur ausgedacht sind, erfordert es von einem Angreifer, auch den
  35256.     richtigen Weg zu finden.
  35257.     <TABLE
  35258. WIDTH="100%"
  35259. BORDER="0"
  35260. CELLPADDING="0"
  35261. CELLSPACING="0"
  35262. CLASS="EXAMPLE"
  35263. ><TR
  35264. ><TD
  35265. ><DIV
  35266. CLASS="example"
  35267. ><A
  35268. NAME="AEN5843"
  35269. ></A
  35270. ><P
  35271. ><B
  35272. >Beispiel 27-3. Entdecken einfacher Manipulationen von Variablen</B
  35273. ></P
  35274. ><TABLE
  35275. BORDER="0"
  35276. BGCOLOR="#E0E0E0"
  35277. CELLPADDING="5"
  35278. ><TR
  35279. ><TD
  35280. ><PRE
  35281. CLASS="php"
  35282. ><?php
  35283. if ($_COOKIE['username'] &&
  35284.     !$_POST['username'] &&
  35285.     !$_GET['username'] ) {
  35286.     // Durchfⁿhren anderer Checks, ob der Benutzername gⁿltig ist...
  35287.     $good_login = 1;
  35288.     fpassthru ("/highly/sensitive/data/index.html");
  35289. } else {
  35290.    mail("admin@example.com", "Possible breakin attempt", $_SERVER['REMOTE_ADDR']);
  35291.    echo "Security violation, admin has been alerted.";
  35292.    exit;
  35293. }
  35294. ?></PRE
  35295. ></TD
  35296. ></TR
  35297. ></TABLE
  35298. ></DIV
  35299. ></TD
  35300. ></TR
  35301. ></TABLE
  35302. >
  35303.     Natⁿrlich bedeutet ein einfaches Deaktivieren von register_globals nicht,
  35304.     dass Ihr Code nun automatisch sicher ist. Jeder Teil mit Daten sollte
  35305.     auch auf andere Arten geprⁿft werden. ▄berprⁿfen Sie immer die Eingaben von
  35306.     Benutzern und initialisieren Sie Ihre Variablen! Um Ihre Skripte auf nicht
  35307.     initialisierte Variablen zu prⁿfen, k÷nnen Sie
  35308.     <A
  35309. HREF="#function.error-reporting"
  35310. ><B
  35311. CLASS="function"
  35312. >error_reporting()</B
  35313. ></A
  35314. > so einstellen, dass Fehler des Levels
  35315.     <TT
  35316. CLASS="constant"
  35317. ><B
  35318. >E_NOTICE</B
  35319. ></TT
  35320. > angezeigt werden.
  35321.    </P
  35322. ><DIV
  35323. CLASS="note"
  35324. ><BLOCKQUOTE
  35325. CLASS="note"
  35326. ><P
  35327. ><B
  35328. >Superglobals: Hinweis zur
  35329. Verfⁿgbarkeit: </B
  35330. >Seit PHP 4.1.0 stehen superglobale Arrays wie
  35331. <VAR
  35332. CLASS="varname"
  35333. >$_GET</VAR
  35334. >, <VAR
  35335. CLASS="varname"
  35336. >$_POST</VAR
  35337. >,<VAR
  35338. CLASS="varname"
  35339. >$_SERVER</VAR
  35340. >, 
  35341. etc. zur Verfⁿgung. Weitere Informationen k÷nnen Sie dem Abschnitt zu 
  35342. <A
  35343. HREF="#language.variables.predefined"
  35344. >superglobals</A
  35345. > entnehmen.</P
  35346. ></BLOCKQUOTE
  35347. ></DIV
  35348. ></DIV
  35349. ><DIV
  35350. CLASS="chapter"
  35351. ><HR><H1
  35352. ><A
  35353. NAME="security.variables"
  35354. >Kapitel 28. Vom Nutzer ⁿbermittelte Daten</A
  35355. ></H1
  35356. ><P
  35357. >     In vielen PHP Programmen liegt die gr÷▀te SchwΣche nicht an der Sprache
  35358.     selbst, sondern blo▀ an Code, der nicht mit dem n÷tigen Augenmerk auf
  35359.     die Sicherheit geschrieben wurde. Deshalb sollten Sie sich immer Zeit
  35360.     nehmen, die Implikationen eines gegebenen Codestⁿcks zu bedenken, um
  35361.     einen m÷glichen Schaden durch eine eventuell unerwartete ⁿbergebene
  35362.     Variable festzustellen.
  35363.     <TABLE
  35364. WIDTH="100%"
  35365. BORDER="0"
  35366. CELLPADDING="0"
  35367. CELLSPACING="0"
  35368. CLASS="EXAMPLE"
  35369. ><TR
  35370. ><TD
  35371. ><DIV
  35372. CLASS="example"
  35373. ><A
  35374. NAME="AEN5858"
  35375. ></A
  35376. ><P
  35377. ><B
  35378. >Beispiel 28-1. GefΣhrliche Verwendung von Variablen</B
  35379. ></P
  35380. ><TABLE
  35381. BORDER="0"
  35382. BGCOLOR="#E0E0E0"
  35383. CELLPADDING="5"
  35384. ><TR
  35385. ><TD
  35386. ><PRE
  35387. CLASS="php"
  35388. ><?php
  35389. // l÷sche eine Datei aus dem Benutzer-Verzeichnis...
  35390. // oder vielleicht dem eines anderen Benutzers?
  35391. unlink ($evil_var);
  35392.  
  35393. // Schreibe die Log-Information von deren Zugriff...
  35394. // oder vielleicht einen /etc/passwd Eintrag?
  35395. fputs ($fp, $evil_var);
  35396.  
  35397. // Fⁿhre etwas triviales aus... oder rm -rf *?
  35398. system ($evil_var);
  35399. exec ($evil_var);
  35400.  
  35401. ?></PRE
  35402. ></TD
  35403. ></TR
  35404. ></TABLE
  35405. ></DIV
  35406. ></TD
  35407. ></TR
  35408. ></TABLE
  35409. >
  35410.     Sie sollten Ihren Code immer sorgfΣltig kontrollieren, um eine
  35411.     sorgfΣltige Prⁿfung irgendwelcher von einem Web-Browser ⁿbertragenen
  35412.     Variablen sicherzustellen, und sich selbst folgende Fragen stellen:
  35413.     <P
  35414. ></P
  35415. ><UL
  35416. ><LI
  35417. ><P
  35418. >        Wird sich dieses Skript nur auf die vorgesehenen Dateien auswirken?
  35419.       </P
  35420. ></LI
  35421. ><LI
  35422. ><P
  35423. >        Kann auf ungew÷hnliche oder unerwⁿnschte Daten reagiert werden?
  35424.       </P
  35425. ></LI
  35426. ><LI
  35427. ><P
  35428. >        Kann dieses Skript auf nicht vorgesehene Art genutzt werden?
  35429.       </P
  35430. ></LI
  35431. ><LI
  35432. ><P
  35433. >        Kann dies in Verbindung mit anderen Skripten in einer negativen
  35434.        Art benutzt werden?
  35435.       </P
  35436. ></LI
  35437. ><LI
  35438. ><P
  35439. >        Werden alle Transaktionen ausreichend geloggt?
  35440.       </P
  35441. ></LI
  35442. ></UL
  35443. >
  35444.     Wenn Sie sich diese Fragen anstatt danach schon wΣhrend dem Schreiben
  35445.     des Skriptes stellen, ersparen Sie sich das unangenehme Umschreiben,
  35446.     wenn eine Erh÷hung der Sicherheit erforderlich wird. Mit dieser Art
  35447.     zu denken werden Sie die Sicherheit des Systems zwar nicht garantieren,
  35448.     aber sie k÷nnen helfen, sie zu erh÷hen.
  35449.    </P
  35450. ><P
  35451. >     Sie k÷nnten auch ▄berlegungen anstellen, ob Sie nicht register_globals,
  35452.     magic_quotes, oder andere bequeme Einstellungen abschalten, welche Sie
  35453.     in Punkto Gⁿltigkeit, Herkunft, oder Inhalt einer gegebenen Variable
  35454.     durcheinanderbringen k÷nnten. Mit PHP im error_reporting(E_ALL) Modus
  35455.     zu arbeiten kann auch helfen, Sie vor Variablen zu warnen, welche
  35456.     benutzt werden, bevor sie geprⁿft oder initialisiert wurden (so k÷nnen
  35457.     Sie verhindern, dass mit ungew÷hnlichen Daten gearbeitet wird).
  35458.    </P
  35459. ></DIV
  35460. ><DIV
  35461. CLASS="chapter"
  35462. ><HR><H1
  35463. ><A
  35464. NAME="security.hiding"
  35465. >Kapitel 29. Verstecken von PHP</A
  35466. ></H1
  35467. ><P
  35468. >     Generell ist Sicherheit durch Unklarheit eine der schwΣchsten Formen von
  35469.     Sicherheit. Aber in manchen FΣllen ist ein klein Wenig mehr an extra
  35470.     Sicherheit wⁿnschenswert.
  35471.    </P
  35472. ><P
  35473. >     Ein paar einfache Techniken helfen PHP zu Verstecken, um einen nach
  35474.     SchwΣchen in Ihrem System suchenden Angreifer m÷glicherweise langsamer
  35475.     zu machen. Wenn Sie in Ihrer <TT
  35476. CLASS="filename"
  35477. >php.ini</TT
  35478. > expose_php = off setzen,
  35479.     reduzieren Sie damit die ihm zur Verfⁿgung stehenden Informationen.
  35480.    </P
  35481. ><P
  35482. >     Eine andere Taktik ist, den Webserver wie z.B. Apache entweder mittels
  35483.     einer <TT
  35484. CLASS="filename"
  35485. >.htaccess</TT
  35486. > Direktive oder in der Apache Konfigurationsdatei selbst
  35487.     so konfigurieren, dass dieser verschiedene Dateitypen durch PHP parst.
  35488.     So k÷nnen Sie irrefⁿhrende Dateierweiterungen verwenden:
  35489.     <TABLE
  35490. WIDTH="100%"
  35491. BORDER="0"
  35492. CELLPADDING="0"
  35493. CELLSPACING="0"
  35494. CLASS="EXAMPLE"
  35495. ><TR
  35496. ><TD
  35497. ><DIV
  35498. CLASS="example"
  35499. ><A
  35500. NAME="AEN5880"
  35501. ></A
  35502. ><P
  35503. ><B
  35504. >Beispiel 29-1. PHP als andere Sprache ausgeben</B
  35505. ></P
  35506. ><TABLE
  35507. BORDER="0"
  35508. BGCOLOR="#E0E0E0"
  35509. CELLPADDING="5"
  35510. ><TR
  35511. ><TD
  35512. ><PRE
  35513. CLASS="apache-conf"
  35514. ># Lasse PHP Code wie andere Arten von Code aussehen
  35515. AddType application/x-httpd-php .asp .py .pl</PRE
  35516. ></TD
  35517. ></TR
  35518. ></TABLE
  35519. ></DIV
  35520. ></TD
  35521. ></TR
  35522. ></TABLE
  35523. >
  35524.     Oder komplett unklar machen:
  35525.     <TABLE
  35526. WIDTH="100%"
  35527. BORDER="0"
  35528. CELLPADDING="0"
  35529. CELLSPACING="0"
  35530. CLASS="EXAMPLE"
  35531. ><TR
  35532. ><TD
  35533. ><DIV
  35534. CLASS="example"
  35535. ><A
  35536. NAME="AEN5883"
  35537. ></A
  35538. ><P
  35539. ><B
  35540. >Beispiel 29-2. Verwenden von unbekannten Typen fⁿr PHP Dateierweiterungen</B
  35541. ></P
  35542. ><TABLE
  35543. BORDER="0"
  35544. BGCOLOR="#E0E0E0"
  35545. CELLPADDING="5"
  35546. ><TR
  35547. ><TD
  35548. ><PRE
  35549. CLASS="apache-conf"
  35550. ># Lasse PHP Code wie unbekannte Typen aussehen
  35551. AddType application/x-httpd-php .bop .foo .133t</PRE
  35552. ></TD
  35553. ></TR
  35554. ></TABLE
  35555. ></DIV
  35556. ></TD
  35557. ></TR
  35558. ></TABLE
  35559. >
  35560.     Oder verstecken Sie ihn als html Code, was einen leichten
  35561.     Performanceverlust bedeutet, da alle html Dateien durch die PHP
  35562.     Engine geparst werden:
  35563.     <TABLE
  35564. WIDTH="100%"
  35565. BORDER="0"
  35566. CELLPADDING="0"
  35567. CELLSPACING="0"
  35568. CLASS="EXAMPLE"
  35569. ><TR
  35570. ><TD
  35571. ><DIV
  35572. CLASS="example"
  35573. ><A
  35574. NAME="AEN5886"
  35575. ></A
  35576. ><P
  35577. ><B
  35578. >Beispiel 29-3. Verwenden von html Typen fⁿr PHP Dateierweiterungen</B
  35579. ></P
  35580. ><TABLE
  35581. BORDER="0"
  35582. BGCOLOR="#E0E0E0"
  35583. CELLPADDING="5"
  35584. ><TR
  35585. ><TD
  35586. ><PRE
  35587. CLASS="apache-conf"
  35588. ># Lasse PHP code wie html aussehen
  35589. AddType application/x-httpd-php .htm .html</PRE
  35590. ></TD
  35591. ></TR
  35592. ></TABLE
  35593. ></DIV
  35594. ></TD
  35595. ></TR
  35596. ></TABLE
  35597. >
  35598.     Um dies effektiv arbeiten zu lassen, mⁿssen Sie Ihre PHP Dateien
  35599.     nach den obigen Dateierweiterungen umbenennen. WΣhrend dies eine
  35600.     Form der Sicherheit durch Verhⁿllung ist, ist es ein kleines
  35601.     prΣventives Ma▀ mit ein paar Nachteilen.
  35602.    </P
  35603. ></DIV
  35604. ><DIV
  35605. CLASS="chapter"
  35606. ><HR><H1
  35607. ><A
  35608. NAME="security.current"
  35609. >Kapitel 30. Aktuell bleiben</A
  35610. ></H1
  35611. ><P
  35612. >     PHP wird, wie jedes andere gro▀e System auch, stΣndig geprⁿft und
  35613.     weiterentwickelt. Jede neue Version wird oft sowohl gr÷▀e, als auch
  35614.     kleine ─nderungen enthalten, welche die Gesamtsicherheit und
  35615.     StabilitΣt des Systems betreffenden Punkte (z.B. Sicherheit,
  35616.     Konfiguration) verbessern bzw. vorhandene MΣngel beheben.
  35617.    </P
  35618. ><P
  35619. >     Wie auch bei anderen Scriptsprachen und Programmen auf Systemebene
  35620.     ist der beste Ansatz ein oftmaliges Update, und sich laufend ⁿber
  35621.     die letzten Versionen und deren ─nderungen zu informieren.
  35622.    </P
  35623. ></DIV
  35624. ></DIV
  35625. ><DIV
  35626. CLASS="PART"
  35627. ><A
  35628. NAME="features"
  35629. ></A
  35630. ><DIV
  35631. CLASS="TITLEPAGE"
  35632. ><H1
  35633. CLASS="title"
  35634. >V. Features</H1
  35635. ><DIV
  35636. CLASS="TOC"
  35637. ><DL
  35638. ><DT
  35639. ><B
  35640. >Inhaltsverzeichnis</B
  35641. ></DT
  35642. ><DT
  35643. >31. <A
  35644. HREF="#features.http-auth"
  35645. >HTTP-Authentifizierung mit PHP</A
  35646. ></DT
  35647. ><DT
  35648. >32. <A
  35649. HREF="#features.cookies"
  35650. >Cookies</A
  35651. ></DT
  35652. ><DT
  35653. >33. <A
  35654. HREF="#features.xforms"
  35655. >Dealing with XForms</A
  35656. ></DT
  35657. ><DT
  35658. >34. <A
  35659. HREF="#features.file-upload"
  35660. >Steuerung von Dateiuploads</A
  35661. ></DT
  35662. ><DT
  35663. >35. <A
  35664. HREF="#features.remote-files"
  35665. >Zugriff auf entfernte Dateien</A
  35666. ></DT
  35667. ><DT
  35668. >36. <A
  35669. HREF="#features.connection-handling"
  35670. >Verbindungssteuerung</A
  35671. ></DT
  35672. ><DT
  35673. >37. <A
  35674. HREF="#features.persistent-connections"
  35675. >Persistente Datenbankverbindungen</A
  35676. ></DT
  35677. ><DT
  35678. >38. <A
  35679. HREF="#features.safe-mode"
  35680. >Safe Mode</A
  35681. ></DT
  35682. ><DT
  35683. >39. <A
  35684. HREF="#features.commandline"
  35685. >PHP auf der Kommandozeile</A
  35686. ></DT
  35687. ></DL
  35688. ></DIV
  35689. ></DIV
  35690. ><DIV
  35691. CLASS="chapter"
  35692. ><HR><H1
  35693. ><A
  35694. NAME="features.http-auth"
  35695. >Kapitel 31. HTTP-Authentifizierung mit PHP</A
  35696. ></H1
  35697. ><P
  35698. >    Die HTTP-Authentifizierung durch PHP ist nur verfⁿgbar, wenn PHP als
  35699.    Apache-Modul lΣuft und funktioniert daher nicht mit der CGI-Version.
  35700.    In einem PHP-Skript fⁿr ein Apache-Modul kann man die Funktion
  35701.    <A
  35702. HREF="#function.header"
  35703. ><B
  35704. CLASS="function"
  35705. >header()</B
  35706. ></A
  35707. > benutzen, um die Nachricht "Authentifizierung 
  35708.    notwendig" an den Client-Browser zu senden, damit dieser
  35709.    ein Fenster zur Eingabe von Benutzername/Passwort ÷ffnet.
  35710.    Hat der Benutzer diese eingegeben, wird die URL des PHP-Scripts
  35711.    mit den Variablen $PHP_AUTH_USER, $PHP_AUTH_PW 
  35712.    und $PHP_AUTH_TYPE, die den jeweiligen Benutzernamen, das 
  35713.    Passwort und den Typ der Identifizierung enthalten, erneut aufgerufen.
  35714.    Momentan wird nur das Authentifizierungsmodell "basic" unterstⁿtzt. 
  35715.    NΣheres hierzu bei der <A
  35716. HREF="#function.header"
  35717. ><B
  35718. CLASS="function"
  35719. >header()</B
  35720. ></A
  35721. > Funktion.
  35722.   </P
  35723. ><DIV
  35724. CLASS="note"
  35725. ><BLOCKQUOTE
  35726. CLASS="note"
  35727. ><P
  35728. ><B
  35729. >Anmerkung zur PHP Version: </B
  35730. >
  35731.     <A
  35732. HREF="#language.variables.superglobals"
  35733. >Autoglobals</A
  35734. >,
  35735.     wie <A
  35736. HREF="#reserved.variables.server"
  35737. >$_SERVER</A
  35738. >, sind seit
  35739.     der PHP Version <A
  35740. HREF="http://www.php.net/release_4_1_0.php"
  35741. TARGET="_top"
  35742. >4.1.0</A
  35743. > verfⁿgbar.
  35744.     <VAR
  35745. CLASS="varname"
  35746. >$HTTP_SERVER_VARS</VAR
  35747. > seit PHP 3.
  35748.    </P
  35749. ></BLOCKQUOTE
  35750. ></DIV
  35751. ><P
  35752. >    Ein Auszug aus einem Skript, das die Clientauthentifizierung
  35753.    auf einer Seite erzwingt, wⁿrde so aussehen:
  35754.  
  35755.    <TABLE
  35756. WIDTH="100%"
  35757. BORDER="0"
  35758. CELLPADDING="0"
  35759. CELLSPACING="0"
  35760. CLASS="EXAMPLE"
  35761. ><TR
  35762. ><TD
  35763. ><DIV
  35764. CLASS="example"
  35765. ><A
  35766. NAME="AEN5908"
  35767. ></A
  35768. ><P
  35769. ><B
  35770. >Beispiel 31-1. HTTP-Authentifizierung</B
  35771. ></P
  35772. ><TABLE
  35773. BORDER="0"
  35774. BGCOLOR="#E0E0E0"
  35775. CELLPADDING="5"
  35776. ><TR
  35777. ><TD
  35778. ><PRE
  35779. CLASS="php"
  35780. ><?php
  35781.   if (!isset($_SERVER['PHP_AUTH_USER'])) {
  35782.        Header("WWW-Authenticate: Basic realm=\"My Realm\"");
  35783.        Header("HTTP/1.0 401 Unauthorized");
  35784.        echo "Text to send if user hits Cancel button\n";
  35785.        exit;
  35786.         } else {
  35787.     echo "Hello {$_SERVER['PHP_AUTH_USER']}";
  35788.     echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
  35789.   }
  35790. ?></PRE
  35791. ></TD
  35792. ></TR
  35793. ></TABLE
  35794. ></DIV
  35795. ></TD
  35796. ></TR
  35797. ></TABLE
  35798. >
  35799.    </P
  35800. ><DIV
  35801. CLASS="note"
  35802. ><BLOCKQUOTE
  35803. CLASS="note"
  35804. ><P
  35805. ><B
  35806. >Hinweis: </B
  35807. >
  35808.     Achten Sie bei den Header-Zeilen fⁿr maximale KompatibilitΣt auf die
  35809.     richtige Schreibweise! Das Schlⁿsselwort "Basic" sollte genau so geschrieben
  35810.     werden, der Realm-String muss in doppelte (nicht einfache) Anfⁿhrungszeichen
  35811.     eingeschlossen sein, und in der "HTTP/1.0 401"-Zeile
  35812.     darf nur genau ein Leerzeichen vor dem 401-Code stehen.
  35813.    </P
  35814. ></BLOCKQUOTE
  35815. ></DIV
  35816. ><P
  35817. >    Anstatt $_SERVER['PHP_AUTH_USER'] und $_SERVER['PHP_AUTH_PW'] einfach nur 
  35818.    auszugeben, werden Sie den Benutzernamen und das Passwort 
  35819.    auf Gⁿltigkeit ⁿberprⁿfen wollen. Dies kann durch die Abfrage 
  35820.    einer Datenbank oder das Einlesen einer Textdatei geschehen.
  35821.   </P
  35822. ><P
  35823. >    Vorsicht bei einigen Internet Explorer-Versionen - sie scheinen
  35824.    sehr wΣhlerisch zu sein, was die Reihenfolge der Header angeht.
  35825.    Abhilfe schafft hier das Senden des <SPAN
  35826. CLASS="emphasis"
  35827. ><I
  35828. CLASS="emphasis"
  35829. >WWW-Authenticate</I
  35830. ></SPAN
  35831. >
  35832.    Headers vor dem <SPAN
  35833. CLASS="errorcode"
  35834. >HTTP/1.0 401</SPAN
  35835. >.
  35836.   </P
  35837. ><P
  35838. >    Um zu unterbinden, dass ein Skript das Passwort einer durch 
  35839.    einen traditionellen externen Mechanismus geschⁿtzten Seite
  35840.    ausliest, werden die PHP_AUTH Variablen nicht gesetzt, wenn 
  35841.    eine externe Authentifizierung fⁿr diese bestimmte Seite aktiviert
  35842.    ist. In diesem Fall kann die $_SERVER['REMOTE_USER'] Variable benutzt
  35843.    werden, um den Benutzer durch die externe Zugriffskontrolle
  35844.    zu identifizieren.
  35845.   </P
  35846. ><DIV
  35847. CLASS="note"
  35848. ><BLOCKQUOTE
  35849. CLASS="note"
  35850. ><P
  35851. ><B
  35852. >Konfigurationshinweis: </B
  35853. >
  35854.     PHP prⁿft das Vorhandensein einer <VAR
  35855. CLASS="literal"
  35856. >AuthType</VAR
  35857. >
  35858.     Apache-Direktive, um zu entscheiden, ob eine externe
  35859.     Authentifizierung aktiv ist. Vermeiden Sie deshalb diese
  35860.     Konfigurationsdirektive im Kontext der PHP-Authentifizierung
  35861.     (anderenfalls wird jeder Authentifizierungsversuch misslingen).
  35862.    </P
  35863. ></BLOCKQUOTE
  35864. ></DIV
  35865. ><P
  35866. >    Zu beachten ist, dass obenstehendes keinesfalls jemanden,
  35867.    der die Kontrolle ⁿber eine nichtgeschⁿtzte URL hat, davon
  35868.    abhalten kann, Passw÷rter von geschⁿtzten URLs auf dem
  35869.    gleichen Rechner auszulesen.
  35870.   </P
  35871. ><P
  35872. >    Sowohl Netscape als auch der Internet Explorer l÷schen den
  35873.    lokalen Authentifizierungscache des Browserfensters, wenn der
  35874.    Server eine 401-Meldung zurⁿckgibt. Dies kann benutzt werden, um
  35875.    einen Benutzer "auszuloggen" und eine erneute Eingabe des
  35876.    Benutzernamens/Passworts zu erzwingen. Manchmal wird dieses Verhalten
  35877.    fⁿr das automatische Ausloggen nach Ablauf einer bestimmten Zeitspanne
  35878.    oder fⁿr einen Logout-Button genutzt.
  35879.   </P
  35880. ><TABLE
  35881. WIDTH="100%"
  35882. BORDER="0"
  35883. CELLPADDING="0"
  35884. CELLSPACING="0"
  35885. CLASS="EXAMPLE"
  35886. ><TR
  35887. ><TD
  35888. ><DIV
  35889. CLASS="example"
  35890. ><A
  35891. NAME="AEN5925"
  35892. ></A
  35893. ><P
  35894. ><B
  35895. >Beispiel 31-2. HTTP-Authentifizierung, mit erneuter Anforderung von Name/Passwort</B
  35896. ></P
  35897. ><TABLE
  35898. BORDER="0"
  35899. BGCOLOR="#E0E0E0"
  35900. CELLPADDING="5"
  35901. ><TR
  35902. ><TD
  35903. ><PRE
  35904. CLASS="php"
  35905. ><?php
  35906.   function authenticate()
  35907.   {
  35908.      Header("WWW-Authenticate: Basic realm=\"Test Authentication System\"");
  35909.      Header("HTTP/1.0 401 Unauthorized");
  35910.      echo "You must enter a valid login ID and password to access this resource\n";
  35911.      exit;
  35912.   }
  35913.  
  35914.   if (!isset($_SERVER['PHP_AUTH_USER']) || ($SeenBefore == 1 && ! strcmp( $OldAuth, $_SERVER['PHP_AUTH_USER']))) {
  35915.     authenticate();
  35916.   } else {
  35917.       echo "Welcome: {$_SERVER['PHP_AUTH_USER']}<br>";
  35918.       echo "Old: $OldAuth";
  35919.       echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">\n";
  35920.       echo "<input type=\"hidden\" name=\"SeenBefore\" value=\"1\">\n";
  35921.       echo "<input type=\"hidden\" name=\"OldAuth\" value=\"{$_SERVER['PHP_AUTH_USER']}\">\n";
  35922.       echo "<input type=\"submit\" value=\"Re Authenticate\">\n";
  35923.       echo "</form>\n";
  35924.   }
  35925. ?></PRE
  35926. ></TD
  35927. ></TR
  35928. ></TABLE
  35929. ></DIV
  35930. ></TD
  35931. ></TR
  35932. ></TABLE
  35933. ><P
  35934. >    Dieses Verhalten wird vom Authentifizierungsstandard HTTP Basic 
  35935.    nicht gefordert, daher sollte man sich nie darauf verlassen. Tests
  35936.    mit Lynx haben gezeigt, dass Lynx die Authentifizierungsinformationen
  35937.    bei Erhalt einer 401-Meldung nicht l÷scht. Ein Klick auf den Zurⁿck-
  35938.    Button und danach auf VorwΣrts wird die angeforderte Adresse
  35939.    ÷ffnen (und zwar so lange, bis die Identifizierung der Benutzer
  35940.    geΣndert wird).
  35941.   </P
  35942. ><P
  35943. >    Weiterhin muss beachtet werden, dass dies unter dem Microsoft
  35944.    IIS mit der CGI-Version von PHP aufgrund einer
  35945.    EinschrΣnkung des IIS nicht funktioniert.
  35946.   </P
  35947. ></DIV
  35948. ><DIV
  35949. CLASS="chapter"
  35950. ><HR><H1
  35951. ><A
  35952. NAME="features.cookies"
  35953. >Kapitel 32. Cookies</A
  35954. ></H1
  35955. ><P
  35956. >    PHP unterstⁿtzt HTTP-Cookies. Hierbei handelt es sich um einen
  35957.    Mechanismus, um Informationen beim Client zu speichern und somit
  35958.    wiederkehrende Besucher zu identifizieren oder ihren Weg innerhalb
  35959.    des Angebotes nachzuvollziehen. Cookies k÷nnen durch die Funktion
  35960.    <A
  35961. HREF="#function.setcookie"
  35962. ><B
  35963. CLASS="function"
  35964. >setcookie()</B
  35965. ></A
  35966. > gesetzt werden. Sie sind Bestandteil
  35967.    des HTTP-Headers, was bedeutet, dass die Funktion
  35968.    <A
  35969. HREF="#function.setcookie"
  35970. ><B
  35971. CLASS="function"
  35972. >setcookie()</B
  35973. ></A
  35974. > aufgerufen werden muss, bevor irgendeine
  35975.    Ausgabe an den Browser erfolgt. Dies ist die gleiche EinschrΣnkung, der
  35976.    auch die Funktion <A
  35977. HREF="#function.header"
  35978. ><B
  35979. CLASS="function"
  35980. >header()</B
  35981. ></A
  35982. > unterliegt. Sie k÷nnen
  35983.    die <A
  35984. HREF="#ref.outcontrol"
  35985. >Funktionen zur Ausgabesteuerung</A
  35986. >
  35987.    benutzen, um die Ausgaben des Skriptes zu verz÷gern, bis entschieden ist,
  35988.    ob Cookies gesetzt bzw. Header gesendet werden sollen oder nicht. 
  35989.   </P
  35990. ><P
  35991. >    Vom Client gesendete Cookies werden - abhΣngig von den
  35992.    Konfigurationsvariablen <VAR
  35993. CLASS="literal"
  35994. >register_globals</VAR
  35995. > und
  35996.    <VAR
  35997. CLASS="literal"
  35998. >variables_order</VAR
  35999. > - automatisch in eine Variable
  36000.    geschrieben, wie es auch bei mittels GET oder POST gesendeten Daten
  36001.    geschieht. Sollen einem Cookie mehrere Werte zugewiesen werden, so
  36002.    muss dem Cookienamen lediglich <SPAN
  36003. CLASS="emphasis"
  36004. ><I
  36005. CLASS="emphasis"
  36006. >[]</I
  36007. ></SPAN
  36008. > angefⁿgt
  36009.    werden.
  36010.   </P
  36011. ><P
  36012. >    Seit PHP 4.1.0 werden alle vom Client gesendeten Cookies in dem
  36013.    auto-globalen Array <VAR
  36014. CLASS="varname"
  36015. >$_COOKIE</VAR
  36016. > gespeichert. In
  36017.    Σlteren PHP-Versionen stehen diese Daten in
  36018.    <VAR
  36019. CLASS="varname"
  36020. >$HTTP_COOKIE_VARS</VAR
  36021. > gespeichert, sofern die
  36022.    Konfigurationsvariable <VAR
  36023. CLASS="literal"
  36024. >track_vars</VAR
  36025. > gesetzt ist.
  36026.   </P
  36027. ><P
  36028. >    Weitere Informationen sowie Anmerkungen zu Browser-Bugs finden
  36029.    Sie im Abschnitt <A
  36030. HREF="#function.setcookie"
  36031. ><B
  36032. CLASS="function"
  36033. >setcookie()</B
  36034. ></A
  36035. >.
  36036.   </P
  36037. ></DIV
  36038. ><DIV
  36039. CLASS="chapter"
  36040. ><HR><H1
  36041. ><A
  36042. NAME="features.xforms"
  36043. >Kapitel 33. Dealing with XForms</A
  36044. ></H1
  36045. ><P
  36046. >   <A
  36047. HREF="http://www.w3.org/MarkUp/Forms/"
  36048. TARGET="_top"
  36049. >XForms</A
  36050. > defines a variation on traditional
  36051.   webforms which allows them to be used on a wider variety of platforms and 
  36052.   browsers or even non-traditional media such as PDF documents.
  36053.  </P
  36054. ><P
  36055. >   The first key difference in XForms is how the form is sent to the client.
  36056.   <A
  36057. HREF="http://www.w3.org/MarkUp/Forms/2003/xforms-for-html-authors.html"
  36058. TARGET="_top"
  36059. >XForms for HTML Authors</A
  36060. >
  36061.   contains a detailed description of how to create XForms, for the purpose
  36062.   of this tutorial we'll only be looking at a simple example.
  36063.  </P
  36064. ><TABLE
  36065. WIDTH="100%"
  36066. BORDER="0"
  36067. CELLPADDING="0"
  36068. CELLSPACING="0"
  36069. CLASS="EXAMPLE"
  36070. ><TR
  36071. ><TD
  36072. ><DIV
  36073. CLASS="example"
  36074. ><A
  36075. NAME="AEN5953"
  36076. ></A
  36077. ><P
  36078. ><B
  36079. >Beispiel 33-1. A simple XForms search form</B
  36080. ></P
  36081. ><TABLE
  36082. BORDER="0"
  36083. BGCOLOR="#E0E0E0"
  36084. CELLPADDING="5"
  36085. ><TR
  36086. ><TD
  36087. ><PRE
  36088. CLASS="html"
  36089. ><h:html xmlns:h="http://www.w3.org/1999/xhtml"
  36090.         xmlns="http://www.w3.org/2002/xforms">
  36091. <h:head>
  36092.  <h:title>Search</h:title>
  36093.  <model>
  36094.   <submission action="http://example.com/search"
  36095.               method="post" id="s"/>
  36096.  </model>
  36097. </h:head>
  36098. <h:body>
  36099.  <h:p>
  36100.   <input ref="q"><label>Find</label></input>
  36101.   <submit submission="s"><label>Go</label></submit>
  36102.  </h:p>
  36103. </h:body>
  36104. </h:html></PRE
  36105. ></TD
  36106. ></TR
  36107. ></TABLE
  36108. ></DIV
  36109. ></TD
  36110. ></TR
  36111. ></TABLE
  36112. ><P
  36113. >   The above form displays a text input box (named <VAR
  36114. CLASS="parameter"
  36115. >q</VAR
  36116. >),
  36117.   and a submit button.  When the submit button is clicked, the form will be
  36118.   sent to the page referred to by <VAR
  36119. CLASS="literal"
  36120. >action</VAR
  36121. >.
  36122.  </P
  36123. ><P
  36124. >   Here's where it starts to look different from your web application's point
  36125.   of view.  In a normal HTML form, the data would be sent as 
  36126.   <VAR
  36127. CLASS="literal"
  36128. >application/x-www-form-urlencoded</VAR
  36129. >, in the XForms world
  36130.   however, this information is sent as XML formatted data.
  36131.  </P
  36132. ><P
  36133. >   If you're choosing to work with XForms then you probably want that data as
  36134.   XML, in that case, look in <VAR
  36135. CLASS="varname"
  36136. >$HTTP_RAW_POST_DATA</VAR
  36137. > where
  36138.   you'll find the XML document generated by the browser which you can pass
  36139.   into your favorite XSLT engine or document parser.
  36140.  </P
  36141. ><P
  36142. >   If you're not interrested in formatting and just want your data to be loaded
  36143.   into the traditional <VAR
  36144. CLASS="varname"
  36145. >$_POST</VAR
  36146. > variable, you can instruct
  36147.   the client browser to send it as <VAR
  36148. CLASS="literal"
  36149. >application/x-www-form-urlencoded</VAR
  36150. >
  36151.   by changing the <VAR
  36152. CLASS="parameter"
  36153. >method</VAR
  36154. > attribute to
  36155.   <SPAN
  36156. CLASS="emphasis"
  36157. ><I
  36158. CLASS="emphasis"
  36159. >urlencoded-post</I
  36160. ></SPAN
  36161. >.
  36162.  </P
  36163. ><TABLE
  36164. WIDTH="100%"
  36165. BORDER="0"
  36166. CELLPADDING="0"
  36167. CELLSPACING="0"
  36168. CLASS="EXAMPLE"
  36169. ><TR
  36170. ><TD
  36171. ><DIV
  36172. CLASS="example"
  36173. ><A
  36174. NAME="AEN5968"
  36175. ></A
  36176. ><P
  36177. ><B
  36178. >Beispiel 33-2. Using an XForm to populate <VAR
  36179. CLASS="varname"
  36180. >$_POST</VAR
  36181. ></B
  36182. ></P
  36183. ><TABLE
  36184. BORDER="0"
  36185. BGCOLOR="#E0E0E0"
  36186. CELLPADDING="5"
  36187. ><TR
  36188. ><TD
  36189. ><PRE
  36190. CLASS="html"
  36191. ><h:html xmlns:h="http://www.w3.org/1999/xhtml"
  36192.         xmlns="http://www.w3.org/2002/xforms">
  36193. <h:head>
  36194.  <h:title>Search</h:title>
  36195.  <model>
  36196.   <submission action="http://example.com/search"
  36197.               method="urlencoded-post" id="s"/>
  36198.  </model>
  36199. </h:head>
  36200. <h:body>
  36201.  <h:p>
  36202.   <input ref="q"><label>Find</label></input>
  36203.   <submit submission="s"><label>Go</label></submit>
  36204.  </h:p>
  36205. </h:body>
  36206. </h:html></PRE
  36207. ></TD
  36208. ></TR
  36209. ></TABLE
  36210. ></DIV
  36211. ></TD
  36212. ></TR
  36213. ></TABLE
  36214. ><DIV
  36215. CLASS="note"
  36216. ><BLOCKQUOTE
  36217. CLASS="note"
  36218. ><P
  36219. ><B
  36220. >Anmerkung: </B
  36221. >
  36222.    As of this writing, many browsers do not support XForms.
  36223.    Check your browser version if the above examples fails.
  36224.   </P
  36225. ></BLOCKQUOTE
  36226. ></DIV
  36227. ></DIV
  36228. ><DIV
  36229. CLASS="chapter"
  36230. ><HR><H1
  36231. ><A
  36232. NAME="features.file-upload"
  36233. >Kapitel 34. Steuerung von Dateiuploads</A
  36234. ></H1
  36235. ><DIV
  36236. CLASS="sect1"
  36237. ><H2
  36238. CLASS="sect1"
  36239. ><A
  36240. NAME="features.file-upload.post-method"
  36241. >Dateiuploads mit POST</A
  36242. ></H2
  36243. ><P
  36244. >     PHP kann Dateiuploads mit jedem RFC-1867 konformen Browser
  36245.     (dazu geh÷ren der Netscape Navigator 3 oder h÷her, Microsoft
  36246.     Internet Explorer 3 mit einem Patch von Microsoft oder h÷her
  36247.     ohne Patch) durchfⁿhren. Es k÷nnen sowohl Text- als auch
  36248.     BinΣrdaten hochgeladen werden. Mit PHP┤s Authentifizierungs-
  36249.     und Dateifunktionen besteht volle Kontrolle darⁿber, wer
  36250.     Dateien hochladen darf und was mit den Dateien geschehen soll,
  36251.     wenn der Upload beendet ist.
  36252.    </P
  36253. ><DIV
  36254. CLASS="note"
  36255. ><BLOCKQUOTE
  36256. CLASS="note"
  36257. ><P
  36258. ><B
  36259. >Diesbezⁿgliche Konfigurationshinweise: </B
  36260. >
  36261.      Siehe auch die Anweisungen
  36262.      <A
  36263. HREF="#ini.file-uploads"
  36264. >file_uploads</A
  36265. >, 
  36266.      <A
  36267. HREF="#ini.upload-max-filesize"
  36268. >upload_max_filesize</A
  36269. >,
  36270.      <A
  36271. HREF="#ini.upload-tmp-dir"
  36272. >upload_tmp_dir</A
  36273. > und
  36274.      <A
  36275. HREF="#ini.post-max-size"
  36276. >post_max_size</A
  36277. > in der <TT
  36278. CLASS="filename"
  36279. >php.ini</TT
  36280. >
  36281.     </P
  36282. ></BLOCKQUOTE
  36283. ></DIV
  36284. ><P
  36285. >     PHP unterstⁿtzt auch Dateiuploads nach der PUT-Methode, die
  36286.     beispielsweise vom Netscape Composer und den W3C Amaya
  36287.     Clients benutzt wird. Siehe dazu <A
  36288. HREF="#features.file-upload.put-method"
  36289. >PUT-Unterstⁿtzung</A
  36290. >
  36291.     fⁿr nΣhere Informationen.
  36292.    </P
  36293. ><P
  36294. >     Eine Maske fⁿr den Dateiupload kann erstellt werden, indem man
  36295.     ein Formular entwirft, das ungefΣhr so aussieht:
  36296.     <TABLE
  36297. WIDTH="100%"
  36298. BORDER="0"
  36299. CELLPADDING="0"
  36300. CELLSPACING="0"
  36301. CLASS="EXAMPLE"
  36302. ><TR
  36303. ><TD
  36304. ><DIV
  36305. CLASS="example"
  36306. ><A
  36307. NAME="AEN5990"
  36308. ></A
  36309. ><P
  36310. ><B
  36311. >Beispiel 34-1. Formular fⁿr den Dateiupload</B
  36312. ></P
  36313. ><TABLE
  36314. BORDER="0"
  36315. BGCOLOR="#E0E0E0"
  36316. CELLPADDING="5"
  36317. ><TR
  36318. ><TD
  36319. ><PRE
  36320. CLASS="html"
  36321. ><form enctype="multipart/form-data" action="_URL_" method="post">
  36322. <input type="hidden" name="MAX_FILE_SIZE" value="30000">
  36323. Send this file: <input name="userfile" type="file">
  36324. <input type="submit" value="Send File">
  36325. </form></PRE
  36326. ></TD
  36327. ></TR
  36328. ></TABLE
  36329. ></DIV
  36330. ></TD
  36331. ></TR
  36332. ></TABLE
  36333. >
  36334.     Die _URL_ sollte auf eine PHP-Datei verweisen. Das versteckte Feld
  36335.     MAX_FILE_SIZE muss dem Dateieingabefeld vorangestellt werden und den
  36336.     Wert der maximal akzeptierten Dateigr÷▀e in Bytes enthalten.
  36337.     <DIV
  36338. CLASS="warning"
  36339. ><P
  36340. ></P
  36341. ><TABLE
  36342. CLASS="warning"
  36343. BORDER="1"
  36344. WIDTH="100%"
  36345. ><TR
  36346. ><TD
  36347. ALIGN="CENTER"
  36348. ><B
  36349. >Warnung</B
  36350. ></TD
  36351. ></TR
  36352. ><TR
  36353. ><TD
  36354. ALIGN="LEFT"
  36355. ><P
  36356. >       Die maximale Dateigr÷▀e MAX_FILE_SIZE ist fⁿr den Browser nur
  36357.       ein Hinweis und es ist leicht, diese Grenze zu umgehen. Also
  36358.       verlassen Sie sich nicht darauf, dass der Browser Ihrem Wunsch
  36359.       auch nachkommt! Wie auch immer, die PHP-Einstellungen fⁿr die
  36360.       maximale Dateigr÷▀e k÷nnen nicht getΣuscht werden.
  36361.      </P
  36362. ></TD
  36363. ></TR
  36364. ></TABLE
  36365. ></DIV
  36366. >
  36367.    </P
  36368. ><P
  36369. >     Die fⁿr hochgeladene Dateien definierten Variablen sind je nach
  36370.     PHP Version und Konfiguration verschieden. Die Autoglobale
  36371.     <A
  36372. HREF="#reserved.variables.files"
  36373. >$_FILES</A
  36374. > existiert
  36375.     seit PHP 4.1.0 und das Array <VAR
  36376. CLASS="varname"
  36377. >$HTTP_POST_FILES</VAR
  36378. >
  36379.     seit PHP 4.0.0. Diese Arrays enthalten alle Informationen ⁿber
  36380.     Ihre hochgeladenen Dateien. Die Verwendung von
  36381.     <VAR
  36382. CLASS="varname"
  36383. >$_FILES</VAR
  36384. > wird bevorzugt. Ist die PHP Anweisung
  36385.     <A
  36386. HREF="#ini.register-globals"
  36387. >register_globals</A
  36388. > auf
  36389.     <SPAN
  36390. CLASS="emphasis"
  36391. ><I
  36392. CLASS="emphasis"
  36393. >on</I
  36394. ></SPAN
  36395. >, stehen auch entsprechende Variablennamen
  36396.     zur Verfⁿgung. Seit PHP <A
  36397. HREF="http://www.php.net/release_4_2_0.php"
  36398. TARGET="_top"
  36399. >4.2.0</A
  36400. >
  36401.     steht <A
  36402. HREF="#ini.register-globals"
  36403. >register_globals</A
  36404. >
  36405.     standardmΣ▀ig  auf <SPAN
  36406. CLASS="emphasis"
  36407. ><I
  36408. CLASS="emphasis"
  36409. >off</I
  36410. ></SPAN
  36411. >.
  36412.    </P
  36413. ><P
  36414. >     Im Folgenden sind die Inhalte von
  36415.     <A
  36416. HREF="#reserved.variables.files"
  36417. >$_FILES</A
  36418. > aus unserem
  36419.     Beispielskript aufgelistet. Beachten Sie, dass dies auf der Annahme
  36420.     basiert, dass der Name des Dateiuploads wie in dem obigen
  36421.     Beispielskript <SPAN
  36422. CLASS="emphasis"
  36423. ><I
  36424. CLASS="emphasis"
  36425. >userfile</I
  36426. ></SPAN
  36427. > ist.
  36428.     <P
  36429. ></P
  36430. ><DIV
  36431. CLASS="variablelist"
  36432. ><DL
  36433. ><DT
  36434. ><VAR
  36435. CLASS="varname"
  36436. >$_FILES['userfile']['name']</VAR
  36437. ></DT
  36438. ><DD
  36439. ><P
  36440. >         Der ursprⁿngliche Dateiname auf der Client Maschine.
  36441.        </P
  36442. ></DD
  36443. ><DT
  36444. ><VAR
  36445. CLASS="varname"
  36446. >$_FILES['userfile']['type']</VAR
  36447. ></DT
  36448. ><DD
  36449. ><P
  36450. >         Der Mime-Type der Datei, falls der Browser diese Information
  36451.         zur Verfⁿgung gestellt hat. Ein Beispiel wΣre
  36452.         <VAR
  36453. CLASS="literal"
  36454. >"image/gif"</VAR
  36455. >.
  36456.         </P
  36457. ></DD
  36458. ><DT
  36459. ><VAR
  36460. CLASS="varname"
  36461. >$_FILES['userfile']['size']</VAR
  36462. ></DT
  36463. ><DD
  36464. ><P
  36465. >         Die Gr÷▀e der hochgeladenen Datei in Bytes.
  36466.        </P
  36467. ></DD
  36468. ><DT
  36469. ><VAR
  36470. CLASS="varname"
  36471. >$_FILES['userfile']['tmp_name']</VAR
  36472. ></DT
  36473. ><DD
  36474. ><P
  36475. >         Der temporΣre Dateiname, unter dem die hochgeladene Datei auf
  36476.         dem Server gespeichert wurde.
  36477.        </P
  36478. ></DD
  36479. ><DT
  36480. ><VAR
  36481. CLASS="varname"
  36482. >$_FILES['userfile']['error']</VAR
  36483. ></DT
  36484. ><DD
  36485. ><P
  36486. >         Der <A
  36487. HREF="#features.file-upload.errors"
  36488. >Fehlercode</A
  36489. >
  36490.         im Zusammenhang mit dem hochladen der Datei.
  36491.         <SPAN
  36492. CLASS="emphasis"
  36493. ><I
  36494. CLASS="emphasis"
  36495. >['error']</I
  36496. ></SPAN
  36497. > wurde in PHP 4.2.0 eingefⁿhrt.
  36498.        </P
  36499. ></DD
  36500. ></DL
  36501. ></DIV
  36502. >
  36503.    </P
  36504. ><DIV
  36505. CLASS="note"
  36506. ><BLOCKQUOTE
  36507. CLASS="note"
  36508. ><P
  36509. ><B
  36510. >Anmerkung: </B
  36511. >
  36512.      In den Versionen vor PHP 4.1.0 war dies
  36513.      <VAR
  36514. CLASS="varname"
  36515. >$HTTP_POST_FILES</VAR
  36516. >, und ist keine 
  36517.      <A
  36518. HREF="#language.variables.superglobals"
  36519. >'Autoglobale'</A
  36520. >
  36521.      Variable wie <VAR
  36522. CLASS="varname"
  36523. >$_FILES</VAR
  36524. >. PHP 3 unterstⁿtzt
  36525.      <VAR
  36526. CLASS="varname"
  36527. >$HTTP_POST_FILES</VAR
  36528. > nicht.
  36529.     </P
  36530. ></BLOCKQUOTE
  36531. ></DIV
  36532. ><P
  36533. >     Ist <A
  36534. HREF="#ini.register-globals"
  36535. >register_globals</A
  36536. >
  36537.     in der <TT
  36538. CLASS="filename"
  36539. >php.ini</TT
  36540. > aktiviert, stehen zusΣtzliche Variablen zur Verfⁿgung.
  36541.     Zum Beispiel entspricht <VAR
  36542. CLASS="varname"
  36543. >$userfile_name</VAR
  36544. >
  36545.     <VAR
  36546. CLASS="varname"
  36547. >$_FILES['userfile']['name']</VAR
  36548. >,
  36549.     <VAR
  36550. CLASS="varname"
  36551. >$userfile_type</VAR
  36552. > entspricht
  36553.     <VAR
  36554. CLASS="varname"
  36555. >$_FILES['userfile']['type']</VAR
  36556. >, etc. Beachten Sie,
  36557.     dass register_globals standardmΣ▀ig  deaktiviert ist, jedoch wird
  36558.     empfohlen, sich nicht darauf zu verlassen.
  36559.    </P
  36560. ><P
  36561. >     StandardmΣ▀ig werden Dateien in dem vorgegebenen temporΣren
  36562.     Verzeichnis des Servers gespeichert, au▀er es wurde mittels
  36563.     <A
  36564. HREF="#ini.upload-tmp-dir"
  36565. >upload_tmp_dir</A
  36566. > in
  36567.     der <TT
  36568. CLASS="filename"
  36569. >php.ini</TT
  36570. > ein anderer Ort konfiguriert.
  36571.     Das Standardverzeichnis des Servers kann durch das Setzen der
  36572.     Umgebungsvariablen <VAR
  36573. CLASS="envar"
  36574. >TMPDIR</VAR
  36575. > in der Umgebung, in der
  36576.     PHP ausgefⁿhrt wird, geΣndert werden. Das Setzen mittels der
  36577.     Funktion <A
  36578. HREF="#function.putenv"
  36579. ><B
  36580. CLASS="function"
  36581. >putenv()</B
  36582. ></A
  36583. > innerhalb eines Skriptes
  36584.     ist nicht m÷glich. Mittels dieser Umgebungsvariable kann auch
  36585.     sichergestellt werden, dass auch andere Operationen an
  36586.     hochgeladenen Dateien arbeiten k÷nnen.
  36587.     <TABLE
  36588. WIDTH="100%"
  36589. BORDER="0"
  36590. CELLPADDING="0"
  36591. CELLSPACING="0"
  36592. CLASS="EXAMPLE"
  36593. ><TR
  36594. ><TD
  36595. ><DIV
  36596. CLASS="example"
  36597. ><A
  36598. NAME="AEN6054"
  36599. ></A
  36600. ><P
  36601. ><B
  36602. >Beispiel 34-2. Dateiuploads prⁿfen</B
  36603. ></P
  36604. ><P
  36605. >       Weitere Informationen finden Sie auch in den Beschreibungen fⁿr
  36606.       <A
  36607. HREF="#function.is-uploaded-file"
  36608. ><B
  36609. CLASS="function"
  36610. >is_uploaded_file()</B
  36611. ></A
  36612. > und
  36613.       <A
  36614. HREF="#function.move-uploaded-file"
  36615. ><B
  36616. CLASS="function"
  36617. >move_uploaded_file()</B
  36618. ></A
  36619. >. Das folgende Beispiel
  36620.       verarbeitet einen von einem HTML-Formular kommenden Dateiupload.
  36621.      </P
  36622. ><TABLE
  36623. BORDER="0"
  36624. BGCOLOR="#E0E0E0"
  36625. CELLPADDING="5"
  36626. ><TR
  36627. ><TD
  36628. ><PRE
  36629. CLASS="php"
  36630. ><?php 
  36631. // In PHP kleiner als 4.1.0 sollten Sie $HTTP_POST_FILES anstatt $_FILES verwenden.
  36632. // In PHP kleiner als 4.0.3 verwenden Sie copy() und is_uploaded_file() anstatt von
  36633. // move_uploaded_file()
  36634.  
  36635. $uploaddir = '/var/www/uploads/';
  36636.  
  36637. print "<pre>";
  36638. if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) {
  36639.     print "File is valid, and was successfully uploaded.  Here's some more debugging info:\n";
  36640.     print_r($_FILES);
  36641. } else {
  36642.     print "Possible file upload attack!  Here's some debugging info:\n";
  36643.     print_r($_FILES);
  36644. }
  36645.  
  36646. ?></PRE
  36647. ></TD
  36648. ></TR
  36649. ></TABLE
  36650. ></DIV
  36651. ></TD
  36652. ></TR
  36653. ></TABLE
  36654. >
  36655.    </P
  36656. ><P
  36657. >     Das die hochgeladene Datei empfangende Skript sollte die notwendige
  36658.     Logik zur Entscheidung enthalten, was mit der hochgeladenen Datei
  36659.     geschehen soll. Sie k÷nnen zum Beispiel
  36660.     <VAR
  36661. CLASS="varname"
  36662. >$_FILES['userfile']['size']</VAR
  36663. > benutzen,
  36664.     um zu kleine bzw. zu gro▀e Dateien wegzuwerfen. Sie k÷nnen
  36665.     <VAR
  36666. CLASS="varname"
  36667. >$_FILES['userfile']['type']</VAR
  36668. > nutzen, um Dateien
  36669.     eines unerwⁿnschten Typs wegzuwerfen. Seit PHP 4.2.0 k÷nnen Sie Ihre
  36670.     Logik auch mittels <VAR
  36671. CLASS="varname"
  36672. >$_FILES['userfile']['error']</VAR
  36673. >
  36674.     anhand der <A
  36675. HREF="#features.file-upload.errors"
  36676. >Fehlercodes</A
  36677. >
  36678.     planen. Egal welche Logik Sie verwenden, Sie sollten die Datei in dem
  36679.     temporΣren Verzeichnis entweder l÷schen, oder an einen anderen Ort
  36680.     verschieben.
  36681.    </P
  36682. ><P
  36683. >     Wurde die Datei in dem temporΣren Verzeichnis nicht verschoben oder
  36684.     umbenannt, wird sie am Ende des Requests gel÷scht.
  36685.    </P
  36686. ></DIV
  36687. ><DIV
  36688. CLASS="sect1"
  36689. ><HR><H2
  36690. CLASS="sect1"
  36691. ><A
  36692. NAME="features.file-upload.errors"
  36693. >Fehlermeldungen erklΣrt</A
  36694. ></H2
  36695. ><P
  36696. >     Seit PHP 4.2.0 gibt PHP zusammen mit dem Datei-Array entsprechende
  36697.     Fehlermeldungen. Die Fehlermeldung befindet sich im Segment
  36698.     <SPAN
  36699. CLASS="emphasis"
  36700. ><I
  36701. CLASS="emphasis"
  36702. >['error']</I
  36703. ></SPAN
  36704. > des Datei-Arrays, welches wΣhrend des
  36705.     Hochladens der Datei erstellt wird. In anderen Worten kann der Fehler
  36706.     in <VAR
  36707. CLASS="varname"
  36708. >$_FILES['userfile']['error']</VAR
  36709. > gefunden werden.
  36710.    </P
  36711. ><P
  36712. >     <P
  36713. ></P
  36714. ><DIV
  36715. CLASS="variablelist"
  36716. ><DL
  36717. ><DT
  36718. ><VAR
  36719. CLASS="varname"
  36720. >UPLOAD_ERR_OK</VAR
  36721. ></DT
  36722. ><DD
  36723. ><P
  36724. >         Wert: 0; Es liegt kein Fehler vor, die Datei wurde erfolgreich hochgeladen.
  36725.        </P
  36726. ></DD
  36727. ><DT
  36728. ><VAR
  36729. CLASS="varname"
  36730. >UPLOAD_ERR_INI_SIZE</VAR
  36731. ></DT
  36732. ><DD
  36733. ><P
  36734. >         Wert: 1; Die hochgeladene Datei ⁿberschreitet die in der Anweisung
  36735.         <A
  36736. HREF="#ini.upload-max-filesize"
  36737. >upload_max_filesize</A
  36738.         in <TT
  36739. CLASS="filename"
  36740. >php.ini</TT
  36741. > festgelegte Gr÷▀e.
  36742.        </P
  36743. ></DD
  36744. ><DT
  36745. ><VAR
  36746. CLASS="varname"
  36747. >UPLOAD_ERR_FORM_SIZE</VAR
  36748. ></DT
  36749. ><DD
  36750. ><P
  36751. >         Wert: 2; Die hochgeladene Datei ⁿberschreitet die in dem HTML Formular
  36752.         mittels der Anweisung <SPAN
  36753. CLASS="emphasis"
  36754. ><I
  36755. CLASS="emphasis"
  36756. >MAX_FILE_SIZE</I
  36757. ></SPAN
  36758. > angegebene
  36759.         maximale Dateigr÷▀e.
  36760.        </P
  36761. ></DD
  36762. ><DT
  36763. ><VAR
  36764. CLASS="varname"
  36765. >UPLOAD_ERR_PARTIAL</VAR
  36766. ></DT
  36767. ><DD
  36768. ><P
  36769. >         Wert: 3; Die Datei wurde nur teilweise hochgeladen.
  36770.        </P
  36771. ></DD
  36772. ><DT
  36773. ><VAR
  36774. CLASS="varname"
  36775. >UPLOAD_ERR_NO_FILE</VAR
  36776. ></DT
  36777. ><DD
  36778. ><P
  36779. >         Wert: 4; Es wurde keine Datei hochgeladen.
  36780.        </P
  36781. ></DD
  36782. ></DL
  36783. ></DIV
  36784. >
  36785.    </P
  36786. ><DIV
  36787. CLASS="note"
  36788. ><BLOCKQUOTE
  36789. CLASS="note"
  36790. ><P
  36791. ><B
  36792. >Anmerkung: </B
  36793. >
  36794.      Dies wurden Konstanten in PHP 4.3.0.
  36795.     </P
  36796. ></BLOCKQUOTE
  36797. ></DIV
  36798. ></DIV
  36799. ><DIV
  36800. CLASS="sect1"
  36801. ><HR><H2
  36802. CLASS="sect1"
  36803. ><A
  36804. NAME="features.file-upload.common-pitfalls"
  36805. >HΣufige Probleme</A
  36806. ></H2
  36807. ><P
  36808. >     Der mit <VAR
  36809. CLASS="literal"
  36810. >MAX_FILE_SIZE</VAR
  36811. > eingestellte Wert
  36812.     kann nicht gr÷▀er sein als der des ini-Parameters <A
  36813. HREF="#ini.upload-max-filesize"
  36814. >upload_max_filesize</A
  36815. >.
  36816.     Der Standardwert ist 2 Megabyte.
  36817.    </P
  36818. ><P
  36819. >     Ist <VAR
  36820. CLASS="literal"
  36821. >memory limit</VAR
  36822. > aktiviert, k÷nnte eine Erh÷hung
  36823.     von <A
  36824. HREF="#ini.memory-limit"
  36825. >memory_limit</A
  36826. > n÷tig sein.
  36827.     Stellen Sie sicher, dass der Wert von <A
  36828. HREF="#ini.memory-limit"
  36829. >memory_limit</A
  36830. > gro▀ genug ist.
  36831.    </P
  36832. ><P
  36833. >     Wenn <A
  36834. HREF="#ini.max-execution-time"
  36835. >max_execution_time</A
  36836. >
  36837.     zu kurz konfiguriert ist, k÷nnte das Skript den Wert ⁿberschritten
  36838.     haben. Stellen Sie sicher, dass der Wert von
  36839.     <VAR
  36840. CLASS="literal"
  36841. >max_execution_time</VAR
  36842. > gro▀ genug ist.
  36843.    </P
  36844. ><P
  36845. >     Ist <A
  36846. HREF="#ini.post-max-size"
  36847. >post_max_size</A
  36848. > zu klein
  36849.     konfiguriert, k÷nnen gro▀e Dateien nicht hochgeladen werden. Stellen
  36850.     Sie sicher, dass der Wert von <VAR
  36851. CLASS="literal"
  36852. >post_max_size</VAR
  36853. > gro▀
  36854.     genug ist.
  36855.    </P
  36856. ><P
  36857. >     Nicht zu prⁿfen an welcher Datei Sie arbeiten kann bedeuten, dass
  36858.     Benutzer auf sensible Informationen in anderen Verzeichnissen Zugriff
  36859.     erhalten.
  36860.    </P
  36861. ><P
  36862. >     Beachten Sie, dass CERN httpd in dem vom Client erhaltenen
  36863.     Content-Type Mime Header alles nach dem ersten Whitespace
  36864.     wegzuschneiden scheint. Solange dies der Fall ist, unterstⁿtzt
  36865.     CERN httpd keine Dateiuploads.
  36866.    </P
  36867. ><P
  36868. >     Aufgrund der vielen m÷glichen Arten der Darstellung von Verzeichnissen
  36869.     k÷nnen wir nicht garantieren, dass Dateien mit exotischen Namen (wie z.B.
  36870.     mit enthaltenen Leerzeichen) auch wirklich richtig verarbeitet werden.
  36871.    </P
  36872. ></DIV
  36873. ><DIV
  36874. CLASS="sect1"
  36875. ><HR><H2
  36876. CLASS="sect1"
  36877. ><A
  36878. NAME="features.file-upload.multiple"
  36879. >Upload mehrerer Dateien</A
  36880. ></H2
  36881. ><P
  36882. >     Mehrere Dateien k÷nnen hochgeladen werden, indem Sie verschiedene
  36883.     Namen <VAR
  36884. CLASS="literal"
  36885. >name</VAR
  36886. > fⁿr <VAR
  36887. CLASS="literal"
  36888. >input</VAR
  36889. > verwenden.
  36890.    </P
  36891. ><P
  36892. >     Es ist ebenfalls m÷glich, mehrere Dateien simultan hochzuladen, und
  36893.     die Informationen automatisch in Arrays zu erhalten. Um dies zu tun,
  36894.     verwenden Sie in dem HTML Formular die gleiche Array-Sende-Syntax
  36895.     wie bei Auswahllisten mit Mehrfachauswahl und Checkboxen:
  36896.    </P
  36897. ><DIV
  36898. CLASS="note"
  36899. ><BLOCKQUOTE
  36900. CLASS="note"
  36901. ><P
  36902. ><B
  36903. >Anmerkung: </B
  36904. >
  36905.      Die Unterstⁿtzung fⁿr den Upload von mehreren Dateien wurde in
  36906.      PHP 3.0.10 hinzugefⁿgt.
  36907.     </P
  36908. ></BLOCKQUOTE
  36909. ></DIV
  36910. ><P
  36911. >     <TABLE
  36912. WIDTH="100%"
  36913. BORDER="0"
  36914. CELLPADDING="0"
  36915. CELLSPACING="0"
  36916. CLASS="EXAMPLE"
  36917. ><TR
  36918. ><TD
  36919. ><DIV
  36920. CLASS="example"
  36921. ><A
  36922. NAME="AEN6130"
  36923. ></A
  36924. ><P
  36925. ><B
  36926. >Beispiel 34-3. Upload mehrerer Dateien</B
  36927. ></P
  36928. ><TABLE
  36929. BORDER="0"
  36930. BGCOLOR="#E0E0E0"
  36931. CELLPADDING="5"
  36932. ><TR
  36933. ><TD
  36934. ><PRE
  36935. CLASS="html"
  36936. ><form action="file-upload.php" method="post" enctype="multipart/form-data">
  36937.   Send these files:<br>
  36938.   <input name="userfile[]" type="file"><br>
  36939.   <input name="userfile[]" type="file"><br>
  36940.   <input type="submit" value="Send files">
  36941. </form></PRE
  36942. ></TD
  36943. ></TR
  36944. ></TABLE
  36945. ></DIV
  36946. ></TD
  36947. ></TR
  36948. ></TABLE
  36949. >
  36950.    </P
  36951. ><P
  36952. >     Wenn das obige Formular ⁿbermittelt ist, werden die Arrays
  36953.     <VAR
  36954. CLASS="varname"
  36955. >$_FILES['userfile']</VAR
  36956. >,
  36957.     <VAR
  36958. CLASS="varname"
  36959. >$_FILES['userfile']['name']</VAR
  36960. > und
  36961.     <VAR
  36962. CLASS="varname"
  36963. >$_FILES['userfile']['size']</VAR
  36964. >
  36965.     initialisiert (wie auch in $HTTP_POST_FILES vor PHP Version 4.1.0.).
  36966.     Ist <VAR
  36967. CLASS="literal"
  36968. >register_globals</VAR
  36969. > aktiviert, werden auch
  36970.     globale Variablen fⁿr die hochgeladenen Dateien initialisiert.
  36971.     Jedes von ihnen ist ein numerisch indiziertes Array mit den
  36972.     entsprechenden Werten fⁿr die hochgeladenen Dateien.
  36973.    </P
  36974. ><P
  36975. >     Nehmen wir zum Beispiel an, dass die Dateinamen
  36976.     <TT
  36977. CLASS="filename"
  36978. >/home/test/review.html</TT
  36979. > und
  36980.     <TT
  36981. CLASS="filename"
  36982. >/home/test/xwp.out</TT
  36983. > ⁿbermittelt wurden.
  36984.     In diesem Fall wⁿrde
  36985.     <VAR
  36986. CLASS="varname"
  36987. >$_FILES['userfile']['name'][0]</VAR
  36988. >
  36989.     <TT
  36990. CLASS="filename"
  36991. >review.html</TT
  36992. > enthalten, und
  36993.     <VAR
  36994. CLASS="varname"
  36995. >$_FILES['userfile']['name'][1]</VAR
  36996. >
  36997.     hΣtte den Wert <TT
  36998. CLASS="filename"
  36999. >xwp.out</TT
  37000. >. Genauso wⁿrde
  37001.     <VAR
  37002. CLASS="varname"
  37003. >$_FILES['userfile']['size'][0]</VAR
  37004. > die
  37005.     Dateigr÷▀e von <TT
  37006. CLASS="filename"
  37007. >review.html</TT
  37008. > enthalten, usw.
  37009.    </P
  37010. ><P
  37011. >     <VAR
  37012. CLASS="varname"
  37013. >$_FILES['userfile']['name'][0]</VAR
  37014. >,
  37015.     <VAR
  37016. CLASS="varname"
  37017. >$_FILES['userfile']['tmp_name'][0]</VAR
  37018. >,
  37019.     <VAR
  37020. CLASS="varname"
  37021. >$_FILES['userfile']['size'][0]</VAR
  37022. > und
  37023.     <VAR
  37024. CLASS="varname"
  37025. >$_FILES['userfile']['type'][0]</VAR
  37026. > sind
  37027.     ebenfalls gesetzt.
  37028.    </P
  37029. ></DIV
  37030. ><DIV
  37031. CLASS="sect1"
  37032. ><HR><H2
  37033. CLASS="sect1"
  37034. ><A
  37035. NAME="features.file-upload.put-method"
  37036. >PUT-Unterstⁿtzung</A
  37037. ></H2
  37038. ><P
  37039. >     Die Unterstⁿtzung der PUT-Methode hat sich zwischen PHP 3 und
  37040.     PHP 4 geΣndert. In PHP 4 sollten Sie den standard Input-Datenstrom
  37041.     benutzen, um die Inhalte eines HTTP PUT zu lesen.
  37042.    </P
  37043. ><P
  37044. >     <TABLE
  37045. WIDTH="100%"
  37046. BORDER="0"
  37047. CELLPADDING="0"
  37048. CELLSPACING="0"
  37049. CLASS="EXAMPLE"
  37050. ><TR
  37051. ><TD
  37052. ><DIV
  37053. CLASS="example"
  37054. ><A
  37055. NAME="AEN6156"
  37056. ></A
  37057. ><P
  37058. ><B
  37059. >Beispiel 34-4. Speicher von HTTP PUT Dateien mit PHP 4</B
  37060. ></P
  37061. ><TABLE
  37062. BORDER="0"
  37063. BGCOLOR="#E0E0E0"
  37064. CELLPADDING="5"
  37065. ><TR
  37066. ><TD
  37067. ><PRE
  37068. CLASS="php"
  37069. ><?php
  37070. /* PUT Daten kommen in den stdin Stream */
  37071. $putdata = fopen("php://stdin","r");
  37072.  
  37073. /* Eine Datei zum Schreiben ÷ffnen */
  37074. $fp = fopen("myputfile.ext","w");
  37075.  
  37076. /* Jeweils 1kB Daten lesen und
  37077.    in die Datei schreiben */
  37078. while ($data = fread($putdata,1024))
  37079.   fwrite($fp,$data);
  37080.  
  37081. /* Die Streams schlie▀en */
  37082. fclose($fp);
  37083. fclose($putdata);
  37084. ?></PRE
  37085. ></TD
  37086. ></TR
  37087. ></TABLE
  37088. ></DIV
  37089. ></TD
  37090. ></TR
  37091. ></TABLE
  37092. >
  37093.    </P
  37094. ><DIV
  37095. CLASS="note"
  37096. ><BLOCKQUOTE
  37097. CLASS="note"
  37098. ><P
  37099. ><B
  37100. >Anmerkung: </B
  37101. >
  37102.      SΣmtliche untenstehende Dokumentation betrifft nur PHP 3.
  37103.     </P
  37104. ></BLOCKQUOTE
  37105. ></DIV
  37106. ><P
  37107. >     PHP unterstⁿtzt die HTTP PUT-Methode, wie sie von Clients wie Netscape
  37108.     Composer oder W3C Amaya benutzt wird. PUT-Anfragen sind weitaus
  37109.     unkomplizierter als ein Dateiupload und sehen etwa so aus:
  37110.     <DIV
  37111. CLASS="informalexample"
  37112. ><P
  37113. ></P
  37114. ><A
  37115. NAME="AEN6162"
  37116. ></A
  37117. ><TABLE
  37118. BORDER="0"
  37119. BGCOLOR="#E0E0E0"
  37120. CELLPADDING="5"
  37121. ><TR
  37122. ><TD
  37123. ><PRE
  37124. CLASS="programlisting"
  37125. >PUT /path/filename.html HTTP/1.1</PRE
  37126. ></TD
  37127. ></TR
  37128. ></TABLE
  37129. ><P
  37130. ></P
  37131. ></DIV
  37132. >
  37133.    </P
  37134. ><P
  37135. >     Das wⁿrde normalerweise bedeuten, dass der entfernte Client den
  37136.     folgenden Inhalt als /path/filename.html im Webverzeichnisbaum
  37137.     speichert. Natⁿrlich ist es keine gute Idee, dass PHP oder
  37138.     Apache jeden Benutzer beliebige Dateien ⁿberschreiben lassen.
  37139.     Um eine solche Anfrage bearbeiten zu k÷nnen, muss der Webserver
  37140.     erst angewiesen werden, ein bestimmtes PHP-Skript fⁿr die
  37141.     Abarbeitung aufzurufen. Im Apache wird dies durch die
  37142.     <SPAN
  37143. CLASS="emphasis"
  37144. ><I
  37145. CLASS="emphasis"
  37146. >Script</I
  37147. ></SPAN
  37148. > - Direktive festgelegt. Sie kann fast
  37149.     ⁿberall in der Apache-Konfigurationsdatei platziert werden,
  37150.     gebrΣuchlich ist die Platzierung innerhalb einer <Directory>- oder
  37151.     <Virtualhost>- Sektion. Eine Zeile wie die folgende erledigt dies:
  37152.     <DIV
  37153. CLASS="informalexample"
  37154. ><P
  37155. ></P
  37156. ><A
  37157. NAME="AEN6166"
  37158. ></A
  37159. ><TABLE
  37160. BORDER="0"
  37161. BGCOLOR="#E0E0E0"
  37162. CELLPADDING="5"
  37163. ><TR
  37164. ><TD
  37165. ><PRE
  37166. CLASS="programlisting"
  37167. >Script PUT /put.php</PRE
  37168. ></TD
  37169. ></TR
  37170. ></TABLE
  37171. ><P
  37172. ></P
  37173. ></DIV
  37174. >
  37175.    </P
  37176. ><P
  37177. >     Diese Zeile legt fest, dass Apache alle PUT-Anfragen fⁿr URIs, die
  37178.     dem Kontext entsprechen, in dem diese Zeile steht, an das put.php
  37179.     Skript weiterleitet. Dies setzt natⁿrlich voraus, dass PHP aktiv
  37180.     und fⁿr die .php-Dateierweiterung registriert ist.
  37181.    </P
  37182. ><P
  37183. >     Innerhalb der put.php-Datei k÷nnte folgendes stehen:
  37184.    </P
  37185. ><P
  37186. >     <DIV
  37187. CLASS="informalexample"
  37188. ><P
  37189. ></P
  37190. ><A
  37191. NAME="AEN6171"
  37192. ></A
  37193. ><TABLE
  37194. BORDER="0"
  37195. BGCOLOR="#E0E0E0"
  37196. CELLPADDING="5"
  37197. ><TR
  37198. ><TD
  37199. ><PRE
  37200. CLASS="php"
  37201. ><?php copy($PHP_UPLOADED_FILE_NAME,$DOCUMENT_ROOT.$REQUEST_URI); ?></PRE
  37202. ></TD
  37203. ></TR
  37204. ></TABLE
  37205. ><P
  37206. ></P
  37207. ></DIV
  37208. >
  37209.    </P
  37210. ><P
  37211. >     Dies kopiert die Datei an den vom Client angegebenen Ort.
  37212.     M÷glicherweise sollen vor dem Kopieren der Datei noch
  37213.     ▄berprⁿfungen und/oder Benutzerauthentifizierung stattfinden.
  37214.     Wenn PHP eine PUT-Anfrage erhΣlt, wird die Datei genau wie bei der
  37215.     <A
  37216. HREF="#features.file-upload.post-method"
  37217. >POST-Methode</A
  37218. >
  37219.     in einem temporΣren Verzeichnis gespeichert. Nach dem Abarbeiten
  37220.     der Anfrage wird die temporΣre Datei gel÷scht. Also muss das
  37221.     PHP-Skript, das die PUT-Anfrage bearbeitet, die Datei irgendwohin
  37222.     kopieren. Der Name der temporΣren Datei findet sich in der
  37223.     Variablen $PHP_PUT_FILENAME; der Name der zu speichernden
  37224.     Datei steht in $REQUEST_URI (kann bei Nicht-Apache Webservern
  37225.     variieren). Dieser Zieldateiname wird vom Client festgelegt. Man
  37226.     kann den Client auch umgehen; beispielsweise k÷nnten alle
  37227.     hochgeladenen Dateien in ein spezielles Upload-Directory kopiert
  37228.     werden.
  37229.    </P
  37230. ></DIV
  37231. ></DIV
  37232. ><DIV
  37233. CLASS="chapter"
  37234. ><HR><H1
  37235. ><A
  37236. NAME="features.remote-files"
  37237. >Kapitel 35. Zugriff auf entfernte Dateien</A
  37238. ></H1
  37239. ><P
  37240. >    Wenn die Unterstⁿtzung fⁿr den "URL fopen wrapper" bei der
  37241.    Konfiguration von PHP vorhanden ist (welche standardmΣ▀ig eingestellt ist, es sei denn,
  37242.    die Option <VAR
  37243. CLASS="option"
  37244. >--disable-url-fopen-wrapper</VAR
  37245. > wurde bei der Installation verwendet (Versionen 
  37246.    bis 4.0.3) oder der Parameter <VAR
  37247. CLASS="parameter"
  37248. >allow_url_fopen</VAR
  37249. > in der php.ini 
  37250.    deaktiviert wurde (neuere Versionen),
  37251.    k÷nnen HTTP und FTP URLs bei den meisten Funktionen verwendet werden, die einen
  37252.    Dateinamen als Parameter ben÷tigen, inklusive <A
  37253. HREF="#function.require"
  37254. ><B
  37255. CLASS="function"
  37256. >require()</B
  37257. ></A
  37258. >
  37259.    und <A
  37260. HREF="#function.include"
  37261. ><B
  37262. CLASS="function"
  37263. >include()</B
  37264. ></A
  37265. > Anweisungen.
  37266.   </P
  37267. ><P
  37268. >    <DIV
  37269. CLASS="note"
  37270. ><BLOCKQUOTE
  37271. CLASS="note"
  37272. ><P
  37273. ><B
  37274. >Anmerkung: </B
  37275. >
  37276.      remote files funktionieren nicht mit <A
  37277. HREF="#function.include"
  37278. ><B
  37279. CLASS="function"
  37280. >include()</B
  37281. ></A
  37282. > und
  37283.      <A
  37284. HREF="#function.require"
  37285. ><B
  37286. CLASS="function"
  37287. >require()</B
  37288. ></A
  37289. > Anweisungen unter Windows.
  37290.     </P
  37291. ></BLOCKQUOTE
  37292. ></DIV
  37293. >
  37294.   </P
  37295. ><P
  37296. >    Beispielsweise kann eine Datei auf einem anderen Webserver ge÷ffnet und verarbeitet werden. 
  37297.    Diese Daten k÷nnen zur Abfrage einer Datenbank benutzt werden oder passend zum Rest der eigenen 
  37298.    Website ausgegeben werden.
  37299.   </P
  37300. ><P
  37301. >    <TABLE
  37302. WIDTH="100%"
  37303. BORDER="0"
  37304. CELLPADDING="0"
  37305. CELLSPACING="0"
  37306. CLASS="EXAMPLE"
  37307. ><TR
  37308. ><TD
  37309. ><DIV
  37310. CLASS="example"
  37311. ><A
  37312. NAME="AEN6189"
  37313. ></A
  37314. ><P
  37315. ><B
  37316. >Beispiel 35-1. Den Titel einer entfernten Seite auslesen</B
  37317. ></P
  37318. ><TABLE
  37319. BORDER="0"
  37320. BGCOLOR="#E0E0E0"
  37321. CELLPADDING="5"
  37322. ><TR
  37323. ><TD
  37324. ><PRE
  37325. CLASS="php"
  37326. ><?php
  37327. $file = fopen ("http://www.example.com/", "r");
  37328. if (!$file) {
  37329.     echo "<p>Datei konnte nicht ge÷ffnet werden.\n";
  37330.     exit;
  37331. }
  37332. while (!feof ($file)) {
  37333.     $line = fgets ($file, 1024);
  37334.     /* Funktioniert nur, wenn Titel und title-Tags in einer Zeile stehen */
  37335.     if (eregi ("<title>(.*)</title>", $line, $out)) {
  37336.         $title = $out[1];
  37337.         break;
  37338.     }
  37339. }
  37340. fclose($file);
  37341. ?></PRE
  37342. ></TD
  37343. ></TR
  37344. ></TABLE
  37345. ></DIV
  37346. ></TD
  37347. ></TR
  37348. ></TABLE
  37349. >
  37350.   </P
  37351. ><P
  37352. >    Auch eine Datei auf einem FTP-Server kann geschrieben werden, solange man sich ⁿber 
  37353.    einen Benutzer mit entsprechenden Zugriffsrechten verbindet und die Datei noch nicht existiert.
  37354.    Um sich mit einem anderen Benutzer als 'anonymous' zu verbinden mu▀ ein
  37355.    username (und m÷glichst ein Passwort) innerhalb der URL angegeben werden, wie z.B.
  37356.    'ftp://user:password@ftp.example.com/pfad/zur/datei'. (Die selbe Syntax 
  37357.    kann verwendet werden, um auf Daten via HTTP zuzugreifen, wenn diese eine Basic
  37358.    Authentication ben÷tigen.)
  37359.   </P
  37360. ><P
  37361. >    <TABLE
  37362. WIDTH="100%"
  37363. BORDER="0"
  37364. CELLPADDING="0"
  37365. CELLSPACING="0"
  37366. CLASS="EXAMPLE"
  37367. ><TR
  37368. ><TD
  37369. ><DIV
  37370. CLASS="example"
  37371. ><A
  37372. NAME="AEN6194"
  37373. ></A
  37374. ><P
  37375. ><B
  37376. >Beispiel 35-2. Daten auf einen entfernten Server speichern</B
  37377. ></P
  37378. ><TABLE
  37379. BORDER="0"
  37380. BGCOLOR="#E0E0E0"
  37381. CELLPADDING="5"
  37382. ><TR
  37383. ><TD
  37384. ><PRE
  37385. CLASS="php"
  37386. ><?php
  37387. $file = fopen ("ftp://ftp.example.com/incoming/outputfile", "w");
  37388. if (!$file) {
  37389.     echo "<p>Datei konnte zum schreiben nicht ge÷ffnet werden.\n";
  37390.     exit;
  37391. }
  37392. /* Schreibe die Daten hier hin. */
  37393. fputs ($file, "$HTTP_USER_AGENT\n");
  37394. fclose ($file);
  37395. ?></PRE
  37396. ></TD
  37397. ></TR
  37398. ></TABLE
  37399. ></DIV
  37400. ></TD
  37401. ></TR
  37402. ></TABLE
  37403. >
  37404.   </P
  37405. ><P
  37406. >    <DIV
  37407. CLASS="note"
  37408. ><BLOCKQUOTE
  37409. CLASS="note"
  37410. ><P
  37411. ><B
  37412. >Anmerkung: </B
  37413. >
  37414.      Obiges Beispiel k÷nnte dazu verleiten, dieses Verfahren zu benutzen, um in ein 'remote log-file' 
  37415.      zu schreiben. Wie oben erwΣhnt kann man jedoch ausschlie▀lich neue Dateien anlegen, 
  37416.      wenn man URL fopen() wrapper benutzt. Fⁿr 'distributed logging' sollte man sich die Funktion 
  37417.      <A
  37418. HREF="#function.syslog"
  37419. ><B
  37420. CLASS="function"
  37421. >syslog()</B
  37422. ></A
  37423. > anschauen.
  37424.     </P
  37425. ></BLOCKQUOTE
  37426. ></DIV
  37427. >
  37428.   </P
  37429. ></DIV
  37430. ><DIV
  37431. CLASS="chapter"
  37432. ><HR><H1
  37433. ><A
  37434. NAME="features.connection-handling"
  37435. >Kapitel 36. Verbindungssteuerung</A
  37436. ></H1
  37437. ><DIV
  37438. CLASS="note"
  37439. ><BLOCKQUOTE
  37440. CLASS="note"
  37441. ><P
  37442. ><B
  37443. >Anmerkung: </B
  37444. >Folgendes trifft auf die Versionen 3.0.7 und spΣter zu.</P
  37445. ></BLOCKQUOTE
  37446. ></DIV
  37447. ><P
  37448. >    PHP erhΣlt intern einen Verbindungsstatus. Dieser kann drei
  37449.    ZustΣnde annehmen:
  37450.    <P
  37451. ></P
  37452. ><UL
  37453. ><LI
  37454. ><P
  37455. >0 - NORMAL</P
  37456. ></LI
  37457. ><LI
  37458. ><P
  37459. >1 - ABORTED</P
  37460. ></LI
  37461. ><LI
  37462. ><P
  37463. >2 - TIMEOUT</P
  37464. ></LI
  37465. ></UL
  37466. >
  37467.   </P
  37468. ><P
  37469. >    Wenn ein PHP-Skript aktiv ist, ist der Status ⁿblicherweise   
  37470.    NORMAL. Sollte der Client-Rechner die Verbindung beenden, wird
  37471.    der Status auf ABORTED gesetzt. Ein clientseitiges Beenden der
  37472.    Verbindung wird fⁿr gew÷hnlich veranla▀t, wenn der Benutzer den
  37473.    STOP-Button seines Browsers drⁿckt. Wenn das eingestellte Zeitlimit
  37474.    (siehe <A
  37475. HREF="#function.set-time-limit"
  37476. ><B
  37477. CLASS="function"
  37478. >set_time_limit()</B
  37479. ></A
  37480. >) ⁿberschritten wird,
  37481.    wird der Status TIMEOUT gesetzt.</P
  37482. ><P
  37483. >    Sie k÷nnen entscheiden, ob der Verbindungsabbruch seitens des Clients
  37484.    den Abbruch des Skriptes zur Folge haben soll.
  37485.    Manchmal ist es sinnvoll, Skripte sauber zu beenden, auch wenn
  37486.    kein Browser mehr zur Verfⁿgung steht, der die Ausgabe empfΣngt.
  37487.    Die Abarbeitung eines Skriptes wird standardmΣ▀ig abgebrochen, wenn
  37488.    der Client die Verbindung beendet.
  37489.    Dieses Verhalten kann sowohl durch die Option ignore_user_abort in
  37490.    der Konfigurationsdatei php3.ini, durch die entsprechende
  37491.    Option php3_ignore_user_abort in der Apache-Konfigurationsdatei
  37492.    als auch durch <A
  37493. HREF="#function.ignore-user-abort"
  37494. ><B
  37495. CLASS="function"
  37496. >ignore_user_abort()</B
  37497. ></A
  37498. > beeinflu▀t
  37499.    werden.
  37500.    Wenn PHP nicht angewiesen wird, einen Verbindungsabbruch durch den
  37501.    Benutzer zu ignorieren und die Verbindung dann durch den Benutzer
  37502.    beendet wird, wird die Abarbeitung des Scriptes abgebrochen. Die einzige
  37503.    Ausnahme ist, wenn durch die Funktion 
  37504.    <A
  37505. HREF="#function.register-shutdown-function"
  37506. ><B
  37507. CLASS="function"
  37508. >register_shutdown_function()</B
  37509. ></A
  37510. > eine Shutdown-Funktion
  37511.    angegeben wird, die bei clientseitigem Abbruch ausgefⁿhrt wird. 
  37512.    Wenn dann der Benutzer den STOP-Button seines Browsers drⁿckt, wird
  37513.    PHP bei der nΣchsten Ausgabe des Skriptes feststellen, dass die
  37514.    Verbindung abgebrochen wurde und die Shutdown-Funktion aufrufen.
  37515.    Diese Shutdown-Funktion wird auch aufgerufen, wenn das Skript auf 
  37516.    normalem Wege beendet wird, daher sollte man, wenn man fⁿr den
  37517.    Fall eines Benutzerabbruchs etwas anderes vorgesehen hat,
  37518.    die Funktion <A
  37519. HREF="#function.connection-aborted"
  37520. ><B
  37521. CLASS="function"
  37522. >connection_aborted()</B
  37523. ></A
  37524. > verwenden.
  37525.    Sie gibt <TT
  37526. CLASS="constant"
  37527. ><B
  37528. >TRUE</B
  37529. ></TT
  37530. > zurⁿck, wenn die Verbindung abgebrochen wurde.</P
  37531. ><P
  37532. >    Ein Skript kann ebenfalls durch den eingebauten Script-Timer
  37533.    beendet werden. Der Standard-Timeout betrΣgt 30 Sekunden. Er kann
  37534.    durch die Option max_execution_time in der php3.ini, durch
  37535.    den entsprechenden Eintrag php3_max_execution_time in der
  37536.    Apache-Konfigurationsdatei oder durch die Funktion
  37537.    <A
  37538. HREF="#function.set-time-limit"
  37539. ><B
  37540. CLASS="function"
  37541. >set_time_limit()</B
  37542. ></A
  37543. > beeinflu▀t werden. Bei
  37544.    Zeitⁿberschreitung wird das Skript beendet und, genau wie im obigen
  37545.    Fall des Verbindungsabbruchs, eine registrierte Shutdown-Funktion
  37546.    ausgefⁿhrt. Um zu ⁿberprⁿfen, ob es sich um einen Abbruch aufgrund
  37547.    von Zeitⁿberschreitung handelt, kann die Funktion
  37548.    <A
  37549. HREF="#function.connection-timeout"
  37550. ><B
  37551. CLASS="function"
  37552. >connection_timeout()</B
  37553. ></A
  37554. > benutzt werden. Sie gibt
  37555.    <TT
  37556. CLASS="constant"
  37557. ><B
  37558. >TRUE</B
  37559. ></TT
  37560. > zurⁿck, wenn es sich um eine Zeitⁿberschreitung handelt.</P
  37561. ><P
  37562. >    Zu bemerken ist, dass der ABORTED und der TIMEOUT-Status gleichzeitig
  37563.    auftreten k÷nnen. Dies ist m÷glich, wenn PHP angewiesen wird,
  37564.    Benutzerabbrⁿche zu ignorieren. PHP wird feststellen, dass der
  37565.    Benutzer die Verbindung abgebrochen hat, das Skript allerdings
  37566.    lΣuft weiter. Sollte es dann das Zeitlimit erreichen, wird es
  37567.    abgebrochen und eine Shutdown-Funktion, wenn definiert, wird
  37568.    aufgerufen. Zu diesem Zeitpunkt kann man feststellen, dass
  37569.    <A
  37570. HREF="#function.connection-timeout"
  37571. ><B
  37572. CLASS="function"
  37573. >connection_timeout()</B
  37574. ></A
  37575. >
  37576.    und <A
  37577. HREF="#function.connection-aborted"
  37578. ><B
  37579. CLASS="function"
  37580. >connection_aborted()</B
  37581. ></A
  37582. > <TT
  37583. CLASS="constant"
  37584. ><B
  37585. >TRUE</B
  37586. ></TT
  37587. > zurⁿckgeben.
  37588.    Diese beiden Statusm÷glichkeiten k÷nnen auch durch einen Aufruf
  37589.    der Funktion <A
  37590. HREF="#function.connection-status"
  37591. ><B
  37592. CLASS="function"
  37593. >connection_status()</B
  37594. ></A
  37595. > abgefragt
  37596.    werden. Sie liefert ein Bitfeld des aktiven Status. Wenn
  37597.    beispielsweise TIMEOUT und ABORTED aktiv sind, wird 3 zurⁿckgegeben.
  37598.    </P
  37599. ></DIV
  37600. ><DIV
  37601. CLASS="chapter"
  37602. ><HR><H1
  37603. ><A
  37604. NAME="features.persistent-connections"
  37605. >Kapitel 37. Persistente Datenbankverbindungen</A
  37606. ></H1
  37607. ><P
  37608. >    Persistente Verbindungen sind SQL-Verbindungen, die nach
  37609.    Abarbeitung des Skriptes nicht geschlossen werden. Wenn eine
  37610.    persistente Verbindung angefordert wird, prⁿft PHP zuerst, ob
  37611.    bereits eine identische persistente Verbindung (die vielleicht
  37612.    vorher offen geblieben ist) existiert und benutzt sie in diesem Fall.
  37613.    Sollte keine Verbindung existieren, wird eine hergestellt. Eine
  37614.    'identische' Verbindung ist eine Verbindung, die zu dem
  37615.    gleichen Host mit dem gleichen Usernamen und Passwort
  37616.    hergestellt wurde.</P
  37617. ><DIV
  37618. CLASS="note"
  37619. ><BLOCKQUOTE
  37620. CLASS="note"
  37621. ><P
  37622. ><B
  37623. >Anmerkung: </B
  37624. >
  37625.     Auch andere Erweiterungen bieten persistente Verbindungen, wie z.B.
  37626.     <A
  37627. HREF="#ref.imap"
  37628. >IMAP extension</A
  37629. >.
  37630.    </P
  37631. ></BLOCKQUOTE
  37632. ></DIV
  37633. ><P
  37634. >    Wer nicht durchgΣngig mit der Art und Weise vertraut ist, wie
  37635.    Webserver arbeiten und die Last verteilen, k÷nnte missverstehen,
  37636.    wofⁿr persistente Verbindungen gedacht sind. Im Besonderen bieten
  37637.    sie <SPAN
  37638. CLASS="emphasis"
  37639. ><I
  37640. CLASS="emphasis"
  37641. >keine</I
  37642. ></SPAN
  37643. > M÷glichkeit, 'Benutzersitzungen'
  37644.    ⁿber die gleiche SQL-Verbindung zu ÷ffnen und
  37645.    <SPAN
  37646. CLASS="emphasis"
  37647. ><I
  37648. CLASS="emphasis"
  37649. >keine</I
  37650. ></SPAN
  37651. > M÷glichkeit, eine Transaktion effizient
  37652.    aufzubauen, und sie k÷nnen auch viele andere Dinge nicht. Um
  37653.    absolute Klarheit zu schaffen: Persistente Verbindungen bieten
  37654.    <SPAN
  37655. CLASS="emphasis"
  37656. ><I
  37657. CLASS="emphasis"
  37658. >keine</I
  37659. ></SPAN
  37660. > FunktionalitΣt, die nicht auch von
  37661.    nicht-persistenten Verbindungen bereitgestellt wird.
  37662.   </P
  37663. ><P
  37664. >    Warum?
  37665.   </P
  37666. ><P
  37667. >    Das hat mit der Arbeitsweise von Webservern zu tun. Es gibt drei
  37668.    M÷glichkeiten, wie ein Webserver PHP zur Generierung von
  37669.    Webseiten einsetzen kann.
  37670.   </P
  37671. ><P
  37672. >    Die erste Methode ist, PHP als CGI-'Wrapper' zu benutzen. 
  37673.    Wenn diese Methode eingesetzt wird, wird fⁿr jede Anfrage 
  37674.    nach einer PHP-Seite vom Webserver eine Instanz des PHP-
  37675.    Interpreters gestartet und anschlie▀end wieder beendet. 
  37676.    Durch die Beendigung des Interpreters nach abgeschlossener
  37677.    Anfrage werden alle Ressourcen, auf die zugegriffen wurde 
  37678.    (wie beispielsweise eine Verbindung zu einem SQL-
  37679.    Datenbankserver) wieder geschlossen. In diesem Fall erreicht
  37680.    man nichts, wenn man persistente Verbindungen benutzt - sie
  37681.    sind eben nicht bestΣndig.
  37682.   </P
  37683. ><P
  37684. >    Die zweite und populΣrste Methode ist der Einsatz von PHP als
  37685.    Modul in einem Multiprozess-Webserver, was momentan nur auf den
  37686.    Apache zutrifft. Typischerweise hat ein Multiprozess-Webserver
  37687.    einen Prozess (den 'Eltern' Prozess), der einen Satz weiterer
  37688.    Prozesse (die 'Kinder') koordiniert, welche die eigentliche Arbeit
  37689.    des Bereitstellens der Seiten ⁿbernehmen. Jede Anfrage, die von
  37690.    einem Client erfolgt, wird an einen untergeordneten Prozess, der
  37691.    noch keine andere Anfrage bearbeitet, weitergereicht. Das bedeutet,
  37692.    dass eine zweite Anfrage des gleichen Clients an den Server unter
  37693.    UmstΣnden von einem anderen untergeordneten Prozess als die
  37694.    erste Anfrage bearbeitet wird. In diesem Fall sorgt eine persistente
  37695.    Verbindung dafⁿr, dass jeder untergeordnete Prozess sich nur 
  37696.    einmal mit dem SQL-Server verbinden muss, wenn eine solche
  37697.    ben÷tigt wird. Ben÷tigt dann eine weitere Seite die Verbindung mit 
  37698.    dem SQL-Server, kann auf die zurⁿckgegriffen werden,
  37699.    die der untergeordnete Prozess vorher hergestellt hat.
  37700.   </P
  37701. ><P
  37702. >    Die letzte Methode ist, PHP als Plug-in fⁿr einen Multithread-
  37703.    Webserver zu benutzen. Derzeit bietet PHP 4 Unterstⁿtzung fⁿr
  37704.    ISAPI, WSAPI und NSAPI (unter Windows), wodurch die Nutzung von
  37705.    PHP mit Multithread-Serven wie Netscape Fast Track (iPlanet),
  37706.    Microsoft Internet Information Server (IIS) und O'Reilly's WebSite
  37707.    Pro erm÷glicht wird. Das Verhalten entspricht im wesentlichen dem
  37708.    oben beschriebenen Multiprozess-Modell. Beachten Sie, dass PHP 3
  37709.    keine Unterstⁿtzung fⁿr SAPI bietet.
  37710.   </P
  37711. ><P
  37712. >    Wozu dienen persistente Verbindungen, wenn sie keine 
  37713.    zusΣtzliche FunktionalitΣt bieten?
  37714.   </P
  37715. ><P
  37716. >    Die Antwort ist au▀erordentlich einfach: Effizienz. Persistente
  37717.    Verbindungen sind nⁿtzlich, wenn der Aufwand fⁿr das Herstellen
  37718.    einer Verbindung zu einem SQL-Server hoch ist. Ob dies der Fall ist
  37719.    oder nicht, hΣngt von vielen Faktoren ab - zum Beispiel, um welche
  37720.    Datenbank es sich handelt, ob sie auf dem gleichen Rechner wie der
  37721.    Webserver lΣuft oder welche Last die SQL-Maschine zu bewΣltigen hat
  37722.    usw. GrundsΣtzlich gilt, dass, wenn viele Verbindungen hergestellt
  37723.    werden mⁿssen, persistente Verbindungen au▀erordentlich hilfreich
  37724.    sind. Sie veranlassen den untergeordneten Prozess, sich wΣhrend
  37725.    seiner gesamten Lebensdauer lediglich einmal mit dem SQL-Server zu
  37726.    verbinden, anstatt bei jedem Aufruf einer Seite, die eine Verbindung
  37727.    ben÷tigt. Das hei▀t, dass jeder untergeordnete Prozess, der eine
  37728.    persistente Verbindung ÷ffnet, seine eigene dauerhafte Verbindung
  37729.    zum Server hat. Bei 20 untergeordneten Prozessen, die ein Skript 
  37730.    ausfⁿhren, das eine persistente Verbindung zum SQL-Server 
  37731.    herstellt, hat man beispielsweise 20 verschiedene Verbindungen 
  37732.    zum SQL-Server - eine fⁿr jeden untergeordneten Prozess.
  37733.   </P
  37734. ><P
  37735. >    Beachten Sie jedoch, dass dies auch ein paar Nachteile haben kann,
  37736.    wenn Sie eine Datenbank mit limitierten Verbindungen benutzen, welche
  37737.    durch persistente Verbindungen ⁿberschritten werden. Wenn Ihre Datenbank
  37738.    ein Limit von 16 gleichzeitigen Verbindungen hat, und aufgrund einer
  37739.    stark ausgelasteten Server-Session 17 Kind-Prozesse versuchen, eine
  37740.    Verbindung herzustellen, wird es einem nicht gelingen. Sollten in
  37741.    Ihren Skripten Fehler bestehen, welche das Schlie▀en der Verbindungen
  37742.    nicht erlauben (wie z.B. Endlosschleifen), kann das eine Datenbank
  37743.    mit mit nur 16 Verbindungen sehr schnell ⁿberschwemmen. Konsultieren
  37744.    Sie die Dokumentation Ihrer Datenbank bezⁿglich der Behandlung von
  37745.    aufgegebenen Verbindungen oder Verbindungen im Leerlauf.
  37746.   </P
  37747. ><DIV
  37748. CLASS="warning"
  37749. ><P
  37750. ></P
  37751. ><TABLE
  37752. CLASS="warning"
  37753. BORDER="1"
  37754. WIDTH="100%"
  37755. ><TR
  37756. ><TD
  37757. ALIGN="CENTER"
  37758. ><B
  37759. >Warnung</B
  37760. ></TD
  37761. ></TR
  37762. ><TR
  37763. ><TD
  37764. ALIGN="LEFT"
  37765. ><P
  37766. >     Sie sollten sich zur Vorsicht noch ein paar Gedanken machen, wenn
  37767.     Sie persistente Verbindungen benutzen. Einer ist, wenn Sie ⁿber eine
  37768.     persistente Verbindung Tabellen sperren und das Skript diese Sperre
  37769.     aus welchem Grund auch immer nicht mehr aufheben kann, nachfolgende
  37770.     Skripte, welche die selbe Verbindung benutzen, blockieren und den
  37771.     Neustart von entweder dem Webserver oder dem Datenbankserver
  37772.     verlangen. Ein weiterer ist, dass wenn Sie Transaktionen benutzen,
  37773.     ein Transaktionsblock zu dem nΣchsten die Verbindung nutzenden Skript
  37774.     ⁿbertragen wird, wenn die Ausfⁿhrung des Skriptes vor dem
  37775.     Transaktionsblock gestoppt wird. In jedem Fall k÷nnen Sie
  37776.     <A
  37777. HREF="#function.register-shutdown-function"
  37778. ><B
  37779. CLASS="function"
  37780. >register_shutdown_function()</B
  37781. ></A
  37782. > benutzen, um eine
  37783.     einfache Funktion zu registrieren, welche Ihre Tabellen wieder
  37784.     entsperrt, oder Ihre Transaktionen zurⁿckstellt. Besser ist es, wenn
  37785.     Sie dieses Problem gΣnzlich vermeiden, indem keine persistenten
  37786.     Verbindungen in Skripten benutzen, welche Tabellen sperren oder
  37787.     Transaktionen verwenden (Sie k÷nnen sie immer noch anderswo benutzen).
  37788.    </P
  37789. ></TD
  37790. ></TR
  37791. ></TABLE
  37792. ></DIV
  37793. ><P
  37794. >    Eine wichtige Zusammenfassung. Persistente Verbindungen wurden
  37795.    entwickelt, um eins-zu-eins Abbildungen auf regulΣre Verbindungen 
  37796.    zu haben. Das hei▀t, dass man <SPAN
  37797. CLASS="emphasis"
  37798. ><I
  37799. CLASS="emphasis"
  37800. >immer</I
  37801. ></SPAN
  37802. > in der Lage
  37803.    sein sollte, die persistenten Verbindungen durch nicht-persistente
  37804.    zu ersetzten, ohne dass dies den Skriptablauf verΣndert. Es <SPAN
  37805. CLASS="emphasis"
  37806. ><I
  37807. CLASS="emphasis"
  37808. >    kann</I
  37809. ></SPAN
  37810. > (und wird vermutlich auch) die Effizienz des Skriptes
  37811.    beeinflussen, aber nicht dessen Verhalten.
  37812.   </P
  37813. ><P
  37814. >    Siehe auch <A
  37815. HREF="#function.fbsql-pconnect"
  37816. ><B
  37817. CLASS="function"
  37818. >fbsql_pconnect()</B
  37819. ></A
  37820. >,
  37821.    <A
  37822. HREF="#function.ibase-pconnect"
  37823. ><B
  37824. CLASS="function"
  37825. >ibase_pconnect()</B
  37826. ></A
  37827. >, <A
  37828. HREF="#function.ifx-pconnect"
  37829. ><B
  37830. CLASS="function"
  37831. >ifx_pconnect()</B
  37832. ></A
  37833. >,
  37834.    <B
  37835. CLASS="function"
  37836. >imap_popen()</B
  37837. >, <A
  37838. HREF="#function.ingres-pconnect"
  37839. ><B
  37840. CLASS="function"
  37841. >ingres_pconnect()</B
  37842. ></A
  37843. >,
  37844.    <A
  37845. HREF="#function.msql-pconnect"
  37846. ><B
  37847. CLASS="function"
  37848. >msql_pconnect()</B
  37849. ></A
  37850. >, <A
  37851. HREF="#function.mssql-pconnect"
  37852. ><B
  37853. CLASS="function"
  37854. >mssql_pconnect()</B
  37855. ></A
  37856. >,
  37857.    <A
  37858. HREF="#function.mysql-pconnect"
  37859. ><B
  37860. CLASS="function"
  37861. >mysql_pconnect()</B
  37862. ></A
  37863. >, <A
  37864. HREF="#function.ociplogon"
  37865. ><B
  37866. CLASS="function"
  37867. >ociplogon()</B
  37868. ></A
  37869. >,
  37870.    <A
  37871. HREF="#function.odbc-pconnect"
  37872. ><B
  37873. CLASS="function"
  37874. >odbc_pconnect()</B
  37875. ></A
  37876. >, <A
  37877. HREF="#function.ora-plogon"
  37878. ><B
  37879. CLASS="function"
  37880. >ora_plogon()</B
  37881. ></A
  37882. >,
  37883.    <A
  37884. HREF="#function.pfsockopen"
  37885. ><B
  37886. CLASS="function"
  37887. >pfsockopen()</B
  37888. ></A
  37889. >, <A
  37890. HREF="#function.pg-pconnect"
  37891. ><B
  37892. CLASS="function"
  37893. >pg_pconnect()</B
  37894. ></A
  37895. > und
  37896.    <A
  37897. HREF="#function.sybase-pconnect"
  37898. ><B
  37899. CLASS="function"
  37900. >sybase_pconnect()</B
  37901. ></A
  37902. >.
  37903.   </P
  37904. ></DIV
  37905. ><DIV
  37906. CLASS="chapter"
  37907. ><HR><H1
  37908. ><A
  37909. NAME="features.safe-mode"
  37910. >Kapitel 38. Safe Mode</A
  37911. ></H1
  37912. ><P
  37913. >     Safe Mode ist der Versuch, Sicherheitsprobleme bei gemeinsam 
  37914.     genutzten Servern zu l÷sen.
  37915.     Bezogen auf die Systemarchitektur, ist es der falsche Ansatz, 
  37916.     diese Probleme innerhalb der PHP Schicht l÷sen zu wollen. 
  37917.     Da es auf Ebene des Webservers bzw. des Betriebssystems keine
  37918.     praktischen Alternativen gibt, wird Safe Mode nunmehr von vielen
  37919.     Leuten, vor allem von Providern, eingesetzt.
  37920.    </P
  37921. ><P
  37922. >     Es existieren folgende Direktiven um Safe Mode zu konfigurieren:
  37923.     <TABLE
  37924. BORDER="0"
  37925. BGCOLOR="#E0E0E0"
  37926. CELLPADDING="5"
  37927. ><TR
  37928. ><TD
  37929. ><PRE
  37930. CLASS="ini"
  37931. >safe_mode = Off 
  37932. safe_mode_gid = 0
  37933. safe_mode_include_dir = 
  37934. safe_mode_exec_dir = 
  37935. open_basedir = 
  37936. safe_mode_allowed_env_vars = PHP_ 
  37937. safe_mode_protected_env_vars = LD_LIBRARY_PATH 
  37938. disable_functions =</PRE
  37939. ></TD
  37940. ></TR
  37941. ></TABLE
  37942. >
  37943.    </P
  37944. ><P
  37945. >     Wenn <A
  37946. HREF="#ini.safe-mode"
  37947. >safe_mode</A
  37948. > aktiviert ist, 
  37949.     ⁿberprⁿft PHP, ob der Eigentⁿmer des laufenden Skriptes dem Eigentⁿmer 
  37950.     der Datei entspricht, an der mit Hilfe der Dateifunktionen gearbeitet 
  37951.     werden soll.
  37952.     Beispiel:
  37953.     <TABLE
  37954. BORDER="0"
  37955. BGCOLOR="#E0E0E0"
  37956. CELLPADDING="5"
  37957. ><TR
  37958. ><TD
  37959. ><PRE
  37960. CLASS="ls"
  37961. >-rw-rw-r--    1 rasmus   rasmus       33 Jul  1 19:20 script.php 
  37962. -rw-r--r--    1 root     root       1116 May 26 18:01 /etc/passwd</PRE
  37963. ></TD
  37964. ></TR
  37965. ></TABLE
  37966. >
  37967.     Bei der Ausfⁿhrung dieses Skriptes
  37968.     <TABLE
  37969. BORDER="0"
  37970. BGCOLOR="#E0E0E0"
  37971. CELLPADDING="5"
  37972. ><TR
  37973. ><TD
  37974. ><PRE
  37975. CLASS="php"
  37976. ><?php
  37977.  readfile('/etc/passwd'); 
  37978. ?></PRE
  37979. ></TD
  37980. ></TR
  37981. ></TABLE
  37982. >
  37983.      erscheint bei aktiviertem Safe Mode folgende Warnung:
  37984.      <TABLE
  37985. BORDER="0"
  37986. BGCOLOR="#E0E0E0"
  37987. CELLPADDING="5"
  37988. ><TR
  37989. ><TD
  37990. ><PRE
  37991. CLASS="screen"
  37992. >Warning: SAFE MODE Restriction in effect. The script whose uid is 500 is not 
  37993. allowed to access /etc/passwd owned by uid 0 in /docroot/script.php on line 2</PRE
  37994. ></TD
  37995. ></TR
  37996. ></TABLE
  37997. >
  37998.    </P
  37999. ><P
  38000. >     Wenn anstelle von <A
  38001. HREF="#ini.safe-mode"
  38002. >safe_mode</A
  38003. > ein 
  38004.     <A
  38005. HREF="#ini.open-basedir"
  38006. >open_basedir</A
  38007.     Verzeichnis angegeben wurde, k÷nnen Dateioperationen 
  38008.     nur noch unterhalb dieses Verzeichnisses vorgenommen werden.
  38009.     Beispiel (Apache httpd.conf):
  38010.     <TABLE
  38011. BORDER="0"
  38012. BGCOLOR="#E0E0E0"
  38013. CELLPADDING="5"
  38014. ><TR
  38015. ><TD
  38016. ><PRE
  38017. CLASS="ini"
  38018. ><Directory /docroot>
  38019. php_admin_value open_basedir /docroot 
  38020. </Directory></PRE
  38021. ></TD
  38022. ></TR
  38023. ></TABLE
  38024. >
  38025.     Wenn das Skript script.php mit der 
  38026.     <A
  38027. HREF="#ini.open-basedir"
  38028. >open_basedir</A
  38029. >
  38030.     Einstellung ausgefⁿhrt wird, erscheint folgende Warnung:
  38031.     <TABLE
  38032. BORDER="0"
  38033. BGCOLOR="#E0E0E0"
  38034. CELLPADDING="5"
  38035. ><TR
  38036. ><TD
  38037. ><PRE
  38038. CLASS="screen"
  38039. >Warning: open_basedir restriction in effect. File is in wrong directory in 
  38040. /docroot/script.php on line 2</PRE
  38041. ></TD
  38042. ></TR
  38043. ></TABLE
  38044. >
  38045.    </P
  38046. ><P
  38047. >     Darⁿberhinaus k÷nnen einzelne Funktionen deaktiviert werden.
  38048.     Wⁿrde man folgenden Eintrag in der php.ini vornehmen:
  38049.     <TABLE
  38050. BORDER="0"
  38051. BGCOLOR="#E0E0E0"
  38052. CELLPADDING="5"
  38053. ><TR
  38054. ><TD
  38055. ><PRE
  38056. CLASS="ini"
  38057. >disable_functions readfile,system</PRE
  38058. ></TD
  38059. ></TR
  38060. ></TABLE
  38061. >
  38062.     Wⁿrde diese Warnung erscheinen:
  38063.     <TABLE
  38064. BORDER="0"
  38065. BGCOLOR="#E0E0E0"
  38066. CELLPADDING="5"
  38067. ><TR
  38068. ><TD
  38069. ><PRE
  38070. CLASS="screen"
  38071. >Warning: readfile() has been disabled for security reasons in 
  38072. /docroot/script.php on line 2</PRE
  38073. ></TD
  38074. ></TR
  38075. ></TABLE
  38076. >
  38077.    </P
  38078. ><DIV
  38079. CLASS="sect1"
  38080. ><HR><H2
  38081. CLASS="sect1"
  38082. ><A
  38083. NAME="features.safe-mode.functions"
  38084. >Funktionen, die durch Safe Mode deaktiviert oder eingeschrΣnkt werden</A
  38085. ></H2
  38086. ><P
  38087. >      Dies ist eine Auflistung der Funktionen, die durch 
  38088.      <A
  38089. HREF="#features.safe-mode"
  38090. >Safe Mode</A
  38091. > eingeschrΣnkt
  38092.      werden. Diese Liste ist m÷glicherweise unvollstΣndig und fehlerhaft!
  38093.      
  38094.      <DIV
  38095. CLASS="table"
  38096. ><A
  38097. NAME="AEN6291"
  38098. ></A
  38099. ><P
  38100. ><B
  38101. >Tabelle 38-1. Durch Safe Mode eingeschrΣnkte Funktionen</B
  38102. ></P
  38103. ><TABLE
  38104. BORDER="1"
  38105. CLASS="CALSTABLE"
  38106. ><COL><COL><THEAD
  38107. ><TR
  38108. ><TH
  38109. >Funktion</TH
  38110. ><TH
  38111. >EinschrΣnkungen</TH
  38112. ></TR
  38113. ></THEAD
  38114. ><TBODY
  38115. ><TR
  38116. ><TD
  38117. ><A
  38118. HREF="#function.dbmopen"
  38119. ><B
  38120. CLASS="function"
  38121. >dbmopen()</B
  38122. ></A
  38123. ></TD
  38124. ><TD
  38125. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38126. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38127. selbst.</TD
  38128. ></TR
  38129. ><TR
  38130. ><TD
  38131. ><A
  38132. HREF="#function.dbase-open"
  38133. ><B
  38134. CLASS="function"
  38135. >dbase_open()</B
  38136. ></A
  38137. ></TD
  38138. ><TD
  38139. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38140. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38141. selbst.</TD
  38142. ></TR
  38143. ><TR
  38144. ><TD
  38145. ><A
  38146. HREF="#function.filepro"
  38147. ><B
  38148. CLASS="function"
  38149. >filepro()</B
  38150. ></A
  38151. ></TD
  38152. ><TD
  38153. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38154. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38155. selbst.</TD
  38156. ></TR
  38157. ><TR
  38158. ><TD
  38159. ><A
  38160. HREF="#function.filepro-rowcount"
  38161. ><B
  38162. CLASS="function"
  38163. >filepro_rowcount()</B
  38164. ></A
  38165. ></TD
  38166. ><TD
  38167. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38168. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38169. selbst.</TD
  38170. ></TR
  38171. ><TR
  38172. ><TD
  38173. ><A
  38174. HREF="#function.filepro-retrieve"
  38175. ><B
  38176. CLASS="function"
  38177. >filepro_retrieve()</B
  38178. ></A
  38179. ></TD
  38180. ><TD
  38181. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38182. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38183. selbst.</TD
  38184. ></TR
  38185. ><TR
  38186. ><TD
  38187. ><B
  38188. CLASS="function"
  38189. >ifx_*()</B
  38190. ></TD
  38191. ><TD
  38192. >sql_safe_mode restrictions, (!= Safe Mode)</TD
  38193. ></TR
  38194. ><TR
  38195. ><TD
  38196. ><B
  38197. CLASS="function"
  38198. >ingres_*()</B
  38199. ></TD
  38200. ><TD
  38201. >sql_safe_mode restrictions, (!= Safe Mode)</TD
  38202. ></TR
  38203. ><TR
  38204. ><TD
  38205. ><B
  38206. CLASS="function"
  38207. >mysql_*()</B
  38208. ></TD
  38209. ><TD
  38210. >sql_safe_mode restrictions, (!= Safe Mode)</TD
  38211. ></TR
  38212. ><TR
  38213. ><TD
  38214. ><B
  38215. CLASS="function"
  38216. >pg_loimport()</B
  38217. ></TD
  38218. ><TD
  38219. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38220. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38221. selbst.</TD
  38222. ></TR
  38223. ><TR
  38224. ><TD
  38225. ><A
  38226. HREF="#function.posix-mkfifo"
  38227. ><B
  38228. CLASS="function"
  38229. >posix_mkfifo()</B
  38230. ></A
  38231. ></TD
  38232. ><TD
  38233. >▄berprⁿft ob das Verzeichnis in dem das Skript
  38234. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst.</TD
  38235. ></TR
  38236. ><TR
  38237. ><TD
  38238. ><A
  38239. HREF="#function.putenv"
  38240. ><B
  38241. CLASS="function"
  38242. >putenv()</B
  38243. ></A
  38244. ></TD
  38245. ><TD
  38246. >           Fⁿhrt die safe_mode_protected_env_vars und 
  38247.           safe_mode_allowed_env_vars ini-directiven aus.
  38248.           Siehe auch Dokumentation zu <A
  38249. HREF="#function.putenv"
  38250. ><B
  38251. CLASS="function"
  38252. >putenv()</B
  38253. ></A
  38254. >
  38255.          </TD
  38256. ></TR
  38257. ><TR
  38258. ><TD
  38259. ><A
  38260. HREF="#function.move-uploaded-file"
  38261. ><B
  38262. CLASS="function"
  38263. >move_uploaded_file()</B
  38264. ></A
  38265. ></TD
  38266. ><TD
  38267. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38268. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38269. selbst. </TD
  38270. ></TR
  38271. ><TR
  38272. ><TD
  38273. ><A
  38274. HREF="#function.chdir"
  38275. ><B
  38276. CLASS="function"
  38277. >chdir()</B
  38278. ></A
  38279. ></TD
  38280. ><TD
  38281. >▄berprⁿft ob das Verzeichnis in dem das Skript
  38282. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst.</TD
  38283. ></TR
  38284. ><TR
  38285. ><TD
  38286. ><A
  38287. HREF="#function.dl"
  38288. ><B
  38289. CLASS="function"
  38290. >dl()</B
  38291. ></A
  38292. ></TD
  38293. ><TD
  38294. >Diese Funktion steht im <A
  38295. HREF="#features.safe-mode"
  38296. >Safe Mode</A
  38297. > nicht zur Verfⁿgung.</TD
  38298. ></TR
  38299. ><TR
  38300. ><TD
  38301. ><A
  38302. HREF="#language.operators.execution"
  38303. >           backtick operator</A
  38304. >
  38305.          </TD
  38306. ><TD
  38307. >Diese Funktion steht im <A
  38308. HREF="#features.safe-mode"
  38309. >Safe Mode</A
  38310. > nicht zur Verfⁿgung.</TD
  38311. ></TR
  38312. ><TR
  38313. ><TD
  38314. ><A
  38315. HREF="#function.shell-exec"
  38316. ><B
  38317. CLASS="function"
  38318. >shell_exec()</B
  38319. ></A
  38320. > (funktional gleichwertig zu den 
  38321.           Backtick-Operatoren)</TD
  38322. ><TD
  38323. >Diese Funktion steht im <A
  38324. HREF="#features.safe-mode"
  38325. >Safe Mode</A
  38326. > nicht zur Verfⁿgung.</TD
  38327. ></TR
  38328. ><TR
  38329. ><TD
  38330. ><A
  38331. HREF="#function.exec"
  38332. ><B
  38333. CLASS="function"
  38334. >exec()</B
  38335. ></A
  38336. ></TD
  38337. ><TD
  38338. >Ausfⁿhrbare Dateien k÷nnen nur innerhalb des durch <A
  38339. HREF="#ini.safe-mode-exec-dir"
  38340. >safe_mode_exec_dir</A
  38341. > angegebenen
  38342.           Verzeichnisses ausgefⁿhrt werden.
  38343.           Aus praktischen Grⁿnden ist es momentan nicht erlaubt, <VAR
  38344. CLASS="literal"
  38345. >..</VAR
  38346. >
  38347.           im Pfad zu den ausfⁿhrbaren Datein anzugeben.
  38348.          </TD
  38349. ></TR
  38350. ><TR
  38351. ><TD
  38352. ><A
  38353. HREF="#function.system"
  38354. ><B
  38355. CLASS="function"
  38356. >system()</B
  38357. ></A
  38358. ></TD
  38359. ><TD
  38360. >Ausfⁿhrbare Dateien k÷nnen nur innerhalb des durch <A
  38361. HREF="#ini.safe-mode-exec-dir"
  38362. >safe_mode_exec_dir</A
  38363. > angegebenen
  38364.           Verzeichnisses ausgefⁿhrt werden.
  38365.           Aus praktischen Grⁿnden ist es momentan nicht erlaubt, <VAR
  38366. CLASS="literal"
  38367. >..</VAR
  38368. >
  38369.           im Pfad zu den ausfⁿhrbaren Datein anzugeben.
  38370.          </TD
  38371. ></TR
  38372. ><TR
  38373. ><TD
  38374. ><A
  38375. HREF="#function.passthru"
  38376. ><B
  38377. CLASS="function"
  38378. >passthru()</B
  38379. ></A
  38380. ></TD
  38381. ><TD
  38382. >Ausfⁿhrbare Dateien k÷nnen nur innerhalb des durch <A
  38383. HREF="#ini.safe-mode-exec-dir"
  38384. >safe_mode_exec_dir</A
  38385. > angegebenen
  38386.           Verzeichnisses ausgefⁿhrt werden.
  38387.           Aus praktischen Grⁿnden ist es momentan nicht erlaubt, <VAR
  38388. CLASS="literal"
  38389. >..</VAR
  38390. >
  38391.           im Pfad zu den ausfⁿhrbaren Datein anzugeben.
  38392.          </TD
  38393. ></TR
  38394. ><TR
  38395. ><TD
  38396. ><A
  38397. HREF="#function.popen"
  38398. ><B
  38399. CLASS="function"
  38400. >popen()</B
  38401. ></A
  38402. ></TD
  38403. ><TD
  38404. >Ausfⁿhrbare Dateien k÷nnen nur innerhalb des durch <A
  38405. HREF="#ini.safe-mode-exec-dir"
  38406. >safe_mode_exec_dir</A
  38407. > angegebenen
  38408.           Verzeichnisses ausgefⁿhrt werden.
  38409.           Aus praktischen Grⁿnden ist es momentan nicht erlaubt, <VAR
  38410. CLASS="literal"
  38411. >..</VAR
  38412. >
  38413.           im Pfad zu den ausfⁿhrbaren Datein anzugeben.
  38414.          </TD
  38415. ></TR
  38416. ><TR
  38417. ><TD
  38418. ><A
  38419. HREF="#function.mkdir"
  38420. ><B
  38421. CLASS="function"
  38422. >mkdir()</B
  38423. ></A
  38424. ></TD
  38425. ><TD
  38426. >▄berprⁿft ob das Verzeichnis in dem das Skript
  38427. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst.</TD
  38428. ></TR
  38429. ><TR
  38430. ><TD
  38431. ><A
  38432. HREF="#function.rmdir"
  38433. ><B
  38434. CLASS="function"
  38435. >rmdir()</B
  38436. ></A
  38437. ></TD
  38438. ><TD
  38439. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38440. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38441. selbst.</TD
  38442. ></TR
  38443. ><TR
  38444. ><TD
  38445. ><A
  38446. HREF="#function.rename"
  38447. ><B
  38448. CLASS="function"
  38449. >rename()</B
  38450. ></A
  38451. ></TD
  38452. ><TD
  38453. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38454. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38455. selbst. ▄berprⁿft ob das Verzeichnis in dem das Skript
  38456. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst.
  38457.           
  38458.          </TD
  38459. ></TR
  38460. ><TR
  38461. ><TD
  38462. ><A
  38463. HREF="#function.unlink"
  38464. ><B
  38465. CLASS="function"
  38466. >unlink()</B
  38467. ></A
  38468. ></TD
  38469. ><TD
  38470. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38471. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38472. selbst. ▄berprⁿft ob das Verzeichnis in dem das Skript
  38473. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst.</TD
  38474. ></TR
  38475. ><TR
  38476. ><TD
  38477. ><A
  38478. HREF="#function.copy"
  38479. ><B
  38480. CLASS="function"
  38481. >copy()</B
  38482. ></A
  38483. ></TD
  38484. ><TD
  38485. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38486. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38487. selbst. ▄berprⁿft ob das Verzeichnis in dem das Skript
  38488. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst. (on 
  38489.          <VAR
  38490. CLASS="parameter"
  38491. >source</VAR
  38492. > and 
  38493.          <VAR
  38494. CLASS="parameter"
  38495. >target</VAR
  38496. >) </TD
  38497. ></TR
  38498. ><TR
  38499. ><TD
  38500. ><A
  38501. HREF="#function.chgrp"
  38502. ><B
  38503. CLASS="function"
  38504. >chgrp()</B
  38505. ></A
  38506. ></TD
  38507. ><TD
  38508. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38509. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38510. selbst.</TD
  38511. ></TR
  38512. ><TR
  38513. ><TD
  38514. ><A
  38515. HREF="#function.chown"
  38516. ><B
  38517. CLASS="function"
  38518. >chown()</B
  38519. ></A
  38520. ></TD
  38521. ><TD
  38522. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38523. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38524. selbst.</TD
  38525. ></TR
  38526. ><TR
  38527. ><TD
  38528. ><A
  38529. HREF="#function.chmod"
  38530. ><B
  38531. CLASS="function"
  38532. >chmod()</B
  38533. ></A
  38534. ></TD
  38535. ><TD
  38536. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38537. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38538. selbst. In addition, you cannot  
  38539.          set the SUID, SGID and sticky bits</TD
  38540. ></TR
  38541. ><TR
  38542. ><TD
  38543. ><A
  38544. HREF="#function.touch"
  38545. ><B
  38546. CLASS="function"
  38547. >touch()</B
  38548. ></A
  38549. ></TD
  38550. ><TD
  38551. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38552. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38553. selbst. ▄berprⁿft ob das Verzeichnis in dem das Skript
  38554. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst.</TD
  38555. ></TR
  38556. ><TR
  38557. ><TD
  38558. ><A
  38559. HREF="#function.symlink"
  38560. ><B
  38561. CLASS="function"
  38562. >symlink()</B
  38563. ></A
  38564. ></TD
  38565. ><TD
  38566. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38567. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38568. selbst. ▄berprⁿft ob das Verzeichnis in dem das Skript
  38569. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst. (note: only the target is 
  38570.          checked)</TD
  38571. ></TR
  38572. ><TR
  38573. ><TD
  38574. ><A
  38575. HREF="#function.link"
  38576. ><B
  38577. CLASS="function"
  38578. >link()</B
  38579. ></A
  38580. ></TD
  38581. ><TD
  38582. >▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38583. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38584. selbst. ▄berprⁿft ob das Verzeichnis in dem das Skript
  38585. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst. (note: only the target is 
  38586.          checked)</TD
  38587. ></TR
  38588. ><TR
  38589. ><TD
  38590. ><A
  38591. HREF="#function.getallheaders"
  38592. ><B
  38593. CLASS="function"
  38594. >getallheaders()</B
  38595. ></A
  38596. ></TD
  38597. ><TD
  38598. >           Header die mit 'authorization' (unabhΣngig von Gro▀- oder Kleinschreibung)
  38599.           beginnen, werden bei Verwendung von Safe Mode nicht zurⁿckgegeben. 
  38600.           Achtung: Dies ist fehlerhaft bei der AOL-Server Implementation 
  38601.           der Funktion <A
  38602. HREF="#function.getallheaders"
  38603. ><B
  38604. CLASS="function"
  38605. >getallheaders()</B
  38606. ></A
  38607. >!
  38608.          </TD
  38609. ></TR
  38610. ><TR
  38611. ><TD
  38612. >           <A
  38613. HREF="#function.highlight-file"
  38614. ><B
  38615. CLASS="function"
  38616. >highlight_file()</B
  38617. ></A
  38618. >,
  38619.           <A
  38620. HREF="#function.show-source"
  38621. ><B
  38622. CLASS="function"
  38623. >show_source()</B
  38624. ></A
  38625. >
  38626.          </TD
  38627. ><TD
  38628. >           ▄berprⁿft ob die Dateien/Verzeichnisse, die mit dem Skript
  38629. bearbeitet werden sollen, die gleiche UID Eigentⁿmer haben wie das Skript
  38630. selbst. ▄berprⁿft ob das Verzeichnis in dem das Skript
  38631. ausgefⁿhrt werden soll, die gleiche UID (Eigentⁿmer) hat wie das Skript selbst. (Hinweis: gilt nur ab Version PHP 4.2.1)
  38632.          </TD
  38633. ></TR
  38634. ><TR
  38635. ><TD
  38636. >Jede Funktion, die 
  38637.           <TT
  38638. CLASS="filename"
  38639. >php4/main/fopen_wrappers.c</TT
  38640. >
  38641.           benutzt...
  38642.          </TD
  38643. ><TD
  38644. >??</TD
  38645. ></TR
  38646. ></TBODY
  38647. ></TABLE
  38648. ></DIV
  38649. >
  38650.     </P
  38651. ></DIV
  38652. ></DIV
  38653. ><DIV
  38654. CLASS="chapter"
  38655. ><HR><H1
  38656. ><A
  38657. NAME="features.commandline"
  38658. >Kapitel 39. PHP auf der Kommandozeile</A
  38659. ></H1
  38660. ><P
  38661. >   Seit Version 4.3.0 unterstⁿtzt <VAR
  38662. CLASS="literal"
  38663. >PHP</VAR
  38664. > einen neuen
  38665.   Typ <VAR
  38666. CLASS="literal"
  38667. >SAPI</VAR
  38668. > (Server Application Programming 
  38669.   Interface) namens <VAR
  38670. CLASS="literal"
  38671. >CLI</VAR
  38672. > (<SPAN
  38673. CLASS="emphasis"
  38674. ><I
  38675. CLASS="emphasis"
  38676. >Command Line
  38677.   Interface</I
  38678. ></SPAN
  38679. >). Wie der Name schon verrΣt, liegt das 
  38680.   Hauptaugemerk dieses <VAR
  38681. CLASS="literal"
  38682. >SAPI</VAR
  38683. >-Typs auf der Entwicklung
  38684.   von Anwendungen fⁿr die Kommandozeile (und auch den Desktop) mit 
  38685.   <VAR
  38686. CLASS="literal"
  38687. >PHP</VAR
  38688. >. Es gibt etliche Unterschiede zwischen dem 
  38689.   <VAR
  38690. CLASS="literal"
  38691. >CLI SAPI</VAR
  38692. > und anderen <VAR
  38693. CLASS="literal"
  38694. >SAPI</VAR
  38695. >s,
  38696.   die in diesem Kapitel beschrieben werden. Es ist erwΣhnenswert, 
  38697.   dass <VAR
  38698. CLASS="literal"
  38699. >CLI</VAR
  38700. > und <VAR
  38701. CLASS="literal"
  38702. >CGI</VAR
  38703. > verschiedene
  38704.   SAPIs sind, obwohl sie viele Verhaltensweisen teilen.
  38705.  </P
  38706. ><P
  38707. >   Das <VAR
  38708. CLASS="literal"
  38709. >CLI SAPI</VAR
  38710. > wurde zum ersten Mal mit 
  38711.   <VAR
  38712. CLASS="literal"
  38713. >PHP 4.2.0</VAR
  38714. > eingefⁿhrt, war aber noch experimentell
  38715.   und musste explizit mit <VAR
  38716. CLASS="literal"
  38717. >--enable-cli</VAR
  38718. > beim 
  38719.   <VAR
  38720. CLASS="literal"
  38721. >./configure</VAR
  38722. >-Aufruf eingeschaltet werden. Seit
  38723.   <VAR
  38724. CLASS="literal"
  38725. >PHP 4.3.0</VAR
  38726. > ist das <VAR
  38727. CLASS="literal"
  38728. >CLI SAPI</VAR
  38729. > nicht
  38730.   lΣnger experimentell und die Option <VAR
  38731. CLASS="literal"
  38732. >--enable-cli</VAR
  38733. >
  38734.   standardmΣ▀ig auf <VAR
  38735. CLASS="literal"
  38736. >on</VAR
  38737. > gestellt. Sie k÷nnen 
  38738.   <VAR
  38739. CLASS="literal"
  38740. >--disable-cli</VAR
  38741. > benutzen, um es auszuschalten.
  38742.  </P
  38743. ><P
  38744. >   Von <VAR
  38745. CLASS="literal"
  38746. >PHP 4.3.0</VAR
  38747. > an werden Namen, Pfade und
  38748.   Vorhandensein der CLI/CGI-Binaries voneinander abweichen, abhΣngig
  38749.   davon, wie <VAR
  38750. CLASS="literal"
  38751. >PHP</VAR
  38752. > auf Ihrem System installiert ist.
  38753.   StandarmΣ▀ig werden nach dem Aufruf von <VAR
  38754. CLASS="literal"
  38755. >make</VAR
  38756. >
  38757.   sowohl CGI als auch CLI kompiliert und als <VAR
  38758. CLASS="literal"
  38759. >sapi/cgi/php</VAR
  38760. >
  38761.   beziehungsweise <VAR
  38762. CLASS="literal"
  38763. >sapi/cli/php</VAR
  38764. > in Ihrem
  38765.   PHP-Quellcodeverzeichnis hinterlegt. Sie werden bemerken, dass beide
  38766.   <VAR
  38767. CLASS="literal"
  38768. >php</VAR
  38769. > benannt sind. Was wΣhrend 
  38770.   <VAR
  38771. CLASS="literal"
  38772. >make install</VAR
  38773. > passiert, hΣngt von Ihrem 
  38774.   configure-Kommando ab. Wenn ein Modul-SAPI wΣhrend configure gewΣhlt
  38775.   wird, wie etwa <VAR
  38776. CLASS="literal"
  38777. >apxs</VAR
  38778. > oder wenn die 
  38779.   <VAR
  38780. CLASS="literal"
  38781. >--disable-cgi</VAR
  38782. >-Option benutzt wird, wird das CLI
  38783.   wΣhrend <VAR
  38784. CLASS="literal"
  38785. >make install</VAR
  38786. > nach 
  38787.   <VAR
  38788. CLASS="literal"
  38789. >{PREFIX}/bin/php</VAR
  38790. > kopiert, ansonsten wird das CGI
  38791.   dort hinterlegt. Also wird, wenn beispielsweise 
  38792.   <VAR
  38793. CLASS="literal"
  38794. >--with--apxs</VAR
  38795. > in Ihrem configure-Kommando auftaucht,
  38796.   das CLI wΣhrend  <VAR
  38797. CLASS="literal"
  38798. >make install</VAR
  38799. > nach 
  38800.   <VAR
  38801. CLASS="literal"
  38802. >{PREFIX}/bin/php</VAR
  38803. > kopiert. Wenn Sie die Installation
  38804.   des CGI-Binaries au▀er Kraft setzen wollen, benutzen Sie 
  38805.   <VAR
  38806. CLASS="literal"
  38807. >make install-cli</VAR
  38808. > nach
  38809.   <VAR
  38810. CLASS="literal"
  38811. >make install</VAR
  38812. >. Alternativ k÷nnen Sie 
  38813.   <VAR
  38814. CLASS="literal"
  38815. >--disable-cgi</VAR
  38816. > in Ihrem configure-Kommando angeben.
  38817.  </P
  38818. ><P
  38819. >   <DIV
  38820. CLASS="note"
  38821. ><BLOCKQUOTE
  38822. CLASS="note"
  38823. ><P
  38824. ><B
  38825. >Anmerkung: </B
  38826. >
  38827.     Weil sowohl <VAR
  38828. CLASS="literal"
  38829. >--enable-cli</VAR
  38830. > als auch <VAR
  38831. CLASS="literal"
  38832. >     --enable-cgi</VAR
  38833. > standardmΣ▀ig eingeschaltet sind, 
  38834.     muss <VAR
  38835. CLASS="literal"
  38836. >--enable-cli</VAR
  38837. > in Ihrem configure-Kommando
  38838.     nicht zwingend bedeuten, dass das CLI wΣhrend 
  38839.     <VAR
  38840. CLASS="literal"
  38841. >make install</VAR
  38842. > nach 
  38843.     <VAR
  38844. CLASS="literal"
  38845. >{PREFIX}/bin/php</VAR
  38846. > kopiert wird.
  38847.    </P
  38848. ></BLOCKQUOTE
  38849. ></DIV
  38850. >
  38851.  </P
  38852. ><P
  38853. >   Die Windows-Pakete zwischen PHP 4.2.0 und PHP 4.2.3 enthielten das
  38854.   CLI als <TT
  38855. CLASS="filename"
  38856. >php-cli.exe</TT
  38857. >, beheimatet im selben
  38858.   Verzeichnis wie das CGI <TT
  38859. CLASS="filename"
  38860. >php.exe</TT
  38861. >. Beginnend mit
  38862.   PHP 4.3.0 enthΣlt das Windows-Paket das CLI als <TT
  38863. CLASS="filename"
  38864. >php.exe</TT
  38865. >
  38866.   in einem eigenen Verzeichnis namens <VAR
  38867. CLASS="literal"
  38868. >cli</VAR
  38869. >, also 
  38870.   <VAR
  38871. CLASS="literal"
  38872. >cli/php.exe</VAR
  38873. >. Beginnend mit PHP 5 wird das CLI im
  38874.   Hauptordner al <TT
  38875. CLASS="filename"
  38876. >php.exe</TT
  38877. > ausgeliefert. Die CGI-Version
  38878.   heisst <TT
  38879. CLASS="filename"
  38880. >php-cgi.exe</TT
  38881. >.
  38882.  </P
  38883. ><P
  38884. >   Seit PHP gibt es eine neue Datei, <TT
  38885. CLASS="filename"
  38886. >php-win.exe</TT
  38887. >. Diese ist
  38888.   identisch mit der CLI-Version, die einzige Ausnahme besteht darin, dass
  38889.   php-win nichts ausgibt und somit keine Konsole bietet. (Es erscheint keine
  38890.   "MS-DOS-Eingabeaufforderung".)  Dieses Verhalten ist Σhnlich php-gtk. Sie
  38891.   sollten die folgende Option fⁿr ./configure benutzen:
  38892.   <VAR
  38893. CLASS="literal"
  38894. >--enable-cli-win32</VAR
  38895. >.
  38896.  </P
  38897. ><P
  38898. >   <DIV
  38899. CLASS="note"
  38900. ><BLOCKQUOTE
  38901. CLASS="note"
  38902. ><P
  38903. ><B
  38904. >Welche SAPI habe ich?: </B
  38905. >
  38906.     Auf der Kommandozeile wird Ihnen die Eingabe von <VAR
  38907. CLASS="literal"
  38908. >php -v</VAR
  38909. >
  38910.     verraten, ob Sie <VAR
  38911. CLASS="literal"
  38912. >php</VAR
  38913. > als CGI oder CLI einsetzen.  
  38914.     Sehen Sie sich auch die Funktion <A
  38915. HREF="#function.php-sapi-name"
  38916. ><B
  38917. CLASS="function"
  38918. >php_sapi_name()</B
  38919. ></A
  38920.     und die Konstante <TT
  38921. CLASS="constant"
  38922. ><B
  38923. >PHP_SAPI</B
  38924. ></TT
  38925. > an.
  38926.    </P
  38927. ></BLOCKQUOTE
  38928. ></DIV
  38929. >
  38930.  </P
  38931. ><P
  38932. >   <DIV
  38933. CLASS="note"
  38934. ><BLOCKQUOTE
  38935. CLASS="note"
  38936. ><P
  38937. ><B
  38938. >Anmerkung: </B
  38939. >
  38940.     Eine UNIX <VAR
  38941. CLASS="literal"
  38942. >man</VAR
  38943. >ual page wurde in PHP 4.3.2 hinzugefⁿgt.
  38944.     Sie k÷nnen sie ansehen, indem sie <VAR
  38945. CLASS="literal"
  38946. >man php</VAR
  38947. > auf der
  38948.     Kommandozeile eintippen.
  38949.    </P
  38950. ></BLOCKQUOTE
  38951. ></DIV
  38952. >
  38953.  </P
  38954. ><P
  38955. >   Beachtenswerte Unterschiede des <VAR
  38956. CLASS="literal"
  38957. >CLI SAPI</VAR
  38958. > verglichen mit
  38959.   anderen <VAR
  38960. CLASS="literal"
  38961. >SAPI</VAR
  38962. >s:
  38963.   <P
  38964. ></P
  38965. ><UL
  38966. ><LI
  38967. ><P
  38968. >      Anders als beim <VAR
  38969. CLASS="literal"
  38970. >CGI SAPI</VAR
  38971. > werden keine 
  38972.      Header ausgegeben.
  38973.     </P
  38974. ><P
  38975. >      Obwohl das <VAR
  38976. CLASS="literal"
  38977. >CGI SAPI</VAR
  38978. > einen Weg bietet, HTTP-Header zu
  38979.      unterdrⁿcken, gibt es keine gleichwertige Option, sie im <VAR
  38980. CLASS="literal"
  38981. >CLI
  38982.      SAPI</VAR
  38983. > anzuzeigen.
  38984.     </P
  38985. ><P
  38986. >      CLI wird standardmΣ▀ig im stillen Modus gestartet, dennoch gibt
  38987.      es die Optionen <VAR
  38988. CLASS="literal"
  38989. >-q</VAR
  38990. > und <VAR
  38991. CLASS="literal"
  38992. >--no-header</VAR
  38993. >
  38994.      aus KompatibilitΣtsgrⁿnden noch, so dass Sie auch Σltere CGI-Skripte noch
  38995.      benutzen k÷nnen.
  38996.     </P
  38997. ><P
  38998. >      Es verΣndert das Arbeitsverzeichnis nicht zu dem des Skriptes.
  38999.      (Die Optionen <VAR
  39000. CLASS="literal"
  39001. >-C</VAR
  39002. > und <VAR
  39003. CLASS="literal"
  39004. >--no-chdir</VAR
  39005. >
  39006.      wurden aus KompatibilitΣtsgrⁿnden beibehalten.)
  39007.     </P
  39008. ><P
  39009. >      Fehlermeldungen in Plaintext (keine HTML-Formatierung).
  39010.     </P
  39011. ></LI
  39012. ><LI
  39013. ><P
  39014. >      Es gibt bestimmte <TT
  39015. CLASS="filename"
  39016. >php.ini</TT
  39017. >-Direktiven, die vom 
  39018.      <VAR
  39019. CLASS="literal"
  39020. >CLI SAPI</VAR
  39021. > au▀er Kraft gesetzt werden, weil sie in
  39022.      einer Kommandozeilenumgebung keinen Sinn ergeben.
  39023.     </P
  39024. ><P
  39025. >      <DIV
  39026. CLASS="table"
  39027. ><A
  39028. NAME="AEN6546"
  39029. ></A
  39030. ><P
  39031. ><B
  39032. >Tabelle 39-1. ▄berschriebene <TT
  39033. CLASS="filename"
  39034. >php.ini</TT
  39035. >-Direktiven</B
  39036. ></P
  39037. ><TABLE
  39038. BORDER="1"
  39039. CLASS="CALSTABLE"
  39040. ><COL><COL><COL><THEAD
  39041. ><TR
  39042. ><TH
  39043. >Direktive</TH
  39044. ><TH
  39045. ><VAR
  39046. CLASS="literal"
  39047. >CLI SAPI</VAR
  39048. >-Standardwert</TH
  39049. ><TH
  39050. >Kommentar</TH
  39051. ></TR
  39052. ></THEAD
  39053. ><TBODY
  39054. ><TR
  39055. ><TD
  39056. ><A
  39057. HREF="#ini.html-errors"
  39058. >html_errors</A
  39059. ></TD
  39060. ><TD
  39061. ><TT
  39062. CLASS="constant"
  39063. ><B
  39064. >FALSE</B
  39065. ></TT
  39066. ></TD
  39067. ><TD
  39068. >           Es kann sehr schwierig sein, eine Fehlermeldung auf der
  39069.           Kommandozeile zu lesen, wenn sie mit all diesen bedeutungslosen
  39070.           <VAR
  39071. CLASS="literal"
  39072. >HTML</VAR
  39073. >-Tags vollgestopft ist, deswegen wird 
  39074.           diese Direktive auf <TT
  39075. CLASS="constant"
  39076. ><B
  39077. >FALSE</B
  39078. ></TT
  39079. > gesetzt.
  39080.          </TD
  39081. ></TR
  39082. ><TR
  39083. ><TD
  39084. ><A
  39085. HREF="#ini.implicit-flush"
  39086. >implicit_flush</A
  39087. ></TD
  39088. ><TD
  39089. ><TT
  39090. CLASS="constant"
  39091. ><B
  39092. >TRUE</B
  39093. ></TT
  39094. ></TD
  39095. ><TD
  39096. >           Es ist erwⁿnscht, dass alle Ausgaben, die von 
  39097.           <A
  39098. HREF="#function.print"
  39099. ><B
  39100. CLASS="function"
  39101. >print()</B
  39102. ></A
  39103. >, <A
  39104. HREF="#function.echo"
  39105. ><B
  39106. CLASS="function"
  39107. >echo()</B
  39108. ></A
  39109. > und Konsorten
  39110.           kommen, sofort auf die Ausgabe geschrieben werden und nicht in
  39111.           irgendeinem Puffer gecacht werden. Sie k÷nnen immer noch 
  39112.           <A
  39113. HREF="#ref.outcontrol"
  39114. >output buffering</A
  39115. > benutzen,
  39116.           wenn Sie die Standardausgabe aufschieben oder manipulieren wollen.
  39117.          </TD
  39118. ></TR
  39119. ><TR
  39120. ><TD
  39121. ><A
  39122. HREF="#ini.max-execution-time"
  39123. >max_execution_time</A
  39124. ></TD
  39125. ><TD
  39126. >0 (unlimited)</TD
  39127. ><TD
  39128. >           Wegen der unendlichen M÷glichkeiten, <VAR
  39129. CLASS="literal"
  39130. >PHP</VAR
  39131. > in 
  39132.           Kommandozeilenumgebungen zu benutzen wurde die maximale 
  39133.           Ausfⁿhrungszeit auf unbegrenzte Zeit eingestellt. Wohingegen
  39134.           Anwendungen, die fⁿr das Web geschrieben wurden, oft in sehr kurzer
  39135.           Zeit ausgefⁿhrt werden, neigen Anwendungen fⁿr die Kommandozeile
  39136.           dazu, eine viel lΣngere Ausfⁿhrungszeit zu beanspruchen. 
  39137.          </TD
  39138. ></TR
  39139. ><TR
  39140. ><TD
  39141. ><A
  39142. HREF="#ini.register-argc-argv"
  39143. >register_argc_argv</A
  39144. ></TD
  39145. ><TD
  39146. ><TT
  39147. CLASS="constant"
  39148. ><B
  39149. >TRUE</B
  39150. ></TT
  39151. ></TD
  39152. ><TD
  39153. >          <P
  39154. >           Weil diese Einstellung auf <TT
  39155. CLASS="constant"
  39156. ><B
  39157. >TRUE</B
  39158. ></TT
  39159. > gesetzt ist, werden Sie immer
  39160.           Zugriff auf <SPAN
  39161. CLASS="emphasis"
  39162. ><I
  39163. CLASS="emphasis"
  39164. >argc</I
  39165. ></SPAN
  39166. > (Anzahl der Argumente, die
  39167.           der Anwendung ⁿbergeben wurden) und <SPAN
  39168. CLASS="emphasis"
  39169. ><I
  39170. CLASS="emphasis"
  39171. >argv</I
  39172. ></SPAN
  39173. >
  39174.           (Array der eigentlichen Argumente) im <VAR
  39175. CLASS="literal"
  39176. >CLI SAPI</VAR
  39177. >
  39178.           haben.
  39179.          </P
  39180. >
  39181.          <P
  39182. >           Seit PHP 4.3.0 werden die <VAR
  39183. CLASS="literal"
  39184. >PHP</VAR
  39185. >-Variablen 
  39186.           <VAR
  39187. CLASS="varname"
  39188. >$argc</VAR
  39189. > und <VAR
  39190. CLASS="varname"
  39191. >$argv</VAR
  39192. > registriert
  39193.           und mit den entsprechenden Werten gefⁿllt, wenn das 
  39194.           <VAR
  39195. CLASS="literal"
  39196. >CLI SAPI</VAR
  39197. > benutzt wird. Vor dieser Version
  39198.           verhielt sich die Erzeugung dieser Variablen so wie in den 
  39199.           <VAR
  39200. CLASS="literal"
  39201. >CGI</VAR
  39202. > und <VAR
  39203. CLASS="literal"
  39204. >MODULE</VAR
  39205. >-Versionen,
  39206.           die die PHP-Direktive 
  39207.           <A
  39208. HREF="#ini.register-globals"
  39209. >register_globals</A
  39210. > auf
  39211.           <SPAN
  39212. CLASS="emphasis"
  39213. ><I
  39214. CLASS="emphasis"
  39215. >on</I
  39216. ></SPAN
  39217. > verlangen. Ungeachtet der Version oder der
  39218.           Einstellung von 
  39219.           <A
  39220. HREF="#ini.register-globals"
  39221. >register_globals</A
  39222. >
  39223.           k÷nnen Sie immer 
  39224.           <A
  39225. HREF="#reserved.variables.server"
  39226. >$_SERVER</A
  39227. > oder 
  39228.           <VAR
  39229. CLASS="varname"
  39230. >$HTTP_SERVER_VARS</VAR
  39231. > benutzen. Beispiel:
  39232.           <VAR
  39233. CLASS="varname"
  39234. >$_SERVER['argv']</VAR
  39235. >
  39236.          </P
  39237. >
  39238.          </TD
  39239. ></TR
  39240. ></TBODY
  39241. ></TABLE
  39242. ></DIV
  39243. >
  39244.     </P
  39245. ><DIV
  39246. CLASS="note"
  39247. ><BLOCKQUOTE
  39248. CLASS="note"
  39249. ><P
  39250. ><B
  39251. >Anmerkung: </B
  39252. >
  39253.       Diese Direktiven k÷nnen nicht mit einem anderen Wert aus der
  39254.       Konfigurationsdatei <TT
  39255. CLASS="filename"
  39256. >php.ini</TT
  39257. > oder einer eigenen (falls angegeben)
  39258.       initialisiert werden. Das ist eine EinschrΣnkung, weil diese
  39259.       Standardwerte angewandt werden, nachdem alle Konfigurationsdateien
  39260.       durchlaufen wurden. Dennoch k÷nnen die Werte zur Laufzeit
  39261.       verΣndert werden (was aber fⁿr alle diese Direktiven keinen
  39262.       Sinn ergibt, beispielsweise 
  39263.       <A
  39264. HREF="#ini.register-argc-argv"
  39265. >register_argc_argv</A
  39266. >).
  39267.      </P
  39268. ></BLOCKQUOTE
  39269. ></DIV
  39270. ></LI
  39271. ><LI
  39272. ><P
  39273. >      Um die Arbeit in der Kommandozeilenumgebung zu vereinfachen, wurden
  39274.      folgende Konstanten definiert:
  39275.      <DIV
  39276. CLASS="table"
  39277. ><A
  39278. NAME="AEN6610"
  39279. ></A
  39280. ><P
  39281. ><B
  39282. >Tabelle 39-2. CLI-spezifische Konstanten</B
  39283. ></P
  39284. ><TABLE
  39285. BORDER="1"
  39286. CLASS="CALSTABLE"
  39287. ><COL><COL><THEAD
  39288. ><TR
  39289. ><TH
  39290. >Konstante</TH
  39291. ><TH
  39292. >Beschreibung</TH
  39293. ></TR
  39294. ></THEAD
  39295. ><TBODY
  39296. ><TR
  39297. ><TD
  39298. ><TT
  39299. CLASS="constant"
  39300. ><B
  39301. >STDIN</B
  39302. ></TT
  39303. ></TD
  39304. ><TD
  39305. >          Ein schon ge÷ffneter Stream auf <VAR
  39306. CLASS="literal"
  39307. >stdin</VAR
  39308. >.
  39309.          Das erspart das ÷ffnen mit
  39310.          <TABLE
  39311. BORDER="0"
  39312. BGCOLOR="#E0E0E0"
  39313. CELLPADDING="5"
  39314. ><TR
  39315. ><TD
  39316. ><PRE
  39317. CLASS="php"
  39318. ><?php
  39319.  
  39320. $stdin = fopen('php://stdin', 'r');
  39321.  
  39322. ?></PRE
  39323. ></TD
  39324. ></TR
  39325. ></TABLE
  39326. >
  39327.          </TD
  39328. ></TR
  39329. ><TR
  39330. ><TD
  39331. ><TT
  39332. CLASS="constant"
  39333. ><B
  39334. >STDOUT</B
  39335. ></TT
  39336. ></TD
  39337. ><TD
  39338. >          Ein schon ge÷ffneter Stream auf <VAR
  39339. CLASS="literal"
  39340. >stdout</VAR
  39341. >.
  39342.          Das erspart das ÷ffnen mit
  39343.          <TABLE
  39344. BORDER="0"
  39345. BGCOLOR="#E0E0E0"
  39346. CELLPADDING="5"
  39347. ><TR
  39348. ><TD
  39349. ><PRE
  39350. CLASS="php"
  39351. ><?php
  39352.  
  39353. $stdout = fopen('php://stdout', 'w');
  39354.  
  39355. ?></PRE
  39356. ></TD
  39357. ></TR
  39358. ></TABLE
  39359. >
  39360.          </TD
  39361. ></TR
  39362. ><TR
  39363. ><TD
  39364. ><TT
  39365. CLASS="constant"
  39366. ><B
  39367. >STDERR</B
  39368. ></TT
  39369. ></TD
  39370. ><TD
  39371. >          Ein schon ge÷ffneter Stream auf <VAR
  39372. CLASS="literal"
  39373. >stderr</VAR
  39374. >.
  39375.          Das erspart das ÷ffnen mit
  39376.          <TABLE
  39377. BORDER="0"
  39378. BGCOLOR="#E0E0E0"
  39379. CELLPADDING="5"
  39380. ><TR
  39381. ><TD
  39382. ><PRE
  39383. CLASS="php"
  39384. ><?php
  39385.  
  39386. $stderr = fopen('php://stderr', 'w');
  39387.  
  39388. ?></PRE
  39389. ></TD
  39390. ></TR
  39391. ></TABLE
  39392. >
  39393.          </TD
  39394. ></TR
  39395. ></TBODY
  39396. ></TABLE
  39397. ></DIV
  39398. >
  39399.     </P
  39400. ><P
  39401. >      Angesichts des oben genannten brauchen Sie beispielsweise nicht 
  39402.      selbst einen Stream fⁿr <VAR
  39403. CLASS="literal"
  39404. >stderr</VAR
  39405. > ÷ffnen, sondern
  39406.      einfach die Konstante statt der Ressource:
  39407.      <TABLE
  39408. BORDER="0"
  39409. BGCOLOR="#E0E0E0"
  39410. CELLPADDING="5"
  39411. ><TR
  39412. ><TD
  39413. ><PRE
  39414. CLASS="shell"
  39415. >php -r 'fwrite(STDERR, "stderr\n");'</PRE
  39416. ></TD
  39417. ></TR
  39418. ></TABLE
  39419. >
  39420.      Sie brauchen diese Ressourcen nicht explizit schliessen, weil sie
  39421.      automatisch von <VAR
  39422. CLASS="literal"
  39423. >PHP</VAR
  39424. > geschlossen werden, wenn 
  39425.      ihr Skript endet.
  39426.     </P
  39427. ></LI
  39428. ><LI
  39429. ><P
  39430. >      Das <VAR
  39431. CLASS="literal"
  39432. >CLI SAPI</VAR
  39433. > Σndert das aktuelle Verzeichnis
  39434.      <SPAN
  39435. CLASS="strong"
  39436. ><B
  39437. CLASS="emphasis"
  39438. >nicht</B
  39439. ></SPAN
  39440. > auf das Verzeichnis des
  39441.      ausgefⁿhrten Skriptes!
  39442.     </P
  39443. ><P
  39444. >      Ein Beispiel, das den Unterschied zum <VAR
  39445. CLASS="literal"
  39446. >CGI SAPI</VAR
  39447. > zeigt:
  39448.      <TABLE
  39449. BORDER="0"
  39450. BGCOLOR="#E0E0E0"
  39451. CELLPADDING="5"
  39452. ><TR
  39453. ><TD
  39454. ><PRE
  39455. CLASS="php"
  39456. ><?php
  39457. // Our simple test application named test.php
  39458. echo getcwd(), "\n";
  39459. ?></PRE
  39460. ></TD
  39461. ></TR
  39462. ></TABLE
  39463. >
  39464.     </P
  39465. ><P
  39466. >      Bei der <VAR
  39467. CLASS="literal"
  39468. >CGI</VAR
  39469. >-Version ist die Ausgabe folgende:
  39470.      <TABLE
  39471. BORDER="0"
  39472. BGCOLOR="#E0E0E0"
  39473. CELLPADDING="5"
  39474. ><TR
  39475. ><TD
  39476. ><PRE
  39477. CLASS="screen"
  39478. >$ pwd
  39479. /tmp
  39480.  
  39481. $ php -q another_directory/test.php
  39482. /tmp/another_directory</PRE
  39483. ></TD
  39484. ></TR
  39485. ></TABLE
  39486. >
  39487.      Dies zeigt deutlich, dass <VAR
  39488. CLASS="literal"
  39489. >PHP</VAR
  39490. > das aktuelle
  39491.      Verzeichnis auf das des asugefⁿhrten Skriptes Σndert.
  39492.     </P
  39493. ><P
  39494. >      Benutzen der <VAR
  39495. CLASS="literal"
  39496. >CLI SAPI</VAR
  39497. >-Version ergibt:
  39498.      <TABLE
  39499. BORDER="0"
  39500. BGCOLOR="#E0E0E0"
  39501. CELLPADDING="5"
  39502. ><TR
  39503. ><TD
  39504. ><PRE
  39505. CLASS="screen"
  39506. >$ pwd
  39507. /tmp
  39508.  
  39509. $ php -f another_directory/test.php
  39510. /tmp</PRE
  39511. ></TD
  39512. ></TR
  39513. ></TABLE
  39514. >
  39515.      Dies erlaubt eine gr÷▀ere AnpassungsfΣhigkeit beim
  39516.      Schreiben von Kommandozeilenanwendungen in <VAR
  39517. CLASS="literal"
  39518. >PHP</VAR
  39519. >.
  39520.     </P
  39521. ><DIV
  39522. CLASS="note"
  39523. ><BLOCKQUOTE
  39524. CLASS="note"
  39525. ><P
  39526. ><B
  39527. >Anmerkung: </B
  39528. >
  39529.       Das <VAR
  39530. CLASS="literal"
  39531. >CGI SAPI</VAR
  39532. > unterstⁿtzt das Verhalten des 
  39533.       <VAR
  39534. CLASS="literal"
  39535. >CLI SAPI</VAR
  39536. > anhand der Option <VAR
  39537. CLASS="literal"
  39538. >-C</VAR
  39539. >,
  39540.       wenn es auf der Kommandozeile gestartet wird.
  39541.      </P
  39542. ></BLOCKQUOTE
  39543. ></DIV
  39544. ></LI
  39545. ></UL
  39546. >
  39547.  </P
  39548. ><P
  39549. >   Die Liste der Kommandozeilenoptionen, die das <VAR
  39550. CLASS="literal"
  39551. >PHP</VAR
  39552. >-Binary
  39553.   bereitstellt, k÷nnen jederzeit abgerufen werden, wenn man
  39554.   <VAR
  39555. CLASS="literal"
  39556. >PHP</VAR
  39557. > mit der Option <VAR
  39558. CLASS="literal"
  39559. >-h</VAR
  39560. > startet:
  39561.   <TABLE
  39562. BORDER="0"
  39563. BGCOLOR="#E0E0E0"
  39564. CELLPADDING="5"
  39565. ><TR
  39566. ><TD
  39567. ><PRE
  39568. CLASS="screen"
  39569. >Usage: php [options] [-f] <file> [args...]
  39570.        php [options] -r <code> [args...]
  39571.        php [options] [-- args...]
  39572.   -s               Display colour syntax highlighted source.
  39573.   -w               Display source with stripped comments and whitespace.
  39574.   -f <file>        Parse <file>.
  39575.   -v               Version number
  39576.   -c <path>|<file> Look for php.ini file in this directory
  39577.   -a               Run interactively
  39578.   -d foo[=bar]     Define INI entry foo with value 'bar'
  39579.   -e               Generate extended information for debugger/profiler
  39580.   -z <file>        Load Zend extension <file>.
  39581.   -l               Syntax check only (lint)
  39582.   -m               Show compiled in modules
  39583.   -i               PHP information
  39584.   -r <code>        Run PHP <code> without using script tags <?..?>
  39585.   -h               This help
  39586.  
  39587.   args...          Arguments passed to script. Use -- args when first argument 
  39588.                    starts with - or script is read from stdin</PRE
  39589. ></TD
  39590. ></TR
  39591. ></TABLE
  39592. >
  39593.  </P
  39594. ><P
  39595. >   Beim <VAR
  39596. CLASS="literal"
  39597. >CLI SAPI</VAR
  39598. > gibt es drei verschiedene
  39599.   M÷glichkeiten, den zur Ausfⁿhrung bestimmten 
  39600.   <VAR
  39601. CLASS="literal"
  39602. >PHP</VAR
  39603. >-Code zu ⁿbergeben: 
  39604.   <P
  39605. ></P
  39606. ><OL
  39607. TYPE="1"
  39608. ><LI
  39609. ><P
  39610. >      <VAR
  39611. CLASS="literal"
  39612. >PHP</VAR
  39613. > mitteilen, eine bestimmte Datei auszufⁿhren.
  39614.     </P
  39615. ><P
  39616. >      <TABLE
  39617. BORDER="0"
  39618. BGCOLOR="#E0E0E0"
  39619. CELLPADDING="5"
  39620. ><TR
  39621. ><TD
  39622. ><PRE
  39623. CLASS="screen"
  39624. >php my_script.php
  39625.  
  39626. php -f my_script.php</PRE
  39627. ></TD
  39628. ></TR
  39629. ></TABLE
  39630. >
  39631.      Beide Arten (ob sie die Option <VAR
  39632. CLASS="literal"
  39633. >-f</VAR
  39634. > benutzen oder 
  39635.      nicht) fⁿhren die Datei <TT
  39636. CLASS="filename"
  39637. >my_script.php</TT
  39638. > aus.
  39639.      Sie k÷nnen eine beliebige Datei ausfⁿhren - Ihr <VAR
  39640. CLASS="literal"
  39641. >PHP</VAR
  39642. >-Skript
  39643.      muss nicht die Dateiendung <TT
  39644. CLASS="filename"
  39645. >.php</TT
  39646. > haben, sie
  39647.      kann einen beliebigen Namen und eine beliebige Endung haben.
  39648.     </P
  39649. ></LI
  39650. ><LI
  39651. ><P
  39652. >      Den <VAR
  39653. CLASS="literal"
  39654. >PHP</VAR
  39655. >-Code, der ausgefⁿhrt werden soll,
  39656.      direkt auf der Kommandozeile ⁿbergeben.
  39657.     </P
  39658. ><P
  39659. >      <TABLE
  39660. BORDER="0"
  39661. BGCOLOR="#E0E0E0"
  39662. CELLPADDING="5"
  39663. ><TR
  39664. ><TD
  39665. ><PRE
  39666. CLASS="screen"
  39667. >php -r 'print_r(get_defined_constants());'</PRE
  39668. ></TD
  39669. ></TR
  39670. ></TABLE
  39671. >
  39672.      Bezⁿglich Ersetzung von Kommandozeilenvariablen und Benutzung von
  39673.      Quotes muss besondere Vorsicht getroffen werden. 
  39674.     </P
  39675. ><DIV
  39676. CLASS="note"
  39677. ><BLOCKQUOTE
  39678. CLASS="note"
  39679. ><P
  39680. ><B
  39681. >Anmerkung: </B
  39682. >
  39683.       Betrachten Sie das Beispiel sorgfΣltig, es sind keine Start- oder 
  39684.       Endtags gesetzt. Die Option <VAR
  39685. CLASS="literal"
  39686. >-r</VAR
  39687. > ben÷tigt sie nicht.
  39688.       Werden sie dennoch verwendet, kommt es zu einem Parser-Fehler.
  39689.      </P
  39690. ></BLOCKQUOTE
  39691. ></DIV
  39692. ></LI
  39693. ><LI
  39694. ><P
  39695. >      Stellen Sie den <VAR
  39696. CLASS="literal"
  39697. >PHP</VAR
  39698. >-Code, der ausgefⁿhrt werden soll
  39699.      ⁿber den Standard-Input (<VAR
  39700. CLASS="literal"
  39701. >stdin</VAR
  39702. >) bereit.
  39703.     </P
  39704. ><P
  39705. >      Dies er÷ffnet die leistungsfΣhige M÷glichkeit,
  39706.      <VAR
  39707. CLASS="literal"
  39708. >PHP</VAR
  39709. >-Code dynamisch zu generieren und ihn dem
  39710.      <VAR
  39711. CLASS="literal"
  39712. >PHP</VAR
  39713. >-Binary zu ⁿbergeben, wie in diesem
  39714.      m÷glichem Beispiel:
  39715.      <TABLE
  39716. BORDER="0"
  39717. BGCOLOR="#E0E0E0"
  39718. CELLPADDING="5"
  39719. ><TR
  39720. ><TD
  39721. ><PRE
  39722. CLASS="screen"
  39723. >$ some_application | some_filter | php | sort -u >final_output.txt</PRE
  39724. ></TD
  39725. ></TR
  39726. ></TABLE
  39727. >
  39728.     </P
  39729. ></LI
  39730. ></OL
  39731. >
  39732.   Sie k÷nnen diese drei M÷glichkeiten zur Ausfⁿhrung nicht kombinieren.
  39733.  </P
  39734. ><P
  39735. >   Wie jede Kommandozeilenanwendung nimmt das <VAR
  39736. CLASS="literal"
  39737. >PHP</VAR
  39738. >-Binary
  39739.   etliche Argumente entegegen, aber auch ein <VAR
  39740. CLASS="literal"
  39741. >PHP</VAR
  39742. >-Skript
  39743.   kann Argumente entgegennehmen. Die Anzahl der Argumente, die an ein
  39744.   Skript ⁿbergeben werden k÷nnen, ist nicht von <VAR
  39745. CLASS="literal"
  39746. >PHP</VAR
  39747. >
  39748.   beschrΣnkt (aber die Kommandozeilenumgebung hat ein bestimmtes Gr÷ssenlimit
  39749.   fⁿr die Anzahl der Argumente, die ⁿbergeben werden k÷nnen; normalerweise
  39750.   werden Sie dieses Limit nicht erreichen). Die Argumente, die dem Skript
  39751.   ⁿbergeben werden, sind in dem globalen Array <VAR
  39752. CLASS="literal"
  39753. >$argv</VAR
  39754. >
  39755.   gespeichert. Der Null-Index enthΣlt immer den Skriptnamen (das bedeutet
  39756.   <VAR
  39757. CLASS="literal"
  39758. >-</VAR
  39759. >, wenn der <VAR
  39760. CLASS="literal"
  39761. >PHP</VAR
  39762. >-Code entweder
  39763.   von der Standardeingabe oder von der Kommandozeilenoption 
  39764.   <VAR
  39765. CLASS="literal"
  39766. >-r</VAR
  39767. > kommt). Die zweite registrierte globale
  39768.   Variable ist <VAR
  39769. CLASS="literal"
  39770. >$argc</VAR
  39771. >, die die Anzahl der Elemente
  39772.   im Array <VAR
  39773. CLASS="literal"
  39774. >$argv</VAR
  39775. > enthΣlt
  39776.   (<SPAN
  39777. CLASS="strong"
  39778. ><B
  39779. CLASS="emphasis"
  39780. >nicht</B
  39781. ></SPAN
  39782. > die Anzahl
  39783.   Argumente, die dem Skript ⁿbergeben wurden).
  39784.  </P
  39785. ><P
  39786. >   Solange die Argumente, die Sie dem Skript ⁿbergeben m÷chten, nicht
  39787.   mit dem Zeichen <VAR
  39788. CLASS="literal"
  39789. >-</VAR
  39790. > beginnen, gibt es nichts besonderes
  39791.   zu beachten. Ein Argument, das mit <VAR
  39792. CLASS="literal"
  39793. >-</VAR
  39794. > beginnt zu
  39795.   ⁿbergeben, wird Probleme bereiten, weil <VAR
  39796. CLASS="literal"
  39797. >PHP</VAR
  39798. >
  39799.   selbst denkt, dass sie verarbeitet werden muss. Benutzen Sie das
  39800.   Argument-Trennzeichen <VAR
  39801. CLASS="literal"
  39802. >--</VAR
  39803. > um das zu vermeiden.
  39804.   Nachdem dieses Trennzeichen von <VAR
  39805. CLASS="literal"
  39806. >PHP</VAR
  39807. > geparst
  39808.   wurde, wird jedes folgende Argument 
  39809.   unangetastet an das Skript weitergereicht.
  39810.  </P
  39811. ><P
  39812. >   <TABLE
  39813. BORDER="0"
  39814. BGCOLOR="#E0E0E0"
  39815. CELLPADDING="5"
  39816. ><TR
  39817. ><TD
  39818. ><PRE
  39819. CLASS="screen"
  39820. ># This will not execute the given code but will show the PHP usage
  39821. $ php -r 'var_dump($argv);' -h
  39822. Usage: php [options] [-f] <file> [args...]
  39823. [...]
  39824.  
  39825. # This will pass the '-h' argument to your script and prevent PHP from showing it's usage
  39826. $ php -r 'var_dump($argv);' -- -h
  39827. array(2) {
  39828.   [0]=>
  39829.   string(1) "-"
  39830.   [1]=>
  39831.   string(2) "-h"
  39832. }</PRE
  39833. ></TD
  39834. ></TR
  39835. ></TABLE
  39836. >
  39837.  </P
  39838. ><P
  39839. >   Dennoch gibt es einen anderen Weg, um <VAR
  39840. CLASS="literal"
  39841. >PHP</VAR
  39842. > fⁿr
  39843.   Kommandozeilenskripte zu benutzen. Sie k÷nnen ein Skript erstellen,
  39844.   in dem die erste Zeile mit <VAR
  39845. CLASS="literal"
  39846. >#!/usr/bin/php</VAR
  39847. > beginnt.
  39848.   Nachfolgend k÷nnen Sie normalen <VAR
  39849. CLASS="literal"
  39850. >PHP</VAR
  39851. >-Code innerhalb
  39852.   der <VAR
  39853. CLASS="literal"
  39854. >PHP</VAR
  39855. >-Start- und -End-Tags setzen. Sobald Sie
  39856.   die Datei ausfⁿhrbar gemacht haben (beispielsweise 
  39857.   <VAR
  39858. CLASS="literal"
  39859. >chmod +x test</VAR
  39860. >), kann Ihr Skript wie ein normales
  39861.   Kommandozeilen- oder Perlskript gestartet werden.
  39862.   <TABLE
  39863. BORDER="0"
  39864. BGCOLOR="#E0E0E0"
  39865. CELLPADDING="5"
  39866. ><TR
  39867. ><TD
  39868. ><PRE
  39869. CLASS="php"
  39870. >#!/usr/bin/php
  39871. <?php
  39872. var_dump($argv);
  39873. ?></PRE
  39874. ></TD
  39875. ></TR
  39876. ></TABLE
  39877. >
  39878.   Angenommen, die Datei heisst <TT
  39879. CLASS="filename"
  39880. >test</TT
  39881. > und befindet
  39882.   sich im aktuellen Verzeichnis, dann k÷nnen wir nun folgendes tun:
  39883.   <TABLE
  39884. BORDER="0"
  39885. BGCOLOR="#E0E0E0"
  39886. CELLPADDING="5"
  39887. ><TR
  39888. ><TD
  39889. ><PRE
  39890. CLASS="screen"
  39891. >$ chmod 755 test
  39892. $ ./test -h -- foo
  39893. array(4) {
  39894.   [0]=>
  39895.   string(6) "./test"
  39896.   [1]=>
  39897.   string(2) "-h"
  39898.   [2]=>
  39899.   string(2) "--"
  39900.   [3]=>
  39901.   string(3) "foo"
  39902. }</PRE
  39903. ></TD
  39904. ></TR
  39905. ></TABLE
  39906. >
  39907.   Wie Sie sehen k÷nnen, mⁿssen Sie sich in diesem Fall um nichts weiter
  39908.   kⁿmmern, wenn Sie Ihrem Skript Paramater, die mit <VAR
  39909. CLASS="literal"
  39910. >-</VAR
  39911. >
  39912.   beginnen, ⁿbergeben.
  39913.  </P
  39914. ><P
  39915. >   Die Langformen der Optionen sind seit PHP 4.3.3 verfⁿgbar.
  39916.   <DIV
  39917. CLASS="table"
  39918. ><A
  39919. NAME="AEN6724"
  39920. ></A
  39921. ><P
  39922. ><B
  39923. >Tabelle 39-3. Kommandozeilenoption</B
  39924. ></P
  39925. ><TABLE
  39926. BORDER="1"
  39927. CLASS="CALSTABLE"
  39928. ><COL><COL><THEAD
  39929. ><TR
  39930. ><TH
  39931. >Option</TH
  39932. ><TH
  39933. >Langform</TH
  39934. ><TH
  39935. >Beschreibung</TH
  39936. ></TR
  39937. ></THEAD
  39938. ><TBODY
  39939. ><TR
  39940. ><TD
  39941. >-s</TD
  39942. ><TD
  39943. >--syntax-highlight</TD
  39944. ><TD
  39945. >        <P
  39946. >            Den Quelltext mit farbiger Syntaxhervorhebung anzeigen.
  39947.        </P
  39948. >
  39949.        <P
  39950. >         Diese Option benutzt den internen Mechanismus zum Analysieren
  39951.         der Datei, generiert eine <VAR
  39952. CLASS="literal"
  39953. >HTML</VAR
  39954. >-Version mit
  39955.         Syntax-Highlighting davon, und schreibt sie auf die
  39956.         Standardausgabe. Beachten Sie, dass sie nur einen Block von
  39957.         <VAR
  39958. CLASS="literal"
  39959. ><code> [...] </code></VAR
  39960. >-HTML-Tags 
  39961.         erzeugt, keine HTML-Header.
  39962.        </P
  39963. >
  39964.        <DIV
  39965. CLASS="note"
  39966. ><BLOCKQUOTE
  39967. CLASS="note"
  39968. ><P
  39969. ><B
  39970. >Anmerkung: </B
  39971. >
  39972.          Diese Option funktioniert nicht zusammen mit <VAR
  39973. CLASS="literal"
  39974. >-r</VAR
  39975. >.
  39976.         </P
  39977. ></BLOCKQUOTE
  39978. ></DIV
  39979. >
  39980.       </TD
  39981. ></TR
  39982. ><TR
  39983. ><TD
  39984. >-s</TD
  39985. ><TD
  39986. >--syntax-highlighting</TD
  39987. ><TD
  39988. >        <P
  39989. >         Ein Alias fⁿr <VAR
  39990. CLASS="literal"
  39991. >--syntax-highlight</VAR
  39992. >.
  39993.        </P
  39994. >
  39995.       </TD
  39996. ></TR
  39997. ><TR
  39998. ><TD
  39999. >-w</TD
  40000. ><TD
  40001. >--strip</TD
  40002. ><TD
  40003. >        <P
  40004. >         Den Quelltext mit entfernten Kommentaren und Leerzeichen anzeigen.
  40005.        </P
  40006. >
  40007.        <DIV
  40008. CLASS="note"
  40009. ><BLOCKQUOTE
  40010. CLASS="note"
  40011. ><P
  40012. ><B
  40013. >Anmerkung: </B
  40014. >
  40015.          Diese Option funktioniert nicht zusammen mit <VAR
  40016. CLASS="literal"
  40017. >-r</VAR
  40018. >.
  40019.         </P
  40020. ></BLOCKQUOTE
  40021. ></DIV
  40022. >
  40023.       </TD
  40024. ></TR
  40025. ><TR
  40026. ><TD
  40027. >-f</TD
  40028. ><TD
  40029. >--file</TD
  40030. ><TD
  40031. >        <P
  40032. >         Parst und fⁿhrt die angegebene Datei aus. Diese Option ist nicht
  40033.         verbindlich und kann weggelassen werden. Alleinige Angabe des
  40034.         Dateinamens ist ausreichend.
  40035.        </P
  40036. >
  40037.       </TD
  40038. ></TR
  40039. ><TR
  40040. ><TD
  40041. >-v</TD
  40042. ><TD
  40043. >--version</TD
  40044. ><TD
  40045. >        <P
  40046. >         Schreibt die <VAR
  40047. CLASS="literal"
  40048. >PHP</VAR
  40049. >, <VAR
  40050. CLASS="literal"
  40051. >PHP SAPI</VAR
  40052. > und
  40053.         <VAR
  40054. CLASS="literal"
  40055. >Zend</VAR
  40056. >-Version auf die Standardausgabe. Zum Beispiel:
  40057.         <TABLE
  40058. BORDER="0"
  40059. BGCOLOR="#E0E0E0"
  40060. CELLPADDING="5"
  40061. ><TR
  40062. ><TD
  40063. ><PRE
  40064. CLASS="screen"
  40065. >$ php -v
  40066. PHP 4.3.0 (cli), Copyright (c) 1997-2002 The PHP Group
  40067. Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies</PRE
  40068. ></TD
  40069. ></TR
  40070. ></TABLE
  40071. >
  40072.        </P
  40073. >
  40074.       </TD
  40075. ></TR
  40076. ><TR
  40077. ><TD
  40078. >-c</TD
  40079. ><TD
  40080. >--php-ini</TD
  40081. ><TD
  40082. >        <P
  40083. >         Mit dieser Option kann man entweder ein Verzichnis angeben, 
  40084.         wo nach <TT
  40085. CLASS="filename"
  40086. >php.ini</TT
  40087. > gesucht werden soll, oder man kann eine
  40088.         eigene <VAR
  40089. CLASS="literal"
  40090. >INI</VAR
  40091. >-Datei direkt angeben (diese
  40092.         muss nicht <TT
  40093. CLASS="filename"
  40094. >php.ini</TT
  40095. > heissen). Zum Beispiel:
  40096.         <TABLE
  40097. BORDER="0"
  40098. BGCOLOR="#E0E0E0"
  40099. CELLPADDING="5"
  40100. ><TR
  40101. ><TD
  40102. ><PRE
  40103. CLASS="screen"
  40104. >$ php -c /custom/directory/ my_script.php
  40105.  
  40106. $ php -c /custom/directory/custom-file.ini my_script.php</PRE
  40107. ></TD
  40108. ></TR
  40109. ></TABLE
  40110. >
  40111.        </P
  40112. >
  40113.       </TD
  40114. ></TR
  40115. ><TR
  40116. ><TD
  40117. >-n</TD
  40118. ><TD
  40119. >--no-php-ini</TD
  40120. ><TD
  40121. >        <P
  40122. >         php.ini komplett ignorieren. Diese Option gibt es seit PHP 4.3.0.
  40123.        </P
  40124. >
  40125.       </TD
  40126. ></TR
  40127. ><TR
  40128. ><TD
  40129. >-d</TD
  40130. ><TD
  40131. >--define</TD
  40132. ><TD
  40133. >        <P
  40134. >         Diese Option erlaubt es Ihnen, einen eigenen Wert fⁿr eine beliebige
  40135.         in <TT
  40136. CLASS="filename"
  40137. >php.ini</TT
  40138. > erlaubte Direktive zu setzen. Die Syntax ist:
  40139.         <TABLE
  40140. BORDER="0"
  40141. BGCOLOR="#E0E0E0"
  40142. CELLPADDING="5"
  40143. ><TR
  40144. ><TD
  40145. ><PRE
  40146. CLASS="screen"
  40147. >-d configuration_directive[=value]</PRE
  40148. ></TD
  40149. ></TR
  40150. ></TABLE
  40151. >
  40152.        </P
  40153. >
  40154.        <P
  40155. >            Beispiel (Die Zeilen sind aus layouttechnischen Grⁿnden umgebrochen):
  40156.         <TABLE
  40157. BORDER="0"
  40158. BGCOLOR="#E0E0E0"
  40159. CELLPADDING="5"
  40160. ><TR
  40161. ><TD
  40162. ><PRE
  40163. CLASS="screen"
  40164. ># Omitting the value part will set the given configuration directive to "1"
  40165. $ php -d max_execution_time
  40166.         -r '$foo = ini_get("max_execution_time"); var_dump($foo);'
  40167. string(1) "1"
  40168.  
  40169. # Passing an empty value part will set the configuration directive to ""
  40170. php -d max_execution_time=
  40171.         -r '$foo = ini_get("max_execution_time"); var_dump($foo);'
  40172. string(0) ""
  40173.  
  40174. # The configuration directive will be set to anything passed after the '=' character
  40175. $  php -d max_execution_time=20
  40176.         -r '$foo = ini_get("max_execution_time"); var_dump($foo);'
  40177. string(2) "20"
  40178. $  php
  40179.         -d max_execution_time=doesntmakesense
  40180.         -r '$foo = ini_get("max_execution_time"); var_dump($foo);'
  40181. string(15) "doesntmakesense"</PRE
  40182. ></TD
  40183. ></TR
  40184. ></TABLE
  40185. >
  40186.        </P
  40187. >
  40188.       </TD
  40189. ></TR
  40190. ><TR
  40191. ><TD
  40192. >-a</TD
  40193. ><TD
  40194. >--interactive</TD
  40195. ><TD
  40196. >        <P
  40197. >         <VAR
  40198. CLASS="literal"
  40199. >PHP</VAR
  40200. > interaktiv starten.
  40201.         
  40202.        </P
  40203. >
  40204.       </TD
  40205. ></TR
  40206. ><TR
  40207. ><TD
  40208. >-e</TD
  40209. ><TD
  40210. >--profile-info</TD
  40211. ><TD
  40212. >        <P
  40213. >         Erweiterte Informationen fⁿr Debugger/Profiler erstellen.
  40214.         
  40215.        </P
  40216. >
  40217.       </TD
  40218. ></TR
  40219. ><TR
  40220. ><TD
  40221. >-z</TD
  40222. ><TD
  40223. >--zend-extension</TD
  40224. ><TD
  40225. >        <P
  40226. >         Eine <VAR
  40227. CLASS="literal"
  40228. >Zend</VAR
  40229. >-Erweiterung laden. Wenn nur ein Dateiname
  40230.         angegeben wird, versucht <VAR
  40231. CLASS="literal"
  40232. >PHP</VAR
  40233. >, die Erweiterung aus
  40234.         dem momentanen Standard-Bibliotheken-Pfad auf Ihrem System zu laden
  40235.         (auf Linux-Systemen normalerweise in
  40236.         <TT
  40237. CLASS="filename"
  40238. >/etc/ld.so.conf</TT
  40239. > angegeben). Wenn ein Dateiname mit
  40240.         absoluter Pfadinformation ⁿbergeben wird, wird der Bibliotheken-Pfad
  40241.         des Systems nicht benutzt. Ein relativer Dateiname mit 
  40242.         Pfadinformationen wird <VAR
  40243. CLASS="literal"
  40244. >PHP</VAR
  40245. > nur veranlassen,
  40246.         zu versuchen, die Erweiterung in einem Pfad relativ zum
  40247.         aktuellen Verzeichnis zu laden.
  40248.        </P
  40249. >
  40250.       </TD
  40251. ></TR
  40252. ><TR
  40253. ><TD
  40254. >-l</TD
  40255. ><TD
  40256. >--syntax-check</TD
  40257. ><TD
  40258. >        <P
  40259. >         Diese Option stellt eine angenehme Methode bereit, nur eine
  40260.         Syntaxⁿberprⁿfung auf den angegebenen <VAR
  40261. CLASS="literal"
  40262. >PHP</VAR
  40263. >-Code
  40264.         durchzufⁿhren. Bei Erfolg wird der Text <VAR
  40265. CLASS="literal"
  40266. >No syntax errors 
  40267.         detected in <filename></VAR
  40268. > auf die Standardausgabe
  40269.         geschrieben und der Rⁿckgabewert ist <VAR
  40270. CLASS="literal"
  40271. >0</VAR
  40272. >. Bei
  40273.         Misserfolg wird der Text <VAR
  40274. CLASS="literal"
  40275. >Errors parsing 
  40276.         <filename></VAR
  40277. > zusΣtzlich zur internen 
  40278.         Parser-Fehlermeldung auf der Standardausgabe
  40279.         ausgegeben und der Rⁿckgabewert auf <VAR
  40280. CLASS="literal"
  40281. >255</VAR
  40282. > gesetzt.
  40283.        </P
  40284. >
  40285.        <P
  40286. >         Diese Option wird keine Fatalen Fehler (wie undefinierte Funktionen)
  40287.         finden. Benutzen Sie die Option <VAR
  40288. CLASS="literal"
  40289. >-f</VAR
  40290. >, wenn sie
  40291.         auch diese ⁿberprⁿfen wollen.
  40292.        </P
  40293. >
  40294.        <DIV
  40295. CLASS="note"
  40296. ><BLOCKQUOTE
  40297. CLASS="note"
  40298. ><P
  40299. ><B
  40300. >Anmerkung: </B
  40301. >
  40302.          Diese Option funktioniert nicht zusammen mit <VAR
  40303. CLASS="literal"
  40304. >-r</VAR
  40305. >.
  40306.         </P
  40307. ></BLOCKQUOTE
  40308. ></DIV
  40309. >
  40310.       </TD
  40311. ></TR
  40312. ><TR
  40313. ><TD
  40314. >-m</TD
  40315. ><TD
  40316. >--modules</TD
  40317. ><TD
  40318. >        <P
  40319. >         Wird diese Option benutzt, gibt <VAR
  40320. CLASS="literal"
  40321. >PHP</VAR
  40322. > die
  40323.         eingebauten (und geladenen) <VAR
  40324. CLASS="literal"
  40325. >PHP</VAR
  40326. >- und
  40327.         <VAR
  40328. CLASS="literal"
  40329. >Zend</VAR
  40330. >-Module aus:
  40331.         <TABLE
  40332. BORDER="0"
  40333. BGCOLOR="#E0E0E0"
  40334. CELLPADDING="5"
  40335. ><TR
  40336. ><TD
  40337. ><PRE
  40338. CLASS="screen"
  40339. >$ php -m
  40340. [PHP Modules]
  40341. xml
  40342. tokenizer
  40343. standard
  40344. session
  40345. posix
  40346. pcre
  40347. overload
  40348. mysql
  40349. mbstring
  40350. ctype
  40351.  
  40352. [Zend Modules]</PRE
  40353. ></TD
  40354. ></TR
  40355. ></TABLE
  40356. >
  40357.        </P
  40358. >
  40359.       </TD
  40360. ></TR
  40361. ><TR
  40362. ><TD
  40363. >-i</TD
  40364. ><TD
  40365. >--info</TD
  40366. ><TD
  40367. >        Diese Kommandozeilenoption ruft <A
  40368. HREF="#function.phpinfo"
  40369. ><B
  40370. CLASS="function"
  40371. >phpinfo()</B
  40372. ></A
  40373. >
  40374.        auf und gibt das Ergebnis aus. Wenn <VAR
  40375. CLASS="literal"
  40376. >PHP</VAR
  40377. >
  40378.        nicht korrekt funktioniert, ist es ratsam, <VAR
  40379. CLASS="literal"
  40380. >php -i</VAR
  40381. >
  40382.        zu benutzen und nachzusehen, ob etwa Fehlermeldungen vor oder
  40383.        statt der Informationstabellen ausgegeben werden. Beachten Sie,
  40384.        dass die Ausgabe in <VAR
  40385. CLASS="literal"
  40386. >HTML</VAR
  40387. > erfolgt
  40388.        und deswegen ziemlich umfangreich ist.
  40389.       </TD
  40390. ></TR
  40391. ><TR
  40392. ><TD
  40393. >-r</TD
  40394. ><TD
  40395. >--run</TD
  40396. ><TD
  40397. >        <P
  40398. >         Diese Option erlaubt die Ausfⁿhrung von <VAR
  40399. CLASS="literal"
  40400. >PHP</VAR
  40401. >
  40402.         direkt aus der Kommandozeile. Die <VAR
  40403. CLASS="literal"
  40404. >PHP</VAR
  40405. >-Start-
  40406.         und -End-Tags (<VAR
  40407. CLASS="literal"
  40408. ><?php</VAR
  40409. > and 
  40410.         <VAR
  40411. CLASS="literal"
  40412. >?></VAR
  40413. >) werden
  40414.         <SPAN
  40415. CLASS="strong"
  40416. ><B
  40417. CLASS="emphasis"
  40418. >nicht ben÷tigt</B
  40419. ></SPAN
  40420. > und verursachen
  40421.         Parserfehler, wenn sie dennoch vorhanden sind.
  40422.        </P
  40423. >
  40424.        <DIV
  40425. CLASS="note"
  40426. ><BLOCKQUOTE
  40427. CLASS="note"
  40428. ><P
  40429. ><B
  40430. >Anmerkung: </B
  40431. >
  40432.          Man muss bei Benutzung dieser Form  von <VAR
  40433. CLASS="literal"
  40434. >PHP</VAR
  40435. >
  40436.          aufpassen, dass es zu keinen Kollisionen mit
  40437.          Kommandozeilenvariablen kommt.
  40438.         </P
  40439. ><P
  40440. >          Dieses Beispiel zeigt einen Parserfehler:
  40441.          <TABLE
  40442. BORDER="0"
  40443. BGCOLOR="#E0E0E0"
  40444. CELLPADDING="5"
  40445. ><TR
  40446. ><TD
  40447. ><PRE
  40448. CLASS="screen"
  40449. >$ php -r "$foo = get_defined_constants();"
  40450. Command line code(1) : Parse error - parse error, unexpected '='</PRE
  40451. ></TD
  40452. ></TR
  40453. ></TABLE
  40454. >
  40455.          Das Problem hier ist, dass die sh/bash Variablen auch ersetzt,
  40456.          wenn doppelte Anfⁿhrungszeichen benutzt werden (<VAR
  40457. CLASS="literal"
  40458. >"</VAR
  40459. >).
  40460.          Weil die Variable <VAR
  40461. CLASS="literal"
  40462. >$foo</VAR
  40463. > wahrscheinlich nicht
  40464.          definiert ist, passiert nichts. Der tatsΣchliche Code, der an
  40465.          <VAR
  40466. CLASS="literal"
  40467. >PHP</VAR
  40468. > ⁿbergeben wird, sieht so aus:
  40469.          <TABLE
  40470. BORDER="0"
  40471. BGCOLOR="#E0E0E0"
  40472. CELLPADDING="5"
  40473. ><TR
  40474. ><TD
  40475. ><PRE
  40476. CLASS="screen"
  40477. >$ php -r " = get_defined_constants();"</PRE
  40478. ></TD
  40479. ></TR
  40480. ></TABLE
  40481. >
  40482.          Der korrekte Weg wΣre, einfache Anfⁿhrungszeichen zu benutzen
  40483.          (<VAR
  40484. CLASS="literal"
  40485. >'</VAR
  40486. >). Variablen in einfachen Anfⁿhrungszeichen
  40487.          werden von sh/bash nicht ersetzt.
  40488.          <TABLE
  40489. BORDER="0"
  40490. BGCOLOR="#E0E0E0"
  40491. CELLPADDING="5"
  40492. ><TR
  40493. ><TD
  40494. ><PRE
  40495. CLASS="screen"
  40496. >$ php -r '$foo = get_defined_constants(); var_dump($foo);'
  40497. array(370) {
  40498.   ["E_ERROR"]=>
  40499.   int(1)
  40500.   ["E_WARNING"]=>
  40501.   int(2)
  40502.   ["E_PARSE"]=>
  40503.   int(4)
  40504.   ["E_NOTICE"]=>
  40505.   int(8)
  40506.   ["E_CORE_ERROR"]=>
  40507.   [...]</PRE
  40508. ></TD
  40509. ></TR
  40510. ></TABLE
  40511. >
  40512.          Wenn Sie eine andere Kommandozeilenumgebung als sh/bash benutzen,
  40513.          k÷nnten Sie auf weitere Probleme stossen. Sie k÷nnen gerne einen
  40514.          Bugreport anmelden oder eine Email an phpdoc@lists.php.net schreiben.
  40515.  
  40516.          Man kann dennoch leicht in Schwierigkeiten kommen, wenn man versucht, 
  40517.          Kommandozeilenvariablen zu verwenden oder mit Backslashes zu escapen.
  40518.          Sie wurden gewarnt. 
  40519.         </P
  40520. ></BLOCKQUOTE
  40521. ></DIV
  40522. >
  40523.        <DIV
  40524. CLASS="note"
  40525. ><BLOCKQUOTE
  40526. CLASS="note"
  40527. ><P
  40528. ><B
  40529. >Anmerkung: </B
  40530. >
  40531.          <VAR
  40532. CLASS="literal"
  40533. >-r</VAR
  40534. > ist nur im <SPAN
  40535. CLASS="emphasis"
  40536. ><I
  40537. CLASS="emphasis"
  40538. >CLI</I
  40539. ></SPAN
  40540. >-SAPI
  40541.          verfⁿgbar und nicht im <SPAN
  40542. CLASS="emphasis"
  40543. ><I
  40544. CLASS="emphasis"
  40545. >CGI</I
  40546. ></SPAN
  40547. >-SAPI
  40548.         </P
  40549. ></BLOCKQUOTE
  40550. ></DIV
  40551. >
  40552.       </TD
  40553. ></TR
  40554. ><TR
  40555. ><TD
  40556. >-h</TD
  40557. ><TD
  40558. >--help</TD
  40559. ><TD
  40560. >        Mit dieser Option bekommen Sie Informationen ⁿber die tatsΣchlichen
  40561.        Kommandozeilenoptionen und kurze Beschreibungen dazu.
  40562.       </TD
  40563. ></TR
  40564. ><TR
  40565. ><TD
  40566. >-?</TD
  40567. ><TD
  40568. >--usage</TD
  40569. ><TD
  40570. >        Ein Alias fⁿr <VAR
  40571. CLASS="literal"
  40572. >--help</VAR
  40573. >.
  40574.       </TD
  40575. ></TR
  40576. ></TBODY
  40577. ></TABLE
  40578. ></DIV
  40579. >
  40580.  </P
  40581. ><P
  40582. >   Die ausfⁿhrbare PHP-Version kann benutzt werden, um PHP-Skripte vollkommen
  40583.   unabhΣngig von einem Webserver auszufⁿhren. Wenn Sie auf einem UNIX-System
  40584.   arbeiten, sollten Sie Ihrem Skript eine spezielle erste Zeile hinzufⁿgen und
  40585.   es ausfⁿhrbar machen, so dass das System erkennt, welches Programm das Skript
  40586.   ausfⁿhren soll. Auf einem Windows-System k÷nnen Sie <VAR
  40587. CLASS="literal"
  40588. >php.exe</VAR
  40589. >
  40590.   mit der Doppelklick-Option von <VAR
  40591. CLASS="literal"
  40592. >.php</VAR
  40593. >-Dateien verknⁿpfen.
  40594.   Sie k÷nnen auch eine Batchdatei erzeugen, um das Skript von PHP ausfⁿhren zu
  40595.   lassen. Die erste Zeile, die dem Skript hinzugefⁿgt wird, damit es unter UNIX
  40596.   lΣuft, st÷rt unter Windows nicht, so dass Sie auf diese Weise problemlos 
  40597.   plattformⁿbergreifende Programme schreiben k÷nnen. Sie finden anschlie▀end
  40598.   ein einfaches Beispiel, wie man ein Kommandozeilenprogramm in PHP schreibt.
  40599.  </P
  40600. ><P
  40601. >   <TABLE
  40602. WIDTH="100%"
  40603. BORDER="0"
  40604. CELLPADDING="0"
  40605. CELLSPACING="0"
  40606. CLASS="EXAMPLE"
  40607. ><TR
  40608. ><TD
  40609. ><DIV
  40610. CLASS="example"
  40611. ><A
  40612. NAME="AEN6886"
  40613. ></A
  40614. ><P
  40615. ><B
  40616. >Beispiel 39-1. Ein Skript, das von der Kommandozeile aus ausgefⁿhrt werden soll (script.php)</B
  40617. ></P
  40618. ><TABLE
  40619. BORDER="0"
  40620. BGCOLOR="#E0E0E0"
  40621. CELLPADDING="5"
  40622. ><TR
  40623. ><TD
  40624. ><PRE
  40625. CLASS="php"
  40626. >#!/usr/bin/php
  40627. <?php
  40628.  
  40629. if ($argc != 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
  40630. ?>
  40631.  
  40632. This is a command line PHP script with one option.
  40633.  
  40634.   Usage:
  40635.   <?php echo $argv[0]; ?> <option>
  40636.  
  40637.   <option> can be some word you would like
  40638.   to print out. With the --help, -help, -h,
  40639.   or -? options, you can get this help.
  40640.  
  40641. <?php
  40642. } else {
  40643.     echo $argv[1];
  40644. }
  40645. ?></PRE
  40646. ></TD
  40647. ></TR
  40648. ></TABLE
  40649. ></DIV
  40650. ></TD
  40651. ></TR
  40652. ></TABLE
  40653. >
  40654.  </P
  40655. ><P
  40656. >   In dem oben beschriebenen Skript haben wir die erste Zeile dazu benutzt,
  40657.   anzugeben, dass die Datei von PHP ausgefⁿhrt werden soll. Wir arbeiten hier
  40658.   mit einer CLI-version, deswegen werden keine HTTP-Header ausgegeben. Es gibt
  40659.   zwei Variablen, die Sie in Kommandozeilen-Applikationen mit PHP benutzen
  40660.   k÷nnen: <VAR
  40661. CLASS="varname"
  40662. >$argc</VAR
  40663. > und <VAR
  40664. CLASS="varname"
  40665. >$argv</VAR
  40666. >. Die erste ist
  40667.   die Anzahl der Argumente plus Eins (dem Namen des laufenden Skripts). Die
  40668.   zweite ist ein Array, das die Argumente enthΣlt, beginnend mit dem Skriptnamen
  40669.   als Nummer Null (<VAR
  40670. CLASS="varname"
  40671. >$argv[0]</VAR
  40672. >).
  40673.  </P
  40674. ><P
  40675. >   In dem oben genannten Programm haben wir ⁿberprⁿft, ob es weniger oder mehr
  40676.   als zwei Argumente gibt. Falls das Argument <VAR
  40677. CLASS="literal"
  40678. >--help</VAR
  40679. >,
  40680.   <VAR
  40681. CLASS="literal"
  40682. >-help</VAR
  40683. >, <VAR
  40684. CLASS="literal"
  40685. >-h</VAR
  40686. > oder <VAR
  40687. CLASS="literal"
  40688. >-?</VAR
  40689. >
  40690.   war, haben wir die Hilfe-Nachricht mit dem dynamisch ⁿbergebenen 
  40691.   Skriptnamen ausgegeben. Wenn wir ein anderes Argument erhalten haben, haben
  40692.   wir es ausgegeben.
  40693.  </P
  40694. ><P
  40695. >   Wenn Sie das oben genannte Skript unter UNIX laufen lassen wollen, mⁿssen Sie
  40696.   es zuerst ausfⁿhrbar machen, und es danach einfach als 
  40697.   <VAR
  40698. CLASS="literal"
  40699. >script.php echothis</VAR
  40700. > oder
  40701.   <VAR
  40702. CLASS="literal"
  40703. >script.php -h</VAR
  40704. > aufrufen. Unter Windows k÷nnen Sie zu diesem
  40705.   Zweck eine Batchdatei erstellen:
  40706.  </P
  40707. ><P
  40708. >   <TABLE
  40709. WIDTH="100%"
  40710. BORDER="0"
  40711. CELLPADDING="0"
  40712. CELLSPACING="0"
  40713. CLASS="EXAMPLE"
  40714. ><TR
  40715. ><TD
  40716. ><DIV
  40717. CLASS="example"
  40718. ><A
  40719. NAME="AEN6902"
  40720. ></A
  40721. ><P
  40722. ><B
  40723. >Beispiel 39-2. Batchdatei zur Ausfⁿhrung eines Kommandozeilen-Skripts in PHP (script.bat)</B
  40724. ></P
  40725. ><TABLE
  40726. BORDER="0"
  40727. BGCOLOR="#E0E0E0"
  40728. CELLPADDING="5"
  40729. ><TR
  40730. ><TD
  40731. ><PRE
  40732. CLASS="shell"
  40733. >@c:\php\cli\php.exe script.php %1 %2 %3 %4</PRE
  40734. ></TD
  40735. ></TR
  40736. ></TABLE
  40737. ></DIV
  40738. ></TD
  40739. ></TR
  40740. ></TABLE
  40741. >
  40742.  </P
  40743. ><P
  40744. >   Angenommen, Sie haben das Programm <TT
  40745. CLASS="filename"
  40746. >script.php</TT
  40747. > genannt
  40748.   und die CLI-<TT
  40749. CLASS="filename"
  40750. >php.exe</TT
  40751. > hat den Pfad
  40752.   <TT
  40753. CLASS="filename"
  40754. >c:\php\cli\php.exe</TT
  40755. >, wird diese Batchdatei es mit den von
  40756.   Ihnen ⁿbergebnen Optionen <VAR
  40757. CLASS="literal"
  40758. >script.bat echothis</VAR
  40759. > oder
  40760.   <VAR
  40761. CLASS="literal"
  40762. >script.bat -h</VAR
  40763. > ausfⁿhren.
  40764.  </P
  40765. ><P
  40766. >   Sehen Sie sich auch die zusΣtzlichen Funktionen in der Dokumentation der 
  40767.   <A
  40768. HREF="#ref.readline"
  40769. >Readline</A
  40770. >-Extension an, um Ihre in PHP
  40771.   geschriebenen Kommandozeilenanwendungen weiterzuentwickeln.
  40772.  </P
  40773. ></DIV
  40774. ></DIV
  40775. ><DIV
  40776. CLASS="PART"
  40777. ><A
  40778. NAME="funcref"
  40779. ></A
  40780. ><DIV
  40781. CLASS="TITLEPAGE"
  40782. ><H1
  40783. CLASS="title"
  40784. >VI. Funktionsreferenz</H1
  40785. ><DIV
  40786. CLASS="TOC"
  40787. ><DL
  40788. ><DT
  40789. ><B
  40790. >Inhaltsverzeichnis</B
  40791. ></DT
  40792. ><DT
  40793. >I. <A
  40794. HREF="#ref.apache"
  40795. >Apache-spezifische Funktionen</A
  40796. ></DT
  40797. ><DT
  40798. >II. <A
  40799. HREF="#ref.array"
  40800. >Array Funktionen</A
  40801. ></DT
  40802. ><DT
  40803. >III. <A
  40804. HREF="#ref.aspell"
  40805. >Aspell Funktionen [veraltet]</A
  40806. ></DT
  40807. ><DT
  40808. >IV. <A
  40809. HREF="#ref.bc"
  40810. >Mathematische Funktionen mit beliebiger Genauigkeit</A
  40811. ></DT
  40812. ><DT
  40813. >V. <A
  40814. HREF="#ref.bzip2"
  40815. >Bzip2 Komprimierungsfunktionen</A
  40816. ></DT
  40817. ><DT
  40818. >VI. <A
  40819. HREF="#ref.calendar"
  40820. >Kalender-Funktionen</A
  40821. ></DT
  40822. ><DT
  40823. >VII. <A
  40824. HREF="#ref.ccvs"
  40825. >CCVS API Funktionen</A
  40826. ></DT
  40827. ><DT
  40828. >VIII. <A
  40829. HREF="#ref.com"
  40830. >COM Support Funktionen fⁿr Windows</A
  40831. ></DT
  40832. ><DT
  40833. >IX. <A
  40834. HREF="#ref.classobj"
  40835. >Klassen- und Objekt-Funktionen</A
  40836. ></DT
  40837. ><DT
  40838. >X. <A
  40839. HREF="#ref.cpdf"
  40840. >ClibPDF Funktionen</A
  40841. ></DT
  40842. ><DT
  40843. >XI. <A
  40844. HREF="#ref.crack"
  40845. >Crack Funktionen</A
  40846. ></DT
  40847. ><DT
  40848. >XII. <A
  40849. HREF="#ref.curl"
  40850. >cURL, Client URL Bibiothek-Funktionen</A
  40851. ></DT
  40852. ><DT
  40853. >XIII. <A
  40854. HREF="#ref.cybercash"
  40855. >Cybercash Bezahl Funktionen</A
  40856. ></DT
  40857. ><DT
  40858. >XIV. <A
  40859. HREF="#ref.cyrus"
  40860. >Cyrus IMAP administration Functions</A
  40861. ></DT
  40862. ><DT
  40863. >XV. <A
  40864. HREF="#ref.ctype"
  40865. >Character type functions</A
  40866. ></DT
  40867. ><DT
  40868. >XVI. <A
  40869. HREF="#ref.dba"
  40870. >dba Datenbank (dbm-style) Abstraktions-Funktionen</A
  40871. ></DT
  40872. ><DT
  40873. >XVII. <A
  40874. HREF="#ref.datetime"
  40875. >Datums- und Zeit-Funktionen</A
  40876. ></DT
  40877. ><DT
  40878. >XVIII. <A
  40879. HREF="#ref.dbase"
  40880. >dBase Funktionen</A
  40881. ></DT
  40882. ><DT
  40883. >XIX. <A
  40884. HREF="#ref.dbm"
  40885. >DBM Datenbankfunktionen</A
  40886. ></DT
  40887. ><DT
  40888. >XX. <A
  40889. HREF="#ref.dbx"
  40890. >dbx Funktionen</A
  40891. ></DT
  40892. ><DT
  40893. >XXI. <A
  40894. HREF="#ref.dbplus"
  40895. >DB++ Functions</A
  40896. ></DT
  40897. ><DT
  40898. >XXII. <A
  40899. HREF="#ref.dio"
  40900. >Direkte Ein-/Ausgabe Funktionen</A
  40901. ></DT
  40902. ><DT
  40903. >XXIII. <A
  40904. HREF="#ref.dir"
  40905. >Verzeichnis-Funktionen</A
  40906. ></DT
  40907. ><DT
  40908. >XXIV. <A
  40909. HREF="#ref.dom"
  40910. >DOM Functions</A
  40911. ></DT
  40912. ><DT
  40913. >XXV. <A
  40914. HREF="#ref.domxml"
  40915. >DOM XML Funktionen</A
  40916. ></DT
  40917. ><DT
  40918. >XXVI. <A
  40919. HREF="#ref.dotnet"
  40920. >.NET Funktionen</A
  40921. ></DT
  40922. ><DT
  40923. >XXVII. <A
  40924. HREF="#ref.errorfunc"
  40925. >Error Handling and Logging Functions</A
  40926. ></DT
  40927. ><DT
  40928. >XXVIII. <A
  40929. HREF="#ref.exif"
  40930. >Exif Functions</A
  40931. ></DT
  40932. ><DT
  40933. >XXIX. <A
  40934. HREF="#ref.fam"
  40935. >File Alteration Monitor Functions</A
  40936. ></DT
  40937. ><DT
  40938. >XXX. <A
  40939. HREF="#ref.fbsql"
  40940. >FrontBase Funktionen</A
  40941. ></DT
  40942. ><DT
  40943. >XXXI. <A
  40944. HREF="#ref.filepro"
  40945. >filePro Funktionen</A
  40946. ></DT
  40947. ><DT
  40948. >XXXII. <A
  40949. HREF="#ref.filesystem"
  40950. >Funktionen des Dateisystems</A
  40951. ></DT
  40952. ><DT
  40953. >XXXIII. <A
  40954. HREF="#ref.fdf"
  40955. >Forms Data Format Funktionen</A
  40956. ></DT
  40957. ><DT
  40958. >XXXIV. <A
  40959. HREF="#ref.fribidi"
  40960. >FriBiDi Funktionen</A
  40961. ></DT
  40962. ><DT
  40963. >XXXV. <A
  40964. HREF="#ref.ftp"
  40965. >FTP-Funktionen</A
  40966. ></DT
  40967. ><DT
  40968. >XXXVI. <A
  40969. HREF="#ref.funchand"
  40970. >Function Handling functions</A
  40971. ></DT
  40972. ><DT
  40973. >XXXVII. <A
  40974. HREF="#ref.gettext"
  40975. >GNU Gettext</A
  40976. ></DT
  40977. ><DT
  40978. >XXXVIII. <A
  40979. HREF="#ref.gmp"
  40980. >GMP Functions</A
  40981. ></DT
  40982. ><DT
  40983. >XXXIX. <A
  40984. HREF="#ref.http"
  40985. >HTTP functions</A
  40986. ></DT
  40987. ><DT
  40988. >XL. <A
  40989. HREF="#ref.hw"
  40990. >Hyperwave Functions</A
  40991. ></DT
  40992. ><DT
  40993. >XLI. <A
  40994. HREF="#ref.hwapi"
  40995. >Hyperwave API Functions</A
  40996. ></DT
  40997. ><DT
  40998. >XLII. <A
  40999. HREF="#ref.iconv"
  41000. >iconv Funktionen</A
  41001. ></DT
  41002. ><DT
  41003. >XLIII. <A
  41004. HREF="#ref.image"
  41005. >Grafik-Funktionen</A
  41006. ></DT
  41007. ><DT
  41008. >XLIV. <A
  41009. HREF="#ref.imap"
  41010. >IMAP, POP3 und NNTP Funktionen</A
  41011. ></DT
  41012. ><DT
  41013. >XLV. <A
  41014. HREF="#ref.ifx"
  41015. >Informix Funktionen</A
  41016. ></DT
  41017. ><DT
  41018. >XLVI. <A
  41019. HREF="#ref.ibase"
  41020. >InterBase-Funktionen</A
  41021. ></DT
  41022. ><DT
  41023. >XLVII. <A
  41024. HREF="#ref.id3"
  41025. >ID3 Functions</A
  41026. ></DT
  41027. ><DT
  41028. >XLVIII. <A
  41029. HREF="#ref.ingres"
  41030. >Ingres II Funktionen</A
  41031. ></DT
  41032. ><DT
  41033. >XLIX. <A
  41034. HREF="#ref.ircg"
  41035. >IRC Gateway Funktionen</A
  41036. ></DT
  41037. ><DT
  41038. >L. <A
  41039. HREF="#ref.java"
  41040. >Java</A
  41041. ></DT
  41042. ><DT
  41043. >LI. <A
  41044. HREF="#ref.ldap"
  41045. >LDAP Funktionen</A
  41046. ></DT
  41047. ><DT
  41048. >LII. <A
  41049. HREF="#ref.lzf"
  41050. >LZF Functions</A
  41051. ></DT
  41052. ><DT
  41053. >LIII. <A
  41054. HREF="#ref.mail"
  41055. >Mail-Funktionen</A
  41056. ></DT
  41057. ><DT
  41058. >LIV. <A
  41059. HREF="#ref.mailparse"
  41060. >mailparse Functions</A
  41061. ></DT
  41062. ><DT
  41063. >LV. <A
  41064. HREF="#ref.math"
  41065. >Mathematische Funktionen</A
  41066. ></DT
  41067. ><DT
  41068. >LVI. <A
  41069. HREF="#ref.mbstring"
  41070. >Multibyte String Functions</A
  41071. ></DT
  41072. ><DT
  41073. >LVII. <A
  41074. HREF="#ref.mcal"
  41075. >MCAL Funktionen</A
  41076. ></DT
  41077. ><DT
  41078. >LVIII. <A
  41079. HREF="#ref.mcrypt"
  41080. >Mcrypt Encryption Functions</A
  41081. ></DT
  41082. ><DT
  41083. >LIX. <A
  41084. HREF="#ref.mcve"
  41085. >MCVE Payment Functions</A
  41086. ></DT
  41087. ><DT
  41088. >LX. <A
  41089. HREF="#ref.memcache"
  41090. >Memcache Functions</A
  41091. ></DT
  41092. ><DT
  41093. >LXI. <A
  41094. HREF="#ref.mhash"
  41095. >Hash Funktionen</A
  41096. ></DT
  41097. ><DT
  41098. >LXII. <A
  41099. HREF="#ref.mime-magic"
  41100. >Mimetype Functions</A
  41101. ></DT
  41102. ><DT
  41103. >LXIII. <A
  41104. HREF="#ref.mssql"
  41105. >Microsoft SQL Server Funktionen</A
  41106. ></DT
  41107. ><DT
  41108. >LXIV. <A
  41109. HREF="#ref.ming"
  41110. >Ming functions for Flash</A
  41111. ></DT
  41112. ><DT
  41113. >LXV. <A
  41114. HREF="#ref.misc"
  41115. >Sonstige Funktionen</A
  41116. ></DT
  41117. ><DT
  41118. >LXVI. <A
  41119. HREF="#ref.mnogo"
  41120. >mnoGoSearch Funktionen</A
  41121. ></DT
  41122. ><DT
  41123. >LXVII. <A
  41124. HREF="#ref.msql"
  41125. >mSQL Funktionen</A
  41126. ></DT
  41127. ><DT
  41128. >LXVIII. <A
  41129. HREF="#ref.mysql"
  41130. >MySQL Funktionen</A
  41131. ></DT
  41132. ><DT
  41133. >LXIX. <A
  41134. HREF="#ref.mysqli"
  41135. >Verbesserte MySQL Erweiterung</A
  41136. ></DT
  41137. ><DT
  41138. >LXX. <A
  41139. HREF="#ref.msession"
  41140. >Mohawk Software Session Handler Funktionen</A
  41141. ></DT
  41142. ><DT
  41143. >LXXI. <A
  41144. HREF="#ref.muscat"
  41145. >muscat Functions</A
  41146. ></DT
  41147. ><DT
  41148. >LXXII. <A
  41149. HREF="#ref.network"
  41150. >Netzwerk Funktionen</A
  41151. ></DT
  41152. ><DT
  41153. >LXXIII. <A
  41154. HREF="#ref.ncurses"
  41155. >Ncurses Terminal Screen Control Functions</A
  41156. ></DT
  41157. ><DT
  41158. >LXXIV. <A
  41159. HREF="#ref.notes"
  41160. >Lotus Notes Functions</A
  41161. ></DT
  41162. ><DT
  41163. >LXXV. <A
  41164. HREF="#ref.nsapi"
  41165. >NSAPI-specific Functions</A
  41166. ></DT
  41167. ><DT
  41168. >LXXVI. <A
  41169. HREF="#ref.odbc"
  41170. >ODBC Funktionen</A
  41171. ></DT
  41172. ><DT
  41173. >LXXVII. <A
  41174. HREF="#ref.objaggregation"
  41175. >Object Aggregation/Composition Functions</A
  41176. ></DT
  41177. ><DT
  41178. >LXXVIII. <A
  41179. HREF="#ref.oci8"
  41180. >Oracle 8 Funktionen</A
  41181. ></DT
  41182. ><DT
  41183. >LXXIX. <A
  41184. HREF="#ref.openssl"
  41185. >OpenSSL Funktionen</A
  41186. ></DT
  41187. ><DT
  41188. >LXXX. <A
  41189. HREF="#ref.oracle"
  41190. >Oracle Funktionen</A
  41191. ></DT
  41192. ><DT
  41193. >LXXXI. <A
  41194. HREF="#ref.ovrimos"
  41195. >Ovrimos SQL Functions</A
  41196. ></DT
  41197. ><DT
  41198. >LXXXII. <A
  41199. HREF="#ref.outcontrol"
  41200. >Funktionen zur Ausgabesteuerung</A
  41201. ></DT
  41202. ><DT
  41203. >LXXXIII. <A
  41204. HREF="#ref.overload"
  41205. >Object property and method call overloading</A
  41206. ></DT
  41207. ><DT
  41208. >LXXXIV. <A
  41209. HREF="#ref.pdf"
  41210. >PDF Funktionen</A
  41211. ></DT
  41212. ><DT
  41213. >LXXXV. <A
  41214. HREF="#ref.pfpro"
  41215. >Verisign Payflow Pro Funktionen</A
  41216. ></DT
  41217. ><DT
  41218. >LXXXVI. <A
  41219. HREF="#ref.info"
  41220. >PHP Optionen & Informationen</A
  41221. ></DT
  41222. ><DT
  41223. >LXXXVII. <A
  41224. HREF="#ref.posix"
  41225. >POSIX Funktionen</A
  41226. ></DT
  41227. ><DT
  41228. >LXXXVIII. <A
  41229. HREF="#ref.pgsql"
  41230. >PostgreSQL Funktionen</A
  41231. ></DT
  41232. ><DT
  41233. >LXXXIX. <A
  41234. HREF="#ref.pcntl"
  41235. >Process Control Functions</A
  41236. ></DT
  41237. ><DT
  41238. >XC. <A
  41239. HREF="#ref.exec"
  41240. >Funktionen zur Programmausfⁿhrung</A
  41241. ></DT
  41242. ><DT
  41243. >XCI. <A
  41244. HREF="#ref.printer"
  41245. >Printer Functions</A
  41246. ></DT
  41247. ><DT
  41248. >XCII. <A
  41249. HREF="#ref.pspell"
  41250. >Pspell Funktionen</A
  41251. ></DT
  41252. ><DT
  41253. >XCIII. <A
  41254. HREF="#ref.readline"
  41255. >GNU Readline</A
  41256. ></DT
  41257. ><DT
  41258. >XCIV. <A
  41259. HREF="#ref.recode"
  41260. >GNU Recode Funktionen</A
  41261. ></DT
  41262. ><DT
  41263. >XCV. <A
  41264. HREF="#ref.pcre"
  41265. >RegulΣre Ausdrⁿcke Funktionen (Perl-kompatibel)</A
  41266. ></DT
  41267. ><DT
  41268. >XCVI. <A
  41269. HREF="#ref.qtdom"
  41270. >qtdom Functions</A
  41271. ></DT
  41272. ><DT
  41273. >XCVII. <A
  41274. HREF="#ref.regex"
  41275. >RegulΣre Ausdrⁿcke Funktionen (POSIX erweitert)</A
  41276. ></DT
  41277. ><DT
  41278. >XCVIII. <A
  41279. HREF="#ref.sem"
  41280. >Semaphor und Shared Memory Funktionen</A
  41281. ></DT
  41282. ><DT
  41283. >XCIX. <A
  41284. HREF="#ref.sesam"
  41285. >SESAM Datenbankfunktionen</A
  41286. ></DT
  41287. ><DT
  41288. >C. <A
  41289. HREF="#ref.session"
  41290. >Session Funktionen</A
  41291. ></DT
  41292. ><DT
  41293. >CI. <A
  41294. HREF="#ref.shmop"
  41295. >Shared Memory Funktionen (Gemeinsamer Speicher)</A
  41296. ></DT
  41297. ><DT
  41298. >CII. <A
  41299. HREF="#ref.simplexml"
  41300. >SimpleXML functions</A
  41301. ></DT
  41302. ><DT
  41303. >CIII. <A
  41304. HREF="#ref.soap"
  41305. >SOAP Functions</A
  41306. ></DT
  41307. ><DT
  41308. >CIV. <A
  41309. HREF="#ref.sqlite"
  41310. >SQLite</A
  41311. ></DT
  41312. ><DT
  41313. >CV. <A
  41314. HREF="#ref.swf"
  41315. >Shockwave Flash Funktionen</A
  41316. ></DT
  41317. ><DT
  41318. >CVI. <A
  41319. HREF="#ref.snmp"
  41320. >SNMP Funktionen</A
  41321. ></DT
  41322. ><DT
  41323. >CVII. <A
  41324. HREF="#ref.sockets"
  41325. >Socket Funktionen</A
  41326. ></DT
  41327. ><DT
  41328. >CVIII. <A
  41329. HREF="#ref.spl"
  41330. >Standard PHP Library (SPL) Functions</A
  41331. ></DT
  41332. ><DT
  41333. >CIX. <A
  41334. HREF="#ref.stream"
  41335. >Stream Functions</A
  41336. ></DT
  41337. ><DT
  41338. >CX. <A
  41339. HREF="#ref.strings"
  41340. >String-Funktionen</A
  41341. ></DT
  41342. ><DT
  41343. >CXI. <A
  41344. HREF="#ref.sybase"
  41345. >Sybase Funktionen</A
  41346. ></DT
  41347. ><DT
  41348. >CXII. <A
  41349. HREF="#ref.tcpwrap"
  41350. >TCP Wrappers Functions</A
  41351. ></DT
  41352. ><DT
  41353. >CXIII. <A
  41354. HREF="#ref.tidy"
  41355. >Tidy Functions</A
  41356. ></DT
  41357. ><DT
  41358. >CXIV. <A
  41359. HREF="#ref.tokenizer"
  41360. >Tokenizer Functions</A
  41361. ></DT
  41362. ><DT
  41363. >CXV. <A
  41364. HREF="#ref.url"
  41365. >URL Funktionen</A
  41366. ></DT
  41367. ><DT
  41368. >CXVI. <A
  41369. HREF="#ref.variables"
  41370. >Variablen-Funktionen</A
  41371. ></DT
  41372. ><DT
  41373. >CXVII. <A
  41374. HREF="#ref.vpopmail"
  41375. >vpopmail Functions</A
  41376. ></DT
  41377. ><DT
  41378. >CXVIII. <A
  41379. HREF="#ref.w32api"
  41380. >W32api Functions</A
  41381. ></DT
  41382. ><DT
  41383. >CXIX. <A
  41384. HREF="#ref.wddx"
  41385. >WDDX Funktionen</A
  41386. ></DT
  41387. ><DT
  41388. >CXX. <A
  41389. HREF="#ref.xml"
  41390. >XML Parser Functions</A
  41391. ></DT
  41392. ><DT
  41393. >CXXI. <A
  41394. HREF="#ref.xmlrpc"
  41395. >XML-RPC Functions</A
  41396. ></DT
  41397. ><DT
  41398. >CXXII. <A
  41399. HREF="#ref.xdiff"
  41400. >xdiff Functions</A
  41401. ></DT
  41402. ><DT
  41403. >CXXIII. <A
  41404. HREF="#ref.xsl"
  41405. >XSL functions</A
  41406. ></DT
  41407. ><DT
  41408. >CXXIV. <A
  41409. HREF="#ref.xslt"
  41410. >XSLT Funktionen</A
  41411. ></DT
  41412. ><DT
  41413. >CXXV. <A
  41414. HREF="#ref.yaz"
  41415. >YAZ Functions</A
  41416. ></DT
  41417. ><DT
  41418. >CXXVI. <A
  41419. HREF="#ref.nis"
  41420. >YP/NIS Funktionen</A
  41421. ></DT
  41422. ><DT
  41423. >CXXVII. <A
  41424. HREF="#ref.zip"
  41425. >ZIP Funktionen (Lesezugriff)</A
  41426. ></DT
  41427. ><DT
  41428. >CXXVIII. <A
  41429. HREF="#ref.zlib"
  41430. >Zlib Komprimierungsfunktionen</A
  41431. ></DT
  41432. ></DL
  41433. ></DIV
  41434. ></DIV
  41435. ><DIV
  41436. CLASS="reference"
  41437. ><A
  41438. NAME="ref.apache"
  41439. ></A
  41440. ><DIV
  41441. CLASS="TITLEPAGE"
  41442. ><H1
  41443. CLASS="title"
  41444. >I. Apache-spezifische Funktionen</H1
  41445. ><DIV
  41446. CLASS="PARTINTRO"
  41447. ><A
  41448. NAME="AEN6918"
  41449. ></A
  41450. ><DIV
  41451. CLASS="section"
  41452. ><H2
  41453. CLASS="section"
  41454. ><A
  41455. NAME="apache.intro"
  41456. >Einfⁿhrung</A
  41457. ></H2
  41458. ><P
  41459. >      Diese Funktionen stehen nur zur Verfⁿgung, wenn PHP als Apache Modul
  41460.      lΣuft.
  41461.     </P
  41462. ><DIV
  41463. CLASS="note"
  41464. ><BLOCKQUOTE
  41465. CLASS="note"
  41466. ><P
  41467. ><B
  41468. >Anmerkung: </B
  41469. >
  41470.       Die Servervariable PATH_TRANSLATED wird bei Verwendung des Apache 2 SAPI
  41471.       nicht mehr lΣnger implizit gesetzt. Im Gegensatz hierzu wird bei
  41472.       Verwendung des Apache 1 SAPI PATH_TRANSLATED, falls von Apache nicht zur
  41473.       Verfⁿgung gestellt, auf den gleichen Wert wie die Servervariable
  41474.       SCRIPT_FILENAME gesetzt. Die VerΣnderung unter Apache 2 wurde
  41475.       vorgenommen um der <A
  41476. HREF="http://hoohoo.ncsa.uiuc.edu/cgi/"
  41477. TARGET="_top"
  41478. >CGI Spezification</A
  41479. >
  41480.       zu entsprechen. Fⁿr weitere Informationen shauen Sie bitte unter
  41481.       <A
  41482. HREF="http://bugs.php.net/23610"
  41483. TARGET="_top"
  41484. >bug #23610</A
  41485. > nach.
  41486.      </P
  41487. ></BLOCKQUOTE
  41488. ></DIV
  41489. ></DIV
  41490. ><DIV
  41491. CLASS="section"
  41492. ><HR><H2
  41493. CLASS="section"
  41494. ><A
  41495. NAME="apache.installation"
  41496. >Installation</A
  41497. ></H2
  41498. ><P
  41499. >      Informationen zur Installation von PHP unter Apache finden Sie im
  41500.      Kapitel Installation unter dem
  41501.      <A
  41502. HREF="#install.apache"
  41503. >Abschnitt zu Apache</A
  41504. >
  41505.     </P
  41506. ></DIV
  41507. ><DIV
  41508. CLASS="section"
  41509. ><HR><H2
  41510. CLASS="section"
  41511. ><A
  41512. NAME="apache.configuration"
  41513. >Laufzeit Konfiguration</A
  41514. ></H2
  41515. ><P
  41516. >   Das Verhalten des Apache PHP-Moduls wird durch Einstellungen in der
  41517.   <TT
  41518. CLASS="filename"
  41519. >php.ini</TT
  41520. > beeinflusst. Konfigurationseinstellungen aus der <TT
  41521. CLASS="filename"
  41522. >php.ini</TT
  41523. > k÷nnen
  41524.   Sie durch <A
  41525. HREF="#configuration.changes.apache"
  41526. >php_flag</A
  41527. >
  41528.   Einstellungen in der Server Konfigurationsdatei oder lokal in <TT
  41529. CLASS="filename"
  41530. >.htaccess</TT
  41531. >
  41532.   Dateien ⁿberschreiben.
  41533.  </P
  41534. ><TABLE
  41535. WIDTH="100%"
  41536. BORDER="0"
  41537. CELLPADDING="0"
  41538. CELLSPACING="0"
  41539. CLASS="EXAMPLE"
  41540. ><TR
  41541. ><TD
  41542. ><DIV
  41543. CLASS="example"
  41544. ><A
  41545. NAME="AEN6937"
  41546. ></A
  41547. ><P
  41548. ><B
  41549. >Beispiel 1. Parsen von PHP fⁿr ein Verzeichnis ausschalten mittels <TT
  41550. CLASS="filename"
  41551. >.htaccess</TT
  41552. ></B
  41553. ></P
  41554. ><TABLE
  41555. BORDER="0"
  41556. BGCOLOR="#E0E0E0"
  41557. CELLPADDING="5"
  41558. ><TR
  41559. ><TD
  41560. ><PRE
  41561. CLASS="programlisting"
  41562. >php_flag engine off</PRE
  41563. ></TD
  41564. ></TR
  41565. ></TABLE
  41566. ></DIV
  41567. ></TD
  41568. ></TR
  41569. ></TABLE
  41570. ><P
  41571. >   <DIV
  41572. CLASS="table"
  41573. ><A
  41574. NAME="AEN6942"
  41575. ></A
  41576. ><P
  41577. ><B
  41578. >Tabelle 1. Apache Konfigurations Optionen</B
  41579. ></P
  41580. ><TABLE
  41581. BORDER="1"
  41582. CLASS="CALSTABLE"
  41583. ><COL><COL><COL><COL><THEAD
  41584. ><TR
  41585. ><TH
  41586. >Bezeichnung</TH
  41587. ><TH
  41588. >Grundeinstellung</TH
  41589. ><TH
  41590. >─nderbar</TH
  41591. ><TH
  41592. >Bedeutung</TH
  41593. ></TR
  41594. ></THEAD
  41595. ><TBODY
  41596. ><TR
  41597. ><TD
  41598. >engine</TD
  41599. ><TD
  41600. >On</TD
  41601. ><TD
  41602. >PHP_INI_ALL</TD
  41603. ><TD
  41604. >Parsen von PHP ein/-auschalten</TD
  41605. ></TR
  41606. ><TR
  41607. ><TD
  41608. >child_terminate</TD
  41609. ><TD
  41610. >Off</TD
  41611. ><TD
  41612. >PHP_INI_ALL</TD
  41613. ><TD
  41614. >        Gibt an, ob PHP Skripte veranlassen, dass Kindprozesse nach dem Request
  41615.        beendet werden, siehe auch <A
  41616. HREF="#function.apache-child-terminate"
  41617. ><B
  41618. CLASS="function"
  41619. >apache_child_terminate()</B
  41620. ></A
  41621. >.
  41622.       </TD
  41623. ></TR
  41624. ><TR
  41625. ><TD
  41626. >last_modified</TD
  41627. ><TD
  41628. >Off</TD
  41629. ><TD
  41630. >PHP_INI_ALL</TD
  41631. ><TD
  41632. >        Das letzte Datum der ─nderung des PHP Skripts wird als
  41633.        Last-Modified: header fⁿr diesen Request gesendet.
  41634.       </TD
  41635. ></TR
  41636. ><TR
  41637. ><TD
  41638. >xbithack</TD
  41639. ><TD
  41640. >Off</TD
  41641. ><TD
  41642. >PHP_INI_ALL</TD
  41643. ><TD
  41644. >        Dateien mit gesetztem ausfⁿhrbaren Bit werden unabhΣngig
  41645.        von ihrer Dateiendung durch PHP geparst.
  41646.       </TD
  41647. ></TR
  41648. ></TBODY
  41649. ></TABLE
  41650. ></DIV
  41651. >
  41652.  </P
  41653. ><P
  41654. >Hier eine kurze ErklΣrung der
  41655. Konfigurationsoptionen:</P
  41656. ><P
  41657. >  <P
  41658. ></P
  41659. ><DIV
  41660. CLASS="variablelist"
  41661. ><DL
  41662. ><DT
  41663. ><A
  41664. NAME="ini.engine"
  41665. ></A
  41666. ><VAR
  41667. CLASS="parameter"
  41668. >engine</VAR
  41669. >
  41670.    <A
  41671. HREF="#language.types.boolean"
  41672. ><B
  41673. CLASS="type"
  41674. >boolean</B
  41675. ></A
  41676. ></DT
  41677. ><DD
  41678. ><P
  41679. >      Diese Option ist in erster Linie nur sinnvoll, wenn PHP als
  41680.      Modul in den Apache einkompiliert wurde. Sie wird von Seiten benutzt,
  41681.      die den PHP-Parser fⁿr bestimmte Verzeichnisse oder virtuelle
  41682.      Server aus- bzw. einschalten wollen. Wenn Sie
  41683.      <KBD
  41684. CLASS="userinput"
  41685. >engine off</KBD
  41686. > in den dafⁿr vorgesehenen
  41687.      Bl÷cken in der <TT
  41688. CLASS="filename"
  41689. >httpd.conf</TT
  41690. > Datei benutzen, kann
  41691.      PHP aktiviert bzw. deaktiviert werden.
  41692.     </P
  41693. ></DD
  41694. ></DL
  41695. ></DIV
  41696. >
  41697.  </P
  41698. ></DIV
  41699. ><DIV
  41700. CLASS="section"
  41701. ><HR><H2
  41702. CLASS="section"
  41703. ><A
  41704. NAME="apache.resources"
  41705. >Resource Typen</A
  41706. ></H2
  41707. ><P
  41708. >Diese Erweiterung definiert keine Resource-Typen.</P
  41709. ></DIV
  41710. ><DIV
  41711. CLASS="section"
  41712. ><HR><H2
  41713. CLASS="section"
  41714. ><A
  41715. NAME="apache.constants"
  41716. >Vordefinierte Konstanten</A
  41717. ></H2
  41718. ><P
  41719. >Diese Erweiterung definiert keine Konstanten.</P
  41720. ></DIV
  41721. ></DIV
  41722. ><DIV
  41723. CLASS="TOC"
  41724. ><DL
  41725. ><DT
  41726. ><B
  41727. >Inhaltsverzeichnis</B
  41728. ></DT
  41729. ><DT
  41730. ><A
  41731. HREF="#function.apache-child-terminate"
  41732. >apache_child_terminate</A
  41733. > -- Beendet einen Apache Prozess nach der Anfrage</DT
  41734. ><DT
  41735. ><A
  41736. HREF="#function.apache-get-modules"
  41737. >apache_get_modules</A
  41738. > -- 
  41739.      Liste der geladenen Apachemodule
  41740.     </DT
  41741. ><DT
  41742. ><A
  41743. HREF="#function.apache-get-version"
  41744. >apache_get_version</A
  41745. > -- 
  41746.      Liefert die Version von Apache
  41747.     </DT
  41748. ><DT
  41749. ><A
  41750. HREF="#function.apache-getenv"
  41751. >apache_getenv</A
  41752. > -- 
  41753.      Get an Apache subprocess_env variable
  41754.     </DT
  41755. ><DT
  41756. ><A
  41757. HREF="#function.apache-lookup-uri"
  41758. >apache_lookup_uri</A
  41759. > -- 
  41760.      Fⁿhrt eine Teilanfrage fⁿr eine URI durch und liefert alle
  41761.      Informationen darⁿber zurⁿck.
  41762.     </DT
  41763. ><DT
  41764. ><A
  41765. HREF="#function.apache-note"
  41766. >apache_note</A
  41767. > -- Setzt und liest Apache Notes</DT
  41768. ><DT
  41769. ><A
  41770. HREF="#function.apache-request-headers"
  41771. >apache_request_headers</A
  41772. > -- Liefert alle HTTP-Header der aktuellen Anfrage</DT
  41773. ><DT
  41774. ><A
  41775. HREF="#function.apache-response-headers"
  41776. >apache_response_headers</A
  41777. > -- 
  41778.      Liefert alle HTTP-Antwort Header
  41779.     </DT
  41780. ><DT
  41781. ><A
  41782. HREF="#function.apache-setenv"
  41783. >apache_setenv</A
  41784. > -- Setzt eine Apache subprocess_env Variable</DT
  41785. ><DT
  41786. ><A
  41787. HREF="#function.ascii2ebcdic"
  41788. >ascii2ebcdic</A
  41789. > -- Zeichenkette von ASCII in EBCDIC ⁿbersetzen</DT
  41790. ><DT
  41791. ><A
  41792. HREF="#function.ebcdic2ascii"
  41793. >ebcdic2ascii</A
  41794. > -- Zeichenkette von EBCDIC in ASCII ⁿbersetzen</DT
  41795. ><DT
  41796. ><A
  41797. HREF="#function.getallheaders"
  41798. >getallheaders</A
  41799. > -- 
  41800.      Liefert alle HTTP-Header der aktuellen Anfrage aus
  41801.     </DT
  41802. ><DT
  41803. ><A
  41804. HREF="#function.virtual"
  41805. >virtual</A
  41806. > -- Fⁿhrt eine Apache-Unteranfrage durch</DT
  41807. ></DL
  41808. ></DIV
  41809. ></DIV
  41810. ><H1
  41811. ><A
  41812. NAME="function.apache-child-terminate"
  41813. ></A
  41814. >apache_child_terminate</H1
  41815. ><DIV
  41816. CLASS="refnamediv"
  41817. ><A
  41818. NAME="AEN6991"
  41819. ></A
  41820. ><P
  41821. >    (PHP 4 >= 4.0.5, PHP 5)</P
  41822. >apache_child_terminate -- Beendet einen Apache Prozess nach der Anfrage</DIV
  41823. ><DIV
  41824. CLASS="refsect1"
  41825. ><A
  41826. NAME="AEN6994"
  41827. ></A
  41828. ><H2
  41829. >Beschreibung</H2
  41830. >bool <B
  41831. CLASS="methodname"
  41832. >apache_child_terminate</B
  41833. > ( void )<BR
  41834. ></BR
  41835. ><P
  41836. >      <B
  41837. CLASS="function"
  41838. >apache_child_terminate()</B
  41839. > beendet den Apache Prozess,
  41840.      der die aktuelle PHP-Anfrage ausfⁿhrt, nachdem diese vollstΣndig
  41841.      ausgefⁿhrt wurde. Sie k÷nnen diese Funktion benutzen, nachdem Sie ein
  41842.      Skript mit hohem Speicherverbrauch ausgefⁿhrt haben. Der verbrauchte
  41843.      Speicher wird gew÷hnlich nur intern, aber nicht fⁿr das Betriebsystem,
  41844.      freigegeben.
  41845.     </P
  41846. ><DIV
  41847. CLASS="note"
  41848. ><BLOCKQUOTE
  41849. CLASS="note"
  41850. ><P
  41851. ><B
  41852. >Anmerkung: </B
  41853. >
  41854.       Die Verfⁿgbarkeit dieses Features wird durch die Anweisung
  41855.       <VAR
  41856. CLASS="option"
  41857. >child_terminate</VAR
  41858. > in der <TT
  41859. CLASS="filename"
  41860. >php.ini</TT
  41861. > beeinflusst.
  41862.       Die Standardeinstellung ist <VAR
  41863. CLASS="literal"
  41864. >off</VAR
  41865. >.
  41866.      </P
  41867. ><P
  41868. >       Dieses Feature steht bei multithreaded Versionen von Apache, wie der win32
  41869.       Version, nicht zur Verfⁿgung.
  41870.      </P
  41871. ></BLOCKQUOTE
  41872. ></DIV
  41873. ><P
  41874. >      Siehe auch <A
  41875. HREF="#function.exit"
  41876. ><B
  41877. CLASS="function"
  41878. >exit()</B
  41879. ></A
  41880. >.
  41881.     </P
  41882. ></DIV
  41883. ><H1
  41884. ><A
  41885. NAME="function.apache-get-modules"
  41886. ></A
  41887. >apache_get_modules</H1
  41888. ><DIV
  41889. CLASS="refnamediv"
  41890. ><A
  41891. NAME="AEN7011"
  41892. ></A
  41893. ><P
  41894. >    (PHP 4 >= 4.3.2, PHP 5)</P
  41895. >apache_get_modules -- 
  41896.      Liste der geladenen Apachemodule
  41897.     </DIV
  41898. ><DIV
  41899. CLASS="refsect1"
  41900. ><A
  41901. NAME="AEN7014"
  41902. ></A
  41903. ><H2
  41904. >Beschreibung</H2
  41905. >array <B
  41906. CLASS="methodname"
  41907. >apache_get_modules</B
  41908. > ( void )<BR
  41909. ></BR
  41910. ><P
  41911. >      Diese Funktion liefert Ihnen ein Array mit allen geladenen Apachemodulen.
  41912.     </P
  41913. ><P
  41914. >      <TABLE
  41915. WIDTH="100%"
  41916. BORDER="0"
  41917. CELLPADDING="0"
  41918. CELLSPACING="0"
  41919. CLASS="EXAMPLE"
  41920. ><TR
  41921. ><TD
  41922. ><DIV
  41923. CLASS="example"
  41924. ><A
  41925. NAME="AEN7022"
  41926. ></A
  41927. ><P
  41928. ><B
  41929. >Beispiel 1. <B
  41930. CLASS="function"
  41931. >apache_get_modules()</B
  41932. > Beispiel</B
  41933. ></P
  41934. ><TABLE
  41935. BORDER="0"
  41936. BGCOLOR="#E0E0E0"
  41937. CELLPADDING="5"
  41938. ><TR
  41939. ><TD
  41940. ><PRE
  41941. CLASS="php"
  41942. ><?php
  41943. print_r(apache_get_modules());
  41944. ?></PRE
  41945. ></TD
  41946. ></TR
  41947. ></TABLE
  41948. ><P
  41949. >        Die Ausgabe des obigen Programms sieht ├ñhnlich wie folgt aus:
  41950.       </P
  41951. ><TABLE
  41952. BORDER="0"
  41953. BGCOLOR="#E0E0E0"
  41954. CELLPADDING="5"
  41955. ><TR
  41956. ><TD
  41957. ><PRE
  41958. CLASS="screen"
  41959. >Array
  41960. (
  41961.     [0] => core
  41962.     [1] => http_core
  41963.     [2] => mod_so
  41964.     [3] => sapi_apache2
  41965.     [4] => mod_mime
  41966.     [5] => mod_rewrite
  41967. )</PRE
  41968. ></TD
  41969. ></TR
  41970. ></TABLE
  41971. ></DIV
  41972. ></TD
  41973. ></TR
  41974. ></TABLE
  41975. >
  41976.     </P
  41977. ></DIV
  41978. ><H1
  41979. ><A
  41980. NAME="function.apache-get-version"
  41981. ></A
  41982. >apache_get_version</H1
  41983. ><DIV
  41984. CLASS="refnamediv"
  41985. ><A
  41986. NAME="AEN7029"
  41987. ></A
  41988. ><P
  41989. >    (PHP 4 >= 4.3.2, PHP 5)</P
  41990. >apache_get_version -- 
  41991.      Liefert die Version von Apache
  41992.     </DIV
  41993. ><DIV
  41994. CLASS="refsect1"
  41995. ><A
  41996. NAME="AEN7032"
  41997. ></A
  41998. ><H2
  41999. >Beschreibung</H2
  42000. >string <B
  42001. CLASS="methodname"
  42002. >apache_get_version</B
  42003. > ( void )<BR
  42004. ></BR
  42005. ><P
  42006. >      <B
  42007. CLASS="function"
  42008. >apache_get_version()</B
  42009. > gibt die Apache-Version als
  42010.      Zeichenkette zurⁿck, oder <TT
  42011. CLASS="constant"
  42012. ><B
  42013. >FALSE</B
  42014. ></TT
  42015. > bei einem Fehler.
  42016.     </P
  42017. ><TABLE
  42018. WIDTH="100%"
  42019. BORDER="0"
  42020. CELLPADDING="0"
  42021. CELLSPACING="0"
  42022. CLASS="EXAMPLE"
  42023. ><TR
  42024. ><TD
  42025. ><DIV
  42026. CLASS="example"
  42027. ><A
  42028. NAME="AEN7041"
  42029. ></A
  42030. ><P
  42031. ><B
  42032. >Beispiel 1. <B
  42033. CLASS="function"
  42034. >apache_get_version()</B
  42035. > Beispiel</B
  42036. ></P
  42037. ><TABLE
  42038. BORDER="0"
  42039. BGCOLOR="#E0E0E0"
  42040. CELLPADDING="5"
  42041. ><TR
  42042. ><TD
  42043. ><PRE
  42044. CLASS="php"
  42045. ><?php
  42046. $version = apache_get_version();
  42047. echo "$version\n";
  42048. ?></PRE
  42049. ></TD
  42050. ></TR
  42051. ></TABLE
  42052. ><P
  42053. >       Die Ausgabe des obigen Programms sieht Σhnlich wie folgt aus:
  42054.      </P
  42055. ><TABLE
  42056. BORDER="0"
  42057. BGCOLOR="#E0E0E0"
  42058. CELLPADDING="5"
  42059. ><TR
  42060. ><TD
  42061. ><PRE
  42062. CLASS="screen"
  42063. >Apache/1.3.29 (Unix) PHP/4.3.4</PRE
  42064. ></TD
  42065. ></TR
  42066. ></TABLE
  42067. ></DIV
  42068. ></TD
  42069. ></TR
  42070. ></TABLE
  42071. ><P
  42072. >      Siehe auch <A
  42073. HREF="#function.phpinfo"
  42074. ><B
  42075. CLASS="function"
  42076. >phpinfo()</B
  42077. ></A
  42078. >.
  42079.     </P
  42080. ></DIV
  42081. ><H1
  42082. ><A
  42083. NAME="function.apache-getenv"
  42084. ></A
  42085. >apache_getenv</H1
  42086. ><DIV
  42087. CLASS="refnamediv"
  42088. ><A
  42089. NAME="AEN7050"
  42090. ></A
  42091. ><P
  42092. >    (PHP 4 >= 4.3.0, PHP 5)</P
  42093. >apache_getenv -- 
  42094.      Get an Apache subprocess_env variable
  42095.     </DIV
  42096. ><DIV
  42097. CLASS="refsect1"
  42098. ><A
  42099. NAME="AEN7053"
  42100. ></A
  42101. ><H2
  42102. >Description</H2
  42103. >string <B
  42104. CLASS="methodname"
  42105. >apache_getenv</B
  42106. > ( string variable [, bool walk_to_top])<BR
  42107. ></BR
  42108. ><DIV
  42109. CLASS="warning"
  42110. ><P
  42111. ></P
  42112. ><TABLE
  42113. CLASS="warning"
  42114. BORDER="1"
  42115. WIDTH="100%"
  42116. ><TR
  42117. ><TD
  42118. ALIGN="CENTER"
  42119. ><B
  42120. >Warnung</B
  42121. ></TD
  42122. ></TR
  42123. ><TR
  42124. ><TD
  42125. ALIGN="LEFT"
  42126. ><P
  42127. >Diese Funktion ist bis jetzt
  42128. nicht dokumentiert. Es steht nur die Liste der Argumente zur Verfⁿgung.
  42129. </P
  42130. ></TD
  42131. ></TR
  42132. ></TABLE
  42133. ></DIV
  42134. ></DIV
  42135. ><H1
  42136. ><A
  42137. NAME="function.apache-lookup-uri"
  42138. ></A
  42139. >apache_lookup_uri</H1
  42140. ><DIV
  42141. CLASS="refnamediv"
  42142. ><A
  42143. NAME="AEN7067"
  42144. ></A
  42145. ><P
  42146. >    (PHP 3>= 3.0.4, PHP 4 , PHP 5)</P
  42147. >apache_lookup_uri -- 
  42148.      Fⁿhrt eine Teilanfrage fⁿr eine URI durch und liefert alle
  42149.      Informationen darⁿber zurⁿck.
  42150.     </DIV
  42151. ><DIV
  42152. CLASS="refsect1"
  42153. ><A
  42154. NAME="AEN7070"
  42155. ></A
  42156. ><H2
  42157. >Beschreibung</H2
  42158. >object <B
  42159. CLASS="methodname"
  42160. >apache_lookup_uri</B
  42161. > ( string Dateiname)<BR
  42162. ></BR
  42163. ><P
  42164. >      <B
  42165. CLASS="function"
  42166. >apache_lookup_uri()</B
  42167. > fⁿhrt eine Teilanfrage
  42168.      ⁿber eine bestimmte URI durch. Die Abfrage geht gerade soweit,
  42169.      dass alle wichtigen Informationen ⁿber die gegebene Quelle
  42170.      gesammelt werden k÷nnen. Als Resultat wird eine Klasse
  42171.      zurⁿckgeliefert, die folgende Elemente enthΣlt:
  42172.      <P
  42173. ></P
  42174. ><TABLE
  42175. BORDER="0"
  42176. ><TBODY
  42177. ><TR
  42178. ><TD
  42179. >status</TD
  42180. ></TR
  42181. ><TR
  42182. ><TD
  42183. >the_request</TD
  42184. ></TR
  42185. ><TR
  42186. ><TD
  42187. >status_line</TD
  42188. ></TR
  42189. ><TR
  42190. ><TD
  42191. >method</TD
  42192. ></TR
  42193. ><TR
  42194. ><TD
  42195. >content_type</TD
  42196. ></TR
  42197. ><TR
  42198. ><TD
  42199. >handler</TD
  42200. ></TR
  42201. ><TR
  42202. ><TD
  42203. >uri</TD
  42204. ></TR
  42205. ><TR
  42206. ><TD
  42207. >filename</TD
  42208. ></TR
  42209. ><TR
  42210. ><TD
  42211. >path_info</TD
  42212. ></TR
  42213. ><TR
  42214. ><TD
  42215. >args</TD
  42216. ></TR
  42217. ><TR
  42218. ><TD
  42219. >boundary</TD
  42220. ></TR
  42221. ><TR
  42222. ><TD
  42223. >no_cache</TD
  42224. ></TR
  42225. ><TR
  42226. ><TD
  42227. >no_local_copy</TD
  42228. ></TR
  42229. ><TR
  42230. ><TD
  42231. >allowed</TD
  42232. ></TR
  42233. ><TR
  42234. ><TD
  42235. >send_bodyct</TD
  42236. ></TR
  42237. ><TR
  42238. ><TD
  42239. >bytes_sent</TD
  42240. ></TR
  42241. ><TR
  42242. ><TD
  42243. >byterange</TD
  42244. ></TR
  42245. ><TR
  42246. ><TD
  42247. >clength</TD
  42248. ></TR
  42249. ><TR
  42250. ><TD
  42251. >unparsed_uri</TD
  42252. ></TR
  42253. ><TR
  42254. ><TD
  42255. >mtime</TD
  42256. ></TR
  42257. ><TR
  42258. ><TD
  42259. >request_time</TD
  42260. ></TR
  42261. ></TBODY
  42262. ></TABLE
  42263. ><P
  42264. ></P
  42265. >
  42266.     </P
  42267. ><P
  42268. >      <TABLE
  42269. WIDTH="100%"
  42270. BORDER="0"
  42271. CELLPADDING="0"
  42272. CELLSPACING="0"
  42273. CLASS="EXAMPLE"
  42274. ><TR
  42275. ><TD
  42276. ><DIV
  42277. CLASS="example"
  42278. ><A
  42279. NAME="AEN7103"
  42280. ></A
  42281. ><P
  42282. ><B
  42283. >Beispiel 1. <B
  42284. CLASS="function"
  42285. >apache_lookup_uri()</B
  42286. > Beispiel</B
  42287. ></P
  42288. ><TABLE
  42289. BORDER="0"
  42290. BGCOLOR="#E0E0E0"
  42291. CELLPADDING="5"
  42292. ><TR
  42293. ><TD
  42294. ><PRE
  42295. CLASS="php"
  42296. ><?php
  42297. $info = apache_lookup_uri('index.php?var=value');
  42298. print_r($info);
  42299.  
  42300. if (file_exists($info->filename)) {
  42301.     echo 'file exists!';
  42302. }
  42303. ?></PRE
  42304. ></TD
  42305. ></TR
  42306. ></TABLE
  42307. ><P
  42308. >        Die Ausgabe des obigen Beispiel sieht so Σhnlich aus wie folgt:
  42309.       </P
  42310. ><TABLE
  42311. BORDER="0"
  42312. BGCOLOR="#E0E0E0"
  42313. CELLPADDING="5"
  42314. ><TR
  42315. ><TD
  42316. ><PRE
  42317. CLASS="screen"
  42318. >stdClass Object
  42319. (
  42320.     [status] => 200
  42321.     [the_request] => GET /dir/file.php HTTP/1.1
  42322.     [method] => GET
  42323.     [mtime] => 0
  42324.     [clength] => 0
  42325.     [chunked] => 0
  42326.     [content_type] => application/x-httpd-php
  42327.     [no_cache] => 0
  42328.     [no_local_copy] => 1
  42329.     [unparsed_uri] => /dir/index.php?var=value
  42330.     [uri] => /dir/index.php
  42331.     [filename] => /home/htdocs/dir/index.php
  42332.     [args] => var=value
  42333.     [allowed] => 0
  42334.     [sent_bodyct] => 0
  42335.     [bytes_sent] => 0
  42336.     [request_time] => 1074282764
  42337. )
  42338. file exists!</PRE
  42339. ></TD
  42340. ></TR
  42341. ></TABLE
  42342. ></DIV
  42343. ></TD
  42344. ></TR
  42345. ></TABLE
  42346. >
  42347.     </P
  42348. ><DIV
  42349. CLASS="note"
  42350. ><BLOCKQUOTE
  42351. CLASS="note"
  42352. ><P
  42353. ><B
  42354. >Anmerkung: </B
  42355. >
  42356.       <B
  42357. CLASS="function"
  42358. >apache_lookup_uri()</B
  42359. > funktioniert nur, wenn PHP
  42360.       als Apache-Modul eingerichtet wurde.
  42361.      </P
  42362. ></BLOCKQUOTE
  42363. ></DIV
  42364. ></DIV
  42365. ><H1
  42366. ><A
  42367. NAME="function.apache-note"
  42368. ></A
  42369. >apache_note</H1
  42370. ><DIV
  42371. CLASS="refnamediv"
  42372. ><A
  42373. NAME="AEN7113"
  42374. ></A
  42375. ><P
  42376. >    (PHP 3>= 3.0.2, PHP 4 , PHP 5)</P
  42377. >apache_note -- Setzt und liest Apache Notes</DIV
  42378. ><DIV
  42379. CLASS="refsect1"
  42380. ><A
  42381. NAME="AEN7116"
  42382. ></A
  42383. ><H2
  42384. >Beschreibung</H2
  42385. >string <B
  42386. CLASS="methodname"
  42387. >apache_note</B
  42388. > ( string note_name [, string note_value])<BR
  42389. ></BR
  42390. ><P
  42391. >      <B
  42392. CLASS="function"
  42393. >apache_note()</B
  42394. > ist eine Apache-spezifische
  42395.      Funktion, die EintrΣge in Apaches
  42396.      <VAR
  42397. CLASS="literal"
  42398. >notes</VAR
  42399. >-Tabelle setzt und ausliest. Wenn sie mit
  42400.      einem einzelnen Parameter aufgerufen wird, gibt sie den aktuellen
  42401.      Wert der Note <VAR
  42402. CLASS="parameter"
  42403. >note_name</VAR
  42404. > zurⁿck. Bei zwei
  42405.      Parametern wird der Eintrag <VAR
  42406. CLASS="parameter"
  42407. >note_name</VAR
  42408. > auf
  42409.      den zweiten Parameter <VAR
  42410. CLASS="parameter"
  42411. >note_value</VAR
  42412. > gesetzt
  42413.      und liefert den bisherigen Wert zurⁿck.
  42414.     </P
  42415. ></DIV
  42416. ><H1
  42417. ><A
  42418. NAME="function.apache-request-headers"
  42419. ></A
  42420. >apache_request_headers</H1
  42421. ><DIV
  42422. CLASS="refnamediv"
  42423. ><A
  42424. NAME="AEN7134"
  42425. ></A
  42426. ><P
  42427. >    (PHP 4 >= 4.3.0, PHP 5)</P
  42428. >apache_request_headers -- Liefert alle HTTP-Header der aktuellen Anfrage</DIV
  42429. ><DIV
  42430. CLASS="refsect1"
  42431. ><A
  42432. NAME="AEN7137"
  42433. ></A
  42434. ><H2
  42435. >Beschreibung</H2
  42436. >array <B
  42437. CLASS="methodname"
  42438. >apache_request_headers</B
  42439. > ( void )<BR
  42440. ></BR
  42441. ><P
  42442. >      Die Funktion <B
  42443. CLASS="function"
  42444. >apache_request_headers()</B
  42445. > liefert ein
  42446.      assoziatives Array zurⁿck, das alle HTTP-Header-Informationen der
  42447.      aktuellen HTTP-Anfrage enthΣlt. Diese Funktion wird nur untersstⁿtzt,
  42448.      wenn PHP als Modul fⁿr <SPAN
  42449. CLASS="productname"
  42450. >Apache</SPAN
  42451. > lΣuft.
  42452.     </P
  42453. ><P
  42454. >      <TABLE
  42455. WIDTH="100%"
  42456. BORDER="0"
  42457. CELLPADDING="0"
  42458. CELLSPACING="0"
  42459. CLASS="EXAMPLE"
  42460. ><TR
  42461. ><TD
  42462. ><DIV
  42463. CLASS="example"
  42464. ><A
  42465. NAME="AEN7147"
  42466. ></A
  42467. ><P
  42468. ><B
  42469. >Beispiel 1. <B
  42470. CLASS="function"
  42471. >apache_request_headers()</B
  42472. > Beispiel</B
  42473. ></P
  42474. ><TABLE
  42475. BORDER="0"
  42476. BGCOLOR="#E0E0E0"
  42477. CELLPADDING="5"
  42478. ><TR
  42479. ><TD
  42480. ><PRE
  42481. CLASS="php"
  42482. ><?php
  42483. $headers = apache_request_headers();
  42484.  
  42485. foreach ($headers as $header => $value) {
  42486.     echo "$header: $value <br />\n";
  42487. }
  42488. ?></PRE
  42489. ></TD
  42490. ></TR
  42491. ></TABLE
  42492. ></DIV
  42493. ></TD
  42494. ></TR
  42495. ></TABLE
  42496. >
  42497.     </P
  42498. ><DIV
  42499. CLASS="note"
  42500. ><BLOCKQUOTE
  42501. CLASS="note"
  42502. ><P
  42503. ><B
  42504. >Anmerkung: </B
  42505. >
  42506.       In frⁿheren Versionen als PHP 4.3.0 hie▀ die Funktion
  42507.       <B
  42508. CLASS="function"
  42509. >apache_request_headers()</B
  42510. >
  42511.       <A
  42512. HREF="#function.getallheaders"
  42513. ><B
  42514. CLASS="function"
  42515. >getallheaders()</B
  42516. ></A
  42517. >. Mit PHP 4.3.0 ist
  42518.       <A
  42519. HREF="#function.getallheaders"
  42520. ><B
  42521. CLASS="function"
  42522. >getallheaders()</B
  42523. ></A
  42524. > ein Alias fⁿr
  42525.       <B
  42526. CLASS="function"
  42527. >apache_request_headers()</B
  42528. >.
  42529.      </P
  42530. ></BLOCKQUOTE
  42531. ></DIV
  42532. ><DIV
  42533. CLASS="note"
  42534. ><BLOCKQUOTE
  42535. CLASS="note"
  42536. ><P
  42537. ><B
  42538. >Anmerkung: </B
  42539. >
  42540.       Die Werte der gebrΣuchlichsten CGI-Variablen k÷nnen Sie auch durch das
  42541.       Auslesen der Umgebungsvariablen erhalten. Dieser Weg funktioniert
  42542.       unabhΣngig davon, ob Sie PHP als Modul fⁿr
  42543.       <SPAN
  42544. CLASS="productname"
  42545. >Apache</SPAN
  42546. > benutzen.
  42547.       Benutzen Sie <A
  42548. HREF="#function.phpinfo"
  42549. ><B
  42550. CLASS="function"
  42551. >phpinfo()</B
  42552. ></A
  42553. >, um eine Liste aller zur
  42554.       Verfⁿgung stehenden
  42555.       <A
  42556. HREF="#language.variables.predefined"
  42557. >Umgebungsvariablen</A
  42558. >
  42559.       zu erhalten.
  42560.      </P
  42561. ></BLOCKQUOTE
  42562. ></DIV
  42563. ><DIV
  42564. CLASS="note"
  42565. ><BLOCKQUOTE
  42566. CLASS="note"
  42567. ><P
  42568. ><B
  42569. >Anmerkung: </B
  42570. >Ab PHP 4.3.3 k÷nnen Sie diese
  42571. Funktion auch mit dem <A
  42572. HREF="#ref.nsapi"
  42573. >NSAPI Server Modul</A
  42574. > fⁿr
  42575. Netscape/iPlanet/SunONE Webserver nutzen.</P
  42576. ></BLOCKQUOTE
  42577. ></DIV
  42578. ><P
  42579. >      Siehe auch <A
  42580. HREF="#function.apache-response-headers"
  42581. ><B
  42582. CLASS="function"
  42583. >apache_response_headers()</B
  42584. ></A
  42585. >.
  42586.     </P
  42587. ></DIV
  42588. ><H1
  42589. ><A
  42590. NAME="function.apache-response-headers"
  42591. ></A
  42592. >apache_response_headers</H1
  42593. ><DIV
  42594. CLASS="refnamediv"
  42595. ><A
  42596. NAME="AEN7168"
  42597. ></A
  42598. ><P
  42599. >    (PHP 4 >= 4.3.0, PHP 5)</P
  42600. >apache_response_headers -- 
  42601.      Liefert alle HTTP-Antwort Header
  42602.     </DIV
  42603. ><DIV
  42604. CLASS="refsect1"
  42605. ><A
  42606. NAME="AEN7171"
  42607. ></A
  42608. ><H2
  42609. >Beschreibung</H2
  42610. >array <B
  42611. CLASS="methodname"
  42612. >apache_response_headers</B
  42613. > ( void )<BR
  42614. ></BR
  42615. ><P
  42616. >      Rⁿckgabewert: ein assoziatives Array mit allen Apache-Antwort Headern.
  42617.     </P
  42618. ><P
  42619. >      Siehe auch <A
  42620. HREF="#function.apache-request-headers"
  42621. ><B
  42622. CLASS="function"
  42623. >apache_request_headers()</B
  42624. ></A
  42625. > und
  42626.      <A
  42627. HREF="#function.headers-sent"
  42628. ><B
  42629. CLASS="function"
  42630. >headers_sent()</B
  42631. ></A
  42632. >.
  42633.     </P
  42634. ><DIV
  42635. CLASS="note"
  42636. ><BLOCKQUOTE
  42637. CLASS="note"
  42638. ><P
  42639. ><B
  42640. >Anmerkung: </B
  42641. >Ab PHP 4.3.3 k÷nnen Sie diese
  42642. Funktion auch mit dem <A
  42643. HREF="#ref.nsapi"
  42644. >NSAPI Server Modul</A
  42645. > fⁿr
  42646. Netscape/iPlanet/SunONE Webserver nutzen.</P
  42647. ></BLOCKQUOTE
  42648. ></DIV
  42649. ></DIV
  42650. ><H1
  42651. ><A
  42652. NAME="function.apache-setenv"
  42653. ></A
  42654. >apache_setenv</H1
  42655. ><DIV
  42656. CLASS="refnamediv"
  42657. ><A
  42658. NAME="AEN7185"
  42659. ></A
  42660. ><P
  42661. >    (PHP 4 >= 4.2.0, PHP 5)</P
  42662. >apache_setenv -- Setzt eine Apache subprocess_env Variable</DIV
  42663. ><DIV
  42664. CLASS="refsect1"
  42665. ><A
  42666. NAME="AEN7188"
  42667. ></A
  42668. ><H2
  42669. >Beschreibung</H2
  42670. >int <B
  42671. CLASS="methodname"
  42672. >apache_setenv</B
  42673. > ( string Variable, string Wert [, bool walk_to_top])<BR
  42674. ></BR
  42675. ><P
  42676. >      <DIV
  42677. CLASS="warning"
  42678. ><P
  42679. ></P
  42680. ><TABLE
  42681. CLASS="warning"
  42682. BORDER="1"
  42683. WIDTH="100%"
  42684. ><TR
  42685. ><TD
  42686. ALIGN="CENTER"
  42687. ><B
  42688. >Warnung</B
  42689. ></TD
  42690. ></TR
  42691. ><TR
  42692. ><TD
  42693. ALIGN="LEFT"
  42694. ><P
  42695. >Diese Funktion ist bis jetzt
  42696. nicht dokumentiert. Es steht nur die Liste der Argumente zur Verfⁿgung.
  42697. </P
  42698. ></TD
  42699. ></TR
  42700. ></TABLE
  42701. ></DIV
  42702. >
  42703.     </P
  42704. ></DIV
  42705. ><H1
  42706. ><A
  42707. NAME="function.ascii2ebcdic"
  42708. ></A
  42709. >ascii2ebcdic</H1
  42710. ><DIV
  42711. CLASS="refnamediv"
  42712. ><A
  42713. NAME="AEN7206"
  42714. ></A
  42715. ><P
  42716. >    (PHP 3>= 3.0.17)</P
  42717. >ascii2ebcdic -- Zeichenkette von ASCII in EBCDIC ⁿbersetzen</DIV
  42718. ><DIV
  42719. CLASS="refsect1"
  42720. ><A
  42721. NAME="AEN7209"
  42722. ></A
  42723. ><H2
  42724. >Beschreibung</H2
  42725. >int <B
  42726. CLASS="methodname"
  42727. >ascii2ebcdic</B
  42728. > ( string ascii_str)<BR
  42729. ></BR
  42730. ><P
  42731. >      <B
  42732. CLASS="function"
  42733. >ascii2ebcdic()</B
  42734. > ist eine Apache-spezifische
  42735.      Funktion, die nur auf Systemen mit EBCDIC-Zeichensatz
  42736.      existiert (Betriebssysteme: OS/390, BS2000).
  42737.      Die Funktion setzt die ASCII-kodierte Zeichenkette
  42738.      <VAR
  42739. CLASS="parameter"
  42740. >ascii_str</VAR
  42741. >
  42742.      in ihre Σquivalente EBCDIC-Darstellung um
  42743.      (binΣrfest), und liefert das konvertierte Ergebnis
  42744.      zurⁿck.
  42745.     </P
  42746. ><P
  42747. >      Siehe auch die Umkehrfunktion
  42748.      <A
  42749. HREF="#function.ebcdic2ascii"
  42750. ><B
  42751. CLASS="function"
  42752. >ebcdic2ascii()</B
  42753. ></A
  42754. >.
  42755.     </P
  42756. ></DIV
  42757. ><H1
  42758. ><A
  42759. NAME="function.ebcdic2ascii"
  42760. ></A
  42761. >ebcdic2ascii</H1
  42762. ><DIV
  42763. CLASS="refnamediv"
  42764. ><A
  42765. NAME="AEN7223"
  42766. ></A
  42767. ><P
  42768. >    (PHP 3>= 3.0.17)</P
  42769. >ebcdic2ascii -- Zeichenkette von EBCDIC in ASCII ⁿbersetzen</DIV
  42770. ><DIV
  42771. CLASS="refsect1"
  42772. ><A
  42773. NAME="AEN7226"
  42774. ></A
  42775. ><H2
  42776. >Beschreibung</H2
  42777. >int <B
  42778. CLASS="methodname"
  42779. >ebcdic2ascii</B
  42780. > ( string ebcdic_str)<BR
  42781. ></BR
  42782. ><P
  42783. >      <B
  42784. CLASS="function"
  42785. >ebcdic2ascii()</B
  42786. > ist eine Apache-spezifische
  42787.      Funktion, die nur auf Systemen mit EBCDIC-Zeichensatz
  42788.      existiert (Betriebssysteme: OS/390, BS2000).
  42789.      Die Funktion setzt die EBCDIC-kodierte Zeichenkette
  42790.      <VAR
  42791. CLASS="parameter"
  42792. >ebcdic_str</VAR
  42793. >
  42794.      in ihre Σquivalente ASCII-Darstellung um
  42795.      (binΣrfest), und liefert das konvertierte Ergebnis
  42796.      zurⁿck.
  42797.     </P
  42798. ><P
  42799. >      Siehe auch die Umkehrfunktion
  42800.      <A
  42801. HREF="#function.ascii2ebcdic"
  42802. ><B
  42803. CLASS="function"
  42804. >ascii2ebcdic()</B
  42805. ></A
  42806. >.
  42807.     </P
  42808. ></DIV
  42809. ><H1
  42810. ><A
  42811. NAME="function.getallheaders"
  42812. ></A
  42813. >getallheaders</H1
  42814. ><DIV
  42815. CLASS="refnamediv"
  42816. ><A
  42817. NAME="AEN7240"
  42818. ></A
  42819. ><P
  42820. >    (PHP 3, PHP 4 , PHP 5)</P
  42821. >getallheaders -- 
  42822.      Liefert alle HTTP-Header der aktuellen Anfrage aus
  42823.     </DIV
  42824. ><DIV
  42825. CLASS="refsect1"
  42826. ><A
  42827. NAME="AEN7243"
  42828. ></A
  42829. ><H2
  42830. >Beschreibung</H2
  42831. >array <B
  42832. CLASS="methodname"
  42833. >getallheaders</B
  42834. > ( void )<BR
  42835. ></BR
  42836. ><P
  42837. >      <B
  42838. CLASS="function"
  42839. >getallheaders()</B
  42840. > ist ein Alias fⁿr die Funktion
  42841.      <A
  42842. HREF="#function.apache-request-headers"
  42843. ><B
  42844. CLASS="function"
  42845. >apache_request_headers()</B
  42846. ></A
  42847. >. Die Funktion liefert ein
  42848.      assoziatives Array zurⁿck, das alle HTTP-Header der
  42849.      aktuellen HTTP-Anfrage enthΣlt. Lesen Sie bitte die Dokumentation zu
  42850.      <A
  42851. HREF="#function.apache-request-headers"
  42852. ><B
  42853. CLASS="function"
  42854. >apache_request_headers()</B
  42855. ></A
  42856. > um mehr Informationen ⁿber die
  42857.      Funktionsweise zu erhalten.
  42858.     </P
  42859. ><DIV
  42860. CLASS="note"
  42861. ><BLOCKQUOTE
  42862. CLASS="note"
  42863. ><P
  42864. ><B
  42865. >Anmerkung: </B
  42866. >
  42867.       In PHP 4.3.0 wurde aus <B
  42868. CLASS="function"
  42869. >getallheaders()</B
  42870. > ein Alias fⁿr
  42871.       <A
  42872. HREF="#function.apache-request-headers"
  42873. ><B
  42874. CLASS="function"
  42875. >apache_request_headers()</B
  42876. ></A
  42877. >. TatsΣchlich wurde die
  42878.       Funktion umbenannt. Der Grund: diese Funktion funktioniert nur, wenn PHP
  42879.       als Modul fⁿr <SPAN
  42880. CLASS="productname"
  42881. >Apache</SPAN
  42882. > kompiliert wurde.
  42883.      </P
  42884. ></BLOCKQUOTE
  42885. ></DIV
  42886. ><DIV
  42887. CLASS="note"
  42888. ><BLOCKQUOTE
  42889. CLASS="note"
  42890. ><P
  42891. ><B
  42892. >Anmerkung: </B
  42893. >Ab PHP 4.3.3 k÷nnen Sie diese
  42894. Funktion auch mit dem <A
  42895. HREF="#ref.nsapi"
  42896. >NSAPI Server Modul</A
  42897. > fⁿr
  42898. Netscape/iPlanet/SunONE Webserver nutzen.</P
  42899. ></BLOCKQUOTE
  42900. ></DIV
  42901. ><P
  42902. >      Siehe auch <A
  42903. HREF="#function.apache-request-headers"
  42904. ><B
  42905. CLASS="function"
  42906. >apache_request_headers()</B
  42907. ></A
  42908. >.
  42909.     </P
  42910. ></DIV
  42911. ><H1
  42912. ><A
  42913. NAME="function.virtual"
  42914. ></A
  42915. >virtual</H1
  42916. ><DIV
  42917. CLASS="refnamediv"
  42918. ><A
  42919. NAME="AEN7264"
  42920. ></A
  42921. ><P
  42922. >    (PHP 3, PHP 4 , PHP 5)</P
  42923. >virtual -- Fⁿhrt eine Apache-Unteranfrage durch</DIV
  42924. ><DIV
  42925. CLASS="refsect1"
  42926. ><A
  42927. NAME="AEN7267"
  42928. ></A
  42929. ><H2
  42930. >Beschreibung</H2
  42931. >int <B
  42932. CLASS="methodname"
  42933. >virtual</B
  42934. > ( string filename)<BR
  42935. ></BR
  42936. ><P
  42937. >      <B
  42938. CLASS="function"
  42939. >virtual()</B
  42940. > ist eine Apache-spezifische 
  42941.      Funktion, die <!--#include virtual... --> aus mod_include
  42942.      entspricht. Diese Funktion fⁿhrt eine Unteranfrage durch. Das ist
  42943.      nⁿtzlich fⁿr das Einbinden von CGI-Skripten, .shtml-Dateien oder allen
  42944.      anderen Inhalten, die von Apache verarbeitet werden sollen. Beachten Sie
  42945.      bitte, dass ein CGI-Skript gⁿltige CGI-Header generieren muss,
  42946.      mindestens einen Content-type-Header.
  42947.     </P
  42948. ><P
  42949. >      Um die Unteranfrage auszufⁿhren, werden alle Buffer beendet und der
  42950.      Inhalt im Browser ausgegeben. Anstehende Header werden ebenfalls
  42951.      abgeschickt.
  42952.     </P
  42953. ><P
  42954. >      Seit PHP 4.0.6 k÷nnen Sie <B
  42955. CLASS="function"
  42956. >virtual()</B
  42957. > fⁿr PHP Dateien
  42958.      benutzen. Trotzdem ist es typischerweise besser,
  42959.      <A
  42960. HREF="#function.include"
  42961. ><B
  42962. CLASS="function"
  42963. >include()</B
  42964. ></A
  42965. > oder <A
  42966. HREF="#function.require"
  42967. ><B
  42968. CLASS="function"
  42969. >require()</B
  42970. ></A
  42971. > zu benutzen
  42972.      um PHP Dateien einzubinden.
  42973.     </P
  42974. ><DIV
  42975. CLASS="note"
  42976. ><BLOCKQUOTE
  42977. CLASS="note"
  42978. ><P
  42979. ><B
  42980. >Anmerkung: </B
  42981. >Ab PHP 4.3.3 k÷nnen Sie diese
  42982. Funktion auch mit dem <A
  42983. HREF="#ref.nsapi"
  42984. >NSAPI Server Modul</A
  42985. > fⁿr
  42986. Netscape/iPlanet/SunONE Webserver nutzen.</P
  42987. ></BLOCKQUOTE
  42988. ></DIV
  42989. ></DIV
  42990. ></DIV
  42991. ><DIV
  42992. CLASS="reference"
  42993. ><A
  42994. NAME="ref.array"
  42995. ></A
  42996. ><DIV
  42997. CLASS="TITLEPAGE"
  42998. ><H1
  42999. CLASS="title"
  43000. >II. Array Funktionen</H1
  43001. ><DIV
  43002. CLASS="PARTINTRO"
  43003. ><A
  43004. NAME="AEN7288"
  43005. ></A
  43006. ><DIV
  43007. CLASS="section"
  43008. ><H2
  43009. CLASS="section"
  43010. ><A
  43011. NAME="array.intro"
  43012. >Einfⁿhrung</A
  43013. ></H2
  43014. ><P
  43015. >     Diese Funktionen erlauben es, Arrays auf verschiedene Arten zu
  43016.     manipulieren bzw. mit ihnen zu interagieren. Arrays sind wichtig,
  43017.     um Gruppen von Variablen zu verwalten, zu bearbeiten, oder zu
  43018.     speichern.
  43019.    </P
  43020. ><P
  43021. >     Es werden einfache und mehrdimensionale Arrays unterstⁿtzt, welche
  43022.     entweder vom Benutzer oder von einer anderen Funktion erstellt
  43023.     werden k÷nnen. Es gibt bestimmte Datenbankfunktionen, welche die
  43024.     Ergebnisse aus Datenbankabfragen in Arrays speichern, und
  43025.     verschiedene andere Funktionen, die Arrays als Rⁿckgabewerte
  43026.     haben.
  43027.    </P
  43028. ><P
  43029. >     Im Abschnitt <A
  43030. HREF="#language.types.array"
  43031. >Arrays</A
  43032. >
  43033.     finden Sie eine detaillierte ErklΣrung, wie Arrays in PHP
  43034.     implementiert sind und wie sie benutzt werden.
  43035.    </P
  43036. ></DIV
  43037. ><DIV
  43038. CLASS="section"
  43039. ><HR><H2
  43040. CLASS="section"
  43041. ><A
  43042. NAME="array.requirements"
  43043. >Anforderungen</A
  43044. ></H2
  43045. ><P
  43046. >Diese Erweiterung ben÷tigt keine externen Bibliotheken.</P
  43047. ></DIV
  43048. ><DIV
  43049. CLASS="section"
  43050. ><HR><H2
  43051. CLASS="section"
  43052. ><A
  43053. NAME="array.installation"
  43054. >Installation</A
  43055. ></H2
  43056. ><P
  43057. >Fⁿr diese Funktionen ist keine Installation erforderlich, 
  43058. diese geh÷ren zum Grundbestand von PHP.</P
  43059. ></DIV
  43060. ><DIV
  43061. CLASS="section"
  43062. ><HR><H2
  43063. CLASS="section"
  43064. ><A
  43065. NAME="array.configuration"
  43066. >Laufzeit Konfiguration</A
  43067. ></H2
  43068. ><P
  43069. >Diese Erweiterung definiert keine Konfigurationseinstellungen in der <TT
  43070. CLASS="filename"
  43071. >php.ini</TT
  43072. >.</P
  43073. ></DIV
  43074. ><DIV
  43075. CLASS="section"
  43076. ><HR><H2
  43077. CLASS="section"
  43078. ><A
  43079. NAME="array.resources"
  43080. >Resource Typen</A
  43081. ></H2
  43082. ><P
  43083. >Diese Erweiterung definiert keine Resource-Typen.</P
  43084. ></DIV
  43085. ><DIV
  43086. CLASS="section"
  43087. ><HR><H2
  43088. CLASS="section"
  43089. ><A
  43090. NAME="array.constants"
  43091. >Vordefinierte Konstanten</A
  43092. ></H2
  43093. ><P
  43094. >Die aufgelisteten Konstanten
  43095. stehen immer zur Verfⁿgung, da sie zum Grundbestand von PHP geh÷ren.</P
  43096. ><P
  43097. ></P
  43098. ><DIV
  43099. CLASS="variablelist"
  43100. ><DL
  43101. ><DT
  43102. ><TT
  43103. CLASS="constant"
  43104. ><B
  43105. >CASE_LOWER</B
  43106. ></TT
  43107. >
  43108.     (<A
  43109. HREF="#language.types.integer"
  43110. >integer</A
  43111. >)</DT
  43112. ><DD
  43113. ><P
  43114. >      <TT
  43115. CLASS="constant"
  43116. ><B
  43117. >CASE_LOWER</B
  43118. ></TT
  43119. > wird benⁿtzt mit
  43120.      <A
  43121. HREF="#function.array-change-key-case"
  43122. ><B
  43123. CLASS="function"
  43124. >array_change_key_case()</B
  43125. ></A
  43126. > um die Schlⁿssel von Arrays
  43127.      in Kleinbuchstaben umzuwandeln. Das ist auch der Standard fⁿr
  43128.      <A
  43129. HREF="#function.array-change-key-case"
  43130. ><B
  43131. CLASS="function"
  43132. >array_change_key_case()</B
  43133. ></A
  43134. >.
  43135.     </P
  43136. ></DD
  43137. ><DT
  43138. ><TT
  43139. CLASS="constant"
  43140. ><B
  43141. >CASE_UPPER</B
  43142. ></TT
  43143. >
  43144.     (<A
  43145. HREF="#language.types.integer"
  43146. >integer</A
  43147. >)</DT
  43148. ><DD
  43149. ><P
  43150. >      <TT
  43151. CLASS="constant"
  43152. ><B
  43153. >CASE_UPPER</B
  43154. ></TT
  43155. > wird benⁿtzt mit
  43156.      <A
  43157. HREF="#function.array-change-key-case"
  43158. ><B
  43159. CLASS="function"
  43160. >array_change_key_case()</B
  43161. ></A
  43162. > um die Schlⁿssel von Arrays
  43163.      in Gro▀buchstaben umzuwandeln.
  43164.     </P
  43165. ></DD
  43166. ></DL
  43167. ></DIV
  43168. ></DIV
  43169. ><DIV
  43170. CLASS="section"
  43171. ><HR><H2
  43172. CLASS="section"
  43173. ><A
  43174. NAME="array.seealso"
  43175. >Siehe auch</A
  43176. ></H2
  43177. ><P
  43178. >      Siehe auch <A
  43179. HREF="#function.is-array"
  43180. ><B
  43181. CLASS="function"
  43182. >is_array()</B
  43183. ></A
  43184. >, <A
  43185. HREF="#function.explode"
  43186. ><B
  43187. CLASS="function"
  43188. >explode()</B
  43189. ></A
  43190. >,
  43191.      <A
  43192. HREF="#function.implode"
  43193. ><B
  43194. CLASS="function"
  43195. >implode()</B
  43196. ></A
  43197. >, <A
  43198. HREF="#function.split"
  43199. ><B
  43200. CLASS="function"
  43201. >split()</B
  43202. ></A
  43203. >,
  43204.      <A
  43205. HREF="#function.preg-split"
  43206. ><B
  43207. CLASS="function"
  43208. >preg_split()</B
  43209. ></A
  43210. > und <A
  43211. HREF="#function.unset"
  43212. ><B
  43213. CLASS="function"
  43214. >unset()</B
  43215. ></A
  43216. >.
  43217.     </P
  43218. ></DIV
  43219. ></DIV
  43220. ><DIV
  43221. CLASS="TOC"
  43222. ><DL
  43223. ><DT
  43224. ><B
  43225. >Inhaltsverzeichnis</B
  43226. ></DT
  43227. ><DT
  43228. ><A
  43229. HREF="#function.array-change-key-case"
  43230. >array_change_key_case</A
  43231. > -- 
  43232.      Liefert ein Array mit allen String-Schlⁿsseln in Klein- oder Gro▀buchstaben
  43233.     </DT
  43234. ><DT
  43235. ><A
  43236. HREF="#function.array-chunk"
  43237. >array_chunk</A
  43238. > -- Splittet ein Array in Teile auf</DT
  43239. ><DT
  43240. ><A
  43241. HREF="#function.array-combine"
  43242. >array_combine</A
  43243. > -- 
  43244.      Creates an array by using one array for keys and another for its values
  43245.     </DT
  43246. ><DT
  43247. ><A
  43248. HREF="#function.array-count-values"
  43249. >array_count_values</A
  43250. > -- ZΣhlt die Werte eines Arrays</DT
  43251. ><DT
  43252. ><A
  43253. HREF="#function.array-diff-assoc"
  43254. >array_diff_assoc</A
  43255. > -- Computes the difference of arrays with additional index check</DT
  43256. ><DT
  43257. ><A
  43258. HREF="#function.array-diff-key"
  43259. >array_diff_key</A
  43260. > -- Computes the difference of arrays using keys for comparison</DT
  43261. ><DT
  43262. ><A
  43263. HREF="#function.array-diff-uassoc"
  43264. >array_diff_uassoc</A
  43265. > -- 
  43266.      Computes the difference of arrays with additional index check
  43267.      which is performed by a user supplied callback function
  43268.     </DT
  43269. ><DT
  43270. ><A
  43271. HREF="#function.array-diff-ukey"
  43272. >array_diff_ukey</A
  43273. > -- Computes the difference of arrays using a callback function on the keys for comparison</DT
  43274. ><DT
  43275. ><A
  43276. HREF="#function.array-diff"
  43277. >array_diff</A
  43278. > -- Ermittelt die Unterschiede von Arrays</DT
  43279. ><DT
  43280. ><A
  43281. HREF="#function.array-fill"
  43282. >array_fill</A
  43283. > -- Fⁿllt ein Array mit Werten</DT
  43284. ><DT
  43285. ><A
  43286. HREF="#function.array-filter"
  43287. >array_filter</A
  43288. > -- 
  43289.      Filtert Elemente eines Arrays mittels einer Callback-Funktion
  43290.     </DT
  43291. ><DT
  43292. ><A
  43293. HREF="#function.array-flip"
  43294. >array_flip</A
  43295. > -- Vertauscht Werte und Schlⁿssel in einem Array</DT
  43296. ><DT
  43297. ><A
  43298. HREF="#function.array-intersect-assoc"
  43299. >array_intersect_assoc</A
  43300. > -- Computes the intersection of arrays with additional index check</DT
  43301. ><DT
  43302. ><A
  43303. HREF="#function.array-intersect-key"
  43304. >array_intersect_key</A
  43305. > -- Computes the intersection of arrays using keys for comparison</DT
  43306. ><DT
  43307. ><A
  43308. HREF="#function.array-intersect-uassoc"
  43309. >array_intersect_uassoc</A
  43310. > -- Computes the intersection of arrays with additional index check. The indexes are compared by using a callback function</DT
  43311. ><DT
  43312. ><A
  43313. HREF="#function.array-intersect-ukey"
  43314. >array_intersect_ukey</A
  43315. > -- Computes the intersection of arrays using a callback function on the keys for comparison</DT
  43316. ><DT
  43317. ><A
  43318. HREF="#function.array-intersect"
  43319. >array_intersect</A
  43320. > -- Ermittelt die Schnittmenge von Arrays</DT
  43321. ><DT
  43322. ><A
  43323. HREF="#function.array-key-exists"
  43324. >array_key_exists</A
  43325. > -- Prⁿft, ob ein Schlⁿssel in einem Array existiert</DT
  43326. ><DT
  43327. ><A
  43328. HREF="#function.array-keys"
  43329. >array_keys</A
  43330. > -- Liefert alle Schlⁿssel eines Arrays</DT
  43331. ><DT
  43332. ><A
  43333. HREF="#function.array-map"
  43334. >array_map</A
  43335. > -- 
  43336.      Wendet eine Callback-Funktion auf die Elemente von Arrays an
  43337.     </DT
  43338. ><DT
  43339. ><A
  43340. HREF="#function.array-merge-recursive"
  43341. >array_merge_recursive</A
  43342. > -- 
  43343.      Fⁿhrt zwei oder mehr Arrays rekursiv zusammen
  43344.     </DT
  43345. ><DT
  43346. ><A
  43347. HREF="#function.array-merge"
  43348. >array_merge</A
  43349. > -- Fⁿhrt zwei oder mehr Arrays zusammen</DT
  43350. ><DT
  43351. ><A
  43352. HREF="#function.array-multisort"
  43353. >array_multisort</A
  43354. > -- Sortiert mehrere oder multidimensionale Arrays</DT
  43355. ><DT
  43356. ><A
  43357. HREF="#function.array-pad"
  43358. >array_pad</A
  43359. > -- 
  43360.      Vergr÷▀ert ein Array auf die spezifizierte LΣnge mit einem Wert
  43361.     </DT
  43362. ><DT
  43363. ><A
  43364. HREF="#function.array-pop"
  43365. >array_pop</A
  43366. > -- Liefert das letzte Element eines Arrays</DT
  43367. ><DT
  43368. ><A
  43369. HREF="#function.array-push"
  43370. >array_push</A
  43371. > -- 
  43372.      Fⁿgt ein oder mehr Elemente an das Ende eines Arrays
  43373.     </DT
  43374. ><DT
  43375. ><A
  43376. HREF="#function.array-rand"
  43377. >array_rand</A
  43378. > -- 
  43379.      Liefert einen oder mehrere zufΣllige EintrΣge eines Arrays
  43380.     </DT
  43381. ><DT
  43382. ><A
  43383. HREF="#function.array-reduce"
  43384. >array_reduce</A
  43385. > -- 
  43386.      Iterative Reduktion eines Arrays zu einem Wert mittels einer
  43387.      Callback Funktion
  43388.     </DT
  43389. ><DT
  43390. ><A
  43391. HREF="#function.array-reverse"
  43392. >array_reverse</A
  43393. > -- 
  43394.      Liefert ein Array mit umgekehrter Reihenfolge der Elemente
  43395.     </DT
  43396. ><DT
  43397. ><A
  43398. HREF="#function.array-search"
  43399. >array_search</A
  43400. > -- 
  43401.      Durchsucht ein Array nach einem Wert liefert bei Erfolg den
  43402.      Schlⁿssel
  43403.     </DT
  43404. ><DT
  43405. ><A
  43406. HREF="#function.array-shift"
  43407. >array_shift</A
  43408. > -- 
  43409.      Liefert ein Element vom Beginn eines Arrays
  43410.     </DT
  43411. ><DT
  43412. ><A
  43413. HREF="#function.array-slice"
  43414. >array_slice</A
  43415. > -- Extrahiert einen Ausschnitt eines Arrays</DT
  43416. ><DT
  43417. ><A
  43418. HREF="#function.array-splice"
  43419. >array_splice</A
  43420. > -- 
  43421.      Entfernt einen Teil eines Arrays und ersetzt ihn durch etwas
  43422.      anderes
  43423.     </DT
  43424. ><DT
  43425. ><A
  43426. HREF="#function.array-sum"
  43427. >array_sum</A
  43428. > -- 
  43429.      Liefert die Summe der Werte in einem Array
  43430.     </DT
  43431. ><DT
  43432. ><A
  43433. HREF="#function.array-udiff-assoc"
  43434. >array_udiff_assoc</A
  43435. > -- Computes the difference of arrays with additional index check. The data is compared by using a callback function</DT
  43436. ><DT
  43437. ><A
  43438. HREF="#function.array-udiff-uassoc"
  43439. >array_udiff_uassoc</A
  43440. > -- Computes the difference of arrays with additional index check. The data is compared by using a callback function. The index check is done by a callback function also</DT
  43441. ><DT
  43442. ><A
  43443. HREF="#function.array-udiff"
  43444. >array_udiff</A
  43445. > -- Computes the difference of arrays by using a callback function for data comparison</DT
  43446. ><DT
  43447. ><A
  43448. HREF="#function.array-uintersect-assoc"
  43449. >array_uintersect_assoc</A
  43450. > -- Computes the intersection of arrays with additional index check. The data is compared by using a callback function</DT
  43451. ><DT
  43452. ><A
  43453. HREF="#function.array-uintersect-uassoc"
  43454. >array_uintersect_uassoc</A
  43455. > -- Computes the intersection of arrays with additional index check. Both the data and the indexes are compared by using a callback functions</DT
  43456. ><DT
  43457. ><A
  43458. HREF="#function.array-uintersect"
  43459. >array_uintersect</A
  43460. > -- Computes the intersection of arrays. The data is compared by using a callback function</DT
  43461. ><DT
  43462. ><A
  43463. HREF="#function.array-unique"
  43464. >array_unique</A
  43465. > -- Entfernt doppelte Werte aus einem Array</DT
  43466. ><DT
  43467. ><A
  43468. HREF="#function.array-unshift"
  43469. >array_unshift</A
  43470. > -- 
  43471.      Fⁿgt ein oder mehr Elemente am Anfang eines Arrays ein
  43472.     </DT
  43473. ><DT
  43474. ><A
  43475. HREF="#function.array-values"
  43476. >array_values</A
  43477. > -- Liefert alle Werte eines Arrays</DT
  43478. ><DT
  43479. ><A
  43480. HREF="#function.array-walk-recursive"
  43481. >array_walk_recursive</A
  43482. > -- 
  43483.    Apply a user function recursively to every member of an array
  43484.   </DT
  43485. ><DT
  43486. ><A
  43487. HREF="#function.array-walk"
  43488. >array_walk</A
  43489. > -- 
  43490.      Wendet eine Benutzerfunktion an jedem Element eines Arrays an
  43491.     </DT
  43492. ><DT
  43493. ><A
  43494. HREF="#function.array"
  43495. >array</A
  43496. > -- 
  43497.      Erstellt ein Array
  43498.     </DT
  43499. ><DT
  43500. ><A
  43501. HREF="#function.arsort"
  43502. >arsort</A
  43503. > -- 
  43504.      Sortiert ein Array in umgekehrter Reihenfolge und behΣlt die
  43505.      Verbindung zum Index
  43506.     </DT
  43507. ><DT
  43508. ><A
  43509. HREF="#function.asort"
  43510. >asort</A
  43511. > -- 
  43512.      Sortiert ein Array und behΣlt die Indexverbindungen
  43513.     </DT
  43514. ><DT
  43515. ><A
  43516. HREF="#function.compact"
  43517. >compact</A
  43518. > -- 
  43519.      Erstellt ein Array mit Variablen und deren Werten
  43520.     </DT
  43521. ><DT
  43522. ><A
  43523. HREF="#function.count"
  43524. >count</A
  43525. > -- ZΣhlt die Elemente einer Variable</DT
  43526. ><DT
  43527. ><A
  43528. HREF="#function.current"
  43529. >current</A
  43530. > -- Liefert das aktuelle Element eines Arrays</DT
  43531. ><DT
  43532. ><A
  43533. HREF="#function.each"
  43534. >each</A
  43535. > -- 
  43536.      Liefert das aktuelle Paar (Schlⁿssel und Wert) eines Arrays und
  43537.      rⁿckt den Array Cursor vor.
  43538.     </DT
  43539. ><DT
  43540. ><A
  43541. HREF="#function.end"
  43542. >end</A
  43543. > -- 
  43544.      Positioniert den internen Zeiger eines Arrays auf dessen letztes Element
  43545.     </DT
  43546. ><DT
  43547. ><A
  43548. HREF="#function.extract"
  43549. >extract</A
  43550. > -- 
  43551.      Importiert Variablen eines Arrays in die aktuelle Symboltabelle 
  43552.     </DT
  43553. ><DT
  43554. ><A
  43555. HREF="#function.in-array"
  43556. >in_array</A
  43557. > -- Prⁿft, ob ein Wert in einem Array existiert</DT
  43558. ><DT
  43559. ><A
  43560. HREF="#function.key"
  43561. >key</A
  43562. > -- 
  43563.      Liefert einen Schlⁿssel eines assoziativen Arrays
  43564.     </DT
  43565. ><DT
  43566. ><A
  43567. HREF="#function.krsort"
  43568. >krsort</A
  43569. > -- 
  43570.      Sortiert ein Array nach Schlⁿsseln in umgekehrter Reihenfolge
  43571.     </DT
  43572. ><DT
  43573. ><A
  43574. HREF="#function.ksort"
  43575. >ksort</A
  43576. > -- Sortiert ein Array nach Schlⁿsseln</DT
  43577. ><DT
  43578. ><A
  43579. HREF="#function.list"
  43580. >list</A
  43581. > -- 
  43582.      Weist Variablen zu, als wΣren sie ein Array
  43583.     </DT
  43584. ><DT
  43585. ><A
  43586. HREF="#function.natcasesort"
  43587. >natcasesort</A
  43588. > -- 
  43589.      Sortiert ein Array in "natⁿrlicher Reihenfolge",
  43590.      Gro▀/Kleinschreibung wird ignoriert
  43591.     </DT
  43592. ><DT
  43593. ><A
  43594. HREF="#function.natsort"
  43595. >natsort</A
  43596. > -- 
  43597.      Sortiert ein Array in "natⁿrlicher Reihenfolge"
  43598.     </DT
  43599. ><DT
  43600. ><A
  43601. HREF="#function.next"
  43602. >next</A
  43603. > -- 
  43604.      Rⁿckt den internen Zeiger eines Arrays vor
  43605.     </DT
  43606. ><DT
  43607. ><A
  43608. HREF="#function.pos"
  43609. >pos</A
  43610. > -- Liefert das aktuelle Element eines Arrays</DT
  43611. ><DT
  43612. ><A
  43613. HREF="#function.prev"
  43614. >prev</A
  43615. > -- 
  43616.      Verkleinert den internen Zeiger eines Arrays
  43617.     </DT
  43618. ><DT
  43619. ><A
  43620. HREF="#function.range"
  43621. >range</A
  43622. > -- 
  43623.      Erstellt ein Array mit einem Bereich von Elementen
  43624.     </DT
  43625. ><DT
  43626. ><A
  43627. HREF="#function.reset"
  43628. >reset</A
  43629. > -- 
  43630.      Setzt den internen Zeiger eines Arrays auf sein erstes Element
  43631.     </DT
  43632. ><DT
  43633. ><A
  43634. HREF="#function.rsort"
  43635. >rsort</A
  43636. > -- 
  43637.      Sortiert ein Array in umgekehrter Reihenfolge
  43638.     </DT
  43639. ><DT
  43640. ><A
  43641. HREF="#function.shuffle"
  43642. >shuffle</A
  43643. > -- Mischt die Elemente eines Arrays</DT
  43644. ><DT
  43645. ><A
  43646. HREF="#function.sizeof"
  43647. >sizeof</A
  43648. > -- Alias fⁿr <A
  43649. HREF="#function.count"
  43650. ><B
  43651. CLASS="function"
  43652. >count()</B
  43653. ></A
  43654. ></DT
  43655. ><DT
  43656. ><A
  43657. HREF="#function.sort"
  43658. >sort</A
  43659. > -- Sortiert ein Array</DT
  43660. ><DT
  43661. ><A
  43662. HREF="#function.uasort"
  43663. >uasort</A
  43664. > -- 
  43665.      Sortiert ein Array mittels einer benutzerdefinierten
  43666.      Vergleichsfunktion und behΣlt Indexassoziationen bei.
  43667.     </DT
  43668. ><DT
  43669. ><A
  43670. HREF="#function.uksort"
  43671. >uksort</A
  43672. > -- 
  43673.      Sortiert ein Array nach Schlⁿsseln mittels einer
  43674.      benutzerdefinierten Vergleichsfunktion.
  43675.     </DT
  43676. ><DT
  43677. ><A
  43678. HREF="#function.usort"
  43679. >usort</A
  43680. > -- 
  43681.      Sortiert ein Array nach Werten mittels einer benutzerdefinierten
  43682.      Vergleichsfunktion.
  43683.     </DT
  43684. ></DL
  43685. ></DIV
  43686. ></DIV
  43687. ><H1
  43688. ><A
  43689. NAME="function.array-change-key-case"
  43690. ></A
  43691. >array_change_key_case</H1
  43692. ><DIV
  43693. CLASS="refnamediv"
  43694. ><A
  43695. NAME="AEN7339"
  43696. ></A
  43697. ><P
  43698. >    (PHP 4 >= 4.2.0, PHP 5)</P
  43699. >array_change_key_case -- 
  43700.      Liefert ein Array mit allen String-Schlⁿsseln in Klein- oder Gro▀buchstaben
  43701.     </DIV
  43702. ><DIV
  43703. CLASS="refsect1"
  43704. ><A
  43705. NAME="AEN7342"
  43706. ></A
  43707. ><H2
  43708. >Beschreibung</H2
  43709. >array <B
  43710. CLASS="methodname"
  43711. >array_change_key_case</B
  43712. > ( array input [, int case])<BR
  43713. ></BR
  43714. ><P
  43715. >      <B
  43716. CLASS="function"
  43717. >array_change_key_case()</B
  43718. > wandelt die Schlⁿssel des
  43719.      Arrays <VAR
  43720. CLASS="parameter"
  43721. >input</VAR
  43722. > in Klein- bzw. Gro▀buchstaben um.
  43723.      Die Richtung der Umwandlung wird mit dem optionalen Parameter
  43724.      <VAR
  43725. CLASS="parameter"
  43726. >case</VAR
  43727. > festgelegt, mit dem die zwei Konstanten
  43728.      <TT
  43729. CLASS="constant"
  43730. ><B
  43731. >CASE_UPPER</B
  43732. ></TT
  43733. > und <TT
  43734. CLASS="constant"
  43735. ><B
  43736. >CASE_LOWER</B
  43737. ></TT
  43738. >
  43739.      ⁿbergeben werden k÷nnen. Default ist <TT
  43740. CLASS="constant"
  43741. ><B
  43742. >CASE_LOWER</B
  43743. ></TT
  43744. >.
  43745.      Diese Funktion lΣsst die numerischen Indizes unverΣndert.
  43746.     </P
  43747. ><TABLE
  43748. WIDTH="100%"
  43749. BORDER="0"
  43750. CELLPADDING="0"
  43751. CELLSPACING="0"
  43752. CLASS="EXAMPLE"
  43753. ><TR
  43754. ><TD
  43755. ><DIV
  43756. CLASS="example"
  43757. ><A
  43758. NAME="AEN7360"
  43759. ></A
  43760. ><P
  43761. ><B
  43762. >Beispiel 1. <B
  43763. CLASS="function"
  43764. >array_change_key_case()</B
  43765. ></B
  43766. ></P
  43767. ><TABLE
  43768. BORDER="0"
  43769. BGCOLOR="#E0E0E0"
  43770. CELLPADDING="5"
  43771. ><TR
  43772. ><TD
  43773. ><PRE
  43774. CLASS="php"
  43775. ><?php
  43776. $input_array = array("FirSt" => 1, "SecOnd" => 4);
  43777. print_r(array_change_key_case($input_array, CASE_UPPER));
  43778. ?></PRE
  43779. ></TD
  43780. ></TR
  43781. ></TABLE
  43782. ><P
  43783. >       wird folgendes ausgeben:
  43784.      </P
  43785. ><TABLE
  43786. BORDER="0"
  43787. BGCOLOR="#E0E0E0"
  43788. CELLPADDING="5"
  43789. ><TR
  43790. ><TD
  43791. ><PRE
  43792. CLASS="screen"
  43793. >Array
  43794. (
  43795.     [FIRST] => 1
  43796.     [SECOND] => 4
  43797. )</PRE
  43798. ></TD
  43799. ></TR
  43800. ></TABLE
  43801. ></DIV
  43802. ></TD
  43803. ></TR
  43804. ></TABLE
  43805. ><P
  43806. >      Hat ein Array Indices, die bei einem Durchlauf durch diese Funktion gleich
  43807.      sind (z.B. "keY" and "kEY"), hebt der letztere Wert im Array andere
  43808.      Indices auf.
  43809.     </P
  43810. ></DIV
  43811. ><H1
  43812. ><A
  43813. NAME="function.array-chunk"
  43814. ></A
  43815. >array_chunk</H1
  43816. ><DIV
  43817. CLASS="refnamediv"
  43818. ><A
  43819. NAME="AEN7368"
  43820. ></A
  43821. ><P
  43822. >    (PHP 4 >= 4.2.0, PHP 5)</P
  43823. >array_chunk -- Splittet ein Array in Teile auf</DIV
  43824. ><DIV
  43825. CLASS="refsect1"
  43826. ><A
  43827. NAME="AEN7371"
  43828. ></A
  43829. ><H2
  43830. >Beschreibung</H2
  43831. >array <B
  43832. CLASS="methodname"
  43833. >array_chunk</B
  43834. > ( array input, int size [, bool preserve_keys])<BR
  43835. ></BR
  43836. ><P
  43837. >      <B
  43838. CLASS="function"
  43839. >array_chunk()</B
  43840. > teilt das Array in verschiedene
  43841.      Arrays mit <VAR
  43842. CLASS="parameter"
  43843. >size</VAR
  43844. > Werten auf. Am Ende kann
  43845.      auch ein Array mit weniger Werten erzeugt werden. Die Arrays werden
  43846.      als Teile eines mehrdimensionalen Arrays erzeugt, welches bei Null
  43847.      und beginnend numerisch indiziert ist.
  43848.     </P
  43849. ><P
  43850. >      Sie k÷nnen PHP dazu zwingen, die originalen Schlⁿssel des
  43851.      Arrays input beizubehalten, indem Sie den optionalen Parameter
  43852.      <VAR
  43853. CLASS="parameter"
  43854. >preserve_keys</VAR
  43855. > auf <TT
  43856. CLASS="constant"
  43857. ><B
  43858. >TRUE</B
  43859. ></TT
  43860. > setzen. Geben
  43861.      Sie <TT
  43862. CLASS="constant"
  43863. ><B
  43864. >FALSE</B
  43865. ></TT
  43866. > an, werden in jedem erzeugten Array neue numerische
  43867.      Indizes erzeugt, welche bei Null beginnen. Default ist <TT
  43868. CLASS="constant"
  43869. ><B
  43870. >FALSE</B
  43871. ></TT
  43872. >.
  43873.     </P
  43874. ><TABLE
  43875. WIDTH="100%"
  43876. BORDER="0"
  43877. CELLPADDING="0"
  43878. CELLSPACING="0"
  43879. CLASS="EXAMPLE"
  43880. ><TR
  43881. ><TD
  43882. ><DIV
  43883. CLASS="example"
  43884. ><A
  43885. NAME="AEN7393"
  43886. ></A
  43887. ><P
  43888. ><B
  43889. >Beispiel 1. <B
  43890. CLASS="function"
  43891. >array_chunk()</B
  43892. ></B
  43893. ></P
  43894. ><TABLE
  43895. BORDER="0"
  43896. BGCOLOR="#E0E0E0"
  43897. CELLPADDING="5"
  43898. ><TR
  43899. ><TD
  43900. ><PRE
  43901. CLASS="php"
  43902. ><?php
  43903. $input_array = array('a', 'b', 'c', 'd', 'e');
  43904. print_r(array_chunk($input_array, 2));
  43905. print_r(array_chunk($input_array, 2, TRUE));
  43906. ?></PRE
  43907. ></TD
  43908. ></TR
  43909. ></TABLE
  43910. ><P
  43911. >       wird folgendes ausgeben:
  43912.      </P
  43913. ><TABLE
  43914. BORDER="0"
  43915. BGCOLOR="#E0E0E0"
  43916. CELLPADDING="5"
  43917. ><TR
  43918. ><TD
  43919. ><PRE
  43920. CLASS="screen"
  43921. >Array
  43922. (
  43923.     [0] => Array
  43924.         (
  43925.             [0] => a
  43926.             [1] => b
  43927.         )
  43928.  
  43929.     [1] => Array
  43930.         (
  43931.             [0] => c
  43932.             [1] => d
  43933.         )
  43934.  
  43935.     [2] => Array
  43936.         (
  43937.             [0] => e
  43938.         )
  43939.  
  43940. )
  43941. Array
  43942. (
  43943.     [0] => Array
  43944.         (
  43945.             [0] => a
  43946.             [1] => b
  43947.         )
  43948.  
  43949.     [1] => Array
  43950.         (
  43951.             [2] => c
  43952.             [3] => d
  43953.         )
  43954.  
  43955.     [2] => Array
  43956.         (
  43957.             [4] => e
  43958.         )
  43959.  
  43960. )</PRE
  43961. ></TD
  43962. ></TR
  43963. ></TABLE
  43964. ></DIV
  43965. ></TD
  43966. ></TR
  43967. ></TABLE
  43968. ></DIV
  43969. ><H1
  43970. ><A
  43971. NAME="function.array-combine"
  43972. ></A
  43973. >array_combine</H1
  43974. ><DIV
  43975. CLASS="refnamediv"
  43976. ><A
  43977. NAME="AEN7400"
  43978. ></A
  43979. ><P
  43980. >    (PHP 5)</P
  43981. >array_combine -- 
  43982.      Creates an array by using one array for keys and another for its values
  43983.     </DIV
  43984. ><DIV
  43985. CLASS="refsect1"
  43986. ><A
  43987. NAME="AEN7403"
  43988. ></A
  43989. ><H2
  43990. >Description</H2
  43991. >array <B
  43992. CLASS="methodname"
  43993. >array_combine</B
  43994. > ( array keys, array values)<BR
  43995. ></BR
  43996. ><P
  43997. >      Returns an <A
  43998. HREF="#language.types.array"
  43999. ><B
  44000. CLASS="type"
  44001. >array</B
  44002. ></A
  44003. > by using the values from the
  44004.      <VAR
  44005. CLASS="parameter"
  44006. >keys</VAR
  44007. > array as keys and the values from the
  44008.      <VAR
  44009. CLASS="parameter"
  44010. >values</VAR
  44011. > array as the corresponding values.
  44012.     </P
  44013. ><P
  44014. >      Returns <TT
  44015. CLASS="constant"
  44016. ><B
  44017. >FALSE</B
  44018. ></TT
  44019. > if the number of elements for each array isn't equal or
  44020.      if the arrays are empty.
  44021.     </P
  44022. ><P
  44023. >      <TABLE
  44024. WIDTH="100%"
  44025. BORDER="0"
  44026. CELLPADDING="0"
  44027. CELLSPACING="0"
  44028. CLASS="EXAMPLE"
  44029. ><TR
  44030. ><TD
  44031. ><DIV
  44032. CLASS="example"
  44033. ><A
  44034. NAME="AEN7421"
  44035. ></A
  44036. ><P
  44037. ><B
  44038. >Beispiel 1. A simple <B
  44039. CLASS="function"
  44040. >array_combine()</B
  44041. > example</B
  44042. ></P
  44043. ><TABLE
  44044. BORDER="0"
  44045. BGCOLOR="#E0E0E0"
  44046. CELLPADDING="5"
  44047. ><TR
  44048. ><TD
  44049. ><PRE
  44050. CLASS="php"
  44051. ><?php
  44052. $a = array('green', 'red', 'yellow');
  44053. $b = array('avocado', 'apple', 'banana');
  44054. $c = array_combine($a, $b);
  44055.  
  44056. print_r($c);
  44057. ?></PRE
  44058. ></TD
  44059. ></TR
  44060. ></TABLE
  44061. ><P
  44062. >        Outputs:
  44063.       </P
  44064. ><TABLE
  44065. BORDER="0"
  44066. BGCOLOR="#E0E0E0"
  44067. CELLPADDING="5"
  44068. ><TR
  44069. ><TD
  44070. ><PRE
  44071. CLASS="screen"
  44072. >Array
  44073. (
  44074.     [green]  => avocado
  44075.     [red]    => apple
  44076.     [yellow] => banana
  44077. )</PRE
  44078. ></TD
  44079. ></TR
  44080. ></TABLE
  44081. ></DIV
  44082. ></TD
  44083. ></TR
  44084. ></TABLE
  44085. >
  44086.     </P
  44087. ><P
  44088. >      See also <A
  44089. HREF="#function.array-merge"
  44090. ><B
  44091. CLASS="function"
  44092. >array_merge()</B
  44093. ></A
  44094. >,
  44095.      <A
  44096. HREF="#function.array-walk"
  44097. ><B
  44098. CLASS="function"
  44099. >array_walk()</B
  44100. ></A
  44101. >, and
  44102.      <A
  44103. HREF="#function.array-values"
  44104. ><B
  44105. CLASS="function"
  44106. >array_values()</B
  44107. ></A
  44108. >.
  44109.     </P
  44110. ></DIV
  44111. ><H1
  44112. ><A
  44113. NAME="function.array-count-values"
  44114. ></A
  44115. >array_count_values</H1
  44116. ><DIV
  44117. CLASS="refnamediv"
  44118. ><A
  44119. NAME="AEN7432"
  44120. ></A
  44121. ><P
  44122. >    (PHP 4 , PHP 5)</P
  44123. >array_count_values -- ZΣhlt die Werte eines Arrays</DIV
  44124. ><DIV
  44125. CLASS="refsect1"
  44126. ><A
  44127. NAME="AEN7435"
  44128. ></A
  44129. ><H2
  44130. >Beschreibung</H2
  44131. >array <B
  44132. CLASS="methodname"
  44133. >array_count_values</B
  44134. > ( array input)<BR
  44135. ></BR
  44136. ><P
  44137. >      <B
  44138. CLASS="function"
  44139. >array_count_values()</B
  44140. > gibt ein Array zurⁿck, in
  44141.      dem die Werte des Arrays <VAR
  44142. CLASS="parameter"
  44143. >input</VAR
  44144. > als
  44145.      Schlⁿssel, und deren Anzahl als Werte angegeben sind.
  44146.     </P
  44147. ><P
  44148. >      <TABLE
  44149. WIDTH="100%"
  44150. BORDER="0"
  44151. CELLPADDING="0"
  44152. CELLSPACING="0"
  44153. CLASS="EXAMPLE"
  44154. ><TR
  44155. ><TD
  44156. ><DIV
  44157. CLASS="example"
  44158. ><A
  44159. NAME="AEN7447"
  44160. ></A
  44161. ><P
  44162. ><B
  44163. >Beispiel 1. <B
  44164. CLASS="function"
  44165. >array_count_values()</B
  44166. ></B
  44167. ></P
  44168. ><TABLE
  44169. BORDER="0"
  44170. BGCOLOR="#E0E0E0"
  44171. CELLPADDING="5"
  44172. ><TR
  44173. ><TD
  44174. ><PRE
  44175. CLASS="php"
  44176. ><?php
  44177. $array = array (1, "hello", 1, "world", "hello");
  44178. print_r(array_count_values ($array));
  44179. ?></PRE
  44180. ></TD
  44181. ></TR
  44182. ></TABLE
  44183. ><P
  44184. >        Wird folgendes ausgeben:
  44185.       </P
  44186. ><TABLE
  44187. BORDER="0"
  44188. BGCOLOR="#E0E0E0"
  44189. CELLPADDING="5"
  44190. ><TR
  44191. ><TD
  44192. ><PRE
  44193. CLASS="screen"
  44194. >Array
  44195. (
  44196.     [1] => 2
  44197.     [hello] => 2
  44198.     [world] => 1
  44199. )</PRE
  44200. ></TD
  44201. ></TR
  44202. ></TABLE
  44203. ></DIV
  44204. ></TD
  44205. ></TR
  44206. ></TABLE
  44207. >
  44208.     </P
  44209. ></DIV
  44210. ><H1
  44211. ><A
  44212. NAME="function.array-diff-assoc"
  44213. ></A
  44214. >array_diff_assoc</H1
  44215. ><DIV
  44216. CLASS="refnamediv"
  44217. ><A
  44218. NAME="AEN7454"
  44219. ></A
  44220. ><P
  44221. >    (PHP 4 >= 4.3.0, PHP 5)</P
  44222. >array_diff_assoc -- Computes the difference of arrays with additional index check</DIV
  44223. ><DIV
  44224. CLASS="refsect1"
  44225. ><A
  44226. NAME="AEN7457"
  44227. ></A
  44228. ><H2
  44229. >Description</H2
  44230. >array <B
  44231. CLASS="methodname"
  44232. >array_diff_assoc</B
  44233. > ( array array1, array array2 [, array ...])<BR
  44234. ></BR
  44235. ><P
  44236. >      <B
  44237. CLASS="function"
  44238. >array_diff_assoc()</B
  44239. > returns an <A
  44240. HREF="#language.types.array"
  44241. ><B
  44242. CLASS="type"
  44243. >array</B
  44244. ></A
  44245. >
  44246.      containing all the values from <VAR
  44247. CLASS="parameter"
  44248. >array1</VAR
  44249. >
  44250.      that are not present in any of the other arguments.
  44251.      Note that the keys are used in the comparison unlike
  44252.      <A
  44253. HREF="#function.array-diff"
  44254. ><B
  44255. CLASS="function"
  44256. >array_diff()</B
  44257. ></A
  44258. >.
  44259.     </P
  44260. ><P
  44261. >      <TABLE
  44262. WIDTH="100%"
  44263. BORDER="0"
  44264. CELLPADDING="0"
  44265. CELLSPACING="0"
  44266. CLASS="EXAMPLE"
  44267. ><TR
  44268. ><TD
  44269. ><DIV
  44270. CLASS="example"
  44271. ><A
  44272. NAME="AEN7477"
  44273. ></A
  44274. ><P
  44275. ><B
  44276. >Beispiel 1. <B
  44277. CLASS="function"
  44278. >array_diff_assoc()</B
  44279. > example</B
  44280. ></P
  44281. ><TABLE
  44282. BORDER="0"
  44283. BGCOLOR="#E0E0E0"
  44284. CELLPADDING="5"
  44285. ><TR
  44286. ><TD
  44287. ><PRE
  44288. CLASS="php"
  44289. ><?php
  44290. $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
  44291. $array2 = array("a" => "green", "yellow", "red");
  44292. $result = array_diff_assoc($array1, $array2);
  44293. print_r($result);
  44294. ?></PRE
  44295. ></TD
  44296. ></TR
  44297. ></TABLE
  44298. ><P
  44299. >        The result is:
  44300.       </P
  44301. ><TABLE
  44302. BORDER="0"
  44303. BGCOLOR="#E0E0E0"
  44304. CELLPADDING="5"
  44305. ><TR
  44306. ><TD
  44307. ><PRE
  44308. CLASS="screen"
  44309. >Array
  44310. (
  44311.     [b] => brown
  44312.     [c] => blue
  44313.     [0] => red
  44314. )</PRE
  44315. ></TD
  44316. ></TR
  44317. ></TABLE
  44318. ></DIV
  44319. ></TD
  44320. ></TR
  44321. ></TABLE
  44322. >
  44323.     </P
  44324. ><P
  44325. >      In our example above you see the <VAR
  44326. CLASS="literal"
  44327. >"a" => "green"</VAR
  44328. >
  44329.      pair is present in both arrays and thus it is not in the ouput from the
  44330.      function. Unlike this, the pair <VAR
  44331. CLASS="literal"
  44332. >0 => "red"</VAR
  44333.      is in the ouput because in the second argument <VAR
  44334. CLASS="literal"
  44335. >"red"</VAR
  44336. >
  44337.      has key which is <VAR
  44338. CLASS="literal"
  44339. >1</VAR
  44340. >. 
  44341.     </P
  44342. ><P
  44343. >      Two values from <SPAN
  44344. CLASS="emphasis"
  44345. ><I
  44346. CLASS="emphasis"
  44347. >key => value</I
  44348. ></SPAN
  44349. > pairs are
  44350.      considered equal only if <VAR
  44351. CLASS="literal"
  44352. >(string) $elem1 === (string)
  44353.      $elem2 </VAR
  44354. >. In other words a strict check takes place so 
  44355.      the string representations must be the same.
  44356.      
  44357.     </P
  44358. ><DIV
  44359. CLASS="note"
  44360. ><BLOCKQUOTE
  44361. CLASS="note"
  44362. ><P
  44363. ><B
  44364. >Anmerkung: </B
  44365. >
  44366.       Please note that this function only checks one dimension of a n-dimensional
  44367.       array. Of course you can check deeper dimensions by using, for example, 
  44368.       <VAR
  44369. CLASS="literal"
  44370. >array_diff_assoc($array1[0], $array2[0]);</VAR
  44371. >.
  44372.      </P
  44373. ></BLOCKQUOTE
  44374. ></DIV
  44375. ><P
  44376. >      See also <A
  44377. HREF="#function.array-diff"
  44378. ><B
  44379. CLASS="function"
  44380. >array_diff()</B
  44381. ></A
  44382. >,
  44383.      <A
  44384. HREF="#function.array-intersect"
  44385. ><B
  44386. CLASS="function"
  44387. >array_intersect()</B
  44388. ></A
  44389. >,
  44390.      and <A
  44391. HREF="#function.array-intersect-assoc"
  44392. ><B
  44393. CLASS="function"
  44394. >array_intersect_assoc()</B
  44395. ></A
  44396. >.
  44397.     </P
  44398. ></DIV
  44399. ><H1
  44400. ><A
  44401. NAME="function.array-diff-key"
  44402. ></A
  44403. >array_diff_key</H1
  44404. ><DIV
  44405. CLASS="refnamediv"
  44406. ><A
  44407. NAME="AEN7499"
  44408. ></A
  44409. ><P
  44410. >    (no version information, might be only in CVS)</P
  44411. >array_diff_key -- Computes the difference of arrays using keys for comparison</DIV
  44412. ><DIV
  44413. CLASS="refsect1"
  44414. ><A
  44415. NAME="AEN7502"
  44416. ></A
  44417. ><H2
  44418. >Description</H2
  44419. >array <B
  44420. CLASS="methodname"
  44421. >array_diff_key</B
  44422. > ( array array1, array array2 [, array ...])<BR
  44423. ></BR
  44424. ><P
  44425. >      <B
  44426. CLASS="function"
  44427. >array_diff_key()</B
  44428. > returns an array
  44429.      containing all the values of <VAR
  44430. CLASS="parameter"
  44431. >array1</VAR
  44432. >
  44433.      that have keys that are not present in any of the other arguments.
  44434.      Note that the associativity is preserved. This function is like
  44435.      <A
  44436. HREF="#function.array-diff"
  44437. ><B
  44438. CLASS="function"
  44439. >array_diff()</B
  44440. ></A
  44441. > except the comparison is done on the
  44442.      keys instead of the values.
  44443.     </P
  44444. ><P
  44445. >      <TABLE
  44446. WIDTH="100%"
  44447. BORDER="0"
  44448. CELLPADDING="0"
  44449. CELLSPACING="0"
  44450. CLASS="EXAMPLE"
  44451. ><TR
  44452. ><TD
  44453. ><DIV
  44454. CLASS="example"
  44455. ><A
  44456. NAME="AEN7521"
  44457. ></A
  44458. ><P
  44459. ><B
  44460. >Beispiel 1. <B
  44461. CLASS="function"
  44462. >array_diff_key()</B
  44463. > example</B
  44464. ></P
  44465. ><TABLE
  44466. BORDER="0"
  44467. BGCOLOR="#E0E0E0"
  44468. CELLPADDING="5"
  44469. ><TR
  44470. ><TD
  44471. ><PRE
  44472. CLASS="php"
  44473. ><?php
  44474. $array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
  44475. $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);
  44476.  
  44477. var_dump(array_diff_key($array1, $array2));
  44478. ?></PRE
  44479. ></TD
  44480. ></TR
  44481. ></TABLE
  44482. ><P
  44483. >        The printout of the above program will be:
  44484.       </P
  44485. ><TABLE
  44486. BORDER="0"
  44487. BGCOLOR="#E0E0E0"
  44488. CELLPADDING="5"
  44489. ><TR
  44490. ><TD
  44491. ><PRE
  44492. CLASS="screen"
  44493. >array(2) {
  44494.   ["red"]=>
  44495.   int(2)
  44496.   ["purple"]=>
  44497.   int(4)
  44498. }</PRE
  44499. ></TD
  44500. ></TR
  44501. ></TABLE
  44502. ></DIV
  44503. ></TD
  44504. ></TR
  44505. ></TABLE
  44506. >
  44507.     </P
  44508. ><P
  44509. >      The two keys from the <VAR
  44510. CLASS="literal"
  44511. >key => value</VAR
  44512. > pairs are
  44513.      considered equal only if 
  44514.      <VAR
  44515. CLASS="literal"
  44516. >(string) $key1 === (string) $key2 </VAR
  44517. >. In other words
  44518.      a strict type check is executed so the string representation must be
  44519.      the same.
  44520.     </P
  44521. ><DIV
  44522. CLASS="note"
  44523. ><BLOCKQUOTE
  44524. CLASS="note"
  44525. ><P
  44526. ><B
  44527. >Anmerkung: </B
  44528. >
  44529.       Please note that this function only checks one dimension of a n-dimensional
  44530.       array. Of course you can check deeper dimensions by using
  44531.       <VAR
  44532. CLASS="literal"
  44533. >array_diff_key($array1[0], $array2[0]);</VAR
  44534. >.
  44535.      </P
  44536. ></BLOCKQUOTE
  44537. ></DIV
  44538. ><P
  44539. >      See also <A
  44540. HREF="#function.array-diff"
  44541. ><B
  44542. CLASS="function"
  44543. >array_diff()</B
  44544. ></A
  44545. >,
  44546.      <A
  44547. HREF="#function.array-udiff"
  44548. ><B
  44549. CLASS="function"
  44550. >array_udiff()</B
  44551. ></A
  44552. >
  44553.      <A
  44554. HREF="#function.array-diff-assoc"
  44555. ><B
  44556. CLASS="function"
  44557. >array_diff_assoc()</B
  44558. ></A
  44559. >,
  44560.      <A
  44561. HREF="#function.array-diff-uassoc"
  44562. ><B
  44563. CLASS="function"
  44564. >array_diff_uassoc()</B
  44565. ></A
  44566. >,
  44567.      <A
  44568. HREF="#function.array-udiff-assoc"
  44569. ><B
  44570. CLASS="function"
  44571. >array_udiff_assoc()</B
  44572. ></A
  44573. >,
  44574.      <A
  44575. HREF="#function.array-udiff-uassoc"
  44576. ><B
  44577. CLASS="function"
  44578. >array_udiff_uassoc()</B
  44579. ></A
  44580. >,
  44581.      <A
  44582. HREF="#function.array-diff-ukey"
  44583. ><B
  44584. CLASS="function"
  44585. >array_diff_ukey()</B
  44586. ></A
  44587. >,
  44588.      <A
  44589. HREF="#function.array-intersect"
  44590. ><B
  44591. CLASS="function"
  44592. >array_intersect()</B
  44593. ></A
  44594. >,
  44595.      <A
  44596. HREF="#function.array-intersect-assoc"
  44597. ><B
  44598. CLASS="function"
  44599. >array_intersect_assoc()</B
  44600. ></A
  44601. >,
  44602.      <A
  44603. HREF="#function.array-intersect-uassoc"
  44604. ><B
  44605. CLASS="function"
  44606. >array_intersect_uassoc()</B
  44607. ></A
  44608. >,
  44609.      <A
  44610. HREF="#function.array-intersect-key"
  44611. ><B
  44612. CLASS="function"
  44613. >array_intersect_key()</B
  44614. ></A
  44615. > and
  44616.      <A
  44617. HREF="#function.array-intersect-ukey"
  44618. ><B
  44619. CLASS="function"
  44620. >array_intersect_ukey()</B
  44621. ></A
  44622. >.
  44623.     </P
  44624. ></DIV
  44625. ><H1
  44626. ><A
  44627. NAME="function.array-diff-uassoc"
  44628. ></A
  44629. >array_diff_uassoc</H1
  44630. ><DIV
  44631. CLASS="refnamediv"
  44632. ><A
  44633. NAME="AEN7547"
  44634. ></A
  44635. ><P
  44636. >    (PHP 5)</P
  44637. >array_diff_uassoc -- 
  44638.      Computes the difference of arrays with additional index check
  44639.      which is performed by a user supplied callback function
  44640.     </DIV
  44641. ><DIV
  44642. CLASS="refsect1"
  44643. ><A
  44644. NAME="AEN7550"
  44645. ></A
  44646. ><H2
  44647. >Description</H2
  44648. >array <B
  44649. CLASS="methodname"
  44650. >array_diff_uassoc</B
  44651. > ( array array1, array array2 [, array ..., callback key_compare_func])<BR
  44652. ></BR
  44653. ><P
  44654. >      <B
  44655. CLASS="function"
  44656. >array_diff_uassoc()</B
  44657. > returns an <A
  44658. HREF="#language.types.array"
  44659. ><B
  44660. CLASS="type"
  44661. >array</B
  44662. ></A
  44663. >
  44664.      containing all the values from <VAR
  44665. CLASS="parameter"
  44666. >array1</VAR
  44667. >
  44668.      that are not present in any of the other arguments.
  44669.      Note that the keys are used in the comparison unlike
  44670.      <A
  44671. HREF="#function.array-diff"
  44672. ><B
  44673. CLASS="function"
  44674. >array_diff()</B
  44675. ></A
  44676. >. This comparison is done by a user supplied callback function.
  44677.      It must return an integer less than, equal
  44678.      to, or greater than zero if the first argument is considered to
  44679.      be respectively less than, equal to, or greater than the
  44680.      second. This is unlike <A
  44681. HREF="#function.array-diff-assoc"
  44682. ><B
  44683. CLASS="function"
  44684. >array_diff_assoc()</B
  44685. ></A
  44686. > where an
  44687.      internal function for comparing the indices is used.
  44688.     </P
  44689. ><P
  44690. >      <TABLE
  44691. WIDTH="100%"
  44692. BORDER="0"
  44693. CELLPADDING="0"
  44694. CELLSPACING="0"
  44695. CLASS="EXAMPLE"
  44696. ><TR
  44697. ><TD
  44698. ><DIV
  44699. CLASS="example"
  44700. ><A
  44701. NAME="AEN7574"
  44702. ></A
  44703. ><P
  44704. ><B
  44705. >Beispiel 1. <B
  44706. CLASS="function"
  44707. >array_diff_uassoc()</B
  44708. > example</B
  44709. ></P
  44710. ><TABLE
  44711. BORDER="0"
  44712. BGCOLOR="#E0E0E0"
  44713. CELLPADDING="5"
  44714. ><TR
  44715. ><TD
  44716. ><PRE
  44717. CLASS="php"
  44718. ><?php
  44719. function key_compare_func($a, $b) 
  44720. {
  44721.     if ($a === $b) {
  44722.         return 0;
  44723.     }
  44724.     return ($a > $b)? 1:-1;
  44725. }
  44726.  
  44727. $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
  44728. $array2 = array("a" => "green", "yellow", "red");
  44729. $result = array_diff_uassoc($array1, $array2, "key_compare_func");
  44730. ?></PRE
  44731. ></TD
  44732. ></TR
  44733. ></TABLE
  44734. ><P
  44735. >        The result is:
  44736.       </P
  44737. ><TABLE
  44738. BORDER="0"
  44739. BGCOLOR="#E0E0E0"
  44740. CELLPADDING="5"
  44741. ><TR
  44742. ><TD
  44743. ><PRE
  44744. CLASS="screen"
  44745. >Array
  44746. (
  44747.     [b] => brown
  44748.     [c] => blue
  44749.     [0] => red
  44750. )</PRE
  44751. ></TD
  44752. ></TR
  44753. ></TABLE
  44754. ></DIV
  44755. ></TD
  44756. ></TR
  44757. ></TABLE
  44758. >
  44759.     </P
  44760. ><P
  44761. >      In our example above you see the <VAR
  44762. CLASS="literal"
  44763. >"a" => "green"</VAR
  44764. >
  44765.      pair is present in both arrays and thus it is not in the ouput from the
  44766.      function. Unlike this, the pair <VAR
  44767. CLASS="literal"
  44768. >0 => "red"</VAR
  44769. >
  44770.      is in the ouput because in the second argument <VAR
  44771. CLASS="literal"
  44772. >"red"</VAR
  44773. >
  44774.      has key which is <VAR
  44775. CLASS="literal"
  44776. >1</VAR
  44777. >.
  44778.     </P
  44779. ><P
  44780. >      The equality of 2 indices is checked by the user supplied callback function.
  44781.     </P
  44782. ><DIV
  44783. CLASS="note"
  44784. ><BLOCKQUOTE
  44785. CLASS="note"
  44786. ><P
  44787. ><B
  44788. >Anmerkung: </B
  44789. >
  44790.       Please note that this function only checks one dimension of a n-dimensional
  44791.       array. Of course you can check deeper dimensions by using, for example,
  44792.       <VAR
  44793. CLASS="literal"
  44794. >array_diff_uassoc($array1[0], $array2[0], "key_compare_func");</VAR
  44795. >.
  44796.      </P
  44797. ></BLOCKQUOTE
  44798. ></DIV
  44799. ><P
  44800. >      See also
  44801.      <A
  44802. HREF="#function.array-diff"
  44803. ><B
  44804. CLASS="function"
  44805. >array_diff()</B
  44806. ></A
  44807. >,
  44808.      <A
  44809. HREF="#function.array-diff-assoc"
  44810. ><B
  44811. CLASS="function"
  44812. >array_diff_assoc()</B
  44813. ></A
  44814. >,
  44815.      <A
  44816. HREF="#function.array-udiff"
  44817. ><B
  44818. CLASS="function"
  44819. >array_udiff()</B
  44820. ></A
  44821. >,
  44822.      <A
  44823. HREF="#function.array-udiff-assoc"
  44824. ><B
  44825. CLASS="function"
  44826. >array_udiff_assoc()</B
  44827. ></A
  44828. >, 
  44829.      <A
  44830. HREF="#function.array-udiff-uassoc"
  44831. ><B
  44832. CLASS="function"
  44833. >array_udiff_uassoc()</B
  44834. ></A
  44835. >, 
  44836.      <A
  44837. HREF="#function.array-intersect"
  44838. ><B
  44839. CLASS="function"
  44840. >array_intersect()</B
  44841. ></A
  44842. >,  
  44843.      <A
  44844. HREF="#function.array-intersect-assoc"
  44845. ><B
  44846. CLASS="function"
  44847. >array_intersect_assoc()</B
  44848. ></A
  44849. >,
  44850.      <A
  44851. HREF="#function.array-uintersect"
  44852. ><B
  44853. CLASS="function"
  44854. >array_uintersect()</B
  44855. ></A
  44856. >,  
  44857.      <A
  44858. HREF="#function.array-uintersect-assoc"
  44859. ><B
  44860. CLASS="function"
  44861. >array_uintersect_assoc()</B
  44862. ></A
  44863. > and 
  44864.      <A
  44865. HREF="#function.array-uintersect-uassoc"
  44866. ><B
  44867. CLASS="function"
  44868. >array_uintersect_uassoc()</B
  44869. ></A
  44870. >.
  44871.     </P
  44872. ></DIV
  44873. ><H1
  44874. ><A
  44875. NAME="function.array-diff-ukey"
  44876. ></A
  44877. >array_diff_ukey</H1
  44878. ><DIV
  44879. CLASS="refnamediv"
  44880. ><A
  44881. NAME="AEN7601"
  44882. ></A
  44883. ><P
  44884. >    (no version information, might be only in CVS)</P
  44885. >array_diff_ukey -- Computes the difference of arrays using a callback function on the keys for comparison</DIV
  44886. ><DIV
  44887. CLASS="refsect1"
  44888. ><A
  44889. NAME="AEN7604"
  44890. ></A
  44891. ><H2
  44892. >Description</H2
  44893. >array <B
  44894. CLASS="methodname"
  44895. >array_diff_ukey</B
  44896. > ( array array1, array array2 [, array ..., callback key_compare_func])<BR
  44897. ></BR
  44898. ><P
  44899. >      <B
  44900. CLASS="function"
  44901. >array_diff_ukey()</B
  44902. > returns an array
  44903.      containing all the values of <VAR
  44904. CLASS="parameter"
  44905. >array1</VAR
  44906. >
  44907.      that have keys that are not present in any of the other arguments.
  44908.      Note that the associativity is preserved. This function is like
  44909.      <A
  44910. HREF="#function.array-diff"
  44911. ><B
  44912. CLASS="function"
  44913. >array_diff()</B
  44914. ></A
  44915. > except the comparison is done on the
  44916.      keys instead of the values.
  44917.     </P
  44918. ><P
  44919. >      This comparison is done by a user supplied callback function.
  44920.      It must return an integer less than, equal to, or greater than zero if the
  44921.      first key is considered to be respectively less than, equal to, or
  44922.      greater than the second.
  44923.     </P
  44924. ><P
  44925. >      <TABLE
  44926. WIDTH="100%"
  44927. BORDER="0"
  44928. CELLPADDING="0"
  44929. CELLSPACING="0"
  44930. CLASS="EXAMPLE"
  44931. ><TR
  44932. ><TD
  44933. ><DIV
  44934. CLASS="example"
  44935. ><A
  44936. NAME="AEN7627"
  44937. ></A
  44938. ><P
  44939. ><B
  44940. >Beispiel 1. <B
  44941. CLASS="function"
  44942. >array_diff_ukey()</B
  44943. > example</B
  44944. ></P
  44945. ><TABLE
  44946. BORDER="0"
  44947. BGCOLOR="#E0E0E0"
  44948. CELLPADDING="5"
  44949. ><TR
  44950. ><TD
  44951. ><PRE
  44952. CLASS="php"
  44953. ><?php
  44954. function key_compare_func($key1, $key2)
  44955. {
  44956.     if ($key1 == $key2)
  44957.         return 0;
  44958.     else if ($key1 > $key2)
  44959.         return 1;
  44960.     else
  44961.         return -1;
  44962. }
  44963.  
  44964. $array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
  44965. $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);
  44966.  
  44967. var_dump(array_diff_ukey($array1, $array2, 'key_compare_func'));
  44968. ?></PRE
  44969. ></TD
  44970. ></TR
  44971. ></TABLE
  44972. ><P
  44973. >        The printout of the above program will be:
  44974.       </P
  44975. ><TABLE
  44976. BORDER="0"
  44977. BGCOLOR="#E0E0E0"
  44978. CELLPADDING="5"
  44979. ><TR
  44980. ><TD
  44981. ><PRE
  44982. CLASS="screen"
  44983. >array(2) {
  44984.   ["red"]=>
  44985.   int(2)
  44986.   ["purple"]=>
  44987.   int(4)
  44988. }</PRE
  44989. ></TD
  44990. ></TR
  44991. ></TABLE
  44992. ></DIV
  44993. ></TD
  44994. ></TR
  44995. ></TABLE
  44996. >
  44997.     </P
  44998. ><P
  44999. >      The two keys from the <VAR
  45000. CLASS="literal"
  45001. >key => value</VAR
  45002. > pairs are
  45003.      considered equal only if 
  45004.      <VAR
  45005. CLASS="literal"
  45006. >(string) $key1 === (string) $key2 </VAR
  45007. >. In other words
  45008.      a strict type check is executed so the string representation must be
  45009.      the same.
  45010.     </P
  45011. ><DIV
  45012. CLASS="note"
  45013. ><BLOCKQUOTE
  45014. CLASS="note"
  45015. ><P
  45016. ><B
  45017. >Anmerkung: </B
  45018. >
  45019.       Please note that this function only checks one dimension of a n-dimensional
  45020.       array. Of course you can check deeper dimensions by using
  45021.       <VAR
  45022. CLASS="literal"
  45023. >array_diff_ukey($array1[0], $array2[0], 'callback_func');</VAR
  45024. >.
  45025.      </P
  45026. ></BLOCKQUOTE
  45027. ></DIV
  45028. ><P
  45029. >      See also <A
  45030. HREF="#function.array-diff"
  45031. ><B
  45032. CLASS="function"
  45033. >array_diff()</B
  45034. ></A
  45035. >,
  45036.      <A
  45037. HREF="#function.array-udiff"
  45038. ><B
  45039. CLASS="function"
  45040. >array_udiff()</B
  45041. ></A
  45042. >
  45043.      <A
  45044. HREF="#function.array-diff-assoc"
  45045. ><B
  45046. CLASS="function"
  45047. >array_diff_assoc()</B
  45048. ></A
  45049. >,
  45050.      <A
  45051. HREF="#function.array-diff-uassoc"
  45052. ><B
  45053. CLASS="function"
  45054. >array_diff_uassoc()</B
  45055. ></A
  45056. >,
  45057.      <A
  45058. HREF="#function.array-udiff-assoc"
  45059. ><B
  45060. CLASS="function"
  45061. >array_udiff_assoc()</B
  45062. ></A
  45063. >,
  45064.      <A
  45065. HREF="#function.array-udiff-uassoc"
  45066. ><B
  45067. CLASS="function"
  45068. >array_udiff_uassoc()</B
  45069. ></A
  45070. >,
  45071.      <A
  45072. HREF="#function.array-diff-key"
  45073. ><B
  45074. CLASS="function"
  45075. >array_diff_key()</B
  45076. ></A
  45077. >,
  45078.      <A
  45079. HREF="#function.array-intersect"
  45080. ><B
  45081. CLASS="function"
  45082. >array_intersect()</B
  45083. ></A
  45084. >,
  45085.      <A
  45086. HREF="#function.array-intersect-assoc"
  45087. ><B
  45088. CLASS="function"
  45089. >array_intersect_assoc()</B
  45090. ></A
  45091. >,
  45092.      <A
  45093. HREF="#function.array-intersect-uassoc"
  45094. ><B
  45095. CLASS="function"
  45096. >array_intersect_uassoc()</B
  45097. ></A
  45098. >,
  45099.      <A
  45100. HREF="#function.array-intersect-key"
  45101. ><B
  45102. CLASS="function"
  45103. >array_intersect_key()</B
  45104. ></A
  45105. > and
  45106.      <A
  45107. HREF="#function.array-intersect-ukey"
  45108. ><B
  45109. CLASS="function"
  45110. >array_intersect_ukey()</B
  45111. ></A
  45112. >.
  45113.     </P
  45114. ></DIV
  45115. ><H1
  45116. ><A
  45117. NAME="function.array-diff"
  45118. ></A
  45119. >array_diff</H1
  45120. ><DIV
  45121. CLASS="refnamediv"
  45122. ><A
  45123. NAME="AEN7653"
  45124. ></A
  45125. ><P
  45126. >    (PHP 4 >= 4.0.1, PHP 5)</P
  45127. >array_diff -- Ermittelt die Unterschiede von Arrays</DIV
  45128. ><DIV
  45129. CLASS="refsect1"
  45130. ><A
  45131. NAME="AEN7656"
  45132. ></A
  45133. ><H2
  45134. >Beschreibung</H2
  45135. >array <B
  45136. CLASS="methodname"
  45137. >array_diff</B
  45138. > ( array array1, array array2 [, array ...])<BR
  45139. ></BR
  45140. ><P
  45141. >      <B
  45142. CLASS="function"
  45143. >array_diff()</B
  45144. > gibt ein Array mit allen Werten von
  45145.      <VAR
  45146. CLASS="parameter"
  45147. >array1</VAR
  45148. >, welche in keinem der anderen Argumente
  45149.      enthalten sind, zurⁿck. Beachten Sie, dass Schlⁿssel erhalten bleiben.
  45150.     </P
  45151. ><P
  45152. >      <TABLE
  45153. WIDTH="100%"
  45154. BORDER="0"
  45155. CELLPADDING="0"
  45156. CELLSPACING="0"
  45157. CLASS="EXAMPLE"
  45158. ><TR
  45159. ><TD
  45160. ><DIV
  45161. CLASS="example"
  45162. ><A
  45163. NAME="AEN7674"
  45164. ></A
  45165. ><P
  45166. ><B
  45167. >Beispiel 1. <B
  45168. CLASS="function"
  45169. >array_diff()</B
  45170. ></B
  45171. ></P
  45172. ><TABLE
  45173. BORDER="0"
  45174. BGCOLOR="#E0E0E0"
  45175. CELLPADDING="5"
  45176. ><TR
  45177. ><TD
  45178. ><PRE
  45179. CLASS="php"
  45180. >$array1 = array ("a" => "grⁿn", "rot", "blau", "rot");
  45181. $array2 = array ("b" => "grⁿn", "gelb", "rot");
  45182. $result = array_diff ($array1, $array2);</PRE
  45183. ></TD
  45184. ></TR
  45185. ></TABLE
  45186. ></DIV
  45187. ></TD
  45188. ></TR
  45189. ></TABLE
  45190. >
  45191.     </P
  45192. ><P
  45193. >      Dies speichert <VAR
  45194. CLASS="literal"
  45195. >array("blau");</VAR
  45196. > in
  45197.      <VAR
  45198. CLASS="varname"
  45199. >$result</VAR
  45200. >.  Mehrfache Vorkommen in $array1
  45201.      werden auf die gleiche Weise behandelt.
  45202.     </P
  45203. ><DIV
  45204. CLASS="note"
  45205. ><BLOCKQUOTE
  45206. CLASS="note"
  45207. ><P
  45208. ><B
  45209. >Anmerkung: </B
  45210. >
  45211.       Zwei Elemente werden nur dann als gleich angesehen, wenn
  45212.       <VAR
  45213. CLASS="literal"
  45214. >(string) $elem1 === (string) $elem2</VAR
  45215. >. In Worten:
  45216.       Wenn die String-ReprΣsentation die gleiche ist.
  45217.      </P
  45218. ></BLOCKQUOTE
  45219. ></DIV
  45220. ><DIV
  45221. CLASS="note"
  45222. ><BLOCKQUOTE
  45223. CLASS="note"
  45224. ><P
  45225. ><B
  45226. >Anmerkung: </B
  45227. >
  45228.       Beachten Sie, dass diese Funktion nur eine Dimension eines n-dimensionalen
  45229.       Arrays prⁿft. Natⁿrlich k÷nnen Sie tiefere Dimensionen prⁿfen, indem Sie
  45230.       z.B. <VAR
  45231. CLASS="literal"
  45232. >array_diff($array1[0], $array2[0]);</VAR
  45233. > benutzen.
  45234.      </P
  45235. ></BLOCKQUOTE
  45236. ></DIV
  45237. ><DIV
  45238. CLASS="warning"
  45239. ><P
  45240. ></P
  45241. ><TABLE
  45242. CLASS="warning"
  45243. BORDER="1"
  45244. WIDTH="100%"
  45245. ><TR
  45246. ><TD
  45247. ALIGN="CENTER"
  45248. ><B
  45249. >Warnung</B
  45250. ></TD
  45251. ></TR
  45252. ><TR
  45253. ><TD
  45254. ALIGN="LEFT"
  45255. ><P
  45256. >       Dies war in PHP 4.0.4 fehlerhaft!
  45257.      </P
  45258. ></TD
  45259. ></TR
  45260. ></TABLE
  45261. ></DIV
  45262. ><P
  45263. >      Siehe auch <A
  45264. HREF="#function.array-diff-assoc"
  45265. ><B
  45266. CLASS="function"
  45267. >array_diff_assoc()</B
  45268. ></A
  45269. >,
  45270.      <A
  45271. HREF="#function.array-intersect"
  45272. ><B
  45273. CLASS="function"
  45274. >array_intersect()</B
  45275. ></A
  45276. > und
  45277.      <A
  45278. HREF="#function.array-intersect-assoc"
  45279. ><B
  45280. CLASS="function"
  45281. >array_intersect_assoc()</B
  45282. ></A
  45283. >.
  45284.     </P
  45285. ></DIV
  45286. ><H1
  45287. ><A
  45288. NAME="function.array-fill"
  45289. ></A
  45290. >array_fill</H1
  45291. ><DIV
  45292. CLASS="refnamediv"
  45293. ><A
  45294. NAME="AEN7694"
  45295. ></A
  45296. ><P
  45297. >    (PHP 4 >= 4.2.0, PHP 5)</P
  45298. >array_fill -- Fⁿllt ein Array mit Werten</DIV
  45299. ><DIV
  45300. CLASS="refsect1"
  45301. ><A
  45302. NAME="AEN7697"
  45303. ></A
  45304. ><H2
  45305. >Beschreibung</H2
  45306. >array <B
  45307. CLASS="methodname"
  45308. >array_fill</B
  45309. > ( int start_index, int num, mixed value)<BR
  45310. ></BR
  45311. ><P
  45312. >      <B
  45313. CLASS="function"
  45314. >array_fill()</B
  45315. > fⁿllt ein Array mit
  45316.      <VAR
  45317. CLASS="parameter"
  45318. >num</VAR
  45319. > EintrΣgen des Wertes des
  45320.      <VAR
  45321. CLASS="parameter"
  45322. >value</VAR
  45323. > Parameters. Die Indizes des Arrays
  45324.      beginnen mit dem <VAR
  45325. CLASS="parameter"
  45326. >start_index</VAR
  45327. > Parameter.
  45328.      Beachten Sie, dass <VAR
  45329. CLASS="parameter"
  45330. >num</VAR
  45331. > eine Zahl gr÷▀er als
  45332.      Null sein muss, ansonsten gibt PHP eine Warnung aus.
  45333.     </P
  45334. ><P
  45335. >      <TABLE
  45336. WIDTH="100%"
  45337. BORDER="0"
  45338. CELLPADDING="0"
  45339. CELLSPACING="0"
  45340. CLASS="EXAMPLE"
  45341. ><TR
  45342. ><TD
  45343. ><DIV
  45344. CLASS="example"
  45345. ><A
  45346. NAME="AEN7718"
  45347. ></A
  45348. ><P
  45349. ><B
  45350. >Beispiel 1. <B
  45351. CLASS="function"
  45352. >array_fill()</B
  45353. ></B
  45354. ></P
  45355. ><TABLE
  45356. BORDER="0"
  45357. BGCOLOR="#E0E0E0"
  45358. CELLPADDING="5"
  45359. ><TR
  45360. ><TD
  45361. ><PRE
  45362. CLASS="php"
  45363. ><?php
  45364. $a = array_fill(5, 6, 'Banane');
  45365. print_r($a);
  45366. ?></PRE
  45367. ></TD
  45368. ></TR
  45369. ></TABLE
  45370. ><P
  45371. >        Nun ist <VAR
  45372. CLASS="varname"
  45373. >$a</VAR
  45374. >:
  45375.       </P
  45376. ><TABLE
  45377. BORDER="0"
  45378. BGCOLOR="#E0E0E0"
  45379. CELLPADDING="5"
  45380. ><TR
  45381. ><TD
  45382. ><PRE
  45383. CLASS="screen"
  45384. >Array
  45385. (
  45386.     [5]  => Banane
  45387.     [6]  => Banane
  45388.     [7]  => Banane
  45389.     [8]  => Banane
  45390.     [9]  => Banane
  45391.     [10] => Banane
  45392. )</PRE
  45393. ></TD
  45394. ></TR
  45395. ></TABLE
  45396. ></DIV
  45397. ></TD
  45398. ></TR
  45399. ></TABLE
  45400. >
  45401.     </P
  45402. ></DIV
  45403. ><H1
  45404. ><A
  45405. NAME="function.array-filter"
  45406. ></A
  45407. >array_filter</H1
  45408. ><DIV
  45409. CLASS="refnamediv"
  45410. ><A
  45411. NAME="AEN7726"
  45412. ></A
  45413. ><P
  45414. >    (PHP 4 >= 4.0.6, PHP 5)</P
  45415. >array_filter -- 
  45416.      Filtert Elemente eines Arrays mittels einer Callback-Funktion
  45417.     </DIV
  45418. ><DIV
  45419. CLASS="refsect1"
  45420. ><A
  45421. NAME="AEN7729"
  45422. ></A
  45423. ><H2
  45424. >Beschreibung</H2
  45425. >array <B
  45426. CLASS="methodname"
  45427. >array_filter</B
  45428. > ( array input [, callback function])<BR
  45429. ></BR
  45430. ><P
  45431. >      <B
  45432. CLASS="function"
  45433. >array_filter()</B
  45434. > ⁿbergibt nacheinander alle Werte in dem
  45435.      Array <VAR
  45436. CLASS="parameter"
  45437. >input</VAR
  45438. > and die <VAR
  45439. CLASS="parameter"
  45440. >callback</VAR
  45441. >
  45442.      Funktion. Gibt die <VAR
  45443. CLASS="parameter"
  45444. >callback</VAR
  45445. > Funktion true zurⁿck,
  45446.      wird der aktuelle Wert von <VAR
  45447. CLASS="parameter"
  45448. >input</VAR
  45449. > in das Ergebnis-Array
  45450.      geschrieben. Die Schlⁿssel des Arrays bleiben erhalten.
  45451.     </P
  45452. ><P
  45453. >      <TABLE
  45454. WIDTH="100%"
  45455. BORDER="0"
  45456. CELLPADDING="0"
  45457. CELLSPACING="0"
  45458. CLASS="EXAMPLE"
  45459. ><TR
  45460. ><TD
  45461. ><DIV
  45462. CLASS="example"
  45463. ><A
  45464. NAME="AEN7747"
  45465. ></A
  45466. ><P
  45467. ><B
  45468. >Beispiel 1. <B
  45469. CLASS="function"
  45470. >array_filter()</B
  45471. ></B
  45472. ></P
  45473. ><TABLE
  45474. BORDER="0"
  45475. BGCOLOR="#E0E0E0"
  45476. CELLPADDING="5"
  45477. ><TR
  45478. ><TD
  45479. ><PRE
  45480. CLASS="php"
  45481. ><?php
  45482. function ungerade($var) {
  45483.     return ($var % 2 == 1);
  45484. }
  45485.  
  45486. function gerade($var) {
  45487.     return ($var % 2 == 0);
  45488. }
  45489.  
  45490. $array1 = array ("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
  45491. $array2 = array (6, 7, 8, 9, 10, 11, 12);
  45492.  
  45493. echo "Ungerade :\n";
  45494. print_r(array_filter($array1, "ungerade"));
  45495. echo "Gerade:\n";
  45496. print_r(array_filter($array2, "gerade"));
  45497. ?></PRE
  45498. ></TD
  45499. ></TR
  45500. ></TABLE
  45501. ><P
  45502. >        Wird folgendes ausgeben:
  45503.       </P
  45504. ><TABLE
  45505. BORDER="0"
  45506. BGCOLOR="#E0E0E0"
  45507. CELLPADDING="5"
  45508. ><TR
  45509. ><TD
  45510. ><PRE
  45511. CLASS="php"
  45512. >Ungerade :
  45513. Array
  45514. (
  45515.     [a] => 1
  45516.     [c] => 3
  45517.     [e] => 5
  45518. )
  45519. Gerade:
  45520. Array
  45521. (
  45522.     [0] => 6
  45523.     [2] => 8
  45524.     [4] => 10
  45525.     [6] => 12
  45526. )</PRE
  45527. ></TD
  45528. ></TR
  45529. ></TABLE
  45530. ></DIV
  45531. ></TD
  45532. ></TR
  45533. ></TABLE
  45534. >
  45535.     </P
  45536. ><P
  45537. >      Von der Benutzerfunktion aus darf das Array selbst nicht geΣndert
  45538.      werden, wie zum Beispiel durch Hinzufⁿgen oder L÷schen eines
  45539.      Elementes, oder auch L÷schen des Arrays, auf das
  45540.      <B
  45541. CLASS="function"
  45542. >array_filter()</B
  45543. > angewendet wird. Ist das Array
  45544.      geΣndert, so ist das Verhalten dieser Funktion undefiniert.
  45545.     </P
  45546. ><P
  45547. >      Siehe auch <A
  45548. HREF="#function.array-map"
  45549. ><B
  45550. CLASS="function"
  45551. >array_map()</B
  45552. ></A
  45553. >,
  45554.      <A
  45555. HREF="#function.array-reduce"
  45556. ><B
  45557. CLASS="function"
  45558. >array_reduce()</B
  45559. ></A
  45560. > und <A
  45561. HREF="#function.array-walk"
  45562. ><B
  45563. CLASS="function"
  45564. >array_walk()</B
  45565. ></A
  45566. >.
  45567.     </P
  45568. ></DIV
  45569. ><H1
  45570. ><A
  45571. NAME="function.array-flip"
  45572. ></A
  45573. >array_flip</H1
  45574. ><DIV
  45575. CLASS="refnamediv"
  45576. ><A
  45577. NAME="AEN7760"
  45578. ></A
  45579. ><P
  45580. >    (PHP 4 , PHP 5)</P
  45581. >array_flip -- Vertauscht Werte und Schlⁿssel in einem Array</DIV
  45582. ><DIV
  45583. CLASS="refsect1"
  45584. ><A
  45585. NAME="AEN7763"
  45586. ></A
  45587. ><H2
  45588. >Beschreibung</H2
  45589. >array <B
  45590. CLASS="methodname"
  45591. >array_flip</B
  45592. > ( array trans)<BR
  45593. ></BR
  45594. ><P
  45595. >      <B
  45596. CLASS="function"
  45597. >array_flip()</B
  45598. > gibt ein Array
  45599.      in umgekehrter Reihenfolge zurⁿck, d.h. Schlⁿssel von
  45600.      <VAR
  45601. CLASS="parameter"
  45602. >trans</VAR
  45603. > werden Werte, und die Werte
  45604.      von <VAR
  45605. CLASS="parameter"
  45606. >trans</VAR
  45607. > werden zu Schlⁿsseln.
  45608.     </P
  45609. ><P
  45610. >      Beachten Sie, dass die Werte von <VAR
  45611. CLASS="parameter"
  45612. >trans</VAR
  45613. > gⁿltige
  45614.      Schlⁿssel sein mⁿssen, z.B. haben sie entweder <A
  45615. HREF="#language.types.integer"
  45616. ><B
  45617. CLASS="type"
  45618. >integer</B
  45619. ></A
  45620. >
  45621.      oder <A
  45622. HREF="#language.types.string"
  45623. ><B
  45624. CLASS="type"
  45625. >string</B
  45626. ></A
  45627. > zu sein. Ist ein Wert vom falschen Typ wird
  45628.      eine Warnung ausgegeben, und das Schlⁿssel/Werte-Paar <SPAN
  45629. CLASS="emphasis"
  45630. ><I
  45631. CLASS="emphasis"
  45632. >wird
  45633.      nicht vertauscht</I
  45634. ></SPAN
  45635. >.
  45636.     </P
  45637. ><P
  45638. >      Kommt ein Wert mehrmals vor, wird der letzte Schlⁿssel mit seinem
  45639.      Wert vertauscht, und alle anderen Schlⁿssel- Wertepaare gehen
  45640.      verloren.
  45641.     </P
  45642. ><P
  45643. >      <B
  45644. CLASS="function"
  45645. >array_flip()</B
  45646. > gibt im Fehlerfall
  45647.      <TT
  45648. CLASS="constant"
  45649. ><B
  45650. >FALSE</B
  45651. ></TT
  45652. > zurⁿck.
  45653.     </P
  45654. ><P
  45655. >      <TABLE
  45656. WIDTH="100%"
  45657. BORDER="0"
  45658. CELLPADDING="0"
  45659. CELLSPACING="0"
  45660. CLASS="EXAMPLE"
  45661. ><TR
  45662. ><TD
  45663. ><DIV
  45664. CLASS="example"
  45665. ><A
  45666. NAME="AEN7786"
  45667. ></A
  45668. ><P
  45669. ><B
  45670. >Beispiel 1. <B
  45671. CLASS="function"
  45672. >array_flip()</B
  45673. ></B
  45674. ></P
  45675. ><TABLE
  45676. BORDER="0"
  45677. BGCOLOR="#E0E0E0"
  45678. CELLPADDING="5"
  45679. ><TR
  45680. ><TD
  45681. ><PRE
  45682. CLASS="php"
  45683. ><?php
  45684. $trans = array_flip ($trans);
  45685. $original = strtr ($str, $trans);
  45686. ?></PRE
  45687. ></TD
  45688. ></TR
  45689. ></TABLE
  45690. ></DIV
  45691. ></TD
  45692. ></TR
  45693. ></TABLE
  45694. >
  45695.     </P
  45696. ><P
  45697. >      <TABLE
  45698. WIDTH="100%"
  45699. BORDER="0"
  45700. CELLPADDING="0"
  45701. CELLSPACING="0"
  45702. CLASS="EXAMPLE"
  45703. ><TR
  45704. ><TD
  45705. ><DIV
  45706. CLASS="example"
  45707. ><A
  45708. NAME="AEN7791"
  45709. ></A
  45710. ><P
  45711. ><B
  45712. >Beispiel 2. <B
  45713. CLASS="function"
  45714. >array_flip()</B
  45715. >: Kollision</B
  45716. ></P
  45717. ><TABLE
  45718. BORDER="0"
  45719. BGCOLOR="#E0E0E0"
  45720. CELLPADDING="5"
  45721. ><TR
  45722. ><TD
  45723. ><PRE
  45724. CLASS="php"
  45725. ><?php
  45726. $trans = array ("a" => 1, "b" => 1, "c" => 2);
  45727. $trans = array_flip ($trans);
  45728. print_r($trans);
  45729. ?></PRE
  45730. ></TD
  45731. ></TR
  45732. ></TABLE
  45733. ><P
  45734. >        Nun ist <VAR
  45735. CLASS="varname"
  45736. >$trans</VAR
  45737. >:
  45738.       </P
  45739. ><TABLE
  45740. BORDER="0"
  45741. BGCOLOR="#E0E0E0"
  45742. CELLPADDING="5"
  45743. ><TR
  45744. ><TD
  45745. ><PRE
  45746. CLASS="screen"
  45747. >Array
  45748. (
  45749.     [1] => b
  45750.     [2] => c
  45751. )</PRE
  45752. ></TD
  45753. ></TR
  45754. ></TABLE
  45755. ></DIV
  45756. ></TD
  45757. ></TR
  45758. ></TABLE
  45759. >
  45760.     </P
  45761. ></DIV
  45762. ><H1
  45763. ><A
  45764. NAME="function.array-intersect-assoc"
  45765. ></A
  45766. >array_intersect_assoc</H1
  45767. ><DIV
  45768. CLASS="refnamediv"
  45769. ><A
  45770. NAME="AEN7799"
  45771. ></A
  45772. ><P
  45773. >    (PHP 4 >= 4.3.0, PHP 5)</P
  45774. >array_intersect_assoc -- Computes the intersection of arrays with additional index check</DIV
  45775. ><DIV
  45776. CLASS="refsect1"
  45777. ><A
  45778. NAME="AEN7802"
  45779. ></A
  45780. ><H2
  45781. >Description</H2
  45782. >array <B
  45783. CLASS="methodname"
  45784. >array_intersect_assoc</B
  45785. > ( array array1, array array2 [, array ...])<BR
  45786. ></BR
  45787. ><P
  45788. >      <B
  45789. CLASS="function"
  45790. >array_intersect_assoc()</B
  45791. > returns an array
  45792.      containing all the values of <VAR
  45793. CLASS="parameter"
  45794. >array1</VAR
  45795. >
  45796.      that are present in all the arguments. Note that the keys are used in
  45797.      the comparison unlike in <A
  45798. HREF="#function.array-intersect"
  45799. ><B
  45800. CLASS="function"
  45801. >array_intersect()</B
  45802. ></A
  45803. >.
  45804.     </P
  45805. ><P
  45806. >      <TABLE
  45807. WIDTH="100%"
  45808. BORDER="0"
  45809. CELLPADDING="0"
  45810. CELLSPACING="0"
  45811. CLASS="EXAMPLE"
  45812. ><TR
  45813. ><TD
  45814. ><DIV
  45815. CLASS="example"
  45816. ><A
  45817. NAME="AEN7821"
  45818. ></A
  45819. ><P
  45820. ><B
  45821. >Beispiel 1. <B
  45822. CLASS="function"
  45823. >array_intersect_assoc()</B
  45824. > example</B
  45825. ></P
  45826. ><TABLE
  45827. BORDER="0"
  45828. BGCOLOR="#E0E0E0"
  45829. CELLPADDING="5"
  45830. ><TR
  45831. ><TD
  45832. ><PRE
  45833. CLASS="php"
  45834. ><?php
  45835. $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
  45836. $array2 = array("a" => "green", "yellow", "red");
  45837. $result_array = array_intersect_assoc($array1, $array2);
  45838. ?></PRE
  45839. ></TD
  45840. ></TR
  45841. ></TABLE
  45842. ><P
  45843. >        $result_array will look like:
  45844.       </P
  45845. ><TABLE
  45846. BORDER="0"
  45847. BGCOLOR="#E0E0E0"
  45848. CELLPADDING="5"
  45849. ><TR
  45850. ><TD
  45851. ><PRE
  45852. CLASS="screen"
  45853. >Array
  45854. (
  45855.     [a] => green
  45856. )</PRE
  45857. ></TD
  45858. ></TR
  45859. ></TABLE
  45860. ></DIV
  45861. ></TD
  45862. ></TR
  45863. ></TABLE
  45864. >
  45865.     </P
  45866. ><P
  45867. >      In our example you see that only the pair <VAR
  45868. CLASS="literal"
  45869. >"a" =>
  45870.      "green"</VAR
  45871. > is present in both arrays and thus is returned. 
  45872.      The value <VAR
  45873. CLASS="literal"
  45874. >"red"</VAR
  45875. > is not returned because in 
  45876.      <VAR
  45877. CLASS="varname"
  45878. >$array1</VAR
  45879. > its key is <VAR
  45880. CLASS="literal"
  45881. >0</VAR
  45882. > while
  45883.      the key of "red" in <VAR
  45884. CLASS="varname"
  45885. >$array2</VAR
  45886. > is 
  45887.      <VAR
  45888. CLASS="literal"
  45889. >1</VAR
  45890. >.
  45891.     </P
  45892. ><P
  45893. >      The two values from the <VAR
  45894. CLASS="literal"
  45895. >key => value</VAR
  45896. > pairs are
  45897.      considered equal only if 
  45898.      <VAR
  45899. CLASS="literal"
  45900. >(string) $elem1 === (string) $elem2 </VAR
  45901. >. In otherwords
  45902.      a strict type check is executed so the string representation must be
  45903.      the same. 
  45904.      
  45905.     </P
  45906. ><P
  45907. >      See also <A
  45908. HREF="#function.array-intersect"
  45909. ><B
  45910. CLASS="function"
  45911. >array_intersect()</B
  45912. ></A
  45913. >,
  45914.      <A
  45915. HREF="#function.array-uintersect-assoc"
  45916. ><B
  45917. CLASS="function"
  45918. >array_uintersect_assoc()</B
  45919. ></A
  45920. >,
  45921.      <A
  45922. HREF="#function.array-intersect-uassoc"
  45923. ><B
  45924. CLASS="function"
  45925. >array_intersect_uassoc()</B
  45926. ></A
  45927. >,
  45928.      <A
  45929. HREF="#function.array-uintersect-uassoc"
  45930. ><B
  45931. CLASS="function"
  45932. >array_uintersect_uassoc()</B
  45933. ></A
  45934. >,
  45935.      <A
  45936. HREF="#function.array-diff"
  45937. ><B
  45938. CLASS="function"
  45939. >array_diff()</B
  45940. ></A
  45941. > and
  45942.      <A
  45943. HREF="#function.array-diff-assoc"
  45944. ><B
  45945. CLASS="function"
  45946. >array_diff_assoc()</B
  45947. ></A
  45948. >.
  45949.     </P
  45950. ></DIV
  45951. ><H1
  45952. ><A
  45953. NAME="function.array-intersect-key"
  45954. ></A
  45955. >array_intersect_key</H1
  45956. ><DIV
  45957. CLASS="refnamediv"
  45958. ><A
  45959. NAME="AEN7845"
  45960. ></A
  45961. ><P
  45962. >    (no version information, might be only in CVS)</P
  45963. >array_intersect_key -- Computes the intersection of arrays using keys for comparison</DIV
  45964. ><DIV
  45965. CLASS="refsect1"
  45966. ><A
  45967. NAME="AEN7848"
  45968. ></A
  45969. ><H2
  45970. >Description</H2
  45971. >array <B
  45972. CLASS="methodname"
  45973. >array_intersect_key</B
  45974. > ( array array1, array array2 [, array ...])<BR
  45975. ></BR
  45976. ><P
  45977. >      <B
  45978. CLASS="function"
  45979. >array_intersect_key()</B
  45980. > returns an array
  45981.      containing all the values of <VAR
  45982. CLASS="parameter"
  45983. >array1</VAR
  45984. >
  45985.      which have matching keys that are present in all the arguments.
  45986.     </P
  45987. ><P
  45988. >      <TABLE
  45989. WIDTH="100%"
  45990. BORDER="0"
  45991. CELLPADDING="0"
  45992. CELLSPACING="0"
  45993. CLASS="EXAMPLE"
  45994. ><TR
  45995. ><TD
  45996. ><DIV
  45997. CLASS="example"
  45998. ><A
  45999. NAME="AEN7866"
  46000. ></A
  46001. ><P
  46002. ><B
  46003. >Beispiel 1. <B
  46004. CLASS="function"
  46005. >array_intersect_key()</B
  46006. > example</B
  46007. ></P
  46008. ><TABLE
  46009. BORDER="0"
  46010. BGCOLOR="#E0E0E0"
  46011. CELLPADDING="5"
  46012. ><TR
  46013. ><TD
  46014. ><PRE
  46015. CLASS="php"
  46016. ><?php
  46017. $array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
  46018. $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);
  46019.  
  46020. var_dump(array_intersect_key($array1, $array2));
  46021. ?></PRE
  46022. ></TD
  46023. ></TR
  46024. ></TABLE
  46025. ><P
  46026. >        The printout of the above program will be:
  46027.       </P
  46028. ><TABLE
  46029. BORDER="0"
  46030. BGCOLOR="#E0E0E0"
  46031. CELLPADDING="5"
  46032. ><TR
  46033. ><TD
  46034. ><PRE
  46035. CLASS="screen"
  46036. >array(2) {
  46037.   ["blue"]=>
  46038.   int(1)
  46039.   ["green"]=>
  46040.   int(3)
  46041. })</PRE
  46042. ></TD
  46043. ></TR
  46044. ></TABLE
  46045. ></DIV
  46046. ></TD
  46047. ></TR
  46048. ></TABLE
  46049. >
  46050.     </P
  46051. ><P
  46052. >      In our example you see that only the keys <VAR
  46053. CLASS="literal"
  46054. >'blue'</VAR
  46055. >
  46056.      and <VAR
  46057. CLASS="literal"
  46058. >'green'</VAR
  46059. > are present in both arrays and thus
  46060.      returned. Also notice that the values for the keys
  46061.      <VAR
  46062. CLASS="literal"
  46063. >'blue'</VAR
  46064. > and <VAR
  46065. CLASS="literal"
  46066. >'green'</VAR
  46067. > differ between
  46068.      the two arrays. A match still occurs because only the keys are checked.
  46069.      The values returned are those of <VAR
  46070. CLASS="parameter"
  46071. >array1</VAR
  46072. >.
  46073.     </P
  46074. ><P
  46075. >      The two keys from the <VAR
  46076. CLASS="literal"
  46077. >key => value</VAR
  46078. > pairs are
  46079.      considered equal only if 
  46080.      <VAR
  46081. CLASS="literal"
  46082. >(string) $key1 === (string) $key2 </VAR
  46083. >. In other words
  46084.      a strict type check is executed so the string representation must be
  46085.      the same.
  46086.     </P
  46087. ><P
  46088. >      See also <A
  46089. HREF="#function.array-diff"
  46090. ><B
  46091. CLASS="function"
  46092. >array_diff()</B
  46093. ></A
  46094. >,
  46095.      <A
  46096. HREF="#function.array-udiff"
  46097. ><B
  46098. CLASS="function"
  46099. >array_udiff()</B
  46100. ></A
  46101. >
  46102.      <A
  46103. HREF="#function.array-diff-assoc"
  46104. ><B
  46105. CLASS="function"
  46106. >array_diff_assoc()</B
  46107. ></A
  46108. >,
  46109.      <A
  46110. HREF="#function.array-diff-uassoc"
  46111. ><B
  46112. CLASS="function"
  46113. >array_diff_uassoc()</B
  46114. ></A
  46115. >,
  46116.      <A
  46117. HREF="#function.array-udiff-assoc"
  46118. ><B
  46119. CLASS="function"
  46120. >array_udiff_assoc()</B
  46121. ></A
  46122. >,
  46123.      <A
  46124. HREF="#function.array-udiff-uassoc"
  46125. ><B
  46126. CLASS="function"
  46127. >array_udiff_uassoc()</B
  46128. ></A
  46129. >,
  46130.      <A
  46131. HREF="#function.array-diff-key"
  46132. ><B
  46133. CLASS="function"
  46134. >array_diff_key()</B
  46135. ></A
  46136. >,
  46137.      <A
  46138. HREF="#function.array-diff-ukey"
  46139. ><B
  46140. CLASS="function"
  46141. >array_diff_ukey()</B
  46142. ></A
  46143. >,
  46144.      <A
  46145. HREF="#function.array-intersect"
  46146. ><B
  46147. CLASS="function"
  46148. >array_intersect()</B
  46149. ></A
  46150. >,
  46151.      <A
  46152. HREF="#function.array-intersect-assoc"
  46153. ><B
  46154. CLASS="function"
  46155. >array_intersect_assoc()</B
  46156. ></A
  46157. >,
  46158.      <A
  46159. HREF="#function.array-intersect-uassoc"
  46160. ><B
  46161. CLASS="function"
  46162. >array_intersect_uassoc()</B
  46163. ></A
  46164. > and
  46165.      <A
  46166. HREF="#function.array-intersect-ukey"
  46167. ><B
  46168. CLASS="function"
  46169. >array_intersect_ukey()</B
  46170. ></A
  46171. >.
  46172.     </P
  46173. ></DIV
  46174. ><H1
  46175. ><A
  46176. NAME="function.array-intersect-uassoc"
  46177. ></A
  46178. >array_intersect_uassoc</H1
  46179. ><DIV
  46180. CLASS="refnamediv"
  46181. ><A
  46182. NAME="AEN7895"
  46183. ></A
  46184. ><P
  46185. >    (PHP 5)</P
  46186. >array_intersect_uassoc -- Computes the intersection of arrays with additional index check. The indexes are compared by using a callback function</DIV
  46187. ><DIV
  46188. CLASS="refsect1"
  46189. ><A
  46190. NAME="AEN7898"
  46191. ></A
  46192. ><H2
  46193. >Description</H2
  46194. >array <B
  46195. CLASS="methodname"
  46196. >array_intersect_uassoc</B
  46197. > ( array array1, array array2 [, array ..., callback key_compare_func])<BR
  46198. ></BR
  46199. ><P
  46200. >      <B
  46201. CLASS="function"
  46202. >array_intersect_uassoc()</B
  46203. > returns an array
  46204.      containing all the values of <VAR
  46205. CLASS="parameter"
  46206. >array1</VAR
  46207. >
  46208.      that are present in all the arguments. Note that the keys are used in
  46209.      the comparison unlike in <A
  46210. HREF="#function.array-intersect"
  46211. ><B
  46212. CLASS="function"
  46213. >array_intersect()</B
  46214. ></A
  46215. >.
  46216.     </P
  46217. ><P
  46218. >      The index comparison is done by a user supplied callback function.
  46219.      It must return an integer less than, equal to, or greater than zero
  46220.      if the first argument is considered to be respectively less than,
  46221.      equal to, or greater than the second.
  46222.     </P
  46223. ><P
  46224. >      <TABLE
  46225. WIDTH="100%"
  46226. BORDER="0"
  46227. CELLPADDING="0"
  46228. CELLSPACING="0"
  46229. CLASS="EXAMPLE"
  46230. ><TR
  46231. ><TD
  46232. ><DIV
  46233. CLASS="example"
  46234. ><A
  46235. NAME="AEN7921"
  46236. ></A
  46237. ><P
  46238. ><B
  46239. >Beispiel 1. <B
  46240. CLASS="function"
  46241. >array_intersect_uassoc()</B
  46242. > example</B
  46243. ></P
  46244. ><TABLE
  46245. BORDER="0"
  46246. BGCOLOR="#E0E0E0"
  46247. CELLPADDING="5"
  46248. ><TR
  46249. ><TD
  46250. ><PRE
  46251. CLASS="php"
  46252. ><?php
  46253. $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
  46254. $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red");
  46255.  
  46256. print_r(array_intersect_uassoc($array1, $array2, "strcasecmp"));
  46257. ?></PRE
  46258. ></TD
  46259. ></TR
  46260. ></TABLE
  46261. ><P
  46262. >        Result will look like:
  46263.       </P
  46264. ><TABLE
  46265. BORDER="0"
  46266. BGCOLOR="#E0E0E0"
  46267. CELLPADDING="5"
  46268. ><TR
  46269. ><TD
  46270. ><PRE
  46271. CLASS="screen"
  46272. >Array
  46273. (
  46274.     [b] => brown
  46275. )</PRE
  46276. ></TD
  46277. ></TR
  46278. ></TABLE
  46279. ></DIV
  46280. ></TD
  46281. ></TR
  46282. ></TABLE
  46283. >
  46284.     </P
  46285. ><P
  46286. >      See also <A
  46287. HREF="#function.array-intersect"
  46288. ><B
  46289. CLASS="function"
  46290. >array_intersect()</B
  46291. ></A
  46292. >,
  46293.      <A
  46294. HREF="#function.array-intersect-assoc"
  46295. ><B
  46296. CLASS="function"
  46297. >array_intersect_assoc()</B
  46298. ></A
  46299. >,
  46300.      <A
  46301. HREF="#function.array-uintersect-assoc"
  46302. ><B
  46303. CLASS="function"
  46304. >array_uintersect_assoc()</B
  46305. ></A
  46306. >,
  46307.      <A
  46308. HREF="#function.array-uintersect-uassoc"
  46309. ><B
  46310. CLASS="function"
  46311. >array_uintersect_uassoc()</B
  46312. ></A
  46313. >,
  46314.      <A
  46315. HREF="#function.array-intersect-key"
  46316. ><B
  46317. CLASS="function"
  46318. >array_intersect_key()</B
  46319. ></A
  46320. > and
  46321.      <A
  46322. HREF="#function.array-intersect-ukey"
  46323. ><B
  46324. CLASS="function"
  46325. >array_intersect_ukey()</B
  46326. ></A
  46327. >.
  46328.     </P
  46329. ></DIV
  46330. ><H1
  46331. ><A
  46332. NAME="function.array-intersect-ukey"
  46333. ></A
  46334. >array_intersect_ukey</H1
  46335. ><DIV
  46336. CLASS="refnamediv"
  46337. ><A
  46338. NAME="AEN7935"
  46339. ></A
  46340. ><P
  46341. >    (no version information, might be only in CVS)</P
  46342. >array_intersect_ukey -- Computes the intersection of arrays using a callback function on the keys for comparison</DIV
  46343. ><DIV
  46344. CLASS="refsect1"
  46345. ><A
  46346. NAME="AEN7938"
  46347. ></A
  46348. ><H2
  46349. >Description</H2
  46350. >array <B
  46351. CLASS="methodname"
  46352. >array_intersect_ukey</B
  46353. > ( array array1, array array2 [, array ..., callback key_compare_func])<BR
  46354. ></BR
  46355. ><P
  46356. >      <B
  46357. CLASS="function"
  46358. >array_intersect_ukey()</B
  46359. > returns an array
  46360.      containing all the values of <VAR
  46361. CLASS="parameter"
  46362. >array1</VAR
  46363. >
  46364.      which have matching keys that are present in all the arguments.
  46365.     </P
  46366. ><P
  46367. >      This comparison is done by a user supplied callback function.
  46368.      It must return an integer less than, equal to, or greater than zero if the
  46369.      first key is considered to be respectively less than, equal to, or
  46370.      greater than the second.
  46371.     </P
  46372. ><P
  46373. >      <TABLE
  46374. WIDTH="100%"
  46375. BORDER="0"
  46376. CELLPADDING="0"
  46377. CELLSPACING="0"
  46378. CLASS="EXAMPLE"
  46379. ><TR
  46380. ><TD
  46381. ><DIV
  46382. CLASS="example"
  46383. ><A
  46384. NAME="AEN7960"
  46385. ></A
  46386. ><P
  46387. ><B
  46388. >Beispiel 1. <B
  46389. CLASS="function"
  46390. >array_intersect_ukey()</B
  46391. > example</B
  46392. ></P
  46393. ><TABLE
  46394. BORDER="0"
  46395. BGCOLOR="#E0E0E0"
  46396. CELLPADDING="5"
  46397. ><TR
  46398. ><TD
  46399. ><PRE
  46400. CLASS="php"
  46401. ><?php
  46402. function key_compare_func($key1, $key2)
  46403. {
  46404.     if ($key1 == $key2)
  46405.         return 0;
  46406.     else if ($key1 > $key2)
  46407.         return 1;
  46408.     else
  46409.         return -1;
  46410. }
  46411.  
  46412. $array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
  46413. $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);
  46414.  
  46415. var_dump(array_intersect_ukey($array1, $array2, 'key_compare_func'));
  46416. ?></PRE
  46417. ></TD
  46418. ></TR
  46419. ></TABLE
  46420. ><P
  46421. >        The printout of the above program will be:
  46422.       </P
  46423. ><TABLE
  46424. BORDER="0"
  46425. BGCOLOR="#E0E0E0"
  46426. CELLPADDING="5"
  46427. ><TR
  46428. ><TD
  46429. ><PRE
  46430. CLASS="screen"
  46431. >array(2) {
  46432.   ["blue"]=>
  46433.   int(1)
  46434.   ["green"]=>
  46435.   int(3)
  46436. })</PRE
  46437. ></TD
  46438. ></TR
  46439. ></TABLE
  46440. ></DIV
  46441. ></TD
  46442. ></TR
  46443. ></TABLE
  46444. >
  46445.     </P
  46446. ><P
  46447. >      In our example you see that only the keys <VAR
  46448. CLASS="literal"
  46449. >'blue'</VAR
  46450. >
  46451.      and <VAR
  46452. CLASS="literal"
  46453. >'green'</VAR
  46454. > are present in both arrays and thus
  46455.      returned. Also notice that the values for the keys
  46456.      <VAR
  46457. CLASS="literal"
  46458. >'blue'</VAR
  46459. > and <VAR
  46460. CLASS="literal"
  46461. >'green'</VAR
  46462. > differ between
  46463.      the two arrays. A match still occurs because only the keys are checked.
  46464.      The values returned are those of <VAR
  46465. CLASS="parameter"
  46466. >array1</VAR
  46467. >.
  46468.     </P
  46469. ><P
  46470. >      The two keys from the <VAR
  46471. CLASS="literal"
  46472. >key => value</VAR
  46473. > pairs are
  46474.      considered equal only if 
  46475.      <VAR
  46476. CLASS="literal"
  46477. >(string) $key1 === (string) $key2 </VAR
  46478. >. In other words
  46479.      a strict type check is executed so the string representation must be
  46480.      the same.
  46481.     </P
  46482. ><P
  46483. >      See also <A
  46484. HREF="#function.array-diff"
  46485. ><B
  46486. CLASS="function"
  46487. >array_diff()</B
  46488. ></A
  46489. >,
  46490.      <A
  46491. HREF="#function.array-udiff"
  46492. ><B
  46493. CLASS="function"
  46494. >array_udiff()</B
  46495. ></A
  46496. >
  46497.      <A
  46498. HREF="#function.array-diff-assoc"
  46499. ><B
  46500. CLASS="function"
  46501. >array_diff_assoc()</B
  46502. ></A
  46503. >,
  46504.      <A
  46505. HREF="#function.array-diff-uassoc"
  46506. ><B
  46507. CLASS="function"
  46508. >array_diff_uassoc()</B
  46509. ></A
  46510. >,
  46511.      <A
  46512. HREF="#function.array-udiff-assoc"
  46513. ><B
  46514. CLASS="function"
  46515. >array_udiff_assoc()</B
  46516. ></A
  46517. >,
  46518.      <A
  46519. HREF="#function.array-udiff-uassoc"
  46520. ><B
  46521. CLASS="function"
  46522. >array_udiff_uassoc()</B
  46523. ></A
  46524. >,
  46525.      <A
  46526. HREF="#function.array-diff-key"
  46527. ><B
  46528. CLASS="function"
  46529. >array_diff_key()</B
  46530. ></A
  46531. >,
  46532.      <A
  46533. HREF="#function.array-diff-ukey"
  46534. ><B
  46535. CLASS="function"
  46536. >array_diff_ukey()</B
  46537. ></A
  46538. >,
  46539.      <A
  46540. HREF="#function.array-intersect"
  46541. ><B
  46542. CLASS="function"
  46543. >array_intersect()</B
  46544. ></A
  46545. >,
  46546.      <A
  46547. HREF="#function.array-intersect-assoc"
  46548. ><B
  46549. CLASS="function"
  46550. >array_intersect_assoc()</B
  46551. ></A
  46552. >,
  46553.      <A
  46554. HREF="#function.array-intersect-uassoc"
  46555. ><B
  46556. CLASS="function"
  46557. >array_intersect_uassoc()</B
  46558. ></A
  46559. > and
  46560.      <A
  46561. HREF="#function.array-intersect-key"
  46562. ><B
  46563. CLASS="function"
  46564. >array_intersect_key()</B
  46565. ></A
  46566. >.
  46567.     </P
  46568. ></DIV
  46569. ><H1
  46570. ><A
  46571. NAME="function.array-intersect"
  46572. ></A
  46573. >array_intersect</H1
  46574. ><DIV
  46575. CLASS="refnamediv"
  46576. ><A
  46577. NAME="AEN7989"
  46578. ></A
  46579. ><P
  46580. >    (PHP 4 >= 4.0.1, PHP 5)</P
  46581. >array_intersect -- Ermittelt die Schnittmenge von Arrays</DIV
  46582. ><DIV
  46583. CLASS="refsect1"
  46584. ><A
  46585. NAME="AEN7992"
  46586. ></A
  46587. ><H2
  46588. >Beschreibung</H2
  46589. >array <B
  46590. CLASS="methodname"
  46591. >array_intersect</B
  46592. > ( array array1, array array2 [, array ...])<BR
  46593. ></BR
  46594. ><P
  46595. >      <B
  46596. CLASS="function"
  46597. >array_intersect()</B
  46598. > gibt ein Array mit allen Werten
  46599.      von <VAR
  46600. CLASS="parameter"
  46601. >array1</VAR
  46602. >, die auch in allen anderen
  46603.      Argumenten enthalten sind, zurⁿck. Beachten Sie, dass die Schlⁿssel
  46604.      erhalten bleiben.
  46605.     </P
  46606. ><P
  46607. >      <TABLE
  46608. WIDTH="100%"
  46609. BORDER="0"
  46610. CELLPADDING="0"
  46611. CELLSPACING="0"
  46612. CLASS="EXAMPLE"
  46613. ><TR
  46614. ><TD
  46615. ><DIV
  46616. CLASS="example"
  46617. ><A
  46618. NAME="AEN8010"
  46619. ></A
  46620. ><P
  46621. ><B
  46622. >Beispiel 1. <B
  46623. CLASS="function"
  46624. >array_intersect()</B
  46625. > Beispiel</B
  46626. ></P
  46627. ><TABLE
  46628. BORDER="0"
  46629. BGCOLOR="#E0E0E0"
  46630. CELLPADDING="5"
  46631. ><TR
  46632. ><TD
  46633. ><PRE
  46634. CLASS="php"
  46635. ><?php
  46636. $array1 = array ("a" => "grⁿn", "rot", "blau");
  46637. $array2 = array ("b" => "grⁿn", "gelb", "rot");
  46638. $result = array_intersect ($array1, $array2);
  46639. ?></PRE
  46640. ></TD
  46641. ></TR
  46642. ></TABLE
  46643. ><P
  46644. >        Danach enthΣlt <VAR
  46645. CLASS="varname"
  46646. >$result</VAR
  46647. >
  46648.       </P
  46649. ><TABLE
  46650. BORDER="0"
  46651. BGCOLOR="#E0E0E0"
  46652. CELLPADDING="5"
  46653. ><TR
  46654. ><TD
  46655. ><PRE
  46656. CLASS="php"
  46657. >Array
  46658. (
  46659.     [a] => grⁿn
  46660.     [0] => rot
  46661. )</PRE
  46662. ></TD
  46663. ></TR
  46664. ></TABLE
  46665. ></DIV
  46666. ></TD
  46667. ></TR
  46668. ></TABLE
  46669. >
  46670.     </P
  46671. ><DIV
  46672. CLASS="note"
  46673. ><BLOCKQUOTE
  46674. CLASS="note"
  46675. ><P
  46676. ><B
  46677. >Anmerkung: </B
  46678. >
  46679.       Zwei Elemente werden nur dann als gleich angesehen, wenn
  46680.       <VAR
  46681. CLASS="literal"
  46682. >(string) $elem1 === (string) $elem2</VAR
  46683. >. In Worten:
  46684.       Wenn die String-ReprΣsentation die gleiche ist.
  46685.      </P
  46686. ></BLOCKQUOTE
  46687. ></DIV
  46688. ><DIV
  46689. CLASS="warning"
  46690. ><P
  46691. ></P
  46692. ><TABLE
  46693. CLASS="warning"
  46694. BORDER="1"
  46695. WIDTH="100%"
  46696. ><TR
  46697. ><TD
  46698. ALIGN="CENTER"
  46699. ><B
  46700. >Warnung</B
  46701. ></TD
  46702. ></TR
  46703. ><TR
  46704. ><TD
  46705. ALIGN="LEFT"
  46706. ><P
  46707. >       Dies war in PHP 4.0.4 fehlerhaft!
  46708.      </P
  46709. ></TD
  46710. ></TR
  46711. ></TABLE
  46712. ></DIV
  46713. ><P
  46714. >      Siehe auch <A
  46715. HREF="#function.array-intersect-assoc"
  46716. ><B
  46717. CLASS="function"
  46718. >array_intersect_assoc()</B
  46719. ></A
  46720. >,
  46721.      <A
  46722. HREF="#function.array-diff"
  46723. ><B
  46724. CLASS="function"
  46725. >array_diff()</B
  46726. ></A
  46727. > und
  46728.      <A
  46729. HREF="#function.array-diff-assoc"
  46730. ><B
  46731. CLASS="function"
  46732. >array_diff_assoc()</B
  46733. ></A
  46734. >.
  46735.     </P
  46736. ></DIV
  46737. ><H1
  46738. ><A
  46739. NAME="function.array-key-exists"
  46740. ></A
  46741. >array_key_exists</H1
  46742. ><DIV
  46743. CLASS="refnamediv"
  46744. ><A
  46745. NAME="AEN8027"
  46746. ></A
  46747. ><P
  46748. >    (PHP 4 >= 4.1.0, PHP 5)</P
  46749. >array_key_exists -- Prⁿft, ob ein Schlⁿssel in einem Array existiert</DIV
  46750. ><DIV
  46751. CLASS="refsect1"
  46752. ><A
  46753. NAME="AEN8030"
  46754. ></A
  46755. ><H2
  46756. >Beschreibung</H2
  46757. >bool <B
  46758. CLASS="methodname"
  46759. >array_key_exists</B
  46760. > ( mixed key, array search)<BR
  46761. ></BR
  46762. ><P
  46763. >      <B
  46764. CLASS="function"
  46765. >array_key_exists()</B
  46766. > gibt <TT
  46767. CLASS="constant"
  46768. ><B
  46769. >TRUE</B
  46770. ></TT
  46771. > zurⁿck, wenn
  46772.      <VAR
  46773. CLASS="parameter"
  46774. >key</VAR
  46775. > in dem Array vorhanden ist.
  46776.      <VAR
  46777. CLASS="parameter"
  46778. >key</VAR
  46779. > kann jeder fⁿr einen Array-Index
  46780.      m÷gliche Wert sein.
  46781.     </P
  46782. ><P
  46783. >      <TABLE
  46784. WIDTH="100%"
  46785. BORDER="0"
  46786. CELLPADDING="0"
  46787. CELLSPACING="0"
  46788. CLASS="EXAMPLE"
  46789. ><TR
  46790. ><TD
  46791. ><DIV
  46792. CLASS="example"
  46793. ><A
  46794. NAME="AEN8047"
  46795. ></A
  46796. ><P
  46797. ><B
  46798. >Beispiel 1. <B
  46799. CLASS="function"
  46800. >array_key_exists()</B
  46801. ></B
  46802. ></P
  46803. ><TABLE
  46804. BORDER="0"
  46805. BGCOLOR="#E0E0E0"
  46806. CELLPADDING="5"
  46807. ><TR
  46808. ><TD
  46809. ><PRE
  46810. CLASS="php"
  46811. ><?php
  46812. $search_array = array("erstes" => 1, "zweites" => 4);
  46813. if (array_key_exists("erstes", $search_array)) {
  46814.     echo "Das Element 'erstes' ist in dem Array vorhanden";
  46815. }
  46816. ?></PRE
  46817. ></TD
  46818. ></TR
  46819. ></TABLE
  46820. ></DIV
  46821. ></TD
  46822. ></TR
  46823. ></TABLE
  46824. >
  46825.     </P
  46826. ><DIV
  46827. CLASS="note"
  46828. ><BLOCKQUOTE
  46829. CLASS="note"
  46830. ><P
  46831. ><B
  46832. >Anmerkung: </B
  46833. >
  46834.       Der Name dieser Funktion ist in PHP 4.0.6
  46835.       <B
  46836. CLASS="function"
  46837. >key_exists()</B
  46838. >.
  46839.      </P
  46840. ></BLOCKQUOTE
  46841. ></DIV
  46842. ><P
  46843. >      Siehe auch <A
  46844. HREF="#function.isset"
  46845. ><B
  46846. CLASS="function"
  46847. >isset()</B
  46848. ></A
  46849. >.
  46850.     </P
  46851. ></DIV
  46852. ><H1
  46853. ><A
  46854. NAME="function.array-keys"
  46855. ></A
  46856. >array_keys</H1
  46857. ><DIV
  46858. CLASS="refnamediv"
  46859. ><A
  46860. NAME="AEN8057"
  46861. ></A
  46862. ><P
  46863. >    (PHP 4 , PHP 5)</P
  46864. >array_keys -- Liefert alle Schlⁿssel eines Arrays</DIV
  46865. ><DIV
  46866. CLASS="refsect1"
  46867. ><A
  46868. NAME="AEN8060"
  46869. ></A
  46870. ><H2
  46871. >Beschreibung</H2
  46872. >array <B
  46873. CLASS="methodname"
  46874. >array_keys</B
  46875. > ( array input [, mixed search_value])<BR
  46876. ></BR
  46877. ><P
  46878. >      <B
  46879. CLASS="function"
  46880. >array_keys()</B
  46881. > gibt die Schlⁿssel (numerisch und
  46882.      String) des Arrays <VAR
  46883. CLASS="parameter"
  46884. >input</VAR
  46885. > zurⁿck.
  46886.     </P
  46887. ><P
  46888. >      Ist der optionale Parameter <VAR
  46889. CLASS="parameter"
  46890. >search_value</VAR
  46891. >
  46892.      angegeben, werden nur die Schlⁿssel fⁿr diesen Wert zurⁿckgegeben.
  46893.      Andernfalls werden all Schlⁿssel von <VAR
  46894. CLASS="parameter"
  46895. >input</VAR
  46896. >
  46897.      zurⁿckgegeben.
  46898.     </P
  46899. ><P
  46900. >      <TABLE
  46901. WIDTH="100%"
  46902. BORDER="0"
  46903. CELLPADDING="0"
  46904. CELLSPACING="0"
  46905. CLASS="EXAMPLE"
  46906. ><TR
  46907. ><TD
  46908. ><DIV
  46909. CLASS="example"
  46910. ><A
  46911. NAME="AEN8078"
  46912. ></A
  46913. ><P
  46914. ><B
  46915. >Beispiel 1. <B
  46916. CLASS="function"
  46917. >array_keys()</B
  46918. ></B
  46919. ></P
  46920. ><TABLE
  46921. BORDER="0"
  46922. BGCOLOR="#E0E0E0"
  46923. CELLPADDING="5"
  46924. ><TR
  46925. ><TD
  46926. ><PRE
  46927. CLASS="php"
  46928. ><?php
  46929. $array = array (0 => 100, "Farbe" => "rot");
  46930. print_r(array_keys ($array));
  46931.  
  46932. $array = array ("blau", "rot", "grⁿn", "blau", "blau");
  46933. print_r(array_keys ($array, "blau"));
  46934.  
  46935. $array = array ("Farbe" => array("blau", "rot", "grⁿn"),
  46936.                 "Gr÷▀e" => array("klein", "mittel", "gro▀"));
  46937. print_r(array_keys ($array));
  46938. ?></PRE
  46939. ></TD
  46940. ></TR
  46941. ></TABLE
  46942. ><P
  46943. >        wⁿrde folgendes ausgeben:
  46944.       </P
  46945. ><TABLE
  46946. BORDER="0"
  46947. BGCOLOR="#E0E0E0"
  46948. CELLPADDING="5"
  46949. ><TR
  46950. ><TD
  46951. ><PRE
  46952. CLASS="screen"
  46953. >Array
  46954. (
  46955.     [0] => 0
  46956.     [1] => Farbe
  46957. )
  46958. Array
  46959. (
  46960.     [0] => 0
  46961.     [1] => 3
  46962.     [2] => 4
  46963. )
  46964. Array
  46965. (
  46966.     [0] => Farbe
  46967.     [1] => Gr÷▀e
  46968. )</PRE
  46969. ></TD
  46970. ></TR
  46971. ></TABLE
  46972. ></DIV
  46973. ></TD
  46974. ></TR
  46975. ></TABLE
  46976. >
  46977.     </P
  46978. ><P
  46979. >      Siehe auch <A
  46980. HREF="#function.array-values"
  46981. ><B
  46982. CLASS="function"
  46983. >array_values()</B
  46984. ></A
  46985. > und.
  46986.      <A
  46987. HREF="#function.array-key-exists"
  46988. ><B
  46989. CLASS="function"
  46990. >array_key_exists()</B
  46991. ></A
  46992. >.
  46993.     </P
  46994. ></DIV
  46995. ><H1
  46996. ><A
  46997. NAME="function.array-map"
  46998. ></A
  46999. >array_map</H1
  47000. ><DIV
  47001. CLASS="refnamediv"
  47002. ><A
  47003. NAME="AEN8088"
  47004. ></A
  47005. ><P
  47006. >    (PHP 4 >= 4.0.6, PHP 5)</P
  47007. >array_map -- 
  47008.      Wendet eine Callback-Funktion auf die Elemente von Arrays an
  47009.     </DIV
  47010. ><DIV
  47011. CLASS="refsect1"
  47012. ><A
  47013. NAME="AEN8091"
  47014. ></A
  47015. ><H2
  47016. >Beschreibung</H2
  47017. >array <B
  47018. CLASS="methodname"
  47019. >array_map</B
  47020. > ( mixed callback, array arr1 [, array ...])<BR
  47021. ></BR
  47022. ><P
  47023. >      <B
  47024. CLASS="function"
  47025. >array_map()</B
  47026. > gibt ein Array mit allen Elementen von
  47027.      <VAR
  47028. CLASS="parameter"
  47029. >arr1</VAR
  47030. > zurⁿck, nachdem die Callback-Funktion
  47031.      <VAR
  47032. CLASS="parameter"
  47033. >callback</VAR
  47034. > auf jedes einzelne Element angewandt
  47035.      wurde. Die Anzahl Parameter, welche die Callback-Funktion
  47036.      <VAR
  47037. CLASS="parameter"
  47038. >callback</VAR
  47039. > akzeptiert, sollte der Anzahl der an
  47040.      <B
  47041. CLASS="function"
  47042. >array_map()</B
  47043. > ⁿbergebenen Arrays entsprechen.
  47044.     </P
  47045. ><P
  47046. >      <TABLE
  47047. WIDTH="100%"
  47048. BORDER="0"
  47049. CELLPADDING="0"
  47050. CELLSPACING="0"
  47051. CLASS="EXAMPLE"
  47052. ><TR
  47053. ><TD
  47054. ><DIV
  47055. CLASS="example"
  47056. ><A
  47057. NAME="AEN8112"
  47058. ></A
  47059. ><P
  47060. ><B
  47061. >Beispiel 1. <B
  47062. CLASS="function"
  47063. >array_map()</B
  47064. ></B
  47065. ></P
  47066. ><TABLE
  47067. BORDER="0"
  47068. BGCOLOR="#E0E0E0"
  47069. CELLPADDING="5"
  47070. ><TR
  47071. ><TD
  47072. ><PRE
  47073. CLASS="php"
  47074. ><?php
  47075. function cube($n) {
  47076.     return $n*$n*$n;
  47077. }
  47078.  
  47079. $a = array(1, 2, 3, 4, 5);
  47080. $b = array_map("cube", $a);
  47081. print_r($b);
  47082. ?></PRE
  47083. ></TD
  47084. ></TR
  47085. ></TABLE
  47086. ><P
  47087. >        Dies speichert in <VAR
  47088. CLASS="varname"
  47089. >$b</VAR
  47090. >:
  47091.       </P
  47092. ><TABLE
  47093. BORDER="0"
  47094. BGCOLOR="#E0E0E0"
  47095. CELLPADDING="5"
  47096. ><TR
  47097. ><TD
  47098. ><PRE
  47099. CLASS="screen"
  47100. >Array
  47101. (
  47102.     [0] => 1
  47103.     [1] => 8
  47104.     [2] => 27
  47105.     [3] => 64
  47106.     [4] => 125
  47107. )</PRE
  47108. ></TD
  47109. ></TR
  47110. ></TABLE
  47111. ></DIV
  47112. ></TD
  47113. ></TR
  47114. ></TABLE
  47115. >
  47116.     </P
  47117. ><P
  47118. >      <TABLE
  47119. WIDTH="100%"
  47120. BORDER="0"
  47121. CELLPADDING="0"
  47122. CELLSPACING="0"
  47123. CLASS="EXAMPLE"
  47124. ><TR
  47125. ><TD
  47126. ><DIV
  47127. CLASS="example"
  47128. ><A
  47129. NAME="AEN8120"
  47130. ></A
  47131. ><P
  47132. ><B
  47133. >Beispiel 2. 
  47134.        <B
  47135. CLASS="function"
  47136. >array_map()</B
  47137. > - Verwendung mehrerer Arrays
  47138.       </B
  47139. ></P
  47140. ><TABLE
  47141. BORDER="0"
  47142. BGCOLOR="#E0E0E0"
  47143. CELLPADDING="5"
  47144. ><TR
  47145. ><TD
  47146. ><PRE
  47147. CLASS="php"
  47148. ><?php
  47149. function show_Spanish($n, $m) {
  47150.     return "Die Zahl $n hei▀t auf Spanisch  $m";
  47151. }
  47152.  
  47153. function map_Spanish($n, $m) {
  47154.     return array ($n => $m);
  47155. }
  47156.  
  47157. $a = array(1, 2, 3, 4, 5);
  47158. $b = array("uno", "dos", "tres", "cuatro", "cinco");
  47159.  
  47160. $c = array_map("show_Spanish", $a, $b);
  47161. print_r($c);
  47162.  
  47163. $d = array_map("map_Spanish", $a , $b);
  47164. print_r($d);
  47165. ?></PRE
  47166. ></TD
  47167. ></TR
  47168. ></TABLE
  47169. ><P
  47170. >        Dies resultiert in:
  47171.       </P
  47172. ><TABLE
  47173. BORDER="0"
  47174. BGCOLOR="#E0E0E0"
  47175. CELLPADDING="5"
  47176. ><TR
  47177. ><TD
  47178. ><PRE
  47179. CLASS="screen"
  47180. >// Ausgabe von $c
  47181. Array
  47182. (
  47183.     [0] => Die Zahl 1 hei▀t auf Spanisch  uno
  47184.     [1] => Die Zahl 2 hei▀t auf Spanisch  dos
  47185.     [2] => Die Zahl 3 hei▀t auf Spanisch  tres
  47186.     [3] => Die Zahl 4 hei▀t auf Spanisch  cuatro
  47187.     [4] => Die Zahl 5 hei▀t auf Spanisch  cinco
  47188. )
  47189.  
  47190. // Ausgabe von $d
  47191. Array
  47192. (
  47193.     [0] => Array
  47194.         (
  47195.             [1] => uno
  47196.         )
  47197.  
  47198.     [1] => Array
  47199.         (
  47200.             [2] => dos
  47201.         )
  47202.  
  47203.     [2] => Array
  47204.         (
  47205.             [3] => tres
  47206.         )
  47207.  
  47208.     [3] => Array
  47209.         (
  47210.             [4] => cuatro
  47211.         )
  47212.  
  47213.     [4] => Array
  47214.         (
  47215.             [5] => cinco
  47216.         )
  47217.  
  47218. )</PRE
  47219. ></TD
  47220. ></TR
  47221. ></TABLE
  47222. ></DIV
  47223. ></TD
  47224. ></TR
  47225. ></TABLE
  47226. >
  47227.     </P
  47228. ><P
  47229. >      Bei Verwendung von zwei oder mehr Arrays sollten diese gew÷hnlich
  47230.      die gleiche LΣnge besitzen, da die Callback-Funktion parallel auf
  47231.      die entsprechenden Elemente angewandt wird.  Haben die Arrays
  47232.      unterschiedliche LΣngen, wird das kⁿrzeste um leere Elemente
  47233.      erweitert.
  47234.     </P
  47235. ><P
  47236. >      Eine interessante Anwendung dieser Funktion ist die Konstruktion
  47237.      eines Arrays bestehend aus Arrays, was mit <TT
  47238. CLASS="constant"
  47239. ><B
  47240. >NULL</B
  47241. ></TT
  47242. > als Name der
  47243.      Callback-Funktion leicht realisiert werden kann.
  47244.     </P
  47245. ><P
  47246. >      <TABLE
  47247. WIDTH="100%"
  47248. BORDER="0"
  47249. CELLPADDING="0"
  47250. CELLSPACING="0"
  47251. CLASS="EXAMPLE"
  47252. ><TR
  47253. ><TD
  47254. ><DIV
  47255. CLASS="example"
  47256. ><A
  47257. NAME="AEN8130"
  47258. ></A
  47259. ><P
  47260. ><B
  47261. >Beispiel 3. Erstellen eines Arrays mit Arrays</B
  47262. ></P
  47263. ><TABLE
  47264. BORDER="0"
  47265. BGCOLOR="#E0E0E0"
  47266. CELLPADDING="5"
  47267. ><TR
  47268. ><TD
  47269. ><PRE
  47270. CLASS="php"
  47271. ><?php
  47272. $a = array(1, 2, 3, 4, 5);
  47273. $b = array("eins", "zwei", "drei", "vier", "fⁿnf");
  47274. $c = array("uno", "dos", "tres", "cuatro", "cinco");
  47275.  
  47276. $d = array_map(null, $a, $b, $c);
  47277. print_r($d);
  47278. ?></PRE
  47279. ></TD
  47280. ></TR
  47281. ></TABLE
  47282. ></DIV
  47283. ></TD
  47284. ></TR
  47285. ></TABLE
  47286. >
  47287.     </P
  47288. ><P
  47289. >      Wⁿrde folgendes ausgeben:
  47290.     </P
  47291. ><TABLE
  47292. BORDER="0"
  47293. BGCOLOR="#E0E0E0"
  47294. CELLPADDING="5"
  47295. ><TR
  47296. ><TD
  47297. ><PRE
  47298. CLASS="screen"
  47299. >Array
  47300. (
  47301.     [0] => Array
  47302.         (
  47303.             [0] => 1
  47304.             [1] => eins
  47305.             [2] => uno
  47306.         )
  47307.  
  47308.     [1] => Array
  47309.         (
  47310.             [0] => 2
  47311.             [1] => zwei
  47312.             [2] => dos
  47313.         )
  47314.  
  47315.     [2] => Array
  47316.         (
  47317.             [0] => 3
  47318.             [1] => drei
  47319.             [2] => tres
  47320.         )
  47321.  
  47322.     [3] => Array
  47323.         (
  47324.             [0] => 4
  47325.             [1] => vier
  47326.             [2] => cuatro
  47327.         )
  47328.  
  47329.     [4] => Array
  47330.         (
  47331.             [0] => 5
  47332.             [1] => fⁿnf
  47333.             [2] => cinco
  47334.         )
  47335.  
  47336. )</PRE
  47337. ></TD
  47338. ></TR
  47339. ></TABLE
  47340. ><P
  47341. >      Siehe auch <A
  47342. HREF="#function.array-filter"
  47343. ><B
  47344. CLASS="function"
  47345. >array_filter()</B
  47346. ></A
  47347. >, 
  47348.      <A
  47349. HREF="#function.array-reduce"
  47350. ><B
  47351. CLASS="function"
  47352. >array_reduce()</B
  47353. ></A
  47354. > und
  47355.      <A
  47356. HREF="#function.array-walk"
  47357. ><B
  47358. CLASS="function"
  47359. >array_walk()</B
  47360. ></A
  47361. >.
  47362.     </P
  47363. ></DIV
  47364. ><H1
  47365. ><A
  47366. NAME="function.array-merge-recursive"
  47367. ></A
  47368. >array_merge_recursive</H1
  47369. ><DIV
  47370. CLASS="refnamediv"
  47371. ><A
  47372. NAME="AEN8140"
  47373. ></A
  47374. ><P
  47375. >    (PHP 4 >= 4.0.1, PHP 5)</P
  47376. >array_merge_recursive -- 
  47377.      Fⁿhrt zwei oder mehr Arrays rekursiv zusammen
  47378.     </DIV
  47379. ><DIV
  47380. CLASS="refsect1"
  47381. ><A
  47382. NAME="AEN8143"
  47383. ></A
  47384. ><H2
  47385. >Beschreibung</H2
  47386. >array <B
  47387. CLASS="methodname"
  47388. >array_merge_recursive</B
  47389. > ( array array1, array array2 [, array ...])<BR
  47390. ></BR
  47391. ><P
  47392. >      <B
  47393. CLASS="function"
  47394. >array_merge_recursive()</B
  47395. > fⁿgt die Elemente von
  47396.      zwei oder mehr Arrays zusammen, so dass die Werte des einen
  47397.      Arrays an die des vorigen angehΣngt werden. Das daraus
  47398.      resultierende Array wird zurⁿckgegeben.
  47399.     </P
  47400. ><P
  47401. >      Haben die angegebenen Arrays die selben String-Schlⁿssel, dann
  47402.      wird der hintere Wert dieses Schlⁿssels den vorhergehenden
  47403.      ⁿberschreiben. Haben die Arrays den gleichen numerischen
  47404.      Schlⁿssel, dann wird der hintere Wert den vorhergehenden nicht
  47405.      ⁿberschreiben, sondern an den vorderen angehΣngt.
  47406.     </P
  47407. ><P
  47408. >      <TABLE
  47409. WIDTH="100%"
  47410. BORDER="0"
  47411. CELLPADDING="0"
  47412. CELLSPACING="0"
  47413. CLASS="EXAMPLE"
  47414. ><TR
  47415. ><TD
  47416. ><DIV
  47417. CLASS="example"
  47418. ><A
  47419. NAME="AEN8161"
  47420. ></A
  47421. ><P
  47422. ><B
  47423. >Beispiel 1. <B
  47424. CLASS="function"
  47425. >array_merge_recursive()</B
  47426. ></B
  47427. ></P
  47428. ><TABLE
  47429. BORDER="0"
  47430. BGCOLOR="#E0E0E0"
  47431. CELLPADDING="5"
  47432. ><TR
  47433. ><TD
  47434. ><PRE
  47435. CLASS="php"
  47436. ><?php
  47437. $ar1 = array ("farbe" => array ("favorit" => "rot"), 5);
  47438. $ar2 = array (10, "farbe" => array ("favorit" => "grⁿn", "blau"));
  47439. $result = array_merge_recursive ($ar1, $ar2);
  47440. ?></PRE
  47441. ></TD
  47442. ></TR
  47443. ></TABLE
  47444. ><P
  47445. >        The <VAR
  47446. CLASS="literal"
  47447. >$result</VAR
  47448. > will be:
  47449.       </P
  47450. ><TABLE
  47451. BORDER="0"
  47452. BGCOLOR="#E0E0E0"
  47453. CELLPADDING="5"
  47454. ><TR
  47455. ><TD
  47456. ><PRE
  47457. CLASS="php"
  47458. >Array
  47459. (
  47460.     [farbe] => Array
  47461.         (
  47462.             [favorit] => Array
  47463.                 (
  47464.                     [0] => rot
  47465.                     [1] => grⁿn
  47466.                 )
  47467.  
  47468.             [0] => blau
  47469.         )
  47470.  
  47471.     [0] => 5
  47472.     [1] => 10
  47473. )</PRE
  47474. ></TD
  47475. ></TR
  47476. ></TABLE
  47477. ></DIV
  47478. ></TD
  47479. ></TR
  47480. ></TABLE
  47481. >
  47482.     </P
  47483. ><P
  47484. >      See also <A
  47485. HREF="#function.array-merge"
  47486. ><B
  47487. CLASS="function"
  47488. >array_merge()</B
  47489. ></A
  47490. >.
  47491.     </P
  47492. ></DIV
  47493. ><H1
  47494. ><A
  47495. NAME="function.array-merge"
  47496. ></A
  47497. >array_merge</H1
  47498. ><DIV
  47499. CLASS="refnamediv"
  47500. ><A
  47501. NAME="AEN8171"
  47502. ></A
  47503. ><P
  47504. >    (PHP 4 , PHP 5)</P
  47505. >array_merge -- Fⁿhrt zwei oder mehr Arrays zusammen</DIV
  47506. ><DIV
  47507. CLASS="refsect1"
  47508. ><A
  47509. NAME="AEN8174"
  47510. ></A
  47511. ><H2
  47512. >Beschreibung</H2
  47513. >array <B
  47514. CLASS="methodname"
  47515. >array_merge</B
  47516. > ( array array1, array array2 [, array ...])<BR
  47517. ></BR
  47518. ><P
  47519. >      <B
  47520. CLASS="function"
  47521. >array_merge()</B
  47522. > fⁿgt die Elemente von zwei oder
  47523.      mehr Arrays zusammen, indem die Werte des einen an das Ende des
  47524.      anderen angehΣngt werden. Das daraus resultierende Array wird
  47525.      zurⁿckgegeben.
  47526.     </P
  47527. ><P
  47528. >      Haben die angegebenen Arrays die selben String-Schlⁿssel, dann
  47529.      wird der hintere Wert dieses Schlⁿssels den vorhergehenden
  47530.      ⁿberschreiben. Haben die Arrays den gleichen numerischen
  47531.      Schlⁿssel, dann wird der hintere Wert den vorhergehenden <SPAN
  47532. CLASS="strong"
  47533. ><B
  47534. CLASS="emphasis"
  47535. >nicht</B
  47536. ></SPAN
  47537. > ⁿberschreiben, sondern angehΣngt.
  47538.     </P
  47539. ><P
  47540. >      <TABLE
  47541. WIDTH="100%"
  47542. BORDER="0"
  47543. CELLPADDING="0"
  47544. CELLSPACING="0"
  47545. CLASS="EXAMPLE"
  47546. ><TR
  47547. ><TD
  47548. ><DIV
  47549. CLASS="example"
  47550. ><A
  47551. NAME="AEN8193"
  47552. ></A
  47553. ><P
  47554. ><B
  47555. >Beispiel 1. <B
  47556. CLASS="function"
  47557. >array_merge()</B
  47558. ></B
  47559. ></P
  47560. ><TABLE
  47561. BORDER="0"
  47562. BGCOLOR="#E0E0E0"
  47563. CELLPADDING="5"
  47564. ><TR
  47565. ><TD
  47566. ><PRE
  47567. CLASS="php"
  47568. ><?php
  47569. $array1 = array ("farbe" => "rot", 2, 4);
  47570. $array2 = array ("a", "b", "farbe" => "grⁿn", "form" => "trapezoid", 4);
  47571. $result = array_merge ($array1, $array2);
  47572. print_r($result);
  47573. ?></PRE
  47574. ></TD
  47575. ></TR
  47576. ></TABLE
  47577. ><P
  47578. >        Nun ist <VAR
  47579. CLASS="literal"
  47580. >$result</VAR
  47581. >:
  47582.       </P
  47583. ><TABLE
  47584. BORDER="0"
  47585. BGCOLOR="#E0E0E0"
  47586. CELLPADDING="5"
  47587. ><TR
  47588. ><TD
  47589. ><PRE
  47590. CLASS="php"
  47591. >Array
  47592. (
  47593.     [farbe] => grⁿn
  47594.     [0] => 2
  47595.     [1] => 4
  47596.     [2] => a
  47597.     [3] => b
  47598.     [form] => trapezoid
  47599.     [4] => 4
  47600. )</PRE
  47601. ></TD
  47602. ></TR
  47603. ></TABLE
  47604. ></DIV
  47605. ></TD
  47606. ></TR
  47607. ></TABLE
  47608. >
  47609.     </P
  47610. ><P
  47611. >      <TABLE
  47612. WIDTH="100%"
  47613. BORDER="0"
  47614. CELLPADDING="0"
  47615. CELLSPACING="0"
  47616. CLASS="EXAMPLE"
  47617. ><TR
  47618. ><TD
  47619. ><DIV
  47620. CLASS="example"
  47621. ><A
  47622. NAME="AEN8201"
  47623. ></A
  47624. ><P
  47625. ><B
  47626. >Beispiel 2. Einfaches <B
  47627. CLASS="function"
  47628. >array_merge()</B
  47629. > Beispiel</B
  47630. ></P
  47631. ><TABLE
  47632. BORDER="0"
  47633. BGCOLOR="#E0E0E0"
  47634. CELLPADDING="5"
  47635. ><TR
  47636. ><TD
  47637. ><PRE
  47638. CLASS="php"
  47639. ><?php
  47640. $array1 = array();
  47641. $array2 = array(1 => "data");
  47642. $result = array_merge($array1, $array2);
  47643. ?></PRE
  47644. ></TD
  47645. ></TR
  47646. ></TABLE
  47647. ><P
  47648. >        Vergessen Sie nicht, dass numerische Schlⁿssel neu numeriert werden!
  47649.       </P
  47650. ><TABLE
  47651. BORDER="0"
  47652. BGCOLOR="#E0E0E0"
  47653. CELLPADDING="5"
  47654. ><TR
  47655. ><TD
  47656. ><PRE
  47657. CLASS="php"
  47658. >Array
  47659. (
  47660.     [0] => data
  47661. )</PRE
  47662. ></TD
  47663. ></TR
  47664. ></TABLE
  47665. ><P
  47666. >        Wenn Sie die Arrays komplett erhalten und nur eines an das andere
  47667.        anhΣngen wollen, verwenden Sie den Operator <VAR
  47668. CLASS="literal"
  47669. >+</VAR
  47670. >:
  47671.       </P
  47672. ><TABLE
  47673. BORDER="0"
  47674. BGCOLOR="#E0E0E0"
  47675. CELLPADDING="5"
  47676. ><TR
  47677. ><TD
  47678. ><PRE
  47679. CLASS="php"
  47680. ><?php
  47681. $array1 = array();
  47682. $array2 = array(1 => "data");
  47683. $result = $array1 + $array2;
  47684. ?></PRE
  47685. ></TD
  47686. ></TR
  47687. ></TABLE
  47688. ><P
  47689. >        Der numerische Schlⁿssel sowie die Assoziation bleiben erhalten.
  47690.       </P
  47691. ><TABLE
  47692. BORDER="0"
  47693. BGCOLOR="#E0E0E0"
  47694. CELLPADDING="5"
  47695. ><TR
  47696. ><TD
  47697. ><PRE
  47698. CLASS="php"
  47699. >Array
  47700. (
  47701.     [1] => data
  47702. )</PRE
  47703. ></TD
  47704. ></TR
  47705. ></TABLE
  47706. ></DIV
  47707. ></TD
  47708. ></TR
  47709. ></TABLE
  47710. >
  47711.     </P
  47712. ><DIV
  47713. CLASS="note"
  47714. ><BLOCKQUOTE
  47715. CLASS="note"
  47716. ><P
  47717. ><B
  47718. >Anmerkung: </B
  47719. >
  47720.       Gemeinsame Schlⁿssel werden nach dem Prinzip "Wer zuerst kommt mahlt 
  47721.       zuerst" behandelt.
  47722.      </P
  47723. ></BLOCKQUOTE
  47724. ></DIV
  47725. ><P
  47726. >      Siehe auch <A
  47727. HREF="#function.array-merge-recursive"
  47728. ><B
  47729. CLASS="function"
  47730. >array_merge_recursive()</B
  47731. ></A
  47732. >.
  47733.     </P
  47734. ></DIV
  47735. ><H1
  47736. ><A
  47737. NAME="function.array-multisort"
  47738. ></A
  47739. >array_multisort</H1
  47740. ><DIV
  47741. CLASS="refnamediv"
  47742. ><A
  47743. NAME="AEN8217"
  47744. ></A
  47745. ><P
  47746. >    (PHP 4 , PHP 5)</P
  47747. >array_multisort -- Sortiert mehrere oder multidimensionale Arrays</DIV
  47748. ><DIV
  47749. CLASS="refsect1"
  47750. ><A
  47751. NAME="AEN8220"
  47752. ></A
  47753. ><H2
  47754. >Beschreibung</H2
  47755. >bool <B
  47756. CLASS="methodname"
  47757. >array_multisort</B
  47758. > ( array ar1 [, mixed arg [, mixed ... [, array ...]]])<BR
  47759. ></BR
  47760. ><P
  47761. >      <B
  47762. CLASS="function"
  47763. >array_multisort()</B
  47764. > wird zum Sortieren von
  47765.      entweder mehreren Arrays auf einmal, oder eines
  47766.      multidimensionalen Arrays (entsprechend einer von mehreren
  47767.      Dimensionen) benutzt. Bei der Sortierung werden die
  47768.      Schlⁿsselassoziationen beibehalten.
  47769.     </P
  47770. ><P
  47771. >      Die angegebenen Arrays werden als Spalten einer Tabelle
  47772.      behandelt, welche nach Reihen sortiert werden - Σhnlich der SQL
  47773.      Klausel ORDER BY.  Das erste Array ist auch das erste in der
  47774.      Sortierreihenfolge. Die in diesem Array gleichen Zeilen (Werte)
  47775.      werden anhand des nΣchsten angegebenen Arrays sortiert, usw.
  47776.     </P
  47777. ><P
  47778. >      Die Struktur der Argumente ist etwas ungew÷hnlich, aber
  47779.      flexibel. Das aller erste Argument muss ein Array sein. Die
  47780.      nachfolgenden Argumente k÷nnen entweder ein Array oder eines der
  47781.      folgenden Sortierflags sein.
  47782.     </P
  47783. ><P
  47784. >      Flags fⁿr Sortierreihenfolge:
  47785.      <P
  47786. ></P
  47787. ><UL
  47788. ><LI
  47789. ><P
  47790. >SORT_ASC - sortiere in aufsteigender Reihenfolge</P
  47791. ></LI
  47792. ><LI
  47793. ><P
  47794. >SORT_DESC - sortiere in absteigender Reihenfolge</P
  47795. ></LI
  47796. ></UL
  47797. >
  47798.     </P
  47799. ><P
  47800. >      Flags fⁿr Sortiertypen:
  47801.      <P
  47802. ></P
  47803. ><UL
  47804. ><LI
  47805. ><P
  47806. >SORT_REGULAR - vergleiche Felder normal</P
  47807. ></LI
  47808. ><LI
  47809. ><P
  47810. >SORT_NUMERIC - vergleiche Felder numerisch</P
  47811. ></LI
  47812. ><LI
  47813. ><P
  47814. >SORT_STRING - vergleiche Felder als Strings</P
  47815. ></LI
  47816. ></UL
  47817. >
  47818.     </P
  47819. ><P
  47820. >      Es kann nur ein Sortierflag des selben Typs nach jedem Array
  47821.      spezifiziert werden. Sortierflags nach einem Array Argument
  47822.      gelten nur fⁿr dieses Array, und werden vor jedem neuen Array
  47823.      Argument zu den Defaultflags SORT_ASC und SORT_REGULAR
  47824.      zurⁿckgesetzt.
  47825.     </P
  47826. ><P
  47827. >      Gibt bei Erfolg <TT
  47828. CLASS="constant"
  47829. ><B
  47830. >TRUE</B
  47831. ></TT
  47832. > zurⁿck, im Fehlerfall <TT
  47833. CLASS="constant"
  47834. ><B
  47835. >FALSE</B
  47836. ></TT
  47837. >.
  47838.     </P
  47839. ><P
  47840. >      <TABLE
  47841. WIDTH="100%"
  47842. BORDER="0"
  47843. CELLPADDING="0"
  47844. CELLSPACING="0"
  47845. CLASS="EXAMPLE"
  47846. ><TR
  47847. ><TD
  47848. ><DIV
  47849. CLASS="example"
  47850. ><A
  47851. NAME="AEN8260"
  47852. ></A
  47853. ><P
  47854. ><B
  47855. >Beispiel 1. Sortieren mehrerer Arrays</B
  47856. ></P
  47857. ><TABLE
  47858. BORDER="0"
  47859. BGCOLOR="#E0E0E0"
  47860. CELLPADDING="5"
  47861. ><TR
  47862. ><TD
  47863. ><PRE
  47864. CLASS="php"
  47865. ><?php
  47866. $ar1 = array ("10", 100, 100, "a");
  47867. $ar2 = array (1, 3, "2", 1);
  47868. array_multisort ($ar1, $ar2);
  47869. ?></PRE
  47870. ></TD
  47871. ></TR
  47872. ></TABLE
  47873. ></DIV
  47874. ></TD
  47875. ></TR
  47876. ></TABLE
  47877. >
  47878.     </P
  47879. ><P
  47880. >      In diesem Beispiel enthΣlt das erste Array nach dem Sortieren 10,
  47881.      "a", 100, 100. Das zweite Array wird 1, 1, "2", 3 enthalten. Die
  47882.      EintrΣge des zweiten Arrays, welche den identischen EintrΣgen des
  47883.      ersten Arrays entsprechen (100 und 100) wurden ebenfalls
  47884.      sortiert.
  47885.     </P
  47886. ><P
  47887. >      <TABLE
  47888. WIDTH="100%"
  47889. BORDER="0"
  47890. CELLPADDING="0"
  47891. CELLSPACING="0"
  47892. CLASS="EXAMPLE"
  47893. ><TR
  47894. ><TD
  47895. ><DIV
  47896. CLASS="example"
  47897. ><A
  47898. NAME="AEN8265"
  47899. ></A
  47900. ><P
  47901. ><B
  47902. >Beispiel 2. Sortieren eines mehrdimensionalen Arrays</B
  47903. ></P
  47904. ><TABLE
  47905. BORDER="0"
  47906. BGCOLOR="#E0E0E0"
  47907. CELLPADDING="5"
  47908. ><TR
  47909. ><TD
  47910. ><PRE
  47911. CLASS="php"
  47912. ><?php
  47913. $ar = array (array ("10", 100, 100, "a"), array (1, 3, "2", 1));
  47914. array_multisort ($ar[0], SORT_ASC, SORT_STRING,
  47915.                  $ar[1], SORT_NUMERIC, SORT_DESC);
  47916. ?></PRE
  47917. ></TD
  47918. ></TR
  47919. ></TABLE
  47920. ></DIV
  47921. ></TD
  47922. ></TR
  47923. ></TABLE
  47924. >
  47925.     </P
  47926. ><P
  47927. >      In diesem Beispiel enthΣlt das erste Array nach dem Sortieren 10,
  47928.      100, 100, "a" (wurde als Strings in aufsteigender Reihenfolge
  47929.      sortiert), und das zweite enthΣlt 1, 3, "2", 1 (numerisch und
  47930.      absteigender Reihenfolge sortiert).
  47931.     </P
  47932. ></DIV
  47933. ><H1
  47934. ><A
  47935. NAME="function.array-pad"
  47936. ></A
  47937. >array_pad</H1
  47938. ><DIV
  47939. CLASS="refnamediv"
  47940. ><A
  47941. NAME="AEN8270"
  47942. ></A
  47943. ><P
  47944. >    (PHP 4 , PHP 5)</P
  47945. >array_pad -- 
  47946.      Vergr÷▀ert ein Array auf die spezifizierte LΣnge mit einem Wert
  47947.     </DIV
  47948. ><DIV
  47949. CLASS="refsect1"
  47950. ><A
  47951. NAME="AEN8273"
  47952. ></A
  47953. ><H2
  47954. >Beschreibung</H2
  47955. >array <B
  47956. CLASS="methodname"
  47957. >array_pad</B
  47958. > ( array input, int pad_size, mixed pad_value)<BR
  47959. ></BR
  47960. ><P
  47961. >      <B
  47962. CLASS="function"
  47963. >array_pad()</B
  47964. > liefert eine Kopie von
  47965.      <VAR
  47966. CLASS="parameter"
  47967. >input</VAR
  47968. >, welche auf die von
  47969.      <VAR
  47970. CLASS="parameter"
  47971. >pad_size</VAR
  47972. > spezifizierte Gr÷▀e mit dem Wert
  47973.      <VAR
  47974. CLASS="parameter"
  47975. >pad_value</VAR
  47976. > erweitert wurde. Ist der
  47977.      Parameter <VAR
  47978. CLASS="parameter"
  47979. >pad_size</VAR
  47980. > positiv, wird das Array
  47981.      rechts erweitert, ist er negativ, dann erfolgt die Erweiterung
  47982.      links. Ist der absolute Wert von <VAR
  47983. CLASS="parameter"
  47984. >pad_size</VAR
  47985. >
  47986.      kleiner oder gleich der LΣnge von <VAR
  47987. CLASS="parameter"
  47988. >input</VAR
  47989. >,
  47990.      erfolgt keine Erweiterung.
  47991.     </P
  47992. ><P
  47993. >      <TABLE
  47994. WIDTH="100%"
  47995. BORDER="0"
  47996. CELLPADDING="0"
  47997. CELLSPACING="0"
  47998. CLASS="EXAMPLE"
  47999. ><TR
  48000. ><TD
  48001. ><DIV
  48002. CLASS="example"
  48003. ><A
  48004. NAME="AEN8296"
  48005. ></A
  48006. ><P
  48007. ><B
  48008. >Beispiel 1. <B
  48009. CLASS="function"
  48010. >array_pad()</B
  48011. ></B
  48012. ></P
  48013. ><TABLE
  48014. BORDER="0"
  48015. BGCOLOR="#E0E0E0"
  48016. CELLPADDING="5"
  48017. ><TR
  48018. ><TD
  48019. ><PRE
  48020. CLASS="php"
  48021. ><?php
  48022. $input = array (12, 10, 9);
  48023.  
  48024. $result = array_pad ($input, 5, 0);
  48025. // Ergebnis ist array (12, 10, 9, 0, 0)
  48026.  
  48027. $result = array_pad ($input, -7, -1);
  48028. // Ergebnis ist array (-1, -1, -1, -1, 12, 10, 9)
  48029.  
  48030. $result = array_pad ($input, 2, "noop");
  48031. // nicht erweitert
  48032. ?></PRE
  48033. ></TD
  48034. ></TR
  48035. ></TABLE
  48036. ></DIV
  48037. ></TD
  48038. ></TR
  48039. ></TABLE
  48040. >
  48041.     </P
  48042. ></DIV
  48043. ><H1
  48044. ><A
  48045. NAME="function.array-pop"
  48046. ></A
  48047. >array_pop</H1
  48048. ><DIV
  48049. CLASS="refnamediv"
  48050. ><A
  48051. NAME="AEN8301"
  48052. ></A
  48053. ><P
  48054. >    (PHP 4 , PHP 5)</P
  48055. >array_pop -- Liefert das letzte Element eines Arrays</DIV
  48056. ><DIV
  48057. CLASS="refsect1"
  48058. ><A
  48059. NAME="AEN8304"
  48060. ></A
  48061. ><H2
  48062. >Beschreibung</H2
  48063. >mixed <B
  48064. CLASS="methodname"
  48065. >array_pop</B
  48066. > ( array array)<BR
  48067. ></BR
  48068. ><P
  48069. >      <B
  48070. CLASS="function"
  48071. >array_pop()</B
  48072. > liefert den letzten Wert von
  48073.      <VAR
  48074. CLASS="parameter"
  48075. >array</VAR
  48076. >, und verkⁿrzt
  48077.      <VAR
  48078. CLASS="parameter"
  48079. >array</VAR
  48080. > um ein Element. Ist
  48081.      <VAR
  48082. CLASS="parameter"
  48083. >array</VAR
  48084. > leer (oder kein Array), wird <TT
  48085. CLASS="constant"
  48086. ><B
  48087. >NULL</B
  48088. ></TT
  48089. >
  48090.      zurⁿckgegeben.
  48091.     </P
  48092. ><DIV
  48093. CLASS="note"
  48094. ><BLOCKQUOTE
  48095. CLASS="note"
  48096. ><P
  48097. ><B
  48098. >Anmerkung: </B
  48099. >Diese Funktion setzt
  48100. (<A
  48101. HREF="#function.reset"
  48102. ><B
  48103. CLASS="function"
  48104. >reset()</B
  48105. ></A
  48106. >) nach Verwendung den <A
  48107. HREF="#language.types.array"
  48108. ><B
  48109. CLASS="type"
  48110. >array</B
  48111. ></A
  48112. >-Zeiger
  48113. zurⁿck.</P
  48114. ></BLOCKQUOTE
  48115. ></DIV
  48116. ><P
  48117. >      <TABLE
  48118. WIDTH="100%"
  48119. BORDER="0"
  48120. CELLPADDING="0"
  48121. CELLSPACING="0"
  48122. CLASS="EXAMPLE"
  48123. ><TR
  48124. ><TD
  48125. ><DIV
  48126. CLASS="example"
  48127. ><A
  48128. NAME="AEN8323"
  48129. ></A
  48130. ><P
  48131. ><B
  48132. >Beispiel 1. <B
  48133. CLASS="function"
  48134. >array_pop()</B
  48135. ></B
  48136. ></P
  48137. ><TABLE
  48138. BORDER="0"
  48139. BGCOLOR="#E0E0E0"
  48140. CELLPADDING="5"
  48141. ><TR
  48142. ><TD
  48143. ><PRE
  48144. CLASS="php"
  48145. ><?php
  48146. $stack = array ("Orange", "Banane", "Apfel", "Himbeere");
  48147. $fruit = array_pop ($stack);
  48148. print_r($stack);
  48149. ?></PRE
  48150. ></TD
  48151. ></TR
  48152. ></TABLE
  48153. ><P
  48154. >        Danach hat <VAR
  48155. CLASS="varname"
  48156. >$stack</VAR
  48157. > nur 3 Elemente:
  48158.       </P
  48159. ><TABLE
  48160. BORDER="0"
  48161. BGCOLOR="#E0E0E0"
  48162. CELLPADDING="5"
  48163. ><TR
  48164. ><TD
  48165. ><PRE
  48166. CLASS="php"
  48167. >Array
  48168. (
  48169.     [0] => Orange
  48170.     [1] => Banane
  48171.     [2] => Apfel
  48172. )</PRE
  48173. ></TD
  48174. ></TR
  48175. ></TABLE
  48176. ><P
  48177. >        und <VAR
  48178. CLASS="literal"
  48179. >Himbeere</VAR
  48180. > wird <VAR
  48181. CLASS="varname"
  48182. >$fruit</VAR
  48183. >
  48184.        zugewiesen.
  48185.       </P
  48186. ></DIV
  48187. ></TD
  48188. ></TR
  48189. ></TABLE
  48190. >
  48191.     </P
  48192. ><DIV
  48193. CLASS="warning"
  48194. ><P
  48195. ></P
  48196. ><TABLE
  48197. CLASS="warning"
  48198. BORDER="1"
  48199. WIDTH="100%"
  48200. ><TR
  48201. ><TD
  48202. ALIGN="CENTER"
  48203. ><B
  48204. >Warnung</B
  48205. ></TD
  48206. ></TR
  48207. ><TR
  48208. ><TD
  48209. ALIGN="LEFT"
  48210. ><P
  48211. >Diese Funktion kann sowohl das
  48212. Boolsche <TT
  48213. CLASS="constant"
  48214. ><B
  48215. >FALSE</B
  48216. ></TT
  48217. > zurⁿckliefern, als auch einen nicht-Boolschen Wert, wie zum
  48218. Beispiel<VAR
  48219. CLASS="literal"
  48220. >0</VAR
  48221. > oder "". der von einem einfachen
  48222. if-Statement als <TT
  48223. CLASS="constant"
  48224. ><B
  48225. >FALSE</B
  48226. ></TT
  48227. > ausgewertet wird. Weitere Informationen entnehmen Sie
  48228. bitte dem Abschnitt ⁿber die <A
  48229. HREF="#language.types.boolean"
  48230. > Boolsche Typen</A
  48231. >. Benutzen Sie deshalb
  48232. <A
  48233. HREF="#language.operators.comparison"
  48234. >den === Operator</A
  48235. >
  48236. um den Rⁿckgabewert dieser Funktion zu ⁿberprⁿfen.</P
  48237. ></TD
  48238. ></TR
  48239. ></TABLE
  48240. ></DIV
  48241. ><P
  48242. >      Siehe auch <A
  48243. HREF="#function.array-push"
  48244. ><B
  48245. CLASS="function"
  48246. >array_push()</B
  48247. ></A
  48248. >,
  48249.      <A
  48250. HREF="#function.array-shift"
  48251. ><B
  48252. CLASS="function"
  48253. >array_shift()</B
  48254. ></A
  48255. > und
  48256.      <A
  48257. HREF="#function.array-unshift"
  48258. ><B
  48259. CLASS="function"
  48260. >array_unshift()</B
  48261. ></A
  48262. >.
  48263.     </P
  48264. ></DIV
  48265. ><H1
  48266. ><A
  48267. NAME="function.array-push"
  48268. ></A
  48269. >array_push</H1
  48270. ><DIV
  48271. CLASS="refnamediv"
  48272. ><A
  48273. NAME="AEN8345"
  48274. ></A
  48275. ><P
  48276. >    (PHP 4 , PHP 5)</P
  48277. >array_push -- 
  48278.      Fⁿgt ein oder mehr Elemente an das Ende eines Arrays
  48279.     </DIV
  48280. ><DIV
  48281. CLASS="refsect1"
  48282. ><A
  48283. NAME="AEN8348"
  48284. ></A
  48285. ><H2
  48286. >Beschreibung</H2
  48287. >int <B
  48288. CLASS="methodname"
  48289. >array_push</B
  48290. > ( array array, mixed var [, mixed ...])<BR
  48291. ></BR
  48292. ><P
  48293. >      <B
  48294. CLASS="function"
  48295. >array_push()</B
  48296. > behandelt
  48297.      <VAR
  48298. CLASS="parameter"
  48299. >array</VAR
  48300. > als Stapel (Stack), und fⁿgt die
  48301.      ⁿbergebenen Variablen an das Ende von
  48302.      <VAR
  48303. CLASS="parameter"
  48304. >array</VAR
  48305. >.  Die LΣnge von
  48306.      <VAR
  48307. CLASS="parameter"
  48308. >array</VAR
  48309. > wird dabei um die Anzahl der
  48310.      angefⁿgten Variablen erh÷ht. Dies hat den selben Effekt wie:
  48311.      <TABLE
  48312. BORDER="0"
  48313. BGCOLOR="#E0E0E0"
  48314. CELLPADDING="5"
  48315. ><TR
  48316. ><TD
  48317. ><PRE
  48318. CLASS="php"
  48319. ><?php
  48320. $array[] = $var;
  48321. ?></PRE
  48322. ></TD
  48323. ></TR
  48324. ></TABLE
  48325. >
  48326.      fⁿr jede Variable <VAR
  48327. CLASS="parameter"
  48328. >var</VAR
  48329. > wiederholt.
  48330.     </P
  48331. ><P
  48332. >      Liefert die neue Anzahl Elemente des Arrays.
  48333.     </P
  48334. ><P
  48335. >      <TABLE
  48336. WIDTH="100%"
  48337. BORDER="0"
  48338. CELLPADDING="0"
  48339. CELLSPACING="0"
  48340. CLASS="EXAMPLE"
  48341. ><TR
  48342. ><TD
  48343. ><DIV
  48344. CLASS="example"
  48345. ><A
  48346. NAME="AEN8371"
  48347. ></A
  48348. ><P
  48349. ><B
  48350. >Beispiel 1. <B
  48351. CLASS="function"
  48352. >array_push()</B
  48353. ></B
  48354. ></P
  48355. ><TABLE
  48356. BORDER="0"
  48357. BGCOLOR="#E0E0E0"
  48358. CELLPADDING="5"
  48359. ><TR
  48360. ><TD
  48361. ><PRE
  48362. CLASS="php"
  48363. ><?php
  48364. $stack = array ("Orange", "Banane");
  48365. array_push ($stack, "Apfel", "Himbeere");
  48366. print_r($stack);
  48367. ?></PRE
  48368. ></TD
  48369. ></TR
  48370. ></TABLE
  48371. ><P
  48372. >        Danach enthΣlt <VAR
  48373. CLASS="varname"
  48374. >$stack</VAR
  48375. >
  48376.        die folgenden Elemente:
  48377.       </P
  48378. ><TABLE
  48379. BORDER="0"
  48380. BGCOLOR="#E0E0E0"
  48381. CELLPADDING="5"
  48382. ><TR
  48383. ><TD
  48384. ><PRE
  48385. CLASS="php"
  48386. >Array
  48387. (
  48388.     [0] => Orange
  48389.     [1] => Banane
  48390.     [2] => Apfel
  48391.     [3] => Himbeere
  48392. )</PRE
  48393. ></TD
  48394. ></TR
  48395. ></TABLE
  48396. ></DIV
  48397. ></TD
  48398. ></TR
  48399. ></TABLE
  48400. >
  48401.     </P
  48402. ><P
  48403. >      Siehe auch <A
  48404. HREF="#function.array-pop"
  48405. ><B
  48406. CLASS="function"
  48407. >array_pop()</B
  48408. ></A
  48409. >,
  48410.      <A
  48411. HREF="#function.array-shift"
  48412. ><B
  48413. CLASS="function"
  48414. >array_shift()</B
  48415. ></A
  48416. > und
  48417.      <A
  48418. HREF="#function.array-unshift"
  48419. ><B
  48420. CLASS="function"
  48421. >array_unshift()</B
  48422. ></A
  48423. >.
  48424.     </P
  48425. ></DIV
  48426. ><H1
  48427. ><A
  48428. NAME="function.array-rand"
  48429. ></A
  48430. >array_rand</H1
  48431. ><DIV
  48432. CLASS="refnamediv"
  48433. ><A
  48434. NAME="AEN8383"
  48435. ></A
  48436. ><P
  48437. >    (PHP 4 , PHP 5)</P
  48438. >array_rand -- 
  48439.      Liefert einen oder mehrere zufΣllige EintrΣge eines Arrays
  48440.     </DIV
  48441. ><DIV
  48442. CLASS="refsect1"
  48443. ><A
  48444. NAME="AEN8386"
  48445. ></A
  48446. ><H2
  48447. >Beschreibung</H2
  48448. >mixed <B
  48449. CLASS="methodname"
  48450. >array_rand</B
  48451. > ( array input [, int num_req])<BR
  48452. ></BR
  48453. ><P
  48454. >      <B
  48455. CLASS="function"
  48456. >array_rand()</B
  48457. > ist ziemlich nⁿtzlich, wenn Sie
  48458.      einen oder mehrere zufΣllige EintrΣge eines Arrays auswΣhlen
  48459.      m÷chten. Die Funktion ⁿbernimmt das Array
  48460.      <VAR
  48461. CLASS="parameter"
  48462. >input</VAR
  48463. >, und ein optionales Argument
  48464.      <VAR
  48465. CLASS="parameter"
  48466. >num_req</VAR
  48467. >, welches die gewⁿnschte Anzahl
  48468.      EintrΣge spezifiziert. Ist <VAR
  48469. CLASS="parameter"
  48470. >num_req</VAR
  48471. > nicht
  48472.      angegeben, wird ein Defaultwert von 1 angenommen.
  48473.     </P
  48474. ><P
  48475. >      Wenn Sie nur einen Eintrag auswΣhlen, liefert
  48476.      <B
  48477. CLASS="function"
  48478. >array_rand()</B
  48479. > den Schlⁿssel eines zufΣlligen
  48480.      Eintrages.  Andernfalls wird ein Array mit den Schlⁿsseln der
  48481.      zufΣlligen EintrΣge zurⁿckgegeben. Dies hat den Zweck, dass Sie
  48482.      zufΣllige Schlⁿssel und auch Werte aus dem Array auswΣhlen
  48483.      k÷nnen.
  48484.     </P
  48485. ><DIV
  48486. CLASS="note"
  48487. ><BLOCKQUOTE
  48488. CLASS="note"
  48489. ><P
  48490. ><B
  48491. >Anmerkung: </B
  48492. >Seit PHP 4.2.0 besteht keine
  48493. Notwendigkeit mehr, den Zufallsgenerator fⁿr Zahlen mit
  48494. <A
  48495. HREF="#function.srand"
  48496. ><B
  48497. CLASS="function"
  48498. >srand()</B
  48499. ></A
  48500. > oder <A
  48501. HREF="#function.mt-srand"
  48502. ><B
  48503. CLASS="function"
  48504. >mt_srand()</B
  48505. ></A
  48506. > zu fⁿttern, das
  48507. geschieht nun automatisch.</P
  48508. ></BLOCKQUOTE
  48509. ></DIV
  48510. ><P
  48511. >      <TABLE
  48512. WIDTH="100%"
  48513. BORDER="0"
  48514. CELLPADDING="0"
  48515. CELLSPACING="0"
  48516. CLASS="EXAMPLE"
  48517. ><TR
  48518. ><TD
  48519. ><DIV
  48520. CLASS="example"
  48521. ><A
  48522. NAME="AEN8409"
  48523. ></A
  48524. ><P
  48525. ><B
  48526. >Beispiel 1. <B
  48527. CLASS="function"
  48528. >array_rand()</B
  48529. ></B
  48530. ></P
  48531. ><TABLE
  48532. BORDER="0"
  48533. BGCOLOR="#E0E0E0"
  48534. CELLPADDING="5"
  48535. ><TR
  48536. ><TD
  48537. ><PRE
  48538. CLASS="php"
  48539. ><?php
  48540. srand ((float) microtime() * 10000000);
  48541. $input = array ("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
  48542. $rand_keys = array_rand ($input, 2);
  48543. print $input[$rand_keys[0]]."\n";
  48544. print $input[$rand_keys[1]]."\n";
  48545. ?></PRE
  48546. ></TD
  48547. ></TR
  48548. ></TABLE
  48549. ></DIV
  48550. ></TD
  48551. ></TR
  48552. ></TABLE
  48553. >
  48554.     </P
  48555. ></DIV
  48556. ><H1
  48557. ><A
  48558. NAME="function.array-reduce"
  48559. ></A
  48560. >array_reduce</H1
  48561. ><DIV
  48562. CLASS="refnamediv"
  48563. ><A
  48564. NAME="AEN8414"
  48565. ></A
  48566. ><P
  48567. >    (PHP 4 >= 4.0.5, PHP 5)</P
  48568. >array_reduce -- 
  48569.      Iterative Reduktion eines Arrays zu einem Wert mittels einer
  48570.      Callback Funktion
  48571.     </DIV
  48572. ><DIV
  48573. CLASS="refsect1"
  48574. ><A
  48575. NAME="AEN8417"
  48576. ></A
  48577. ><H2
  48578. >Beschreibung</H2
  48579. >mixed <B
  48580. CLASS="methodname"
  48581. >array_reduce</B
  48582. > ( array input, callback function [, int initial])<BR
  48583. ></BR
  48584. ><P
  48585. >      <B
  48586. CLASS="function"
  48587. >array_reduce()</B
  48588. > wendet die Funktion
  48589.      <VAR
  48590. CLASS="parameter"
  48591. >function</VAR
  48592. > iterativ bei den Elementen des Arrays
  48593.      <VAR
  48594. CLASS="parameter"
  48595. >input</VAR
  48596. > so an, dass das Array auf einen einzigen
  48597.      Wert reduziert wird. Ist der optionale Parameter
  48598.      <VAR
  48599. CLASS="parameter"
  48600. >intial</VAR
  48601. > angegeben, wird er am Beginn des Prozesses
  48602.      benutzt oder als Resultat verwendet, sollte das Array leer sein.
  48603.     </P
  48604. ><P
  48605. >      <TABLE
  48606. WIDTH="100%"
  48607. BORDER="0"
  48608. CELLPADDING="0"
  48609. CELLSPACING="0"
  48610. CLASS="EXAMPLE"
  48611. ><TR
  48612. ><TD
  48613. ><DIV
  48614. CLASS="example"
  48615. ><A
  48616. NAME="AEN8437"
  48617. ></A
  48618. ><P
  48619. ><B
  48620. >Beispiel 1. <B
  48621. CLASS="function"
  48622. >array_reduce()</B
  48623. ></B
  48624. ></P
  48625. ><TABLE
  48626. BORDER="0"
  48627. BGCOLOR="#E0E0E0"
  48628. CELLPADDING="5"
  48629. ><TR
  48630. ><TD
  48631. ><PRE
  48632. CLASS="php"
  48633. ><?php
  48634. function rsum($v, $w) {
  48635.     $v += $w;
  48636.     return $v;
  48637. }
  48638.  
  48639. function rmul($v, $w) {
  48640.     $v *= $w;
  48641.     return $v;
  48642. }
  48643.  
  48644. $a = array(1, 2, 3, 4, 5);
  48645. $x = array();
  48646. $b = array_reduce($a, "rsum");
  48647. $c = array_reduce($a, "rmul", 10);
  48648. $d = array_reduce($x, "rsum", 1);
  48649. ?></PRE
  48650. ></TD
  48651. ></TR
  48652. ></TABLE
  48653. ></DIV
  48654. ></TD
  48655. ></TR
  48656. ></TABLE
  48657. >
  48658.     </P
  48659. ><P
  48660. >      Hier enthΣlt <VAR
  48661. CLASS="varname"
  48662. >$b</VAR
  48663. > <VAR
  48664. CLASS="literal"
  48665. >15</VAR
  48666. >,
  48667.      <VAR
  48668. CLASS="varname"
  48669. >$c</VAR
  48670. > <VAR
  48671. CLASS="literal"
  48672. >1200</VAR
  48673. > (= 1*2*3*4*5*10),
  48674.      und <VAR
  48675. CLASS="varname"
  48676. >$d</VAR
  48677. > enthΣlt <VAR
  48678. CLASS="literal"
  48679. >1</VAR
  48680. >.
  48681.     </P
  48682. ><P
  48683. >      Siehe auch <A
  48684. HREF="#function.array-filter"
  48685. ><B
  48686. CLASS="function"
  48687. >array_filter()</B
  48688. ></A
  48689. > und
  48690.      <A
  48691. HREF="#function.array-map"
  48692. ><B
  48693. CLASS="function"
  48694. >array_map()</B
  48695. ></A
  48696. >.
  48697.     </P
  48698. ></DIV
  48699. ><H1
  48700. ><A
  48701. NAME="function.array-reverse"
  48702. ></A
  48703. >array_reverse</H1
  48704. ><DIV
  48705. CLASS="refnamediv"
  48706. ><A
  48707. NAME="AEN8452"
  48708. ></A
  48709. ><P
  48710. >    (PHP 4 , PHP 5)</P
  48711. >array_reverse -- 
  48712.      Liefert ein Array mit umgekehrter Reihenfolge der Elemente
  48713.     </DIV
  48714. ><DIV
  48715. CLASS="refsect1"
  48716. ><A
  48717. NAME="AEN8455"
  48718. ></A
  48719. ><H2
  48720. >Beschreibung</H2
  48721. >array <B
  48722. CLASS="methodname"
  48723. >array_reverse</B
  48724. > ( array array [, bool preserve_keys])<BR
  48725. ></BR
  48726. ><P
  48727. >      <B
  48728. CLASS="function"
  48729. >array_reverse()</B
  48730. > liefert ein Array mit der
  48731.      umgekehrten Reihenfolge der Elemente von
  48732.      <VAR
  48733. CLASS="parameter"
  48734. >array</VAR
  48735. >. Ist der optionale Parameter
  48736.      <VAR
  48737. CLASS="parameter"
  48738. >preserve_keys</VAR
  48739. > <TT
  48740. CLASS="constant"
  48741. ><B
  48742. >TRUE</B
  48743. ></TT
  48744. >, bleibt die
  48745.      Reihenfolge der Schlⁿssel aufrecht.
  48746.     </P
  48747. ><P
  48748. >      <TABLE
  48749. WIDTH="100%"
  48750. BORDER="0"
  48751. CELLPADDING="0"
  48752. CELLSPACING="0"
  48753. CLASS="EXAMPLE"
  48754. ><TR
  48755. ><TD
  48756. ><DIV
  48757. CLASS="example"
  48758. ><A
  48759. NAME="AEN8472"
  48760. ></A
  48761. ><P
  48762. ><B
  48763. >Beispiel 1. <B
  48764. CLASS="function"
  48765. >array_reverse()</B
  48766. ></B
  48767. ></P
  48768. ><TABLE
  48769. BORDER="0"
  48770. BGCOLOR="#E0E0E0"
  48771. CELLPADDING="5"
  48772. ><TR
  48773. ><TD
  48774. ><PRE
  48775. CLASS="php"
  48776. ><?php
  48777. $input  = array ("php", 4.0, array ("grⁿn", "rot"));
  48778. $result = array_reverse ($input);
  48779. $result_keyed = array_reverse ($input, TRUE);
  48780. ?></PRE
  48781. ></TD
  48782. ></TR
  48783. ></TABLE
  48784. ><P
  48785. >        Danach haben <VAR
  48786. CLASS="varname"
  48787. >$result</VAR
  48788. > und
  48789.        <VAR
  48790. CLASS="varname"
  48791. >$result_keyed</VAR
  48792. > die gleichen Elemente, aber
  48793.        Beachten Sie den Unterschied zwischen den Schlⁿsseln. Die
  48794.        Ausgabe von <VAR
  48795. CLASS="varname"
  48796. >$result</VAR
  48797. > und
  48798.        <VAR
  48799. CLASS="varname"
  48800. >$result_keyed</VAR
  48801. > wird wie folgt aussehen:
  48802.       </P
  48803. ><TABLE
  48804. BORDER="0"
  48805. BGCOLOR="#E0E0E0"
  48806. CELLPADDING="5"
  48807. ><TR
  48808. ><TD
  48809. ><PRE
  48810. CLASS="php"
  48811. >Array
  48812. (
  48813.     [0] => Array
  48814.         (
  48815.             [0] => grⁿn
  48816.             [1] => rot
  48817.         )
  48818.  
  48819.     [1] => 4
  48820.     [2] => php
  48821. )
  48822. Array
  48823. (
  48824.     [2] => Array
  48825.         (
  48826.             [0] => grⁿn
  48827.             [1] => rot
  48828.         )
  48829.  
  48830.     [1] => 4
  48831.     [0] => php
  48832. )</PRE
  48833. ></TD
  48834. ></TR
  48835. ></TABLE
  48836. ></DIV
  48837. ></TD
  48838. ></TR
  48839. ></TABLE
  48840. >
  48841.     </P
  48842. ><DIV
  48843. CLASS="note"
  48844. ><BLOCKQUOTE
  48845. CLASS="note"
  48846. ><P
  48847. ><B
  48848. >Anmerkung: </B
  48849. >
  48850.       Der zweite Parameter wurde in PHP 4.0.3 hinzugefⁿgt.
  48851.      </P
  48852. ></BLOCKQUOTE
  48853. ></DIV
  48854. ></DIV
  48855. ><H1
  48856. ><A
  48857. NAME="function.array-search"
  48858. ></A
  48859. >array_search</H1
  48860. ><DIV
  48861. CLASS="refnamediv"
  48862. ><A
  48863. NAME="AEN8485"
  48864. ></A
  48865. ><P
  48866. >    (PHP 4 >= 4.0.5, PHP 5)</P
  48867. >array_search -- 
  48868.      Durchsucht ein Array nach einem Wert liefert bei Erfolg den
  48869.      Schlⁿssel
  48870.     </DIV
  48871. ><DIV
  48872. CLASS="refsect1"
  48873. ><A
  48874. NAME="AEN8488"
  48875. ></A
  48876. ><H2
  48877. >Beschreibung</H2
  48878. >mixed <B
  48879. CLASS="methodname"
  48880. >array_search</B
  48881. > ( mixed needle, array haystack [, bool strict])<BR
  48882. ></BR
  48883. ><P
  48884. >      Diese Funktion durchsucht <VAR
  48885. CLASS="parameter"
  48886. >haystack</VAR
  48887. > nach
  48888.      <VAR
  48889. CLASS="parameter"
  48890. >needle</VAR
  48891. > und gibt bei Erfolg den Schlⁿssel
  48892.      zurⁿck, andernfalls <TT
  48893. CLASS="constant"
  48894. ><B
  48895. >FALSE</B
  48896. ></TT
  48897. >.
  48898.     </P
  48899. ><DIV
  48900. CLASS="note"
  48901. ><BLOCKQUOTE
  48902. CLASS="note"
  48903. ><P
  48904. ><B
  48905. >Anmerkung: </B
  48906. >
  48907.       Vor PHP 4.2.0 gibt <B
  48908. CLASS="function"
  48909. >array_search()</B
  48910. > im Fehlerfall
  48911.       <TT
  48912. CLASS="constant"
  48913. ><B
  48914. >NULL</B
  48915. ></TT
  48916. > statt <TT
  48917. CLASS="constant"
  48918. ><B
  48919. >FALSE</B
  48920. ></TT
  48921. > zurⁿck.
  48922.      </P
  48923. ></BLOCKQUOTE
  48924. ></DIV
  48925. ><P
  48926. >      Ist der optionale dritte Parameter <VAR
  48927. CLASS="parameter"
  48928. >strict</VAR
  48929. >
  48930.      auf <TT
  48931. CLASS="constant"
  48932. ><B
  48933. >TRUE</B
  48934. ></TT
  48935. > gesetzt, prⁿft <B
  48936. CLASS="function"
  48937. >array_search()</B
  48938. >
  48939.      auch die Typen von <VAR
  48940. CLASS="parameter"
  48941. >needle</VAR
  48942. > in
  48943.      <VAR
  48944. CLASS="parameter"
  48945. >haystack</VAR
  48946. >.
  48947.     </P
  48948. ><DIV
  48949. CLASS="warning"
  48950. ><P
  48951. ></P
  48952. ><TABLE
  48953. CLASS="warning"
  48954. BORDER="1"
  48955. WIDTH="100%"
  48956. ><TR
  48957. ><TD
  48958. ALIGN="CENTER"
  48959. ><B
  48960. >Warnung</B
  48961. ></TD
  48962. ></TR
  48963. ><TR
  48964. ><TD
  48965. ALIGN="LEFT"
  48966. ><P
  48967. >Diese Funktion kann sowohl das
  48968. Boolsche <TT
  48969. CLASS="constant"
  48970. ><B
  48971. >FALSE</B
  48972. ></TT
  48973. > zurⁿckliefern, als auch einen nicht-Boolschen Wert, wie zum
  48974. Beispiel<VAR
  48975. CLASS="literal"
  48976. >0</VAR
  48977. > oder "". der von einem einfachen
  48978. if-Statement als <TT
  48979. CLASS="constant"
  48980. ><B
  48981. >FALSE</B
  48982. ></TT
  48983. > ausgewertet wird. Weitere Informationen entnehmen Sie
  48984. bitte dem Abschnitt ⁿber die <A
  48985. HREF="#language.types.boolean"
  48986. > Boolsche Typen</A
  48987. >. Benutzen Sie deshalb
  48988. <A
  48989. HREF="#language.operators.comparison"
  48990. >den === Operator</A
  48991. >
  48992. um den Rⁿckgabewert dieser Funktion zu ⁿberprⁿfen.</P
  48993. ></TD
  48994. ></TR
  48995. ></TABLE
  48996. ></DIV
  48997. ><P
  48998. >      Siehe auch <A
  48999. HREF="#function.array-keys"
  49000. ><B
  49001. CLASS="function"
  49002. >array_keys()</B
  49003. ></A
  49004. > und <A
  49005. HREF="#function.in-array"
  49006. ><B
  49007. CLASS="function"
  49008. >in_array()</B
  49009. ></A
  49010. >.
  49011.     </P
  49012. ></DIV
  49013. ><H1
  49014. ><A
  49015. NAME="function.array-shift"
  49016. ></A
  49017. >array_shift</H1
  49018. ><DIV
  49019. CLASS="refnamediv"
  49020. ><A
  49021. NAME="AEN8528"
  49022. ></A
  49023. ><P
  49024. >    (PHP 4 , PHP 5)</P
  49025. >array_shift -- 
  49026.      Liefert ein Element vom Beginn eines Arrays
  49027.     </DIV
  49028. ><DIV
  49029. CLASS="refsect1"
  49030. ><A
  49031. NAME="AEN8531"
  49032. ></A
  49033. ><H2
  49034. >Beschreibung</H2
  49035. >mixed <B
  49036. CLASS="methodname"
  49037. >array_shift</B
  49038. > ( array array)<BR
  49039. ></BR
  49040. ><P
  49041. >      <B
  49042. CLASS="function"
  49043. >array_shift()</B
  49044. > liefert den ersten Wert von
  49045.      <VAR
  49046. CLASS="parameter"
  49047. >array</VAR
  49048. >, verschiebt die anderen Werte
  49049.      hinunter, und verkⁿrzt <VAR
  49050. CLASS="parameter"
  49051. >array</VAR
  49052. > um ein
  49053.      Element. Alle numerischen Schlⁿssel werden so modifiziert, dass
  49054.      bei null zu zΣhlen begonnen wird. Strings als Schlⁿssel bleiben
  49055.      unverΣndert. Ist <VAR
  49056. CLASS="parameter"
  49057. >array</VAR
  49058. > leer (oder kein
  49059.      Array), wird <TT
  49060. CLASS="constant"
  49061. ><B
  49062. >NULL</B
  49063. ></TT
  49064. > zurⁿckgegeben.
  49065.     </P
  49066. ><DIV
  49067. CLASS="note"
  49068. ><BLOCKQUOTE
  49069. CLASS="note"
  49070. ><P
  49071. ><B
  49072. >Anmerkung: </B
  49073. >Diese Funktion setzt
  49074. (<A
  49075. HREF="#function.reset"
  49076. ><B
  49077. CLASS="function"
  49078. >reset()</B
  49079. ></A
  49080. >) nach Verwendung den <A
  49081. HREF="#language.types.array"
  49082. ><B
  49083. CLASS="type"
  49084. >array</B
  49085. ></A
  49086. >-Zeiger
  49087. zurⁿck.</P
  49088. ></BLOCKQUOTE
  49089. ></DIV
  49090. ><TABLE
  49091. WIDTH="100%"
  49092. BORDER="0"
  49093. CELLPADDING="0"
  49094. CELLSPACING="0"
  49095. CLASS="EXAMPLE"
  49096. ><TR
  49097. ><TD
  49098. ><DIV
  49099. CLASS="example"
  49100. ><A
  49101. NAME="AEN8549"
  49102. ></A
  49103. ><P
  49104. ><B
  49105. >Beispiel 1. <B
  49106. CLASS="function"
  49107. >array_shift()</B
  49108. ></B
  49109. ></P
  49110. ><TABLE
  49111. BORDER="0"
  49112. BGCOLOR="#E0E0E0"
  49113. CELLPADDING="5"
  49114. ><TR
  49115. ><TD
  49116. ><PRE
  49117. CLASS="php"
  49118. ><?php
  49119. $stack = array ("Orange", "Banane", "Apfel", "Himbeere");
  49120. $fruit = array_shift ($stack);
  49121. print_r($stack);
  49122. ?></PRE
  49123. ></TD
  49124. ></TR
  49125. ></TABLE
  49126. ><P
  49127. >       Danach blieben in <VAR
  49128. CLASS="varname"
  49129. >$stack</VAR
  49130. > 3 Elemente ⁿbrig:
  49131.      </P
  49132. ><TABLE
  49133. BORDER="0"
  49134. BGCOLOR="#E0E0E0"
  49135. CELLPADDING="5"
  49136. ><TR
  49137. ><TD
  49138. ><PRE
  49139. CLASS="php"
  49140. >Array
  49141. (
  49142.     [0] => Banane
  49143.     [1] => Apfel
  49144.     [2] => Himbeere
  49145. )</PRE
  49146. ></TD
  49147. ></TR
  49148. ></TABLE
  49149. ><P
  49150. >       und <VAR
  49151. CLASS="literal"
  49152. >orange</VAR
  49153. > wird
  49154.       <VAR
  49155. CLASS="varname"
  49156. >$fruit</VAR
  49157. > zugeordnet.
  49158.      </P
  49159. ></DIV
  49160. ></TD
  49161. ></TR
  49162. ></TABLE
  49163. ><P
  49164. >      Siehe auch <A
  49165. HREF="#function.array-unshift"
  49166. ><B
  49167. CLASS="function"
  49168. >array_unshift()</B
  49169. ></A
  49170. >,
  49171.      <A
  49172. HREF="#function.array-push"
  49173. ><B
  49174. CLASS="function"
  49175. >array_push()</B
  49176. ></A
  49177. > und
  49178.      <A
  49179. HREF="#function.array-pop"
  49180. ><B
  49181. CLASS="function"
  49182. >array_pop()</B
  49183. ></A
  49184. >.
  49185.     </P
  49186. ></DIV
  49187. ><H1
  49188. ><A
  49189. NAME="function.array-slice"
  49190. ></A
  49191. >array_slice</H1
  49192. ><DIV
  49193. CLASS="refnamediv"
  49194. ><A
  49195. NAME="AEN8564"
  49196. ></A
  49197. ><P
  49198. >    (PHP 4 , PHP 5)</P
  49199. >array_slice -- Extrahiert einen Ausschnitt eines Arrays</DIV
  49200. ><DIV
  49201. CLASS="refsect1"
  49202. ><A
  49203. NAME="AEN8567"
  49204. ></A
  49205. ><H2
  49206. >Beschreibung</H2
  49207. >array <B
  49208. CLASS="methodname"
  49209. >array_slice</B
  49210. > ( array array, int offset [, int length])<BR
  49211. ></BR
  49212. ><P
  49213. >      <B
  49214. CLASS="function"
  49215. >array_slice()</B
  49216. > liefert die mittels
  49217.      <VAR
  49218. CLASS="parameter"
  49219. >offset</VAR
  49220. > und <VAR
  49221. CLASS="parameter"
  49222. >length</VAR
  49223. >
  49224.      spezifizierte Sequenz von Elementen des Arrays
  49225.      <VAR
  49226. CLASS="parameter"
  49227. >array</VAR
  49228. >
  49229.     </P
  49230. ><P
  49231. >      Ist <VAR
  49232. CLASS="parameter"
  49233. >offset</VAR
  49234. > positiv, beginnt die Sequenz bei
  49235.      diesem Offset in dem <VAR
  49236. CLASS="parameter"
  49237. >array</VAR
  49238. >. Ist
  49239.      <VAR
  49240. CLASS="parameter"
  49241. >offset</VAR
  49242. > negativ, beginnt die Sequenz
  49243.      <VAR
  49244. CLASS="parameter"
  49245. >offset</VAR
  49246. > Elemente vor dem Ende von
  49247.      <VAR
  49248. CLASS="parameter"
  49249. >array</VAR
  49250. >.
  49251.     </P
  49252. ><P
  49253. >      Ist <VAR
  49254. CLASS="parameter"
  49255. >length</VAR
  49256. > positiv, enthΣlt die Sequenz
  49257.      genauso viele Elemente. Ist <VAR
  49258. CLASS="parameter"
  49259. >length</VAR
  49260. >
  49261.      negativ, enthΣlt die Sequenz alle Elemente des Arrays von
  49262.      <VAR
  49263. CLASS="parameter"
  49264. >offset</VAR
  49265. > bis <VAR
  49266. CLASS="parameter"
  49267. >length</VAR
  49268. >
  49269.      Elemente vor dem Ende des Arrays. Ist
  49270.      <VAR
  49271. CLASS="parameter"
  49272. >length</VAR
  49273. > nicht angegeben, enthΣlt die
  49274.      Sequenz alle Elemente von <VAR
  49275. CLASS="parameter"
  49276. >offset</VAR
  49277. > bis zum
  49278.      Ende von <VAR
  49279. CLASS="parameter"
  49280. >array</VAR
  49281. >.
  49282.     </P
  49283. ><P
  49284. >      Beachten Sie, dass <B
  49285. CLASS="function"
  49286. >array_slice()</B
  49287. > Schlⁿssel
  49288.      ignoriert, und Offsets sowie LΣngen anhand der aktuellen
  49289.      Positionen berechnet.
  49290.     </P
  49291. ><P
  49292. >      <TABLE
  49293. WIDTH="100%"
  49294. BORDER="0"
  49295. CELLPADDING="0"
  49296. CELLSPACING="0"
  49297. CLASS="EXAMPLE"
  49298. ><TR
  49299. ><TD
  49300. ><DIV
  49301. CLASS="example"
  49302. ><A
  49303. NAME="AEN8603"
  49304. ></A
  49305. ><P
  49306. ><B
  49307. >Beispiel 1. <B
  49308. CLASS="function"
  49309. >array_slice()</B
  49310. ></B
  49311. ></P
  49312. ><TABLE
  49313. BORDER="0"
  49314. BGCOLOR="#E0E0E0"
  49315. CELLPADDING="5"
  49316. ><TR
  49317. ><TD
  49318. ><PRE
  49319. CLASS="php"
  49320. ><?php
  49321. $input = array ("a", "b", "c", "d", "e");
  49322.  
  49323. $output = array_slice ($input, 2);      // liefert "c", "d", und "e"
  49324. $output = array_slice ($input, 2, -1);  // liefert "c", "d"
  49325. $output = array_slice ($input, -2, 1);  // liefert "d"
  49326. $output = array_slice ($input, 0, 3);   // liefert "a", "b", und "c"
  49327. ?></PRE
  49328. ></TD
  49329. ></TR
  49330. ></TABLE
  49331. ></DIV
  49332. ></TD
  49333. ></TR
  49334. ></TABLE
  49335. >
  49336.     </P
  49337. ><P
  49338. >      Siehe auch <A
  49339. HREF="#function.array-splice"
  49340. ><B
  49341. CLASS="function"
  49342. >array_splice()</B
  49343. ></A
  49344. >.
  49345.     </P
  49346. ></DIV
  49347. ><H1
  49348. ><A
  49349. NAME="function.array-splice"
  49350. ></A
  49351. >array_splice</H1
  49352. ><DIV
  49353. CLASS="refnamediv"
  49354. ><A
  49355. NAME="AEN8610"
  49356. ></A
  49357. ><P
  49358. >    (PHP 4 , PHP 5)</P
  49359. >array_splice -- 
  49360.      Entfernt einen Teil eines Arrays und ersetzt ihn durch etwas
  49361.      anderes
  49362.     </DIV
  49363. ><DIV
  49364. CLASS="refsect1"
  49365. ><A
  49366. NAME="AEN8613"
  49367. ></A
  49368. ><H2
  49369. >Beschreibung</H2
  49370. >array <B
  49371. CLASS="methodname"
  49372. >array_splice</B
  49373. > ( array input, int offset [, int length [, array replacement]])<BR
  49374. ></BR
  49375. ><P
  49376. >      <B
  49377. CLASS="function"
  49378. >array_splice()</B
  49379. > entfernt die durch
  49380.      <VAR
  49381. CLASS="parameter"
  49382. >offset</VAR
  49383. > und <VAR
  49384. CLASS="parameter"
  49385. >length</VAR
  49386. >
  49387.      angegebenen Elemente des Arrays <VAR
  49388. CLASS="parameter"
  49389. >input</VAR
  49390. >, und
  49391.      ersetzt diese durch die Elemente des Arrays
  49392.      <VAR
  49393. CLASS="parameter"
  49394. >replacement</VAR
  49395. >, wenn angegeben und gibt ein
  49396.      Array mit den entfernten Elemente zurⁿck.
  49397.     </P
  49398. ><P
  49399. >      Ist <VAR
  49400. CLASS="parameter"
  49401. >offset</VAR
  49402. > positiv, beginnt der zu
  49403.      entfernende Bereich bei diesem Offset vom Anfang des Arrays
  49404.      <VAR
  49405. CLASS="parameter"
  49406. >input</VAR
  49407. >. Ist <VAR
  49408. CLASS="parameter"
  49409. >offset</VAR
  49410. >
  49411.      negativ, beginnt der zu entfernende Bereich
  49412.      <VAR
  49413. CLASS="parameter"
  49414. >offset</VAR
  49415. > Elemente vor dem Ende des Arrays
  49416.      <VAR
  49417. CLASS="parameter"
  49418. >input</VAR
  49419. >.
  49420.     </P
  49421. ><P
  49422. >      Ist <VAR
  49423. CLASS="parameter"
  49424. >length</VAR
  49425. > nicht angegeben, wird alles von
  49426.      <VAR
  49427. CLASS="parameter"
  49428. >offset</VAR
  49429. > bis zum Ende des Arrays
  49430.      entfernt. Ist <VAR
  49431. CLASS="parameter"
  49432. >length</VAR
  49433. > positiv, wird die
  49434.      angegebene Anzahl Elemente entfernt. Ist
  49435.      <VAR
  49436. CLASS="parameter"
  49437. >length</VAR
  49438. > negativ, dann wird der Bereich von
  49439.      <VAR
  49440. CLASS="parameter"
  49441. >length</VAR
  49442. > Elementen vor dem Ende, bis zum
  49443.      Ende des Arrays entfernt. Tipp: Um alles von
  49444.      <VAR
  49445. CLASS="parameter"
  49446. >offset</VAR
  49447. > bis zum Ende des Arrays zu
  49448.      entfernen wenn <VAR
  49449. CLASS="parameter"
  49450. >replacement</VAR
  49451. > ebenfalls
  49452.      angegeben ist, verwenden Sie <VAR
  49453. CLASS="literal"
  49454. >count($input)</VAR
  49455. > als
  49456.      <VAR
  49457. CLASS="parameter"
  49458. >length</VAR
  49459. >.
  49460.     </P
  49461. ><P
  49462. >      Ist das Array <VAR
  49463. CLASS="parameter"
  49464. >replacement</VAR
  49465. > angegeben,
  49466.      werden die entfernten Elemente durch die Elemente dieses Arrays
  49467.      ersetzt. Sind <VAR
  49468. CLASS="parameter"
  49469. >offset</VAR
  49470. > und
  49471.      <VAR
  49472. CLASS="parameter"
  49473. >length</VAR
  49474. > so angegeben dass nichts entfernt
  49475.      wird, werden die Elemente von <VAR
  49476. CLASS="parameter"
  49477. >replacement</VAR
  49478. >
  49479.      an der von <VAR
  49480. CLASS="parameter"
  49481. >offset</VAR
  49482. > spezifizierten Stelle
  49483.      eingefⁿgt. Tipp: Soll die Ersetzung durch nur ein Element erfolgen
  49484.      ist es nicht n÷tig ein Array zu anzugeben es sei denn, dieses
  49485.      Element ist selbst ein Array.
  49486.     </P
  49487. ><P
  49488. >      Hier einige Entsprechungen:
  49489.      <DIV
  49490. CLASS="table"
  49491. ><A
  49492. NAME="AEN8659"
  49493. ></A
  49494. ><P
  49495. ><B
  49496. >Tabelle 1. <B
  49497. CLASS="function"
  49498. >array_splice()</B
  49499. > equivalents</B
  49500. ></P
  49501. ><TABLE
  49502. BORDER="1"
  49503. CLASS="CALSTABLE"
  49504. ><COL><COL><TBODY
  49505. ><TR
  49506. ><TD
  49507. >           array_push($input, $x, $y) 
  49508.          </TD
  49509. ><TD
  49510. >           array_splice($input, count($input), 0, array($x, $y))
  49511.          </TD
  49512. ></TR
  49513. ><TR
  49514. ><TD
  49515. >           array_pop($input) 
  49516.          </TD
  49517. ><TD
  49518. >           array_splice($input, -1)
  49519.          </TD
  49520. ></TR
  49521. ><TR
  49522. ><TD
  49523. >           array_shift($input)
  49524.          </TD
  49525. ><TD
  49526. >           array_splice($input, -1)
  49527.          </TD
  49528. ></TR
  49529. ><TR
  49530. ><TD
  49531. >           array_unshift($input, $x, $y)
  49532.          </TD
  49533. ><TD
  49534. >           array_splice($input, 0, 0, array($x, $y))
  49535.          </TD
  49536. ></TR
  49537. ><TR
  49538. ><TD
  49539. >           $a[$x] = $y
  49540.          </TD
  49541. ><TD
  49542. >           array_splice($input, $x, 1, $y)
  49543.          </TD
  49544. ></TR
  49545. ></TBODY
  49546. ></TABLE
  49547. ></DIV
  49548. >
  49549.     </P
  49550. ><P
  49551. >      Gibt das Array mit den entfernten Elementen zurⁿck.
  49552.     </P
  49553. ><P
  49554. >      <TABLE
  49555. WIDTH="100%"
  49556. BORDER="0"
  49557. CELLPADDING="0"
  49558. CELLSPACING="0"
  49559. CLASS="EXAMPLE"
  49560. ><TR
  49561. ><TD
  49562. ><DIV
  49563. CLASS="example"
  49564. ><A
  49565. NAME="AEN8681"
  49566. ></A
  49567. ><P
  49568. ><B
  49569. >Beispiel 1. <B
  49570. CLASS="function"
  49571. >array_splice()</B
  49572. ></B
  49573. ></P
  49574. ><TABLE
  49575. BORDER="0"
  49576. BGCOLOR="#E0E0E0"
  49577. CELLPADDING="5"
  49578. ><TR
  49579. ><TD
  49580. ><PRE
  49581. CLASS="php"
  49582. ><?php
  49583. $input = array ("rot", "grⁿn", "blau", "gelb");
  49584. array_splice ($input, 2);
  49585. // $input ist nun array ("rot", "grⁿn")
  49586.  
  49587. $input = array ("rot", "grⁿn", "blau", "gelb");
  49588. array_splice ($input, 1, -1);
  49589. // $input ist nun array ("rot", "gelb")
  49590.  
  49591. $input = array ("rot", "grⁿn", "blau", "gelb");
  49592. array_splice ($input, 1, count($input), "orange");
  49593. // $input ist nun array ("rot", "orange")
  49594.  
  49595. $input = array ("rot", "grⁿn", "blau", "gelb");
  49596. array_splice ($input, -1, 1, array("schwarz", "braun"));
  49597. // $input ist nun array ("rot", "grⁿn", "blau", "schwarz", "braun")
  49598. ?></PRE
  49599. ></TD
  49600. ></TR
  49601. ></TABLE
  49602. ></DIV
  49603. ></TD
  49604. ></TR
  49605. ></TABLE
  49606. >
  49607.     </P
  49608. ><P
  49609. >      Siehe auch <A
  49610. HREF="#function.array-slice"
  49611. ><B
  49612. CLASS="function"
  49613. >array_slice()</B
  49614. ></A
  49615. >.
  49616.     </P
  49617. ></DIV
  49618. ><H1
  49619. ><A
  49620. NAME="function.array-sum"
  49621. ></A
  49622. >array_sum</H1
  49623. ><DIV
  49624. CLASS="refnamediv"
  49625. ><A
  49626. NAME="AEN8688"
  49627. ></A
  49628. ><P
  49629. >    (PHP 4 >= 4.0.4, PHP 5)</P
  49630. >array_sum -- 
  49631.      Liefert die Summe der Werte in einem Array
  49632.     </DIV
  49633. ><DIV
  49634. CLASS="refsect1"
  49635. ><A
  49636. NAME="AEN8691"
  49637. ></A
  49638. ><H2
  49639. >Beschreibung</H2
  49640. >mixed <B
  49641. CLASS="methodname"
  49642. >array_sum</B
  49643. > ( array array)<BR
  49644. ></BR
  49645. ><P
  49646. >      <B
  49647. CLASS="function"
  49648. >array_sum()</B
  49649. > liefert die Summe der Werte eines
  49650.      Arrays als Integer oder Float.
  49651.     </P
  49652. ><P
  49653. >      <TABLE
  49654. WIDTH="100%"
  49655. BORDER="0"
  49656. CELLPADDING="0"
  49657. CELLSPACING="0"
  49658. CLASS="EXAMPLE"
  49659. ><TR
  49660. ><TD
  49661. ><DIV
  49662. CLASS="example"
  49663. ><A
  49664. NAME="AEN8702"
  49665. ></A
  49666. ><P
  49667. ><B
  49668. >Beispiel 1. <B
  49669. CLASS="function"
  49670. >array_sum()</B
  49671. ></B
  49672. ></P
  49673. ><TABLE
  49674. BORDER="0"
  49675. BGCOLOR="#E0E0E0"
  49676. CELLPADDING="5"
  49677. ><TR
  49678. ><TD
  49679. ><PRE
  49680. CLASS="php"
  49681. ><?php
  49682. $a = array(2, 4, 6, 8);
  49683. echo "sum(a) = ".array_sum($a)."\n";
  49684.  
  49685. $b = array("a"=>1.2,"b"=>2.3,"c"=>3.4);
  49686. echo "sum(b) = ".array_sum($b)."\n";
  49687. ?></PRE
  49688. ></TD
  49689. ></TR
  49690. ></TABLE
  49691. ><P
  49692. >        Obiges Programm wird folgendes ausgeben:
  49693.       </P
  49694. ><TABLE
  49695. BORDER="0"
  49696. BGCOLOR="#E0E0E0"
  49697. CELLPADDING="5"
  49698. ><TR
  49699. ><TD
  49700. ><PRE
  49701. CLASS="php"
  49702. >sum(a) = 20
  49703. sum(b) = 6.9</PRE
  49704. ></TD
  49705. ></TR
  49706. ></TABLE
  49707. ></DIV
  49708. ></TD
  49709. ></TR
  49710. ></TABLE
  49711. >
  49712.     </P
  49713. ><DIV
  49714. CLASS="note"
  49715. ><BLOCKQUOTE
  49716. CLASS="note"
  49717. ><P
  49718. ><B
  49719. >Anmerkung: </B
  49720. >
  49721.       PHP Versionen vor 4.2.1 haben das ⁿbergebene Array selbst
  49722.       modifiziert, und Strings in Zahlen konvertiert (welche
  49723.       abhΣngig von deren Wert meist zu null konvertiert wurden).
  49724.      </P
  49725. ></BLOCKQUOTE
  49726. ></DIV
  49727. ></DIV
  49728. ><H1
  49729. ><A
  49730. NAME="function.array-udiff-assoc"
  49731. ></A
  49732. >array_udiff_assoc</H1
  49733. ><DIV
  49734. CLASS="refnamediv"
  49735. ><A
  49736. NAME="AEN8711"
  49737. ></A
  49738. ><P
  49739. >    (PHP 5)</P
  49740. >array_udiff_assoc -- Computes the difference of arrays with additional index check. The data is compared by using a callback function</DIV
  49741. ><DIV
  49742. CLASS="refsect1"
  49743. ><A
  49744. NAME="AEN8714"
  49745. ></A
  49746. ><H2
  49747. >Description</H2
  49748. >array <B
  49749. CLASS="methodname"
  49750. >array_udiff_assoc</B
  49751. > ( array array1, array array2 [, array ..., callback data_compare_func])<BR
  49752. ></BR
  49753. ><P
  49754. >      <B
  49755. CLASS="function"
  49756. >array_udiff_assoc()</B
  49757. > returns an <A
  49758. HREF="#language.types.array"
  49759. ><B
  49760. CLASS="type"
  49761. >array</B
  49762. ></A
  49763. >
  49764.      containing all the values from <VAR
  49765. CLASS="parameter"
  49766. >array1</VAR
  49767. >
  49768.      that are not present in any of the other arguments.
  49769.      Note that the keys are used in the comparison unlike 
  49770.      <A
  49771. HREF="#function.array-diff"
  49772. ><B
  49773. CLASS="function"
  49774. >array_diff()</B
  49775. ></A
  49776. > and <A
  49777. HREF="#function.array-udiff"
  49778. ><B
  49779. CLASS="function"
  49780. >array_udiff()</B
  49781. ></A
  49782. >.
  49783.      The comparison of arrays' data is performed by using an user-supplied
  49784.      callback. In this aspect the behaviour is opposite to the behaviour of
  49785.      <A
  49786. HREF="#function.array-diff-assoc"
  49787. ><B
  49788. CLASS="function"
  49789. >array_diff_assoc()</B
  49790. ></A
  49791. > which uses internal function for
  49792.      comparison.
  49793.     </P
  49794. ><P
  49795. >      <TABLE
  49796. WIDTH="100%"
  49797. BORDER="0"
  49798. CELLPADDING="0"
  49799. CELLSPACING="0"
  49800. CLASS="EXAMPLE"
  49801. ><TR
  49802. ><TD
  49803. ><DIV
  49804. CLASS="example"
  49805. ><A
  49806. NAME="AEN8739"
  49807. ></A
  49808. ><P
  49809. ><B
  49810. >Beispiel 1. <B
  49811. CLASS="function"
  49812. >array_udiff_assoc()</B
  49813. > example</B
  49814. ></P
  49815. ><TABLE
  49816. BORDER="0"
  49817. BGCOLOR="#E0E0E0"
  49818. CELLPADDING="5"
  49819. ><TR
  49820. ><TD
  49821. ><PRE
  49822. CLASS="php"
  49823. ><?php
  49824. class cr {
  49825.     private $priv_member;
  49826.     function cr($val) 
  49827.     {
  49828.         $this->priv_member = $val;
  49829.     }
  49830.     
  49831.     function comp_func_cr($a, $b) 
  49832.     {
  49833.         if ($a->priv_member === $b->priv_member) return 0;
  49834.         return ($a->priv_member > $b->priv_member)? 1:-1;
  49835.     }
  49836. }
  49837.  
  49838. $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),);
  49839. $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),);
  49840.  
  49841. $result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr"));
  49842. print_r($result);
  49843. ?></PRE
  49844. ></TD
  49845. ></TR
  49846. ></TABLE
  49847. ><P
  49848. >        The result is:
  49849.       </P
  49850. ><TABLE
  49851. BORDER="0"
  49852. BGCOLOR="#E0E0E0"
  49853. CELLPADDING="5"
  49854. ><TR
  49855. ><TD
  49856. ><PRE
  49857. CLASS="screen"
  49858. >Array
  49859. (
  49860.     [0.1] => cr Object
  49861.         (
  49862.             [priv_member:private] => 9
  49863.         )
  49864.  
  49865.     [0.5] => cr Object
  49866.         (
  49867.             [priv_member:private] => 12
  49868.         )
  49869.  
  49870.     [0] => cr Object
  49871.         (
  49872.             [priv_member:private] => 23
  49873.         )
  49874. )</PRE
  49875. ></TD
  49876. ></TR
  49877. ></TABLE
  49878. ></DIV
  49879. ></TD
  49880. ></TR
  49881. ></TABLE
  49882. >
  49883.     </P
  49884. ><P
  49885. >      In our example above you see the <VAR
  49886. CLASS="literal"
  49887. >"1" => new cr(4)</VAR
  49888. >
  49889.      pair is present in both arrays and thus it is not in the ouput from the
  49890.      function.
  49891.     </P
  49892. ><P
  49893. >      For comparison is used the user supplied callback function.
  49894.      It must return an integer less than, equal
  49895.      to, or greater than zero if the first argument is considered to
  49896.      be respectively less than, equal to, or greater than the
  49897.      second.
  49898.     </P
  49899. ><DIV
  49900. CLASS="note"
  49901. ><BLOCKQUOTE
  49902. CLASS="note"
  49903. ><P
  49904. ><B
  49905. >Anmerkung: </B
  49906. >
  49907.       Please note that this function only checks one dimension of a n-dimensional
  49908.       array. Of course you can check deeper dimensions by using, for example, 
  49909.       <VAR
  49910. CLASS="literal"
  49911. >array_udiff_assoc($array1[0], $array2[0], "some_comparison_func");</VAR
  49912. >.
  49913.      </P
  49914. ></BLOCKQUOTE
  49915. ></DIV
  49916. ><P
  49917. >      See also
  49918.      <A
  49919. HREF="#function.array-diff"
  49920. ><B
  49921. CLASS="function"
  49922. >array_diff()</B
  49923. ></A
  49924. >,
  49925.      <A
  49926. HREF="#function.array-diff-assoc"
  49927. ><B
  49928. CLASS="function"
  49929. >array_diff_assoc()</B
  49930. ></A
  49931. >,
  49932.      <A
  49933. HREF="#function.array-diff-uassoc"
  49934. ><B
  49935. CLASS="function"
  49936. >array_diff_uassoc()</B
  49937. ></A
  49938. >,
  49939.      <A
  49940. HREF="#function.array-udiff"
  49941. ><B
  49942. CLASS="function"
  49943. >array_udiff()</B
  49944. ></A
  49945. >,
  49946.      <A
  49947. HREF="#function.array-udiff-uassoc"
  49948. ><B
  49949. CLASS="function"
  49950. >array_udiff_uassoc()</B
  49951. ></A
  49952. >, 
  49953.      <A
  49954. HREF="#function.array-intersect"
  49955. ><B
  49956. CLASS="function"
  49957. >array_intersect()</B
  49958. ></A
  49959. >,  
  49960.      <A
  49961. HREF="#function.array-intersect-assoc"
  49962. ><B
  49963. CLASS="function"
  49964. >array_intersect_assoc()</B
  49965. ></A
  49966. >,
  49967.      <A
  49968. HREF="#function.array-uintersect"
  49969. ><B
  49970. CLASS="function"
  49971. >array_uintersect()</B
  49972. ></A
  49973. >,  
  49974.      <A
  49975. HREF="#function.array-uintersect-assoc"
  49976. ><B
  49977. CLASS="function"
  49978. >array_uintersect_assoc()</B
  49979. ></A
  49980. > and 
  49981.      <A
  49982. HREF="#function.array-uintersect-uassoc"
  49983. ><B
  49984. CLASS="function"
  49985. >array_uintersect_uassoc()</B
  49986. ></A
  49987. >.
  49988.     </P
  49989. ></DIV
  49990. ><H1
  49991. ><A
  49992. NAME="function.array-udiff-uassoc"
  49993. ></A
  49994. >array_udiff_uassoc</H1
  49995. ><DIV
  49996. CLASS="refnamediv"
  49997. ><A
  49998. NAME="AEN8763"
  49999. ></A
  50000. ><P
  50001. >    (PHP 5)</P
  50002. >array_udiff_uassoc -- Computes the difference of arrays with additional index check. The data is compared by using a callback function. The index check is done by a callback function also</DIV
  50003. ><DIV
  50004. CLASS="refsect1"
  50005. ><A
  50006. NAME="AEN8766"
  50007. ></A
  50008. ><H2
  50009. >Description</H2
  50010. >array <B
  50011. CLASS="methodname"
  50012. >array_udiff_uassoc</B
  50013. > ( array array1, array array2 [, array ..., callback data_compare_func, callback key_compare_func])<BR
  50014. ></BR
  50015. ><P
  50016. >      <B
  50017. CLASS="function"
  50018. >array_udiff_uassoc()</B
  50019. > returns an <A
  50020. HREF="#language.types.array"
  50021. ><B
  50022. CLASS="type"
  50023. >array</B
  50024. ></A
  50025. >
  50026.      containing all the values from <VAR
  50027. CLASS="parameter"
  50028. >array1</VAR
  50029. >
  50030.      that are not present in any of the other arguments.
  50031.      Note that the keys are used in the comparison unlike 
  50032.      <A
  50033. HREF="#function.array-diff"
  50034. ><B
  50035. CLASS="function"
  50036. >array_diff()</B
  50037. ></A
  50038. > and <A
  50039. HREF="#function.array-udiff"
  50040. ><B
  50041. CLASS="function"
  50042. >array_udiff()</B
  50043. ></A
  50044. >.
  50045.      The comparison of arrays' data is performed by using an user-supplied
  50046.      callback : <VAR
  50047. CLASS="parameter"
  50048. >data_compare_func</VAR
  50049. >. In this aspect
  50050.      the behaviour is opposite to the behaviour of
  50051.      <A
  50052. HREF="#function.array-diff-assoc"
  50053. ><B
  50054. CLASS="function"
  50055. >array_diff_assoc()</B
  50056. ></A
  50057. > which uses internal function for
  50058.      comparison. The comparison of keys (indices) is done also by the 
  50059.      callback function <VAR
  50060. CLASS="parameter"
  50061. >key_compare_func</VAR
  50062. >. This
  50063.      behaviour is unlike what <A
  50064. HREF="#function.array-udiff-assoc"
  50065. ><B
  50066. CLASS="function"
  50067. >array_udiff_assoc()</B
  50068. ></A
  50069. > does, since
  50070.      the latter compares the indices by using an internal function.
  50071.     </P
  50072. ><P
  50073. >      <TABLE
  50074. WIDTH="100%"
  50075. BORDER="0"
  50076. CELLPADDING="0"
  50077. CELLSPACING="0"
  50078. CLASS="EXAMPLE"
  50079. ><TR
  50080. ><TD
  50081. ><DIV
  50082. CLASS="example"
  50083. ><A
  50084. NAME="AEN8797"
  50085. ></A
  50086. ><P
  50087. ><B
  50088. >Beispiel 1. <B
  50089. CLASS="function"
  50090. >array_udiff_uassoc()</B
  50091. > example</B
  50092. ></P
  50093. ><TABLE
  50094. BORDER="0"
  50095. BGCOLOR="#E0E0E0"
  50096. CELLPADDING="5"
  50097. ><TR
  50098. ><TD
  50099. ><PRE
  50100. CLASS="php"
  50101. ><?php
  50102. class cr {
  50103.     private $priv_member;
  50104.     function cr($val) 
  50105.     {
  50106.         $this->priv_member = $val;
  50107.     }
  50108.  
  50109.     function comp_func_cr($a, $b) 
  50110.     {
  50111.         if ($a->priv_member === $b->priv_member) return 0;
  50112.         return ($a->priv_member > $b->priv_member)? 1:-1;
  50113.     }
  50114.     
  50115.     function comp_func_key($a, $b) 
  50116.     {
  50117.         if ($a === $b) return 0;
  50118.         return ($a > $b)? 1:-1;
  50119.     }
  50120. }
  50121. $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),);
  50122. $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),);
  50123.  
  50124. $result = array_udiff_uassoc($a, $b, array("cr", "comp_func_cr"), array("cr", "comp_func_key"));
  50125. print_r($result);
  50126. ?></PRE
  50127. ></TD
  50128. ></TR
  50129. ></TABLE
  50130. ><P
  50131. >        The result is:
  50132.       </P
  50133. ><TABLE
  50134. BORDER="0"
  50135. BGCOLOR="#E0E0E0"
  50136. CELLPADDING="5"
  50137. ><TR
  50138. ><TD
  50139. ><PRE
  50140. CLASS="screen"
  50141. >Array
  50142. (
  50143.     [0.1] => cr Object
  50144.         (
  50145.             [priv_member:private] => 9
  50146.         )
  50147.  
  50148.     [0.5] => cr Object
  50149.         (
  50150.             [priv_member:private] => 12
  50151.         )
  50152.  
  50153.     [0] => cr Object
  50154.         (
  50155.             [priv_member:private] => 23
  50156.         )
  50157. )</PRE
  50158. ></TD
  50159. ></TR
  50160. ></TABLE
  50161. ></DIV
  50162. ></TD
  50163. ></TR
  50164. ></TABLE
  50165. >
  50166.     </P
  50167. ><P
  50168. >      In our example above you see the <VAR
  50169. CLASS="literal"
  50170. >"1" => new cr(4)</VAR
  50171. >
  50172.      pair is present in both arrays and thus it is not in the ouput from the
  50173.      function. Keep in mind that you have to supply 2 callback functions.
  50174.     </P
  50175. ><P
  50176. >      For comparison is used the user supplied callback function.
  50177.      It must return an integer less than, equal
  50178.      to, or greater than zero if the first argument is considered to
  50179.      be respectively less than, equal to, or greater than the
  50180.      second.
  50181.     </P
  50182. ><DIV
  50183. CLASS="note"
  50184. ><BLOCKQUOTE
  50185. CLASS="note"
  50186. ><P
  50187. ><B
  50188. >Anmerkung: </B
  50189. >
  50190.       Please note that this function only checks one dimension of a n-dimensional
  50191.       array. Of course you can check deeper dimensions by using, for example, 
  50192.       <VAR
  50193. CLASS="literal"
  50194. >array_udiff_uassoc($array1[0], $array2[0], "data_compare_func",
  50195.       "key_compare_func");</VAR
  50196. >.
  50197.      </P
  50198. ></BLOCKQUOTE
  50199. ></DIV
  50200. ><P
  50201. >      See also
  50202.      <A
  50203. HREF="#function.array-diff"
  50204. ><B
  50205. CLASS="function"
  50206. >array_diff()</B
  50207. ></A
  50208. >,
  50209.      <A
  50210. HREF="#function.array-diff-assoc"
  50211. ><B
  50212. CLASS="function"
  50213. >array_diff_assoc()</B
  50214. ></A
  50215. >,
  50216.      <A
  50217. HREF="#function.array-diff-uassoc"
  50218. ><B
  50219. CLASS="function"
  50220. >array_diff_uassoc()</B
  50221. ></A
  50222. >,
  50223.      <A
  50224. HREF="#function.array-udiff"
  50225. ><B
  50226. CLASS="function"
  50227. >array_udiff()</B
  50228. ></A
  50229. >,
  50230.      <A
  50231. HREF="#function.array-udiff-assoc"
  50232. ><B
  50233. CLASS="function"
  50234. >array_udiff_assoc()</B
  50235. ></A
  50236. >, 
  50237.      <A
  50238. HREF="#function.array-intersect"
  50239. ><B
  50240. CLASS="function"
  50241. >array_intersect()</B
  50242. ></A
  50243. >,  
  50244.      <A
  50245. HREF="#function.array-intersect-assoc"
  50246. ><B
  50247. CLASS="function"
  50248. >array_intersect_assoc()</B
  50249. ></A
  50250. >,
  50251.      <A
  50252. HREF="#function.array-uintersect"
  50253. ><B
  50254. CLASS="function"
  50255. >array_uintersect()</B
  50256. ></A
  50257. >,  
  50258.      <A
  50259. HREF="#function.array-uintersect-assoc"
  50260. ><B
  50261. CLASS="function"
  50262. >array_uintersect_assoc()</B
  50263. ></A
  50264. > and 
  50265.      <A
  50266. HREF="#function.array-uintersect-uassoc"
  50267. ><B
  50268. CLASS="function"
  50269. >array_uintersect_uassoc()</B
  50270. ></A
  50271. >.
  50272.     </P
  50273. ></DIV
  50274. ><H1
  50275. ><A
  50276. NAME="function.array-udiff"
  50277. ></A
  50278. >array_udiff</H1
  50279. ><DIV
  50280. CLASS="refnamediv"
  50281. ><A
  50282. NAME="AEN8821"
  50283. ></A
  50284. ><P
  50285. >    (PHP 5)</P
  50286. >array_udiff -- Computes the difference of arrays by using a callback function for data comparison</DIV
  50287. ><DIV
  50288. CLASS="refsect1"
  50289. ><A
  50290. NAME="AEN8824"
  50291. ></A
  50292. ><H2
  50293. >Description</H2
  50294. >array <B
  50295. CLASS="methodname"
  50296. >array_udiff</B
  50297. > ( array array1, array array2 [, array ..., callback data_compare_func])<BR
  50298. ></BR
  50299. ><P
  50300. >      <B
  50301. CLASS="function"
  50302. >array_udiff()</B
  50303. > returns an array
  50304.      containing all the values of <VAR
  50305. CLASS="parameter"
  50306. >array1</VAR
  50307. >
  50308.      that are not present in any of the other arguments.
  50309.      Note that keys are preserved. For the comparison of the data
  50310.      <VAR
  50311. CLASS="parameter"
  50312. >data_compare_func</VAR
  50313. > is used.
  50314.      It must return an integer less than, equal
  50315.      to, or greater than zero if the first argument is considered to
  50316.      be respectively less than, equal to, or greater than the
  50317.      second. This is unlike <A
  50318. HREF="#function.array-diff"
  50319. ><B
  50320. CLASS="function"
  50321. >array_diff()</B
  50322. ></A
  50323. > which uses an
  50324.      internal function for comparing the data.
  50325.     </P
  50326. ><P
  50327. >      <TABLE
  50328. WIDTH="100%"
  50329. BORDER="0"
  50330. CELLPADDING="0"
  50331. CELLSPACING="0"
  50332. CLASS="EXAMPLE"
  50333. ><TR
  50334. ><TD
  50335. ><DIV
  50336. CLASS="example"
  50337. ><A
  50338. NAME="AEN8847"
  50339. ></A
  50340. ><P
  50341. ><B
  50342. >Beispiel 1. <B
  50343. CLASS="function"
  50344. >array_udiff()</B
  50345. > example</B
  50346. ></P
  50347. ><TABLE
  50348. BORDER="0"
  50349. BGCOLOR="#E0E0E0"
  50350. CELLPADDING="5"
  50351. ><TR
  50352. ><TD
  50353. ><PRE
  50354. CLASS="php"
  50355. ><?php
  50356. class cr {
  50357.     private $priv_member;
  50358.     function cr($val) 
  50359.     {
  50360.         $this->priv_member = $val;
  50361.     }
  50362.     
  50363.     function comp_func_cr($a, $b) 
  50364.     {
  50365.         if ($a->priv_member === $b->priv_member) return 0;
  50366.         return ($a->priv_member > $b->priv_member)? 1:-1;
  50367.     }
  50368. }
  50369. $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),);
  50370. $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),);
  50371.  
  50372. $result = array_udiff($a, $b, array("cr", "comp_func_cr"));
  50373. print_r($result);
  50374. ?></PRE
  50375. ></TD
  50376. ></TR
  50377. ></TABLE
  50378. ><P
  50379. >        The result is:
  50380.       </P
  50381. ><TABLE
  50382. BORDER="0"
  50383. BGCOLOR="#E0E0E0"
  50384. CELLPADDING="5"
  50385. ><TR
  50386. ><TD
  50387. ><PRE
  50388. CLASS="screen"
  50389. >Array
  50390. (
  50391.     [0.5] => cr Object
  50392.         (
  50393.             [priv_member:private] => 12
  50394.         )
  50395.  
  50396.     [0] => cr Object
  50397.         (
  50398.             [priv_member:private] => 23
  50399.         )
  50400.  
  50401. )</PRE
  50402. ></TD
  50403. ></TR
  50404. ></TABLE
  50405. ></DIV
  50406. ></TD
  50407. ></TR
  50408. ></TABLE
  50409. >
  50410.     </P
  50411. ><DIV
  50412. CLASS="note"
  50413. ><BLOCKQUOTE
  50414. CLASS="note"
  50415. ><P
  50416. ><B
  50417. >Anmerkung: </B
  50418. >
  50419.       Two elements are considered equal if and only if
  50420.       <VAR
  50421. CLASS="literal"
  50422. >(string) $elem1 === (string) $elem2</VAR
  50423. >. In words:
  50424.       when the string representation is the same.
  50425.      </P
  50426. ></BLOCKQUOTE
  50427. ></DIV
  50428. ><DIV
  50429. CLASS="note"
  50430. ><BLOCKQUOTE
  50431. CLASS="note"
  50432. ><P
  50433. ><B
  50434. >Anmerkung: </B
  50435. >
  50436.       Please note that this function only checks one dimension of a n-dimensional
  50437.       array. Of course you can check deeper dimensions by using
  50438.       <VAR
  50439. CLASS="literal"
  50440. >array_udiff($array1[0], $array2[0], "data_compare_func");</VAR
  50441. >.
  50442.      </P
  50443. ></BLOCKQUOTE
  50444. ></DIV
  50445. ><P
  50446. >      See also
  50447.      <A
  50448. HREF="#function.array-diff"
  50449. ><B
  50450. CLASS="function"
  50451. >array_diff()</B
  50452. ></A
  50453. >,
  50454.      <A
  50455. HREF="#function.array-diff-assoc"
  50456. ><B
  50457. CLASS="function"
  50458. >array_diff_assoc()</B
  50459. ></A
  50460. >,
  50461.      <A
  50462. HREF="#function.array-diff-uassoc"
  50463. ><B
  50464. CLASS="function"
  50465. >array_diff_uassoc()</B
  50466. ></A
  50467. >,
  50468.      <A
  50469. HREF="#function.array-udiff-assoc"
  50470. ><B
  50471. CLASS="function"
  50472. >array_udiff_assoc()</B
  50473. ></A
  50474. >, 
  50475.      <A
  50476. HREF="#function.array-udiff-uassoc"
  50477. ><B
  50478. CLASS="function"
  50479. >array_udiff_uassoc()</B
  50480. ></A
  50481. >, 
  50482.      <A
  50483. HREF="#function.array-intersect"
  50484. ><B
  50485. CLASS="function"
  50486. >array_intersect()</B
  50487. ></A
  50488. >,  
  50489.      <A
  50490. HREF="#function.array-intersect-assoc"
  50491. ><B
  50492. CLASS="function"
  50493. >array_intersect_assoc()</B
  50494. ></A
  50495. >,
  50496.      <A
  50497. HREF="#function.array-uintersect"
  50498. ><B
  50499. CLASS="function"
  50500. >array_uintersect()</B
  50501. ></A
  50502. >,  
  50503.      <A
  50504. HREF="#function.array-uintersect-assoc"
  50505. ><B
  50506. CLASS="function"
  50507. >array_uintersect_assoc()</B
  50508. ></A
  50509. > and 
  50510.      <A
  50511. HREF="#function.array-uintersect-uassoc"
  50512. ><B
  50513. CLASS="function"
  50514. >array_uintersect_uassoc()</B
  50515. ></A
  50516. >.
  50517.     </P
  50518. ></DIV
  50519. ><H1
  50520. ><A
  50521. NAME="function.array-uintersect-assoc"
  50522. ></A
  50523. >array_uintersect_assoc</H1
  50524. ><DIV
  50525. CLASS="refnamediv"
  50526. ><A
  50527. NAME="AEN8871"
  50528. ></A
  50529. ><P
  50530. >    (PHP 5)</P
  50531. >array_uintersect_assoc -- Computes the intersection of arrays with additional index check. The data is compared by using a callback function</DIV
  50532. ><DIV
  50533. CLASS="refsect1"
  50534. ><A
  50535. NAME="AEN8874"
  50536. ></A
  50537. ><H2
  50538. >Description</H2
  50539. >array <B
  50540. CLASS="methodname"
  50541. >array_uintersect_assoc</B
  50542. > ( array array1, array array2 [, array ..., callback data_compare_func])<BR
  50543. ></BR
  50544. ><P
  50545. >      <B
  50546. CLASS="function"
  50547. >array_uintersect_assoc()</B
  50548. > returns an array
  50549.      containing all the values of <VAR
  50550. CLASS="parameter"
  50551. >array1</VAR
  50552. >
  50553.      that are present in all the arguments. Note that the keys are used in
  50554.      the comparison unlike in <A
  50555. HREF="#function.array-uintersect"
  50556. ><B
  50557. CLASS="function"
  50558. >array_uintersect()</B
  50559. ></A
  50560. >.
  50561.      The data is compared by using a callback function.
  50562.     </P
  50563. ><P
  50564. >      <TABLE
  50565. WIDTH="100%"
  50566. BORDER="0"
  50567. CELLPADDING="0"
  50568. CELLSPACING="0"
  50569. CLASS="EXAMPLE"
  50570. ><TR
  50571. ><TD
  50572. ><DIV
  50573. CLASS="example"
  50574. ><A
  50575. NAME="AEN8896"
  50576. ></A
  50577. ><P
  50578. ><B
  50579. >Beispiel 1. <B
  50580. CLASS="function"
  50581. >array_uintersect_assoc()</B
  50582. > example</B
  50583. ></P
  50584. ><TABLE
  50585. BORDER="0"
  50586. BGCOLOR="#E0E0E0"
  50587. CELLPADDING="5"
  50588. ><TR
  50589. ><TD
  50590. ><PRE
  50591. CLASS="php"
  50592. ><?php
  50593. $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
  50594. $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red");
  50595.  
  50596. print_r(array_uintersect_assoc($array1, $array2, "strcasecmp"));
  50597. ?></PRE
  50598. ></TD
  50599. ></TR
  50600. ></TABLE
  50601. ><P
  50602. >        Result will look like:
  50603.       </P
  50604. ><TABLE
  50605. BORDER="0"
  50606. BGCOLOR="#E0E0E0"
  50607. CELLPADDING="5"
  50608. ><TR
  50609. ><TD
  50610. ><PRE
  50611. CLASS="screen"
  50612. >Array
  50613. (
  50614.     [a] => green
  50615. )</PRE
  50616. ></TD
  50617. ></TR
  50618. ></TABLE
  50619. ></DIV
  50620. ></TD
  50621. ></TR
  50622. ></TABLE
  50623. >
  50624.     </P
  50625. ><P
  50626. >      For comparison is used the user supplied callback function.
  50627.      It must return an integer less than, equal
  50628.      to, or greater than zero if the first argument is considered to
  50629.      be respectively less than, equal to, or greater than the
  50630.      second.
  50631.     </P
  50632. ><P
  50633. >      See also <A
  50634. HREF="#function.array-uintersect"
  50635. ><B
  50636. CLASS="function"
  50637. >array_uintersect()</B
  50638. ></A
  50639. >,
  50640.      <A
  50641. HREF="#function.array-intersect-assoc"
  50642. ><B
  50643. CLASS="function"
  50644. >array_intersect_assoc()</B
  50645. ></A
  50646. >,
  50647.      <A
  50648. HREF="#function.array-intersect-uassoc"
  50649. ><B
  50650. CLASS="function"
  50651. >array_intersect_uassoc()</B
  50652. ></A
  50653. > and
  50654.      <A
  50655. HREF="#function.array-uintersect-uassoc"
  50656. ><B
  50657. CLASS="function"
  50658. >array_uintersect_uassoc()</B
  50659. ></A
  50660. >.
  50661.     </P
  50662. ></DIV
  50663. ><H1
  50664. ><A
  50665. NAME="function.array-uintersect-uassoc"
  50666. ></A
  50667. >array_uintersect_uassoc</H1
  50668. ><DIV
  50669. CLASS="refnamediv"
  50670. ><A
  50671. NAME="AEN8909"
  50672. ></A
  50673. ><P
  50674. >    (PHP 5)</P
  50675. >array_uintersect_uassoc -- Computes the intersection of arrays with additional index check. Both the data and the indexes are compared by using a callback functions</DIV
  50676. ><DIV
  50677. CLASS="refsect1"
  50678. ><A
  50679. NAME="AEN8912"
  50680. ></A
  50681. ><H2
  50682. >Description</H2
  50683. >array <B
  50684. CLASS="methodname"
  50685. >array_uintersect_uassoc</B
  50686. > ( array array1, array array2 [, array ..., callback data_compare_func, callback key_compare_func])<BR
  50687. ></BR
  50688. ><P
  50689. >      <B
  50690. CLASS="function"
  50691. >array_uintersect_uassoc()</B
  50692. > returns an array
  50693.      containing all the values of <VAR
  50694. CLASS="parameter"
  50695. >array1</VAR
  50696. >
  50697.      that are present in all the arguments. Note that the keys are used in
  50698.      the comparison unlike in <A
  50699. HREF="#function.array-uintersect"
  50700. ><B
  50701. CLASS="function"
  50702. >array_uintersect()</B
  50703. ></A
  50704. >.
  50705.      Both the data and the indexes are compared by using a callback functions.
  50706.     </P
  50707. ><P
  50708. >      <TABLE
  50709. WIDTH="100%"
  50710. BORDER="0"
  50711. CELLPADDING="0"
  50712. CELLSPACING="0"
  50713. CLASS="EXAMPLE"
  50714. ><TR
  50715. ><TD
  50716. ><DIV
  50717. CLASS="example"
  50718. ><A
  50719. NAME="AEN8937"
  50720. ></A
  50721. ><P
  50722. ><B
  50723. >Beispiel 1. <B
  50724. CLASS="function"
  50725. >array_uintersect_uassoc()</B
  50726. > example</B
  50727. ></P
  50728. ><TABLE
  50729. BORDER="0"
  50730. BGCOLOR="#E0E0E0"
  50731. CELLPADDING="5"
  50732. ><TR
  50733. ><TD
  50734. ><PRE
  50735. CLASS="php"
  50736. ><?php
  50737. $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
  50738. $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red");
  50739.  
  50740. print_r(array_uintersect_uassoc($array1, $array2, "strcasecmp", "strcasecmp"));
  50741. ?></PRE
  50742. ></TD
  50743. ></TR
  50744. ></TABLE
  50745. ><P
  50746. >        Result will look like:
  50747.       </P
  50748. ><TABLE
  50749. BORDER="0"
  50750. BGCOLOR="#E0E0E0"
  50751. CELLPADDING="5"
  50752. ><TR
  50753. ><TD
  50754. ><PRE
  50755. CLASS="screen"
  50756. >Array
  50757. (
  50758.     [a] => green
  50759.     [b] => brown
  50760. )</PRE
  50761. ></TD
  50762. ></TR
  50763. ></TABLE
  50764. ></DIV
  50765. ></TD
  50766. ></TR
  50767. ></TABLE
  50768. >
  50769.     </P
  50770. ><P
  50771. >      For comparison is used the user supplied callback function.
  50772.      It must return an integer less than, equal
  50773.      to, or greater than zero if the first argument is considered to
  50774.      be respectively less than, equal to, or greater than the
  50775.      second.
  50776.     </P
  50777. ><P
  50778. >      See also <A
  50779. HREF="#function.array-uintersect"
  50780. ><B
  50781. CLASS="function"
  50782. >array_uintersect()</B
  50783. ></A
  50784. >,
  50785.      <A
  50786. HREF="#function.array-intersect-assoc"
  50787. ><B
  50788. CLASS="function"
  50789. >array_intersect_assoc()</B
  50790. ></A
  50791. >,
  50792.      <A
  50793. HREF="#function.array-intersect-uassoc"
  50794. ><B
  50795. CLASS="function"
  50796. >array_intersect_uassoc()</B
  50797. ></A
  50798. > and
  50799.      <A
  50800. HREF="#function.array-uintersect-assoc"
  50801. ><B
  50802. CLASS="function"
  50803. >array_uintersect_assoc()</B
  50804. ></A
  50805. >.
  50806.     </P
  50807. ></DIV
  50808. ><H1
  50809. ><A
  50810. NAME="function.array-uintersect"
  50811. ></A
  50812. >array_uintersect</H1
  50813. ><DIV
  50814. CLASS="refnamediv"
  50815. ><A
  50816. NAME="AEN8950"
  50817. ></A
  50818. ><P
  50819. >    (PHP 5)</P
  50820. >array_uintersect -- Computes the intersection of arrays. The data is compared by using a callback function</DIV
  50821. ><DIV
  50822. CLASS="refsect1"
  50823. ><A
  50824. NAME="AEN8953"
  50825. ></A
  50826. ><H2
  50827. >Description</H2
  50828. >array <B
  50829. CLASS="methodname"
  50830. >array_uintersect</B
  50831. > ( array array1, array array2 [, array ..., callback data_compare_func])<BR
  50832. ></BR
  50833. ><P
  50834. >      <B
  50835. CLASS="function"
  50836. >array_uintersect()</B
  50837. > returns an array
  50838.      containing all the values of <VAR
  50839. CLASS="parameter"
  50840. >array1</VAR
  50841. >
  50842.      that are present in all the arguments.
  50843.      The data is compared by using a callback function.
  50844.     </P
  50845. ><P
  50846. >      <TABLE
  50847. WIDTH="100%"
  50848. BORDER="0"
  50849. CELLPADDING="0"
  50850. CELLSPACING="0"
  50851. CLASS="EXAMPLE"
  50852. ><TR
  50853. ><TD
  50854. ><DIV
  50855. CLASS="example"
  50856. ><A
  50857. NAME="AEN8974"
  50858. ></A
  50859. ><P
  50860. ><B
  50861. >Beispiel 1. <B
  50862. CLASS="function"
  50863. >array_uintersect()</B
  50864. > example</B
  50865. ></P
  50866. ><TABLE
  50867. BORDER="0"
  50868. BGCOLOR="#E0E0E0"
  50869. CELLPADDING="5"
  50870. ><TR
  50871. ><TD
  50872. ><PRE
  50873. CLASS="php"
  50874. ><?php
  50875. $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
  50876. $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red");
  50877.  
  50878. print_r(array_uintersect($array1, $array2, "strcasecmp"));
  50879. ?></PRE
  50880. ></TD
  50881. ></TR
  50882. ></TABLE
  50883. ><P
  50884. >        Result will look like:
  50885.       </P
  50886. ><TABLE
  50887. BORDER="0"
  50888. BGCOLOR="#E0E0E0"
  50889. CELLPADDING="5"
  50890. ><TR
  50891. ><TD
  50892. ><PRE
  50893. CLASS="screen"
  50894. >Array
  50895. (
  50896.     [a] => green
  50897.     [b] => brown
  50898.     [0] => red
  50899. )</PRE
  50900. ></TD
  50901. ></TR
  50902. ></TABLE
  50903. ></DIV
  50904. ></TD
  50905. ></TR
  50906. ></TABLE
  50907. >
  50908.     </P
  50909. ><P
  50910. >      For comparison is used the user supplied callback function.
  50911.      It must return an integer less than, equal
  50912.      to, or greater than zero if the first argument is considered to
  50913.      be respectively less than, equal to, or greater than the
  50914.      second.
  50915.     </P
  50916. ><P
  50917. >      See also <A
  50918. HREF="#function.array-intersect"
  50919. ><B
  50920. CLASS="function"
  50921. >array_intersect()</B
  50922. ></A
  50923. >,
  50924.      <A
  50925. HREF="#function.array-uintersect-assoc"
  50926. ><B
  50927. CLASS="function"
  50928. >array_uintersect_assoc()</B
  50929. ></A
  50930. >,
  50931.      <A
  50932. HREF="#function.array-intersect-uassoc"
  50933. ><B
  50934. CLASS="function"
  50935. >array_intersect_uassoc()</B
  50936. ></A
  50937. > and
  50938.      <A
  50939. HREF="#function.array-uintersect-uassoc"
  50940. ><B
  50941. CLASS="function"
  50942. >array_uintersect_uassoc()</B
  50943. ></A
  50944. >.
  50945.     </P
  50946. ></DIV
  50947. ><H1
  50948. ><A
  50949. NAME="function.array-unique"
  50950. ></A
  50951. >array_unique</H1
  50952. ><DIV
  50953. CLASS="refnamediv"
  50954. ><A
  50955. NAME="AEN8987"
  50956. ></A
  50957. ><P
  50958. >    (PHP 4 >= 4.0.1, PHP 5)</P
  50959. >array_unique -- Entfernt doppelte Werte aus einem Array</DIV
  50960. ><DIV
  50961. CLASS="refsect1"
  50962. ><A
  50963. NAME="AEN8990"
  50964. ></A
  50965. ><H2
  50966. >Beschreibung</H2
  50967. >array <B
  50968. CLASS="methodname"
  50969. >array_unique</B
  50970. > ( array array)<BR
  50971. ></BR
  50972. ><P
  50973. >      <B
  50974. CLASS="function"
  50975. >array_unique()</B
  50976. > nimmt
  50977.      <VAR
  50978. CLASS="parameter"
  50979. >array</VAR
  50980. > und gibt ein neues Array zurⁿck, aus
  50981.      dem alle doppelten EintrΣge entfernt wurden.
  50982.     </P
  50983. ><P
  50984. >      Beachten Sie, dass Schlⁿssel bewahrt bleiben. Erst behandelt
  50985.      <B
  50986. CLASS="function"
  50987. >array_unique()</B
  50988. > die Werte als Strings und sortiert
  50989.      sie, danach wird der erste gefundene Schlⁿssel behalten, und alle
  50990.      folgenden Schlⁿssel ignoriert. Das hei▀t nicht, dass der Schlⁿssel
  50991.      des ersten zugeh÷rigen Wertes aus dem unsortierten
  50992.      <VAR
  50993. CLASS="parameter"
  50994. >array</VAR
  50995. > behalten wird.
  50996.     </P
  50997. ><DIV
  50998. CLASS="note"
  50999. ><BLOCKQUOTE
  51000. CLASS="note"
  51001. ><P
  51002. ><B
  51003. >Anmerkung: </B
  51004. >
  51005.       Zwei Elemente werden nur dann als gleich angesehen, wenn
  51006.       <VAR
  51007. CLASS="literal"
  51008. >(string) $elem1 === (string) $elem2</VAR
  51009. >. In Worten:
  51010.       Wenn die String-ReprΣsentation die gleiche ist.
  51011.      </P
  51012. ><P
  51013. >       Das erste Element wird verwendet.
  51014.      </P
  51015. ></BLOCKQUOTE
  51016. ></DIV
  51017. ><P
  51018. >      <TABLE
  51019. WIDTH="100%"
  51020. BORDER="0"
  51021. CELLPADDING="0"
  51022. CELLSPACING="0"
  51023. CLASS="EXAMPLE"
  51024. ><TR
  51025. ><TD
  51026. ><DIV
  51027. CLASS="example"
  51028. ><A
  51029. NAME="AEN9009"
  51030. ></A
  51031. ><P
  51032. ><B
  51033. >Beispiel 1. <B
  51034. CLASS="function"
  51035. >array_unique()</B
  51036. > example</B
  51037. ></P
  51038. ><TABLE
  51039. BORDER="0"
  51040. BGCOLOR="#E0E0E0"
  51041. CELLPADDING="5"
  51042. ><TR
  51043. ><TD
  51044. ><PRE
  51045. CLASS="php"
  51046. ><?php
  51047. $input = array ("a" => "grⁿn", "rot", "b" => "grⁿn", "blau", "rot");
  51048. $result = array_unique ($input);
  51049. print_r($result);
  51050. ?></PRE
  51051. ></TD
  51052. ></TR
  51053. ></TABLE
  51054. ><P
  51055. >        Dies wird folgendes ausgeben:
  51056.       </P
  51057. ><TABLE
  51058. BORDER="0"
  51059. BGCOLOR="#E0E0E0"
  51060. CELLPADDING="5"
  51061. ><TR
  51062. ><TD
  51063. ><PRE
  51064. CLASS="php"
  51065. >Array
  51066. (
  51067.     [a] => grⁿn
  51068.     [0] => rot
  51069.     [1] => blau
  51070. )</PRE
  51071. ></TD
  51072. ></TR
  51073. ></TABLE
  51074. ></DIV
  51075. ></TD
  51076. ></TR
  51077. ></TABLE
  51078. >
  51079.     </P
  51080. ><P
  51081. >      <TABLE
  51082. WIDTH="100%"
  51083. BORDER="0"
  51084. CELLPADDING="0"
  51085. CELLSPACING="0"
  51086. CLASS="EXAMPLE"
  51087. ><TR
  51088. ><TD
  51089. ><DIV
  51090. CLASS="example"
  51091. ><A
  51092. NAME="AEN9016"
  51093. ></A
  51094. ><P
  51095. ><B
  51096. >Beispiel 2. <B
  51097. CLASS="function"
  51098. >array_unique()</B
  51099. > und Typen</B
  51100. ></P
  51101. ><TABLE
  51102. BORDER="0"
  51103. BGCOLOR="#E0E0E0"
  51104. CELLPADDING="5"
  51105. ><TR
  51106. ><TD
  51107. ><PRE
  51108. CLASS="php"
  51109. ><?php
  51110. $input = array (4,"4","3",4,3,"3");
  51111. $result = array_unique ($input);
  51112. var_dump($result);
  51113. ?></PRE
  51114. ></TD
  51115. ></TR
  51116. ></TABLE
  51117. ><P
  51118. >        Dies wird folgendes ausgeben:
  51119.       </P
  51120. ><TABLE
  51121. BORDER="0"
  51122. BGCOLOR="#E0E0E0"
  51123. CELLPADDING="5"
  51124. ><TR
  51125. ><TD
  51126. ><PRE
  51127. CLASS="php"
  51128. >array(2) {
  51129.   [0] => int(4)
  51130.   [2] => string(1) "3"
  51131. }</PRE
  51132. ></TD
  51133. ></TR
  51134. ></TABLE
  51135. ></DIV
  51136. ></TD
  51137. ></TR
  51138. ></TABLE
  51139. >
  51140.     </P
  51141. ></DIV
  51142. ><H1
  51143. ><A
  51144. NAME="function.array-unshift"
  51145. ></A
  51146. >array_unshift</H1
  51147. ><DIV
  51148. CLASS="refnamediv"
  51149. ><A
  51150. NAME="AEN9023"
  51151. ></A
  51152. ><P
  51153. >    (PHP 4 , PHP 5)</P
  51154. >array_unshift -- 
  51155.      Fⁿgt ein oder mehr Elemente am Anfang eines Arrays ein
  51156.     </DIV
  51157. ><DIV
  51158. CLASS="refsect1"
  51159. ><A
  51160. NAME="AEN9026"
  51161. ></A
  51162. ><H2
  51163. >Beschreibung</H2
  51164. >int <B
  51165. CLASS="methodname"
  51166. >array_unshift</B
  51167. > ( array array, mixed var [, mixed ...])<BR
  51168. ></BR
  51169. ><P
  51170. >      <B
  51171. CLASS="function"
  51172. >array_unshift()</B
  51173. > fⁿgt die ⁿbergebenen Elemente
  51174.      am Anfang von <VAR
  51175. CLASS="parameter"
  51176. >array</VAR
  51177. > ein. Beachten Sie,
  51178.      dass die Liste von Elementen als Ganzes eingefⁿgt wird, sodass
  51179.      die eingefⁿgten Elemente die selbe Reihenfolge haben. Die
  51180.      numerischen Schlⁿssel werden so modifiziert, dass bei null zu
  51181.      zΣhlen begonnen wird, Strings als Schlⁿssel bleiben unverΣndert.
  51182.     </P
  51183. ><P
  51184. >      Diese Funktion gibt die neue Anzahl der in
  51185.      <VAR
  51186. CLASS="parameter"
  51187. >array</VAR
  51188. > enthaltenen Elemente zurⁿck.
  51189.     </P
  51190. ><P
  51191. >      <TABLE
  51192. WIDTH="100%"
  51193. BORDER="0"
  51194. CELLPADDING="0"
  51195. CELLSPACING="0"
  51196. CLASS="EXAMPLE"
  51197. ><TR
  51198. ><TD
  51199. ><DIV
  51200. CLASS="example"
  51201. ><A
  51202. NAME="AEN9046"
  51203. ></A
  51204. ><P
  51205. ><B
  51206. >Beispiel 1. <B
  51207. CLASS="function"
  51208. >array_unshift()</B
  51209. ></B
  51210. ></P
  51211. ><TABLE
  51212. BORDER="0"
  51213. BGCOLOR="#E0E0E0"
  51214. CELLPADDING="5"
  51215. ><TR
  51216. ><TD
  51217. ><PRE
  51218. CLASS="php"
  51219. ><?php
  51220. $queue = array ("Orange", "Banane");
  51221. array_unshift ($queue, "Apfel", "Himbeere");
  51222. ?></PRE
  51223. ></TD
  51224. ></TR
  51225. ></TABLE
  51226. ><P
  51227. >        Als Ergebnis enthΣlt <VAR
  51228. CLASS="varname"
  51229. >$queue</VAR
  51230. >
  51231.        die folgenden Elemente:
  51232.       </P
  51233. ><TABLE
  51234. BORDER="0"
  51235. BGCOLOR="#E0E0E0"
  51236. CELLPADDING="5"
  51237. ><TR
  51238. ><TD
  51239. ><PRE
  51240. CLASS="php"
  51241. >Array
  51242. (
  51243.     [0] => Apfel
  51244.     [1] => Himbeere
  51245.     [2] => Orange
  51246.     [3] => Banane
  51247. )</PRE
  51248. ></TD
  51249. ></TR
  51250. ></TABLE
  51251. ></DIV
  51252. ></TD
  51253. ></TR
  51254. ></TABLE
  51255. >
  51256.     </P
  51257. ><P
  51258. >      Siehe auch <A
  51259. HREF="#function.array-shift"
  51260. ><B
  51261. CLASS="function"
  51262. >array_shift()</B
  51263. ></A
  51264. >,
  51265.      <A
  51266. HREF="#function.array-push"
  51267. ><B
  51268. CLASS="function"
  51269. >array_push()</B
  51270. ></A
  51271. > und
  51272.      <A
  51273. HREF="#function.array-pop"
  51274. ><B
  51275. CLASS="function"
  51276. >array_pop()</B
  51277. ></A
  51278. >.
  51279.     </P
  51280. ></DIV
  51281. ><H1
  51282. ><A
  51283. NAME="function.array-values"
  51284. ></A
  51285. >array_values</H1
  51286. ><DIV
  51287. CLASS="refnamediv"
  51288. ><A
  51289. NAME="AEN9058"
  51290. ></A
  51291. ><P
  51292. >    (PHP 4 , PHP 5)</P
  51293. >array_values -- Liefert alle Werte eines Arrays</DIV
  51294. ><DIV
  51295. CLASS="refsect1"
  51296. ><A
  51297. NAME="AEN9061"
  51298. ></A
  51299. ><H2
  51300. >Beschreibung</H2
  51301. >array <B
  51302. CLASS="methodname"
  51303. >array_values</B
  51304. > ( array input)<BR
  51305. ></BR
  51306. ><P
  51307. >      <B
  51308. CLASS="function"
  51309. >array_values()</B
  51310. > liefert alle Werte des Arrays
  51311.      <VAR
  51312. CLASS="parameter"
  51313. >input</VAR
  51314. > mit einem numerischen Index.
  51315.     </P
  51316. ><P
  51317. >      <TABLE
  51318. WIDTH="100%"
  51319. BORDER="0"
  51320. CELLPADDING="0"
  51321. CELLSPACING="0"
  51322. CLASS="EXAMPLE"
  51323. ><TR
  51324. ><TD
  51325. ><DIV
  51326. CLASS="example"
  51327. ><A
  51328. NAME="AEN9073"
  51329. ></A
  51330. ><P
  51331. ><B
  51332. >Beispiel 1. <B
  51333. CLASS="function"
  51334. >array_values()</B
  51335. ></B
  51336. ></P
  51337. ><TABLE
  51338. BORDER="0"
  51339. BGCOLOR="#E0E0E0"
  51340. CELLPADDING="5"
  51341. ><TR
  51342. ><TD
  51343. ><PRE
  51344. CLASS="php"
  51345. ><?php
  51346. $array = array ("gr÷▀e" => "XL", "farbe" => "gold");
  51347. print_r(array_values ($array));
  51348. ?></PRE
  51349. ></TD
  51350. ></TR
  51351. ></TABLE
  51352. ><P
  51353. >        Dies wird folgendes ausgeben:
  51354.       </P
  51355. ><TABLE
  51356. BORDER="0"
  51357. BGCOLOR="#E0E0E0"
  51358. CELLPADDING="5"
  51359. ><TR
  51360. ><TD
  51361. ><PRE
  51362. CLASS="php"
  51363. >Array
  51364. (
  51365.     [0] => XL
  51366.     [1] => gold
  51367. )</PRE
  51368. ></TD
  51369. ></TR
  51370. ></TABLE
  51371. ></DIV
  51372. ></TD
  51373. ></TR
  51374. ></TABLE
  51375. >
  51376.     </P
  51377. ><P
  51378. >      Siehe auch <A
  51379. HREF="#function.array-keys"
  51380. ><B
  51381. CLASS="function"
  51382. >array_keys()</B
  51383. ></A
  51384. >.
  51385.     </P
  51386. ></DIV
  51387. ><H1
  51388. ><A
  51389. NAME="function.array-walk-recursive"
  51390. ></A
  51391. >array_walk_recursive</H1
  51392. ><DIV
  51393. CLASS="refnamediv"
  51394. ><A
  51395. NAME="AEN9082"
  51396. ></A
  51397. ><P
  51398. >    (PHP 5)</P
  51399. >array_walk_recursive -- 
  51400.    Apply a user function recursively to every member of an array
  51401.   </DIV
  51402. ><DIV
  51403. CLASS="refsect1"
  51404. ><A
  51405. NAME="AEN9085"
  51406. ></A
  51407. ><H2
  51408. >Description</H2
  51409. >bool <B
  51410. CLASS="methodname"
  51411. >array_walk_recursive</B
  51412. > ( array &input, string funcname [, mixed userdata])<BR
  51413. ></BR
  51414. ><P
  51415. >    Applies the user-defined function <VAR
  51416. CLASS="parameter"
  51417. >funcname</VAR
  51418. > to each
  51419.    element of the <VAR
  51420. CLASS="parameter"
  51421. >input</VAR
  51422. > array. This function will recur
  51423.    into deeper arrays. Typically,  <VAR
  51424. CLASS="parameter"
  51425. >funcname</VAR
  51426. > takes on two
  51427.    parameters. The <VAR
  51428. CLASS="parameter"
  51429. >input</VAR
  51430. > parameter's value being the first, and
  51431.    the key/index second. If the optional <VAR
  51432. CLASS="parameter"
  51433. >userdata</VAR
  51434. >
  51435.    parameter is supplied, it will be passed as the third parameter to
  51436.    the callback <VAR
  51437. CLASS="parameter"
  51438. >funcname</VAR
  51439. >.
  51440.   </P
  51441. ><P
  51442. >    Gibt bei Erfolg <TT
  51443. CLASS="constant"
  51444. ><B
  51445. >TRUE</B
  51446. ></TT
  51447. > zurⁿck, im Fehlerfall <TT
  51448. CLASS="constant"
  51449. ><B
  51450. >FALSE</B
  51451. ></TT
  51452. >.
  51453.   </P
  51454. ><DIV
  51455. CLASS="note"
  51456. ><BLOCKQUOTE
  51457. CLASS="note"
  51458. ><P
  51459. ><B
  51460. >Anmerkung: </B
  51461. >
  51462.     If <VAR
  51463. CLASS="parameter"
  51464. >funcname</VAR
  51465. > needs to be working with the
  51466.     actual values of the array, specify the first parameter of
  51467.     <VAR
  51468. CLASS="parameter"
  51469. >funcname</VAR
  51470. > as a 
  51471.     <A
  51472. HREF="#language.references"
  51473. >reference</A
  51474. >. Then,
  51475.     any changes made to those elements will be made in the 
  51476.     original array itself.
  51477.    </P
  51478. ></BLOCKQUOTE
  51479. ></DIV
  51480. ><P
  51481. >    <TABLE
  51482. WIDTH="100%"
  51483. BORDER="0"
  51484. CELLPADDING="0"
  51485. CELLSPACING="0"
  51486. CLASS="EXAMPLE"
  51487. ><TR
  51488. ><TD
  51489. ><DIV
  51490. CLASS="example"
  51491. ><A
  51492. NAME="AEN9115"
  51493. ></A
  51494. ><P
  51495. ><B
  51496. >Beispiel 1. <B
  51497. CLASS="function"
  51498. >array_walk_recursive()</B
  51499. > example</B
  51500. ></P
  51501. ><TABLE
  51502. BORDER="0"
  51503. BGCOLOR="#E0E0E0"
  51504. CELLPADDING="5"
  51505. ><TR
  51506. ><TD
  51507. ><PRE
  51508. CLASS="php"
  51509. ><?php
  51510. $sweet = array('a' => 'apple', 'b' => 'banana');
  51511. $fruits = array('sweet' => $sweet, 'sour' => 'lemon');
  51512.  
  51513. function test_print($item, $key) 
  51514. {
  51515.     echo "$key holds $item\n";
  51516. }
  51517.  
  51518. array_walk_recursive($fruits, 'test_print');
  51519. ?></PRE
  51520. ></TD
  51521. ></TR
  51522. ></TABLE
  51523. ><P
  51524. >      The printout of the program above will be:
  51525.     </P
  51526. ><TABLE
  51527. BORDER="0"
  51528. BGCOLOR="#E0E0E0"
  51529. CELLPADDING="5"
  51530. ><TR
  51531. ><TD
  51532. ><PRE
  51533. CLASS="php"
  51534. >a holds apple
  51535. b holds banana
  51536. sour holds lemon</PRE
  51537. ></TD
  51538. ></TR
  51539. ></TABLE
  51540. ><P
  51541. >      You may notice that the key 'sweet' is never displayed. Any key that holds an
  51542.      <A
  51543. HREF="#language.types.array"
  51544. ><B
  51545. CLASS="type"
  51546. >array</B
  51547. ></A
  51548. > will not be passed to the function.
  51549.     </P
  51550. ></DIV
  51551. ></TD
  51552. ></TR
  51553. ></TABLE
  51554. >
  51555.   </P
  51556. ><P
  51557. >    See also <A
  51558. HREF="#function.array-walk"
  51559. ><B
  51560. CLASS="function"
  51561. >array_walk()</B
  51562. ></A
  51563. >.
  51564.   </P
  51565. ></DIV
  51566. ><H1
  51567. ><A
  51568. NAME="function.array-walk"
  51569. ></A
  51570. >array_walk</H1
  51571. ><DIV
  51572. CLASS="refnamediv"
  51573. ><A
  51574. NAME="AEN9126"
  51575. ></A
  51576. ><P
  51577. >    (PHP 3>= 3.0.3, PHP 4 , PHP 5)</P
  51578. >array_walk -- 
  51579.      Wendet eine Benutzerfunktion an jedem Element eines Arrays an
  51580.     </DIV
  51581. ><DIV
  51582. CLASS="refsect1"
  51583. ><A
  51584. NAME="AEN9129"
  51585. ></A
  51586. ><H2
  51587. >Beschreibung</H2
  51588. >int <B
  51589. CLASS="methodname"
  51590. >array_walk</B
  51591. > ( array array, callback function [, mixed userdata])<BR
  51592. ></BR
  51593. ><P
  51594. >
  51595.        Gibt bei Erfolg <TT
  51596. CLASS="constant"
  51597. ><B
  51598. >TRUE</B
  51599. ></TT
  51600. > zurⁿck, im Fehlerfall <TT
  51601. CLASS="constant"
  51602. ><B
  51603. >FALSE</B
  51604. ></TT
  51605. >.
  51606.  
  51607.       </P
  51608. ><P
  51609. >      Wendet die mittels <VAR
  51610. CLASS="parameter"
  51611. >function</VAR
  51612. > angegebene
  51613.      Benutzerfunktion fⁿr jedes Element von <VAR
  51614. CLASS="parameter"
  51615. >array</VAR
  51616. >
  51617.      an. <VAR
  51618. CLASS="parameter"
  51619. >function</VAR
  51620. > ben÷tigt zwei Parameter. Der Wert
  51621.      von <VAR
  51622. CLASS="parameter"
  51623. >array</VAR
  51624. > wird als erster ⁿbergeben, und der
  51625.      Schlⁿssel/Index als zweites. Ist der optionale Parameter
  51626.      <VAR
  51627. CLASS="parameter"
  51628. >userdata</VAR
  51629. > angegeben, so wird er als dritter
  51630.      Parameter an die Funktion <VAR
  51631. CLASS="parameter"
  51632. >function</VAR
  51633. > ⁿbergeben.
  51634.     </P
  51635. ><P
  51636. >      Sollte <VAR
  51637. CLASS="parameter"
  51638. >function</VAR
  51639. > mehr als die ihr ⁿbergebenen
  51640.      Parameter ben÷tigen, wird bei jedem Aufruf von
  51641.      <VAR
  51642. CLASS="parameter"
  51643. >function</VAR
  51644. > seitens <B
  51645. CLASS="function"
  51646. >array_walk()</B
  51647. >
  51648.      eine Fehlermeldung der Stufe <A
  51649. HREF="#errorfunc.constants"
  51650. >      E_WARNING</A
  51651. > generiert. Diese Warnmeldungen k÷nnen unterdrⁿckt
  51652.      werden, indem man dem Funktionsaufruf von
  51653.      <B
  51654. CLASS="function"
  51655. >array_walk()</B
  51656. > den Operator <A
  51657. HREF="#language.operators.errorcontrol"
  51658. >@</A
  51659. > voranstellt,
  51660.      oder <A
  51661. HREF="#function.error-reporting"
  51662. ><B
  51663. CLASS="function"
  51664. >error_reporting()</B
  51665. ></A
  51666. > verwendet.
  51667.     </P
  51668. ><DIV
  51669. CLASS="note"
  51670. ><BLOCKQUOTE
  51671. CLASS="note"
  51672. ><P
  51673. ><B
  51674. >Anmerkung: </B
  51675. >
  51676.       Wenn <VAR
  51677. CLASS="parameter"
  51678. >function</VAR
  51679. > direkt mit den Werten des
  51680.       Arrays arbeiten soll, spezifizieren Sie den ersten Parameter
  51681.       von <VAR
  51682. CLASS="parameter"
  51683. >function</VAR
  51684. > als <A
  51685. HREF="#language.references"
  51686. >Referenz</A
  51687. >. Dann werden alle
  51688.       ─nderungen an diesen Elementen direkt in dem originalen Array
  51689.       durchgefⁿhrt.
  51690.      </P
  51691. ><P
  51692. >       Die Modifizierung des Arrays aus <VAR
  51693. CLASS="parameter"
  51694. >function</VAR
  51695. >
  51696.       heraus k÷nnte ein unvorhersehbares Verhalten hervorrufen.
  51697.      </P
  51698. ></BLOCKQUOTE
  51699. ></DIV
  51700. ><DIV
  51701. CLASS="note"
  51702. ><BLOCKQUOTE
  51703. CLASS="note"
  51704. ><P
  51705. ><B
  51706. >Anmerkung: </B
  51707. >
  51708.       Die ▄bergabe des Schlⁿssels und von <VAR
  51709. CLASS="parameter"
  51710. >userdata</VAR
  51711. >
  51712.       an <VAR
  51713. CLASS="parameter"
  51714. >function</VAR
  51715. > wurde mit PHP 4.0.0 eingefⁿhrt.
  51716.      </P
  51717. ></BLOCKQUOTE
  51718. ></DIV
  51719. ><P
  51720. >      <B
  51721. CLASS="function"
  51722. >array_walk()</B
  51723. > ist nicht von dem internen
  51724.      Arrayzeiger von <VAR
  51725. CLASS="parameter"
  51726. >array</VAR
  51727. > betroffen. <B
  51728. CLASS="function"
  51729. >      array_walk()</B
  51730. > geht ungeachtet der Zeigerposition das
  51731.      gesamte Array durch. Um den Zeiger zurⁿckzusetzen, verwenden Sie
  51732.      <A
  51733. HREF="#function.reset"
  51734. ><B
  51735. CLASS="function"
  51736. >reset()</B
  51737. ></A
  51738. >. In PHP 3 setzt
  51739.      <B
  51740. CLASS="function"
  51741. >array_walk()</B
  51742. > den Zeiger zurⁿck.
  51743.     </P
  51744. ><P
  51745. >      Von der Benutzerfunktion aus darf das Array selbst nicht geΣndert
  51746.      werden, wie zum Beispiel durch Hinzufⁿgen oder L÷schen eines
  51747.      Elementes, etc. Wird das auf <B
  51748. CLASS="function"
  51749. >array_walk()</B
  51750.      angewendete Array geΣndert, so ist das Verhalten dieser Funktion
  51751.      undefiniert und unvorhersagbar.
  51752.     </P
  51753. ><P
  51754. >      <TABLE
  51755. WIDTH="100%"
  51756. BORDER="0"
  51757. CELLPADDING="0"
  51758. CELLSPACING="0"
  51759. CLASS="EXAMPLE"
  51760. ><TR
  51761. ><TD
  51762. ><DIV
  51763. CLASS="example"
  51764. ><A
  51765. NAME="AEN9181"
  51766. ></A
  51767. ><P
  51768. ><B
  51769. >Beispiel 1. <B
  51770. CLASS="function"
  51771. >array_walk()</B
  51772. ></B
  51773. ></P
  51774. ><TABLE
  51775. BORDER="0"
  51776. BGCOLOR="#E0E0E0"
  51777. CELLPADDING="5"
  51778. ><TR
  51779. ><TD
  51780. ><PRE
  51781. CLASS="php"
  51782. ><?php
  51783. $fruits = array ("d"=>"Zitrone", "a"=>"Orange", "b"=>"Banane", "c"=>"Apfel");
  51784.  
  51785. function test_alter (&$item1, $key, $prefix) {
  51786.     $item1 = "$prefix: $item1";
  51787. }
  51788.  
  51789. function test_print ($item2, $key) {
  51790.     echo "$key. $item2<br>\n";
  51791. }
  51792.  
  51793. echo "Vorher ...:\n";
  51794. array_walk ($fruits, 'test_print');
  51795.  
  51796. array_walk ($fruits, 'test_alter', 'Frucht');
  51797. echo "... und nachher:\n";
  51798.  
  51799. array_walk ($fruits, 'test_print');
  51800. ?></PRE
  51801. ></TD
  51802. ></TR
  51803. ></TABLE
  51804. ><P
  51805. >        Das obige Programm wird folgendes ausgeben:
  51806.       </P
  51807. ><TABLE
  51808. BORDER="0"
  51809. BGCOLOR="#E0E0E0"
  51810. CELLPADDING="5"
  51811. ><TR
  51812. ><TD
  51813. ><PRE
  51814. CLASS="php"
  51815. >Vorher ...:
  51816. d. Zitrone
  51817. a. Orange
  51818. b. Banane
  51819. c. Apfel
  51820. ... und nachher:
  51821. d. Frucht: Zitrone
  51822. a. Frucht: Orange
  51823. b. Frucht: Banane
  51824. c. Frucht: Apfel</PRE
  51825. ></TD
  51826. ></TR
  51827. ></TABLE
  51828. ></DIV
  51829. ></TD
  51830. ></TR
  51831. ></TABLE
  51832. >
  51833.     </P
  51834. ><P
  51835. >      Siehe auch <A
  51836. HREF="#function.list"
  51837. ><B
  51838. CLASS="function"
  51839. >list()</B
  51840. ></A
  51841. >, 
  51842.      <A
  51843. HREF="#control-structures.foreach"
  51844. >foreach</A
  51845. >, 
  51846.      <A
  51847. HREF="#function.each"
  51848. ><B
  51849. CLASS="function"
  51850. >each()</B
  51851. ></A
  51852. > und <A
  51853. HREF="#function.call-user-func-array"
  51854. ><B
  51855. CLASS="function"
  51856. >call_user_func_array()</B
  51857. ></A
  51858. >.
  51859.     </P
  51860. ></DIV
  51861. ><H1
  51862. ><A
  51863. NAME="function.array"
  51864. ></A
  51865. >array</H1
  51866. ><DIV
  51867. CLASS="refnamediv"
  51868. ><A
  51869. NAME="AEN9193"
  51870. ></A
  51871. ><P
  51872. >    (PHP 3, PHP 4, PHP 5 )</P
  51873. >array -- 
  51874.      Erstellt ein Array
  51875.     </DIV
  51876. ><DIV
  51877. CLASS="refsect1"
  51878. ><A
  51879. NAME="AEN9196"
  51880. ></A
  51881. ><H2
  51882. >Beschreibung</H2
  51883. >array <B
  51884. CLASS="methodname"
  51885. >array</B
  51886. > ( [mixed ...])<BR
  51887. ></BR
  51888. ><P
  51889. >      Gibt ein den Parametern entsprechendes Array zurⁿck. Mit dem
  51890.      <VAR
  51891. CLASS="literal"
  51892. >=></VAR
  51893. > Operator k÷nnen die Parameter indiziert werden.
  51894.      Weitere Informationen zu Arrays finden Sie im Abschnitt
  51895.      <A
  51896. HREF="#language.types.array"
  51897. >array type</A
  51898. >.
  51899.     </P
  51900. ><P
  51901. >      <DIV
  51902. CLASS="note"
  51903. ><BLOCKQUOTE
  51904. CLASS="note"
  51905. ><P
  51906. ><B
  51907. >Anmerkung: </B
  51908. >
  51909.        <B
  51910. CLASS="function"
  51911. >array()</B
  51912. > ist keine richtige Funktion sondern ein
  51913.        Sprachkonstrukt, das zur Erzeugung eines Wertefeldes genutzt wird.
  51914.       </P
  51915. ></BLOCKQUOTE
  51916. ></DIV
  51917. >
  51918.     </P
  51919. ><P
  51920. >      Die Syntax "Index => Werte", durch Kommas getrennt, definiert
  51921.      Index und Werte. Index kann vom Typ String oder numerisch sein.
  51922.      Wird der Index weggelassen, erstellt die Funktion automatisch
  51923.      einen numerischen Index, der bei 0 beginnt. Ist der Index als
  51924.      Integer-Wert angegeben, wird der nΣchste generierte Index der
  51925.      gr÷▀te Integer Index + 1. Beachten Sie, dass wenn zwei identische
  51926.      Indexe definiert sind, der letzte den ersten ⁿberschreibt.
  51927.     </P
  51928. ><P
  51929. >      Das folgende Beispiel zeigt wie man ein zweidimensionales Array
  51930.      erstellt, wie man Schlⁿssel fⁿr assoziative Arrays festlegt, und
  51931.      wie man numerische Indizes in normalen Arrays ⁿberspringt und
  51932.      fortsetzt.
  51933.      <TABLE
  51934. WIDTH="100%"
  51935. BORDER="0"
  51936. CELLPADDING="0"
  51937. CELLSPACING="0"
  51938. CLASS="EXAMPLE"
  51939. ><TR
  51940. ><TD
  51941. ><DIV
  51942. CLASS="example"
  51943. ><A
  51944. NAME="AEN9213"
  51945. ></A
  51946. ><P
  51947. ><B
  51948. >Beispiel 1. <B
  51949. CLASS="function"
  51950. >array()</B
  51951. ></B
  51952. ></P
  51953. ><TABLE
  51954. BORDER="0"
  51955. BGCOLOR="#E0E0E0"
  51956. CELLPADDING="5"
  51957. ><TR
  51958. ><TD
  51959. ><PRE
  51960. CLASS="php"
  51961. ><?php
  51962. $fruits = array (
  51963.     "Frⁿchte" => array ("a"=>"Orange", "b"=>"Banane", "c"=>"Apfel"),
  51964.     "Zahlen"  => array (1, 2, 3, 4, 5, 6),
  51965.     "L÷cher"  => array ("erstes", 5 => "zweites", "drittes")
  51966. );
  51967. ?></PRE
  51968. ></TD
  51969. ></TR
  51970. ></TABLE
  51971. ></DIV
  51972. ></TD
  51973. ></TR
  51974. ></TABLE
  51975. >
  51976.     </P
  51977. ><P
  51978. >      <TABLE
  51979. WIDTH="100%"
  51980. BORDER="0"
  51981. CELLPADDING="0"
  51982. CELLSPACING="0"
  51983. CLASS="EXAMPLE"
  51984. ><TR
  51985. ><TD
  51986. ><DIV
  51987. CLASS="example"
  51988. ><A
  51989. NAME="AEN9218"
  51990. ></A
  51991. ><P
  51992. ><B
  51993. >Beispiel 2. Automatischer Index mit <B
  51994. CLASS="function"
  51995. >array()</B
  51996. ></B
  51997. ></P
  51998. ><TABLE
  51999. BORDER="0"
  52000. BGCOLOR="#E0E0E0"
  52001. CELLPADDING="5"
  52002. ><TR
  52003. ><TD
  52004. ><PRE
  52005. CLASS="php"
  52006. ><?php
  52007. $array = array( 1, 1, 1, 1, 1, 8=>1, 4=>1, 19, 3=>13);
  52008. print_r($array);
  52009. ?></PRE
  52010. ></TD
  52011. ></TR
  52012. ></TABLE
  52013. ><P
  52014. >        wird folgendes anzeigen:
  52015.       </P
  52016. ><TABLE
  52017. BORDER="0"
  52018. BGCOLOR="#E0E0E0"
  52019. CELLPADDING="5"
  52020. ><TR
  52021. ><TD
  52022. ><PRE
  52023. CLASS="php"
  52024. >Array
  52025. (
  52026.     [0] => 1
  52027.     [1] => 1
  52028.     [2] => 1
  52029.     [3] => 13
  52030.     [4] => 1
  52031.     [8] => 1
  52032.     [9] => 19
  52033. )</PRE
  52034. ></TD
  52035. ></TR
  52036. ></TABLE
  52037. ></DIV
  52038. ></TD
  52039. ></TR
  52040. ></TABLE
  52041. >
  52042.     </P
  52043. ><P
  52044. >      Beachten Sie, dass Index '3' doppelt definiert ist, und den letzten
  52045.      definierten Wert 13 behΣlt. Index 4 wurde nach dem Index 8 definiert,
  52046.      und der nΣchste generierte Index (Wert 19) ist 9, da der gr÷▀te Index
  52047.      8 war.
  52048.     </P
  52049. ><P
  52050. >      Dieses Beispiel erstellt ein auf dem Index 1 basierendes Array.
  52051.      <TABLE
  52052. WIDTH="100%"
  52053. BORDER="0"
  52054. CELLPADDING="0"
  52055. CELLSPACING="0"
  52056. CLASS="EXAMPLE"
  52057. ><TR
  52058. ><TD
  52059. ><DIV
  52060. CLASS="example"
  52061. ><A
  52062. NAME="AEN9226"
  52063. ></A
  52064. ><P
  52065. ><B
  52066. >Beispiel 3. 1-basierter Index mit <B
  52067. CLASS="function"
  52068. >array()</B
  52069. ></B
  52070. ></P
  52071. ><TABLE
  52072. BORDER="0"
  52073. BGCOLOR="#E0E0E0"
  52074. CELLPADDING="5"
  52075. ><TR
  52076. ><TD
  52077. ><PRE
  52078. CLASS="php"
  52079. ><?php
  52080. $erstesquartal  = array(1 => 'Januar', 'Februar', 'MΣrz');
  52081. print_r($erstesquartal);
  52082. ?></PRE
  52083. ></TD
  52084. ></TR
  52085. ></TABLE
  52086. ><P
  52087. >        wird folgendes ausgeben:
  52088.       </P
  52089. ><TABLE
  52090. BORDER="0"
  52091. BGCOLOR="#E0E0E0"
  52092. CELLPADDING="5"
  52093. ><TR
  52094. ><TD
  52095. ><PRE
  52096. CLASS="screen"
  52097. >Array
  52098. (
  52099.     [1] => Januar
  52100.     [2] => Februar
  52101.     [3] => MΣrz
  52102. )</PRE
  52103. ></TD
  52104. ></TR
  52105. ></TABLE
  52106. ></DIV
  52107. ></TD
  52108. ></TR
  52109. ></TABLE
  52110. >
  52111.     </P
  52112. ><P
  52113. >      Siehe auch <A
  52114. HREF="#function.array-pad"
  52115. ><B
  52116. CLASS="function"
  52117. >array_pad()</B
  52118. ></A
  52119. >,
  52120.      <A
  52121. HREF="#function.list"
  52122. ><B
  52123. CLASS="function"
  52124. >list()</B
  52125. ></A
  52126. >,
  52127.  
  52128.        <A
  52129. HREF="#control-structures.foreach"
  52130. >foreach</A
  52131. > und
  52132.  
  52133.        <A
  52134. HREF="#function.range"
  52135. ><B
  52136. CLASS="function"
  52137. >range()</B
  52138. ></A
  52139. >.
  52140.     </P
  52141. ></DIV
  52142. ><H1
  52143. ><A
  52144. NAME="function.arsort"
  52145. ></A
  52146. >arsort</H1
  52147. ><DIV
  52148. CLASS="refnamediv"
  52149. ><A
  52150. NAME="AEN9238"
  52151. ></A
  52152. ><P
  52153. >    (PHP 3, PHP 4 , PHP 5)</P
  52154. >arsort -- 
  52155.      Sortiert ein Array in umgekehrter Reihenfolge und behΣlt die
  52156.      Verbindung zum Index
  52157.     </DIV
  52158. ><DIV
  52159. CLASS="refsect1"
  52160. ><A
  52161. NAME="AEN9241"
  52162. ></A
  52163. ><H2
  52164. >Beschreibung</H2
  52165. >void <B
  52166. CLASS="methodname"
  52167. >arsort</B
  52168. > ( array array [, int sort_flags])<BR
  52169. ></BR
  52170. ><P
  52171. >      Diese Funktion sortiert ein Array so, dass der Zusammenhang zwischen
  52172.      den Indizes und den entsprechenden Arrayelementen erhalten bleibt.
  52173.      Dies wird hauptsΣchlich bei assoziativen Arrays verwendet, bei denen
  52174.      die aktuelle Reihenfolge der Elemente bedeutend ist.
  52175.     </P
  52176. ><TABLE
  52177. WIDTH="100%"
  52178. BORDER="0"
  52179. CELLPADDING="0"
  52180. CELLSPACING="0"
  52181. CLASS="EXAMPLE"
  52182. ><TR
  52183. ><TD
  52184. ><DIV
  52185. CLASS="example"
  52186. ><A
  52187. NAME="AEN9253"
  52188. ></A
  52189. ><P
  52190. ><B
  52191. >Beispiel 1. <B
  52192. CLASS="function"
  52193. >arsort()</B
  52194. ></B
  52195. ></P
  52196. ><TABLE
  52197. BORDER="0"
  52198. BGCOLOR="#E0E0E0"
  52199. CELLPADDING="5"
  52200. ><TR
  52201. ><TD
  52202. ><PRE
  52203. CLASS="php"
  52204. ><?php
  52205. $fruits = array ("d"=>"Zitrone", "a"=>"Orange", "b"=>"Banane", "c"=>"Apfel");
  52206. arsort ($fruits);
  52207. reset ($fruits);
  52208. while (list ($key, $val) = each ($fruits)) {
  52209.     echo "$key = $val\n";
  52210. }
  52211. ?></PRE
  52212. ></TD
  52213. ></TR
  52214. ></TABLE
  52215. ><P
  52216. >       Dieses Beispiel wⁿrde folgendes ausgeben:
  52217.      </P
  52218. ><TABLE
  52219. BORDER="0"
  52220. BGCOLOR="#E0E0E0"
  52221. CELLPADDING="5"
  52222. ><TR
  52223. ><TD
  52224. ><PRE
  52225. CLASS="screen"
  52226. >d = Zitrone
  52227. a = Orange
  52228. b = Banane
  52229. c = Apfel</PRE
  52230. ></TD
  52231. ></TR
  52232. ></TABLE
  52233. ></DIV
  52234. ></TD
  52235. ></TR
  52236. ></TABLE
  52237. ><P
  52238. >      Die Frⁿchte wurden in umgekehrter alphabetischer Reihenfolge
  52239.      sortiert, und die Zuordnung zwischen Index und Element blieb
  52240.      beibehalten.
  52241.     </P
  52242. ><P
  52243. >      Sie k÷nnen das Verhalten der Sortierung mittels dem optionalen
  52244.      Parameter <VAR
  52245. CLASS="parameter"
  52246. >sort_flags</VAR
  52247. > beeinflussen, fⁿr
  52248.      Details siehe <A
  52249. HREF="#function.sort"
  52250. ><B
  52251. CLASS="function"
  52252. >sort()</B
  52253. ></A
  52254. >.
  52255.     </P
  52256. ><P
  52257. >      Siehe auch <A
  52258. HREF="#function.asort"
  52259. ><B
  52260. CLASS="function"
  52261. >asort()</B
  52262. ></A
  52263. >,
  52264.      <A
  52265. HREF="#function.rsort"
  52266. ><B
  52267. CLASS="function"
  52268. >rsort()</B
  52269. ></A
  52270. >, <A
  52271. HREF="#function.ksort"
  52272. ><B
  52273. CLASS="function"
  52274. >ksort()</B
  52275. ></A
  52276. > und
  52277.      <A
  52278. HREF="#function.sort"
  52279. ><B
  52280. CLASS="function"
  52281. >sort()</B
  52282. ></A
  52283. >.
  52284.     </P
  52285. ></DIV
  52286. ><H1
  52287. ><A
  52288. NAME="function.asort"
  52289. ></A
  52290. >asort</H1
  52291. ><DIV
  52292. CLASS="refnamediv"
  52293. ><A
  52294. NAME="AEN9269"
  52295. ></A
  52296. ><P
  52297. >    (PHP 3, PHP 4 , PHP 5)</P
  52298. >asort -- 
  52299.      Sortiert ein Array und behΣlt die Indexverbindungen
  52300.     </DIV
  52301. ><DIV
  52302. CLASS="refsect1"
  52303. ><A
  52304. NAME="AEN9272"
  52305. ></A
  52306. ><H2
  52307. >Beschreibung</H2
  52308. >void <B
  52309. CLASS="methodname"
  52310. >asort</B
  52311. > ( array array [, int sort_flags])<BR
  52312. ></BR
  52313. ><P
  52314. >      Diese Funktion sortiert ein Array so, dass der Zusammenhang
  52315.      zwischen den Indizes und den entsprechenden Arrayelementen
  52316.      erhalten bleibt.  Dies wird hauptsΣchlich bei assoziativen Arrays
  52317.      verwendet, bei denen die aktuelle Reihenfolge der Elemente
  52318.      bedeutend ist.
  52319.     </P
  52320. ><TABLE
  52321. WIDTH="100%"
  52322. BORDER="0"
  52323. CELLPADDING="0"
  52324. CELLSPACING="0"
  52325. CLASS="EXAMPLE"
  52326. ><TR
  52327. ><TD
  52328. ><DIV
  52329. CLASS="example"
  52330. ><A
  52331. NAME="AEN9284"
  52332. ></A
  52333. ><P
  52334. ><B
  52335. >Beispiel 1. <B
  52336. CLASS="function"
  52337. >asort()</B
  52338. ></B
  52339. ></P
  52340. ><TABLE
  52341. BORDER="0"
  52342. BGCOLOR="#E0E0E0"
  52343. CELLPADDING="5"
  52344. ><TR
  52345. ><TD
  52346. ><PRE
  52347. CLASS="php"
  52348. ><?php
  52349. $fruits = array ("d"=>"Zitrone", "a"=>"Orange", "b"=>"Banane", "c"=>"Apfel");
  52350. asort ($fruits);
  52351. reset ($fruits);
  52352. while (list ($key, $val) = each ($fruits)) {
  52353.     echo "$key = $val\n";
  52354. }
  52355. ?></PRE
  52356. ></TD
  52357. ></TR
  52358. ></TABLE
  52359. ><P
  52360. >       Dieses Beispiel wⁿrde folgendes ausgeben:
  52361.      </P
  52362. ><TABLE
  52363. BORDER="0"
  52364. BGCOLOR="#E0E0E0"
  52365. CELLPADDING="5"
  52366. ><TR
  52367. ><TD
  52368. ><PRE
  52369. CLASS="screen"
  52370. >c = Apfel
  52371. b = Banane
  52372. a = Orange
  52373. d = Zitrone</PRE
  52374. ></TD
  52375. ></TR
  52376. ></TABLE
  52377. ></DIV
  52378. ></TD
  52379. ></TR
  52380. ></TABLE
  52381. ><P
  52382. >      Die Frⁿchte wurden alphabetisch sortiert, und die Zuordnung
  52383.      zwischen Index und Element blieb beibehalten
  52384.     </P
  52385. ><P
  52386. >      Sie k÷nnen das Verhalten der Sortierung mittels dem optionalen
  52387.      Parameter <VAR
  52388. CLASS="parameter"
  52389. >sort_flags</VAR
  52390. > beeinflussen, fⁿr
  52391.      Details siehe <A
  52392. HREF="#function.sort"
  52393. ><B
  52394. CLASS="function"
  52395. >sort()</B
  52396. ></A
  52397. >.
  52398.     </P
  52399. ><P
  52400. >      Siehe auch <A
  52401. HREF="#function.arsort"
  52402. ><B
  52403. CLASS="function"
  52404. >arsort()</B
  52405. ></A
  52406. >,
  52407.      <A
  52408. HREF="#function.rsort"
  52409. ><B
  52410. CLASS="function"
  52411. >rsort()</B
  52412. ></A
  52413. >, <A
  52414. HREF="#function.ksort"
  52415. ><B
  52416. CLASS="function"
  52417. >ksort()</B
  52418. ></A
  52419. > und
  52420.      <A
  52421. HREF="#function.sort"
  52422. ><B
  52423. CLASS="function"
  52424. >sort()</B
  52425. ></A
  52426. >.
  52427.     </P
  52428. ></DIV
  52429. ><H1
  52430. ><A
  52431. NAME="function.compact"
  52432. ></A
  52433. >compact</H1
  52434. ><DIV
  52435. CLASS="refnamediv"
  52436. ><A
  52437. NAME="AEN9300"
  52438. ></A
  52439. ><P
  52440. >    (PHP 4 , PHP 5)</P
  52441. >compact -- 
  52442.      Erstellt ein Array mit Variablen und deren Werten
  52443.     </DIV
  52444. ><DIV
  52445. CLASS="refsect1"
  52446. ><A
  52447. NAME="AEN9303"
  52448. ></A
  52449. ><H2
  52450. >Beschreibung</H2
  52451. >array <B
  52452. CLASS="methodname"
  52453. >compact</B
  52454. > ( mixed varname [, mixed ...])<BR
  52455. ></BR
  52456. ><P
  52457. >      <B
  52458. CLASS="function"
  52459. >compact()</B
  52460. > ⁿbernimmt eine variable Anzahl von
  52461.      Parametern. Jeder Parameter kann entweder ein String mit einem
  52462.      Variablennamen, oder ein Array mit Variablennamen sein. Dieses
  52463.      Array kann auch andere Arrays mit Variablennamen enthalten;
  52464.      <B
  52465. CLASS="function"
  52466. >compact()</B
  52467. > behandelt sie rekursiv.
  52468.     </P
  52469. ><P
  52470. >      Fⁿr alle diese sucht <B
  52471. CLASS="function"
  52472. >compact()</B
  52473. > nach einer
  52474.      Variablen in der aktuellen Symboltabelle, und fⁿgt diese dem
  52475.      zurⁿckzugebenden Array hinzu, wobei der Variablenname als
  52476.      Schlⁿssel, und der Inhalt der Variablen als Wert gespeichert
  52477.      wird. Kurz, diese Funktion tut das Gegenteil von
  52478.      <A
  52479. HREF="#function.extract"
  52480. ><B
  52481. CLASS="function"
  52482. >extract()</B
  52483. ></A
  52484. >. Sie gibt ein Array mit allen
  52485.      Variablen zurⁿck.
  52486.     </P
  52487. ><P
  52488. >      Strings, welche nicht gesetzt sind, werden einfach ignoriert.
  52489.     </P
  52490. ><P
  52491. >      <TABLE
  52492. WIDTH="100%"
  52493. BORDER="0"
  52494. CELLPADDING="0"
  52495. CELLSPACING="0"
  52496. CLASS="EXAMPLE"
  52497. ><TR
  52498. ><TD
  52499. ><DIV
  52500. CLASS="example"
  52501. ><A
  52502. NAME="AEN9322"
  52503. ></A
  52504. ><P
  52505. ><B
  52506. >Beispiel 1. <B
  52507. CLASS="function"
  52508. >compact()</B
  52509. ></B
  52510. ></P
  52511. ><TABLE
  52512. BORDER="0"
  52513. BGCOLOR="#E0E0E0"
  52514. CELLPADDING="5"
  52515. ><TR
  52516. ><TD
  52517. ><PRE
  52518. CLASS="php"
  52519. ><?php
  52520. $city = "San Francisco";
  52521. $state = "CA";
  52522. $event = "SIGGRAPH";
  52523.  
  52524. $location_vars = array ("city", "state");
  52525.  
  52526. $result = compact ("event", "nothing_here", $location_vars);
  52527. ?></PRE
  52528. ></TD
  52529. ></TR
  52530. ></TABLE
  52531. ><P
  52532. >        Danach wird <VAR
  52533. CLASS="varname"
  52534. >$result</VAR
  52535. >:
  52536.       </P
  52537. ><TABLE
  52538. BORDER="0"
  52539. BGCOLOR="#E0E0E0"
  52540. CELLPADDING="5"
  52541. ><TR
  52542. ><TD
  52543. ><PRE
  52544. CLASS="php"
  52545. >Array
  52546. (
  52547.     [event] => SIGGRAPH
  52548.     [city] => San Francisco
  52549.     [state] => CA
  52550. )</PRE
  52551. ></TD
  52552. ></TR
  52553. ></TABLE
  52554. ></DIV
  52555. ></TD
  52556. ></TR
  52557. ></TABLE
  52558. >
  52559.     </P
  52560. ><P
  52561. >      Siehe auch <A
  52562. HREF="#function.extract"
  52563. ><B
  52564. CLASS="function"
  52565. >extract()</B
  52566. ></A
  52567. >.
  52568.     </P
  52569. ></DIV
  52570. ><H1
  52571. ><A
  52572. NAME="function.count"
  52573. ></A
  52574. >count</H1
  52575. ><DIV
  52576. CLASS="refnamediv"
  52577. ><A
  52578. NAME="AEN9332"
  52579. ></A
  52580. ><P
  52581. >    (PHP 3, PHP 4 , PHP 5)</P
  52582. >count -- ZΣhlt die Elemente einer Variable</DIV
  52583. ><DIV
  52584. CLASS="refsect1"
  52585. ><A
  52586. NAME="AEN9335"
  52587. ></A
  52588. ><H2
  52589. >Beschreibung</H2
  52590. >int <B
  52591. CLASS="methodname"
  52592. >count</B
  52593. > ( mixed var)<BR
  52594. ></BR
  52595. ><P
  52596. >      Liefert die Anzahl von Elementen in <VAR
  52597. CLASS="parameter"
  52598. >var</VAR
  52599. >,
  52600.      welche typischerweise ein Array ist (da alles andere
  52601.      ein Element enthΣlt).
  52602.     </P
  52603. ><P
  52604. >      Ist <VAR
  52605. CLASS="parameter"
  52606. >var</VAR
  52607. > kein Array, wird <VAR
  52608. CLASS="literal"
  52609. >1</VAR
  52610. >
  52611.      zurⁿckgegeben (Ausnahme: <VAR
  52612. CLASS="literal"
  52613. >count(<TT
  52614. CLASS="constant"
  52615. ><B
  52616. >NULL</B
  52617. ></TT
  52618. >)</VAR
  52619. > ist gleich
  52620.      <VAR
  52621. CLASS="literal"
  52622. >0</VAR
  52623. >).
  52624.     </P
  52625. ><DIV
  52626. CLASS="warning"
  52627. ><P
  52628. ></P
  52629. ><TABLE
  52630. CLASS="warning"
  52631. BORDER="1"
  52632. WIDTH="100%"
  52633. ><TR
  52634. ><TD
  52635. ALIGN="CENTER"
  52636. ><B
  52637. >Warnung</B
  52638. ></TD
  52639. ></TR
  52640. ><TR
  52641. ><TD
  52642. ALIGN="LEFT"
  52643. ><P
  52644. >       <B
  52645. CLASS="function"
  52646. >count()</B
  52647. > kann 0 zurⁿckgeben wenn die Variable
  52648.       nicht gesetzt ist, aber sie k÷nnte ebenfalls 0 zurⁿckgeben, wenn
  52649.       eine Variable als leeres Array initialisiert wurde. Verwenden Sie
  52650.       <A
  52651. HREF="#function.isset"
  52652. ><B
  52653. CLASS="function"
  52654. >isset()</B
  52655. ></A
  52656. > um zu testen, ob eine Variable gesetzt
  52657.       ist.
  52658.      </P
  52659. ></TD
  52660. ></TR
  52661. ></TABLE
  52662. ></DIV
  52663. ><P
  52664. >      In der Sektion <A
  52665. HREF="#language.types.array"
  52666. >Arrays</A
  52667. >
  52668.      finden Sie eine detaillierte ErklΣrung, wie Arrays in PHP
  52669.      implementiert sind und wie sie benutzt werden.
  52670.     </P
  52671. ><P
  52672. >      <TABLE
  52673. WIDTH="100%"
  52674. BORDER="0"
  52675. CELLPADDING="0"
  52676. CELLSPACING="0"
  52677. CLASS="EXAMPLE"
  52678. ><TR
  52679. ><TD
  52680. ><DIV
  52681. CLASS="example"
  52682. ><A
  52683. NAME="AEN9359"
  52684. ></A
  52685. ><P
  52686. ><B
  52687. >Beispiel 1. <B
  52688. CLASS="function"
  52689. >count()</B
  52690. ></B
  52691. ></P
  52692. ><TABLE
  52693. BORDER="0"
  52694. BGCOLOR="#E0E0E0"
  52695. CELLPADDING="5"
  52696. ><TR
  52697. ><TD
  52698. ><PRE
  52699. CLASS="php"
  52700. ><?php
  52701. $a[0] = 1;
  52702. $a[1] = 3;
  52703. $a[2] = 5;
  52704. $result = count ($a);
  52705. //$result == 3
  52706.  
  52707. $b[0] = 7;
  52708. $b[5] = 9;
  52709. $b[10] = 11;
  52710. $result = count ($b);
  52711. // $result == 3;
  52712. ?></PRE
  52713. ></TD
  52714. ></TR
  52715. ></TABLE
  52716. ></DIV
  52717. ></TD
  52718. ></TR
  52719. ></TABLE
  52720. >
  52721.     </P
  52722. ><DIV
  52723. CLASS="note"
  52724. ><BLOCKQUOTE
  52725. CLASS="note"
  52726. ><P
  52727. ><B
  52728. >Anmerkung: </B
  52729. >
  52730.      Die Funktion <A
  52731. HREF="#function.sizeof"
  52732. ><B
  52733. CLASS="function"
  52734. >sizeof()</B
  52735. ></A
  52736. > ist ein
  52737.      <A
  52738. HREF="#aliases"
  52739. >Alias</A
  52740. > fⁿr <B
  52741. CLASS="function"
  52742. >count()</B
  52743. >.
  52744.      </P
  52745. ></BLOCKQUOTE
  52746. ></DIV
  52747. ><P
  52748. >      Siehe auch <A
  52749. HREF="#function.is-array"
  52750. ><B
  52751. CLASS="function"
  52752. >is_array()</B
  52753. ></A
  52754. >,
  52755.      <A
  52756. HREF="#function.isset"
  52757. ><B
  52758. CLASS="function"
  52759. >isset()</B
  52760. ></A
  52761. > und
  52762.      <A
  52763. HREF="#function.strlen"
  52764. ><B
  52765. CLASS="function"
  52766. >strlen()</B
  52767. ></A
  52768. >.
  52769.     </P
  52770. ></DIV
  52771. ><H1
  52772. ><A
  52773. NAME="function.current"
  52774. ></A
  52775. >current</H1
  52776. ><DIV
  52777. CLASS="refnamediv"
  52778. ><A
  52779. NAME="AEN9373"
  52780. ></A
  52781. ><P
  52782. >    (PHP 3, PHP 4 , PHP 5)</P
  52783. >current -- Liefert das aktuelle Element eines Arrays</DIV
  52784. ><DIV
  52785. CLASS="refsect1"
  52786. ><A
  52787. NAME="AEN9376"
  52788. ></A
  52789. ><H2
  52790. >Beschreibung</H2
  52791. >mixed <B
  52792. CLASS="methodname"
  52793. >current</B
  52794. > ( array array)<BR
  52795. ></BR
  52796. ><P
  52797. >      Jedes Array hat einen internen Zeiger auf sein "aktuelles"
  52798.      Element, welcher auf das erste in das Array eingefⁿgte Element
  52799.      initialisiert wird.
  52800.     </P
  52801. ><P
  52802. >      Die Funktion <B
  52803. CLASS="function"
  52804. >current()</B
  52805. > liefert das Array
  52806.      Element, auf das gerade vom internen Zeiger gezeigt wird. Sie
  52807.      bewegt den Zeiger in keinster Weise. Zeigt der interne Zeiger
  52808.      hinter das Ende der Elementenliste, gibt
  52809.      <B
  52810. CLASS="function"
  52811. >current()</B
  52812. > <TT
  52813. CLASS="constant"
  52814. ><B
  52815. >FALSE</B
  52816. ></TT
  52817. > zurⁿck.
  52818.      <DIV
  52819. CLASS="warning"
  52820. ><P
  52821. ></P
  52822. ><TABLE
  52823. CLASS="warning"
  52824. BORDER="1"
  52825. WIDTH="100%"
  52826. ><TR
  52827. ><TD
  52828. ALIGN="CENTER"
  52829. ><B
  52830. >Warnung</B
  52831. ></TD
  52832. ></TR
  52833. ><TR
  52834. ><TD
  52835. ALIGN="LEFT"
  52836. ><P
  52837. >        EnthΣlt das Array leere Elemente (0 oder "", den leeren
  52838.        String), gibt diese Funktion auch fⁿr diese Elemente <TT
  52839. CLASS="constant"
  52840. ><B
  52841. >FALSE</B
  52842. ></TT
  52843. >
  52844.        zurⁿck. Das macht es unm÷glich, unter Verwendung von
  52845.        <B
  52846. CLASS="function"
  52847. >current()</B
  52848. > herauszufinden, ob das wirklich am
  52849.        Ende der Liste sind. Um ein Array, das leere Elemente enthalten
  52850.        k÷nnte richtig durchzugehen, verwenden Sie die Funktion
  52851.        <A
  52852. HREF="#function.each"
  52853. ><B
  52854. CLASS="function"
  52855. >each()</B
  52856. ></A
  52857. >.
  52858.       </P
  52859. ></TD
  52860. ></TR
  52861. ></TABLE
  52862. ></DIV
  52863. >
  52864.     </P
  52865. ><P
  52866. >      Siehe auch <A
  52867. HREF="#function.end"
  52868. ><B
  52869. CLASS="function"
  52870. >end()</B
  52871. ></A
  52872. >, <A
  52873. HREF="#function.key"
  52874. ><B
  52875. CLASS="function"
  52876. >key()</B
  52877. ></A
  52878. >,
  52879.      <A
  52880. HREF="#function.next"
  52881. ><B
  52882. CLASS="function"
  52883. >next()</B
  52884. ></A
  52885. >, <A
  52886. HREF="#function.prev"
  52887. ><B
  52888. CLASS="function"
  52889. >prev()</B
  52890. ></A
  52891. > und
  52892.      <A
  52893. HREF="#function.reset"
  52894. ><B
  52895. CLASS="function"
  52896. >reset()</B
  52897. ></A
  52898. >.
  52899.     </P
  52900. ></DIV
  52901. ><H1
  52902. ><A
  52903. NAME="function.each"
  52904. ></A
  52905. >each</H1
  52906. ><DIV
  52907. CLASS="refnamediv"
  52908. ><A
  52909. NAME="AEN9401"
  52910. ></A
  52911. ><P
  52912. >    (PHP 3, PHP 4 , PHP 5)</P
  52913. >each -- 
  52914.      Liefert das aktuelle Paar (Schlⁿssel und Wert) eines Arrays und
  52915.      rⁿckt den Array Cursor vor.
  52916.     </DIV
  52917. ><DIV
  52918. CLASS="refsect1"
  52919. ><A
  52920. NAME="AEN9404"
  52921. ></A
  52922. ><H2
  52923. >Beschreibung</H2
  52924. >array <B
  52925. CLASS="methodname"
  52926. >each</B
  52927. > ( array array)<BR
  52928. ></BR
  52929. ><P
  52930. >      Liefert das aktuelle Schlⁿssel- Wertepaar des Arrays
  52931.      <VAR
  52932. CLASS="parameter"
  52933. >array</VAR
  52934. >, und erh÷ht den Array Cursor. Dieses
  52935.      Paar wird als Array mit 4 Elementen zurⁿckgegeben, und zwar mit
  52936.      den Schlⁿsseln <SPAN
  52937. CLASS="emphasis"
  52938. ><I
  52939. CLASS="emphasis"
  52940. >0</I
  52941. ></SPAN
  52942. >, <SPAN
  52943. CLASS="emphasis"
  52944. ><I
  52945. CLASS="emphasis"
  52946. >1</I
  52947. ></SPAN
  52948. >,
  52949.      <SPAN
  52950. CLASS="emphasis"
  52951. ><I
  52952. CLASS="emphasis"
  52953. >key</I
  52954. ></SPAN
  52955. >, und <SPAN
  52956. CLASS="emphasis"
  52957. ><I
  52958. CLASS="emphasis"
  52959. >value</I
  52960. ></SPAN
  52961. >. Die
  52962.      Elemente <SPAN
  52963. CLASS="emphasis"
  52964. ><I
  52965. CLASS="emphasis"
  52966. >0</I
  52967. ></SPAN
  52968. > und <SPAN
  52969. CLASS="emphasis"
  52970. ><I
  52971. CLASS="emphasis"
  52972. >key</I
  52973. ></SPAN
  52974. >
  52975.      enthalten den Namen des Schlⁿssels, <SPAN
  52976. CLASS="emphasis"
  52977. ><I
  52978. CLASS="emphasis"
  52979. >1</I
  52980. ></SPAN
  52981. > und
  52982.      <SPAN
  52983. CLASS="emphasis"
  52984. ><I
  52985. CLASS="emphasis"
  52986. >value</I
  52987. ></SPAN
  52988. > den Wert.
  52989.     </P
  52990. ><P
  52991. >      Zeigt der interne Zeiger hinter das Ende der Array-Inhalte, gibt
  52992.      <B
  52993. CLASS="function"
  52994. >each()</B
  52995. > <TT
  52996. CLASS="constant"
  52997. ><B
  52998. >FALSE</B
  52999. ></TT
  53000. > zurⁿck.
  53001.     </P
  53002. ><P
  53003. >      <TABLE
  53004. WIDTH="100%"
  53005. BORDER="0"
  53006. CELLPADDING="0"
  53007. CELLSPACING="0"
  53008. CLASS="EXAMPLE"
  53009. ><TR
  53010. ><TD
  53011. ><DIV
  53012. CLASS="example"
  53013. ><A
  53014. NAME="AEN9426"
  53015. ></A
  53016. ><P
  53017. ><B
  53018. >Beispiel 1. <B
  53019. CLASS="function"
  53020. >each()</B
  53021. > Beispiele</B
  53022. ></P
  53023. ><TABLE
  53024. BORDER="0"
  53025. BGCOLOR="#E0E0E0"
  53026. CELLPADDING="5"
  53027. ><TR
  53028. ><TD
  53029. ><PRE
  53030. CLASS="php"
  53031. ><?php
  53032. $foo = array ("bob", "fred", "jussi", "jouni", "egon", "marliese");
  53033. $bar = each ($foo);
  53034. print_r($bar);
  53035. ?></PRE
  53036. ></TD
  53037. ></TR
  53038. ></TABLE
  53039. ><P
  53040. >        <VAR
  53041. CLASS="varname"
  53042. >$bar</VAR
  53043. > enthΣlt nun die folgenden Schlⁿssel/Wert
  53044.        Paare:
  53045.       </P
  53046. ><TABLE
  53047. BORDER="0"
  53048. BGCOLOR="#E0E0E0"
  53049. CELLPADDING="5"
  53050. ><TR
  53051. ><TD
  53052. ><PRE
  53053. CLASS="screen"
  53054. >Array
  53055. (
  53056.     [1] => bob
  53057.     [value] => bob
  53058.     [0] => 0
  53059.     [key] => 0
  53060. )</PRE
  53061. ></TD
  53062. ></TR
  53063. ></TABLE
  53064. ></DIV
  53065. ></TD
  53066. ></TR
  53067. ></TABLE
  53068. >
  53069.     </P
  53070. ><P
  53071. >      <DIV
  53072. CLASS="informalexample"
  53073. ><P
  53074. ></P
  53075. ><A
  53076. NAME="AEN9434"
  53077. ></A
  53078. ><TABLE
  53079. BORDER="0"
  53080. BGCOLOR="#E0E0E0"
  53081. CELLPADDING="5"
  53082. ><TR
  53083. ><TD
  53084. ><PRE
  53085. CLASS="php"
  53086. ><?php
  53087. $foo = array ("Robert" => "Bob", "Seppo" => "Sepi");
  53088. $bar = each ($foo);
  53089. print_r($bar);
  53090. ?></PRE
  53091. ></TD
  53092. ></TR
  53093. ></TABLE
  53094. ><P
  53095. >        <VAR
  53096. CLASS="varname"
  53097. >$bar</VAR
  53098. > enthΣlt nun die folgenden Schlⁿssel/Wert
  53099.        Paare:
  53100.       </P
  53101. ><TABLE
  53102. BORDER="0"
  53103. BGCOLOR="#E0E0E0"
  53104. CELLPADDING="5"
  53105. ><TR
  53106. ><TD
  53107. ><PRE
  53108. CLASS="screen"
  53109. >Array
  53110. (
  53111.     [1] => Bob
  53112.     [value] => Bob
  53113.     [0] => Robert
  53114.     [key] => Robert
  53115. )</PRE
  53116. ></TD
  53117. ></TR
  53118. ></TABLE
  53119. ><P
  53120. ></P
  53121. ></DIV
  53122. >
  53123.     </P
  53124. ><P
  53125. >      <B
  53126. CLASS="function"
  53127. >each()</B
  53128. > wird typischerweise in Verbindung mit
  53129.      <A
  53130. HREF="#function.list"
  53131. ><B
  53132. CLASS="function"
  53133. >list()</B
  53134. ></A
  53135. > verwendet, um ein Array durchzugehen:
  53136.      <TABLE
  53137. WIDTH="100%"
  53138. BORDER="0"
  53139. CELLPADDING="0"
  53140. CELLSPACING="0"
  53141. CLASS="EXAMPLE"
  53142. ><TR
  53143. ><TD
  53144. ><DIV
  53145. CLASS="example"
  53146. ><A
  53147. NAME="AEN9442"
  53148. ></A
  53149. ><P
  53150. ><B
  53151. >Beispiel 2. Durchgehen eines Arrays mit <B
  53152. CLASS="function"
  53153. >each()</B
  53154. ></B
  53155. ></P
  53156. ><TABLE
  53157. BORDER="0"
  53158. BGCOLOR="#E0E0E0"
  53159. CELLPADDING="5"
  53160. ><TR
  53161. ><TD
  53162. ><PRE
  53163. CLASS="php"
  53164. ><?php
  53165. $fruit = array('a' => 'Apfel', 'b' => 'Banane', 'c' => 'Preiselbeere');
  53166.  
  53167. reset ($fruit);
  53168. while (list ($key, $val) = each ($fruit)) {
  53169.     echo "$key => $val\n";
  53170. }
  53171.  
  53172. /* Ausgabe:
  53173.  
  53174. a => Apfel
  53175. b => Banane
  53176. c => Preiselbeere
  53177.  
  53178. */
  53179. ?></PRE
  53180. ></TD
  53181. ></TR
  53182. ></TABLE
  53183. ></DIV
  53184. ></TD
  53185. ></TR
  53186. ></TABLE
  53187. >
  53188.     </P
  53189. ><P
  53190. >      Nachdem <B
  53191. CLASS="function"
  53192. >each()</B
  53193. > ausgefⁿhrt wurde, bleibt der
  53194.      Array Cursor beim nΣchsten Element des Arrays, oder wenn am Ende
  53195.      des Arrays angelangt, nach dem letzten Element. Sie mⁿssen
  53196.      <A
  53197. HREF="#function.reset"
  53198. ><B
  53199. CLASS="function"
  53200. >reset()</B
  53201. ></A
  53202. > verwenden, wenn Sie das Array erneut
  53203.      mittels each durchgehen wollen.
  53204.     </P
  53205. ><DIV
  53206. CLASS="caution"
  53207. ><P
  53208. ></P
  53209. ><TABLE
  53210. CLASS="caution"
  53211. BORDER="1"
  53212. WIDTH="100%"
  53213. ><TR
  53214. ><TD
  53215. ALIGN="CENTER"
  53216. ><B
  53217. >Achtung</B
  53218. ></TD
  53219. ></TR
  53220. ><TR
  53221. ><TD
  53222. ALIGN="LEFT"
  53223. ><P
  53224. >       Da die Zuweisung eines Arrays zu einer anderen Variable den originalen
  53225.       Arrayzeiger zurⁿcksetzt, wⁿrde unser obiges Beispiel in eine Endlosschleife
  53226.       geraten, hΣtten wir <VAR
  53227. CLASS="varname"
  53228. >$fruit</VAR
  53229. > innerhalb der Schleife
  53230.       einer anderen Variable zugeordnet.
  53231.      </P
  53232. ></TD
  53233. ></TR
  53234. ></TABLE
  53235. ></DIV
  53236. ><P
  53237. >      Siehe auch <A
  53238. HREF="#function.key"
  53239. ><B
  53240. CLASS="function"
  53241. >key()</B
  53242. ></A
  53243. >, <A
  53244. HREF="#function.list"
  53245. ><B
  53246. CLASS="function"
  53247. >list()</B
  53248. ></A
  53249. >,
  53250.      <A
  53251. HREF="#function.current"
  53252. ><B
  53253. CLASS="function"
  53254. >current()</B
  53255. ></A
  53256. >, <A
  53257. HREF="#function.reset"
  53258. ><B
  53259. CLASS="function"
  53260. >reset()</B
  53261. ></A
  53262. >,
  53263.      <A
  53264. HREF="#function.next"
  53265. ><B
  53266. CLASS="function"
  53267. >next()</B
  53268. ></A
  53269. >, <A
  53270. HREF="#function.prev"
  53271. ><B
  53272. CLASS="function"
  53273. >prev()</B
  53274. ></A
  53275. > und
  53276.      <A
  53277. HREF="#control-structures.foreach"
  53278. >foreach</A
  53279. >.
  53280.     </P
  53281. ></DIV
  53282. ><H1
  53283. ><A
  53284. NAME="function.end"
  53285. ></A
  53286. >end</H1
  53287. ><DIV
  53288. CLASS="refnamediv"
  53289. ><A
  53290. NAME="AEN9461"
  53291. ></A
  53292. ><P
  53293. >    (PHP 3, PHP 4 , PHP 5)</P
  53294. >end -- 
  53295.      Positioniert den internen Zeiger eines Arrays auf dessen letztes Element
  53296.     </DIV
  53297. ><DIV
  53298. CLASS="refsect1"
  53299. ><A
  53300. NAME="AEN9464"
  53301. ></A
  53302. ><H2
  53303. >Beschreibung</H2
  53304. >mixed <B
  53305. CLASS="methodname"
  53306. >end</B
  53307. > ( array array)<BR
  53308. ></BR
  53309. ><P
  53310. >      <B
  53311. CLASS="function"
  53312. >end()</B
  53313. > rⁿckt den internen Zeiger von
  53314.      <VAR
  53315. CLASS="parameter"
  53316. >array</VAR
  53317. > bis zum letzten Element vor, und gibt
  53318.      dieses Element zurⁿck.
  53319.     </P
  53320. ><P
  53321. >      <TABLE
  53322. WIDTH="100%"
  53323. BORDER="0"
  53324. CELLPADDING="0"
  53325. CELLSPACING="0"
  53326. CLASS="EXAMPLE"
  53327. ><TR
  53328. ><TD
  53329. ><DIV
  53330. CLASS="example"
  53331. ><A
  53332. NAME="AEN9476"
  53333. ></A
  53334. ><P
  53335. ><B
  53336. >Beispiel 1. Ein einfaches <B
  53337. CLASS="function"
  53338. >end()</B
  53339. > Beispiel</B
  53340. ></P
  53341. ><TABLE
  53342. BORDER="0"
  53343. BGCOLOR="#E0E0E0"
  53344. CELLPADDING="5"
  53345. ><TR
  53346. ><TD
  53347. ><PRE
  53348. CLASS="php"
  53349. ><?php
  53350.  
  53351.   $fruits = array('apple','banana','cranberry');
  53352.     
  53353.   print end($fruits); // cranberry
  53354.       
  53355. ?></PRE
  53356. ></TD
  53357. ></TR
  53358. ></TABLE
  53359. ></DIV
  53360. ></TD
  53361. ></TR
  53362. ></TABLE
  53363. >
  53364.     </P
  53365. ><P
  53366. >      Siehe auch <A
  53367. HREF="#function.current"
  53368. ><B
  53369. CLASS="function"
  53370. >current()</B
  53371. ></A
  53372. >,
  53373.      <A
  53374. HREF="#function.each"
  53375. ><B
  53376. CLASS="function"
  53377. >each()</B
  53378. ></A
  53379. >,
  53380.      <A
  53381. HREF="#function.next"
  53382. ><B
  53383. CLASS="function"
  53384. >next()</B
  53385. ></A
  53386. > und <A
  53387. HREF="#function.reset"
  53388. ><B
  53389. CLASS="function"
  53390. >reset()</B
  53391. ></A
  53392. >.
  53393.     </P
  53394. ></DIV
  53395. ><H1
  53396. ><A
  53397. NAME="function.extract"
  53398. ></A
  53399. >extract</H1
  53400. ><DIV
  53401. CLASS="refnamediv"
  53402. ><A
  53403. NAME="AEN9486"
  53404. ></A
  53405. ><P
  53406. >    (PHP 3>= 3.0.7, PHP 4 , PHP 5)</P
  53407. >extract -- 
  53408.      Importiert Variablen eines Arrays in die aktuelle Symboltabelle 
  53409.     </DIV
  53410. ><DIV
  53411. CLASS="refsect1"
  53412. ><A
  53413. NAME="AEN9489"
  53414. ></A
  53415. ><H2
  53416. >Beschreibung</H2
  53417. >int <B
  53418. CLASS="methodname"
  53419. >extract</B
  53420. > ( array var_array [, int extract_type [, string prefix]])<BR
  53421. ></BR
  53422. ><P
  53423. >      Diese Funktion wird verwendet, um Variablen eines Arrays in die
  53424.      aktuelle Symboltabelle zu importieren. Es behandelt die Schlⁿssel
  53425.      des assoziativen Arrays <VAR
  53426. CLASS="parameter"
  53427. >var_array</VAR
  53428. > als
  53429.      Variablennamen, und die Werte als Variablenwerte. Fⁿr jedes Paar
  53430.      Schlⁿssel/Wert wird - abhΣngig von den Parametern
  53431.      <VAR
  53432. CLASS="parameter"
  53433. >extract_type</VAR
  53434. > und
  53435.      <VAR
  53436. CLASS="parameter"
  53437. >prefix</VAR
  53438. > - eine Variable in der aktuellen
  53439.      Symboltabelle eingetragen.
  53440.     </P
  53441. ><DIV
  53442. CLASS="note"
  53443. ><BLOCKQUOTE
  53444. CLASS="note"
  53445. ><P
  53446. ><B
  53447. >Anmerkung: </B
  53448. >
  53449.       Seit Version 4.0.5 gibt diese Funktion die Anzahl der
  53450.       extrahierten Variablen zurⁿck.
  53451.      </P
  53452. ></BLOCKQUOTE
  53453. ></DIV
  53454. ><DIV
  53455. CLASS="note"
  53456. ><BLOCKQUOTE
  53457. CLASS="note"
  53458. ><P
  53459. ><B
  53460. >Anmerkung: </B
  53461. >
  53462.       <TT
  53463. CLASS="constant"
  53464. ><B
  53465. >EXTR_IF_EXISTS</B
  53466. ></TT
  53467. > und <TT
  53468. CLASS="constant"
  53469. ><B
  53470. >EXTR_PREFIX_IF_EXISTS</B
  53471. ></TT
  53472. >
  53473.       wurden in Version 4.2.0. eingefⁿhrt.
  53474.      </P
  53475. ></BLOCKQUOTE
  53476. ></DIV
  53477. ><DIV
  53478. CLASS="note"
  53479. ><BLOCKQUOTE
  53480. CLASS="note"
  53481. ><P
  53482. ><B
  53483. >Anmerkung: </B
  53484. >
  53485.       <TT
  53486. CLASS="constant"
  53487. ><B
  53488. >EXTR_REFS</B
  53489. ></TT
  53490. > wurde in Version 4.3.0 eingefⁿhrt.
  53491.      </P
  53492. ></BLOCKQUOTE
  53493. ></DIV
  53494. ><P
  53495. >      <B
  53496. CLASS="function"
  53497. >extract()</B
  53498. > prⁿft jeden Schlⁿssel, ob dieser
  53499.      einen gⁿltigen Variablennamen ergibt, und auch auf eventuelle
  53500.      Kollisionen mit existierenden Variablen in der Symboltabelle. Die
  53501.      Art, wie ungⁿltige/numerische Schlⁿssel und Kollisionen behandelt
  53502.      werden, wird mit <VAR
  53503. CLASS="parameter"
  53504. >extract_type</VAR
  53505. >
  53506.      spezifiziert. Es kann einen der folgenden Werte annehmen:
  53507.      <P
  53508. ></P
  53509. ><DIV
  53510. CLASS="variablelist"
  53511. ><DL
  53512. ><DT
  53513. ><TT
  53514. CLASS="constant"
  53515. ><B
  53516. >EXTR_OVERWRITE</B
  53517. ></TT
  53518. ></DT
  53519. ><DD
  53520. ><P
  53521. >          Im Falle einer Kollision wird die existierende Variable
  53522.          ⁿberschrieben.
  53523.         </P
  53524. ></DD
  53525. ><DT
  53526. ><TT
  53527. CLASS="constant"
  53528. ><B
  53529. >EXTR_SKIP</B
  53530. ></TT
  53531. ></DT
  53532. ><DD
  53533. ><P
  53534. >          Im Falle einer Kollision wird die existierende Variable
  53535.          nicht ⁿberschrieben.
  53536.         </P
  53537. ></DD
  53538. ><DT
  53539. ><TT
  53540. CLASS="constant"
  53541. ><B
  53542. >EXTR_PREFIX_SAME</B
  53543. ></TT
  53544. ></DT
  53545. ><DD
  53546. ><P
  53547. >Im Falle einer Kollision wird dem Variablennamen
  53548.         <VAR
  53549. CLASS="parameter"
  53550. >prefix</VAR
  53551. > vorangestellt.
  53552.         </P
  53553. ></DD
  53554. ><DT
  53555. ><TT
  53556. CLASS="constant"
  53557. ><B
  53558. >EXTR_PREFIX_ALL</B
  53559. ></TT
  53560. ></DT
  53561. ><DD
  53562. ><P
  53563. >          Allen Variablennamen wird <VAR
  53564. CLASS="parameter"
  53565. >prefix</VAR
  53566. >
  53567.          vorangestellt. Seit PHP 4.0.5 gilt dies auch fⁿr numerische
  53568.          Variablen.
  53569.         </P
  53570. ></DD
  53571. ><DT
  53572. ><TT
  53573. CLASS="constant"
  53574. ><B
  53575. >EXTR_PREFIX_INVALID</B
  53576. ></TT
  53577. ></DT
  53578. ><DD
  53579. ><P
  53580. >          Nur ungⁿltigen/numerischen Variablennamen wird
  53581.          <VAR
  53582. CLASS="parameter"
  53583. >prefix</VAR
  53584. > vorangestellt. Dieser Flag
  53585.          wurde mit PHP 4.0.5 eingefⁿhrt.
  53586.         </P
  53587. ></DD
  53588. ><DT
  53589. ><TT
  53590. CLASS="constant"
  53591. ><B
  53592. >EXTR_IF_EXISTS</B
  53593. ></TT
  53594. ></DT
  53595. ><DD
  53596. ><P
  53597. >          ▄berschreibt die Variable nur, wenn sie bereits in der aktuellen
  53598.          Symboltabelle existiert, sonst geschieht nichts. Dies ist dann
  53599.          hilfreich, wenn Sie eine Liste mit gⁿltigen Variablen definieren,
  53600.          und dann z.B. nur jene Variablen extrahieren, welche Sie aus
  53601.          $_REQUEST definiert haben. Dieser Flag wurde in PHP 4.2.0
  53602.          eingefⁿhrt.
  53603.         </P
  53604. ></DD
  53605. ><DT
  53606. ><TT
  53607. CLASS="constant"
  53608. ><B
  53609. >EXTR_PREFIX_IF_EXISTS</B
  53610. ></TT
  53611. ></DT
  53612. ><DD
  53613. ><P
  53614. >          Erstellt nur Variablennamen mit PrΣfix, wenn die Version ohne
  53615.          PrΣfix der selben Variable in der aktuellen Symboltabelle
  53616.          existiert. Dieser Flag wurde in PHP 4.2.0 eingefⁿhrt.
  53617.         </P
  53618. ></DD
  53619. ><DT
  53620. ><TT
  53621. CLASS="constant"
  53622. ><B
  53623. >EXTR_REFS</B
  53624. ></TT
  53625. ></DT
  53626. ><DD
  53627. ><P
  53628. >          Extrahiert Variablen als Referenzen. Das hei▀t, dass die Werte der
  53629.          importierten Variablen noch immer auf die Werte des Parameters
  53630.          <VAR
  53631. CLASS="parameter"
  53632. >var_array</VAR
  53633. > referenzieren. Sie k÷nnen diesen
  53634.          Flag alleine oder auch in Kombination mit einem anderen Flag verwenden,
  53635.          indem Sie Oder-Verknⁿpfungen im <VAR
  53636. CLASS="parameter"
  53637. >extract_type</VAR
  53638. >
  53639.          erstellen. Dieser Flag wurde in PHP 4.3.0 eingefⁿhrt.
  53640.         </P
  53641. ></DD
  53642. ></DL
  53643. ></DIV
  53644. >
  53645.     </P
  53646. ><P
  53647. >      Ist <VAR
  53648. CLASS="parameter"
  53649. >extract_type</VAR
  53650. > nicht spezifiziert, so wird
  53651.      <TT
  53652. CLASS="constant"
  53653. ><B
  53654. >EXTR_OVERWRITE</B
  53655. ></TT
  53656. > angenommen.
  53657.     </P
  53658. ><P
  53659. >      Beachten Sie, dass <VAR
  53660. CLASS="parameter"
  53661. >prefix</VAR
  53662. > nur dann n÷tig ist,
  53663.      wenn <VAR
  53664. CLASS="parameter"
  53665. >extract_type</VAR
  53666. > <TT
  53667. CLASS="constant"
  53668. ><B
  53669. >EXTR_PREFIX_SAME</B
  53670. ></TT
  53671. >,
  53672.      <TT
  53673. CLASS="constant"
  53674. ><B
  53675. >EXTR_PREFIX_ALL</B
  53676. ></TT
  53677. >, <TT
  53678. CLASS="constant"
  53679. ><B
  53680. >EXTR_PREFIX_INVALID</B
  53681. ></TT
  53682.      or <TT
  53683. CLASS="constant"
  53684. ><B
  53685. >EXTR_PREFIX_IF_EXISTS</B
  53686. ></TT
  53687. > ist. Ist das Resultat trotz
  53688.      PrΣfix kein gⁿltiger Variablenname, wird es nicht in die Symboltabelle
  53689.      importiert.
  53690.     </P
  53691. ><P
  53692. >      <B
  53693. CLASS="function"
  53694. >extract()</B
  53695. > gibt die Anzahl erfolgreich in die
  53696.      Symboltabelle importierter Variablen zurⁿck.
  53697.     </P
  53698. ><P
  53699. >      Eine m÷gliche Verwendung fⁿr <B
  53700. CLASS="function"
  53701. >extract()</B
  53702. > ist der Import
  53703.      der Variablen in einem von <A
  53704. HREF="#function.wddx-deserialize"
  53705. ><B
  53706. CLASS="function"
  53707. >wddx_deserialize()</B
  53708. ></A
  53709. > gelieferten
  53710.      assoziativen Array in die Symboltabelle.
  53711.     </P
  53712. ><P
  53713. >      <TABLE
  53714. WIDTH="100%"
  53715. BORDER="0"
  53716. CELLPADDING="0"
  53717. CELLSPACING="0"
  53718. CLASS="EXAMPLE"
  53719. ><TR
  53720. ><TD
  53721. ><DIV
  53722. CLASS="example"
  53723. ><A
  53724. NAME="AEN9581"
  53725. ></A
  53726. ><P
  53727. ><B
  53728. >Beispiel 1. <B
  53729. CLASS="function"
  53730. >extract()</B
  53731. ></B
  53732. ></P
  53733. ><TABLE
  53734. BORDER="0"
  53735. BGCOLOR="#E0E0E0"
  53736. CELLPADDING="5"
  53737. ><TR
  53738. ><TD
  53739. ><PRE
  53740. CLASS="php"
  53741. ><?php
  53742.  
  53743. /* Annahme: $var_array ist ein von wddx_deserialize
  53744.    zurⁿckgegebenes Array */
  53745.  
  53746. $groesse = "gro▀";
  53747. $var_array = array ("farbe"   => "blau",
  53748.                     "groesse" => "mittel",
  53749.                     "form"    => "Kugel");
  53750. extract ($var_array, EXTR_PREFIX_SAME, "wddx");
  53751.  
  53752. print "$farbe, $groesse, $form, $wddx_groesse\n";
  53753.  
  53754. ?></PRE
  53755. ></TD
  53756. ></TR
  53757. ></TABLE
  53758. ><P
  53759. >        Das obige Beispiel wird folgendes ausgeben:
  53760.       </P
  53761. ><TABLE
  53762. BORDER="0"
  53763. BGCOLOR="#E0E0E0"
  53764. CELLPADDING="5"
  53765. ><TR
  53766. ><TD
  53767. ><PRE
  53768. CLASS="programlisting"
  53769. >blau, gro▀, Kugel, mittel</PRE
  53770. ></TD
  53771. ></TR
  53772. ></TABLE
  53773. ></DIV
  53774. ></TD
  53775. ></TR
  53776. ></TABLE
  53777. >
  53778.     </P
  53779. ><P
  53780. >      <VAR
  53781. CLASS="varname"
  53782. >$size</VAR
  53783. > wurde nicht ⁿberschrieben, da wir
  53784.      <TT
  53785. CLASS="constant"
  53786. ><B
  53787. >EXTR_PREFIX_SAME</B
  53788. ></TT
  53789. > spezifiziert haben, was im Anlegen
  53790.      von <VAR
  53791. CLASS="varname"
  53792. >$wddx_size</VAR
  53793. > endete. WΣre <TT
  53794. CLASS="constant"
  53795. ><B
  53796. >EXTR_SKIP</B
  53797. ></TT
  53798. >
  53799.      spezifiziert worden, dann wΣre $wddx_size nicht angelegt worden.
  53800.      <TT
  53801. CLASS="constant"
  53802. ><B
  53803. >EXTR_OVERWRITE</B
  53804. ></TT
  53805. > hΣtte <VAR
  53806. CLASS="varname"
  53807. >$size</VAR
  53808. > mit dem
  53809.      Wert "medium" ⁿberschrieben, und <TT
  53810. CLASS="constant"
  53811. ><B
  53812. >EXTR_PREFIX_ALL</B
  53813. ></TT
  53814. > hΣtte
  53815.      die neuen Variablen <VAR
  53816. CLASS="varname"
  53817. >$wddx_color</VAR
  53818. >,
  53819.      <VAR
  53820. CLASS="varname"
  53821. >$wddx_size</VAR
  53822. >, und <VAR
  53823. CLASS="varname"
  53824. >$wddx_shape</VAR
  53825. > angelegt.
  53826.     </P
  53827. ><P
  53828. >      Sie mⁿssen assoziative Arrays benutzen, numerisch indizierte
  53829.      Arrays liefern keine Resultate, au▀er Sie verwenden
  53830.      <TT
  53831. CLASS="constant"
  53832. ><B
  53833. >EXTR_PREFIX_ALL</B
  53834. ></TT
  53835. > oder
  53836.      <TT
  53837. CLASS="constant"
  53838. ><B
  53839. >EXTR_PREFIX_INVALID</B
  53840. ></TT
  53841. >.
  53842.     </P
  53843. ><P
  53844. >      Siehe auch <A
  53845. HREF="#function.compact"
  53846. ><B
  53847. CLASS="function"
  53848. >compact()</B
  53849. ></A
  53850. >.
  53851.     </P
  53852. ></DIV
  53853. ><H1
  53854. ><A
  53855. NAME="function.in-array"
  53856. ></A
  53857. >in_array</H1
  53858. ><DIV
  53859. CLASS="refnamediv"
  53860. ><A
  53861. NAME="AEN9604"
  53862. ></A
  53863. ><P
  53864. >    (PHP 4 , PHP 5)</P
  53865. >in_array -- Prⁿft, ob ein Wert in einem Array existiert</DIV
  53866. ><DIV
  53867. CLASS="refsect1"
  53868. ><A
  53869. NAME="AEN9607"
  53870. ></A
  53871. ><H2
  53872. >Beschreibung</H2
  53873. >bool <B
  53874. CLASS="methodname"
  53875. >in_array</B
  53876. > ( mixed needle, array haystack [, bool strict])<BR
  53877. ></BR
  53878. ><P
  53879. >      Diese Funktion sucht in <VAR
  53880. CLASS="parameter"
  53881. >haystack</VAR
  53882. > nach
  53883.      <VAR
  53884. CLASS="parameter"
  53885. >needle</VAR
  53886. > und gibt bei Erfolg <TT
  53887. CLASS="constant"
  53888. ><B
  53889. >TRUE</B
  53890. ></TT
  53891. > zurⁿck,
  53892.      andernfalls <TT
  53893. CLASS="constant"
  53894. ><B
  53895. >FALSE</B
  53896. ></TT
  53897. >.
  53898.     </P
  53899. ><P
  53900. >      Ist der dritte Parameter <VAR
  53901. CLASS="parameter"
  53902. >strict</VAR
  53903. > auf <TT
  53904. CLASS="constant"
  53905. ><B
  53906. >TRUE</B
  53907. ></TT
  53908. >
  53909.      gesetzt, prⁿft <B
  53910. CLASS="function"
  53911. >in_array()</B
  53912. > auch die
  53913.      <A
  53914. HREF="#language.types"
  53915. >Typen</A
  53916. > von
  53917.      <VAR
  53918. CLASS="parameter"
  53919. >needle</VAR
  53920. > in <VAR
  53921. CLASS="parameter"
  53922. >haystack</VAR
  53923. >.
  53924.     </P
  53925. ><DIV
  53926. CLASS="note"
  53927. ><BLOCKQUOTE
  53928. CLASS="note"
  53929. ><P
  53930. ><B
  53931. >Anmerkung: </B
  53932. >
  53933.       Ist <VAR
  53934. CLASS="parameter"
  53935. >needle</VAR
  53936. > ein String, erfolgt der Vergleich
  53937.       unter Berⁿcksichtigung der Gro▀- und Kleinschreibung.
  53938.      </P
  53939. ></BLOCKQUOTE
  53940. ></DIV
  53941. ><DIV
  53942. CLASS="note"
  53943. ><BLOCKQUOTE
  53944. CLASS="note"
  53945. ><P
  53946. ><B
  53947. >Anmerkung: </B
  53948. >
  53949.       In den PHP Versionen vor 4.2.0 durfte <VAR
  53950. CLASS="parameter"
  53951. >needle</VAR
  53952. >
  53953.       kein Array sein
  53954.      </P
  53955. ></BLOCKQUOTE
  53956. ></DIV
  53957. ><P
  53958. >      <TABLE
  53959. WIDTH="100%"
  53960. BORDER="0"
  53961. CELLPADDING="0"
  53962. CELLSPACING="0"
  53963. CLASS="EXAMPLE"
  53964. ><TR
  53965. ><TD
  53966. ><DIV
  53967. CLASS="example"
  53968. ><A
  53969. NAME="AEN9640"
  53970. ></A
  53971. ><P
  53972. ><B
  53973. >Beispiel 1. <B
  53974. CLASS="function"
  53975. >in_array()</B
  53976. ></B
  53977. ></P
  53978. ><TABLE
  53979. BORDER="0"
  53980. BGCOLOR="#E0E0E0"
  53981. CELLPADDING="5"
  53982. ><TR
  53983. ><TD
  53984. ><PRE
  53985. CLASS="php"
  53986. ><?php
  53987. $os = array ("Mac", "NT", "Irix", "Linux");
  53988. if (in_array ("Irix", $os)) {
  53989.     print "Got Irix";
  53990. }
  53991. if (in_array ("mac", $os)) {
  53992.     print "Got mac";
  53993. }
  53994. ?></PRE
  53995. ></TD
  53996. ></TR
  53997. ></TABLE
  53998. ><P
  53999. >        Die zweite Bedingung schlΣgt fehl, da <B
  54000. CLASS="function"
  54001. >in_array()</B
  54002. >
  54003.        die Gro▀-/Kleinschreibung berⁿcksichtigt, daher wird das obige
  54004.        Programm folgendes ausgeben:
  54005.       </P
  54006. ><TABLE
  54007. BORDER="0"
  54008. BGCOLOR="#E0E0E0"
  54009. CELLPADDING="5"
  54010. ><TR
  54011. ><TD
  54012. ><PRE
  54013. CLASS="php"
  54014. >Got Irix</PRE
  54015. ></TD
  54016. ></TR
  54017. ></TABLE
  54018. ></DIV
  54019. ></TD
  54020. ></TR
  54021. ></TABLE
  54022. >
  54023.     </P
  54024. ><P
  54025. >      <TABLE
  54026. WIDTH="100%"
  54027. BORDER="0"
  54028. CELLPADDING="0"
  54029. CELLSPACING="0"
  54030. CLASS="EXAMPLE"
  54031. ><TR
  54032. ><TD
  54033. ><DIV
  54034. CLASS="example"
  54035. ><A
  54036. NAME="AEN9648"
  54037. ></A
  54038. ><P
  54039. ><B
  54040. >Beispiel 2. <B
  54041. CLASS="function"
  54042. >in_array()</B
  54043. > mit strict</B
  54044. ></P
  54045. ><TABLE
  54046. BORDER="0"
  54047. BGCOLOR="#E0E0E0"
  54048. CELLPADDING="5"
  54049. ><TR
  54050. ><TD
  54051. ><PRE
  54052. CLASS="php"
  54053. ><?php
  54054. $a = array('1.10', 12.4, 1.13);
  54055.  
  54056. if (in_array('12.4', $a, TRUE)) {
  54057.     echo "'12.4' gefunden mit strict check\n";
  54058. }
  54059. if (in_array(1.13, $a, TRUE)) {
  54060.     echo "1.13 gefunden mit strict check\n";
  54061. }
  54062. ?></PRE
  54063. ></TD
  54064. ></TR
  54065. ></TABLE
  54066. ><P
  54067. >        Dies wird folgendes anzeigen:
  54068.       </P
  54069. ><TABLE
  54070. BORDER="0"
  54071. BGCOLOR="#E0E0E0"
  54072. CELLPADDING="5"
  54073. ><TR
  54074. ><TD
  54075. ><PRE
  54076. CLASS="screen"
  54077. >1.13 gefunden mit strict check</PRE
  54078. ></TD
  54079. ></TR
  54080. ></TABLE
  54081. ></DIV
  54082. ></TD
  54083. ></TR
  54084. ></TABLE
  54085. >
  54086.     </P
  54087. ><P
  54088. >      <TABLE
  54089. WIDTH="100%"
  54090. BORDER="0"
  54091. CELLPADDING="0"
  54092. CELLSPACING="0"
  54093. CLASS="EXAMPLE"
  54094. ><TR
  54095. ><TD
  54096. ><DIV
  54097. CLASS="example"
  54098. ><A
  54099. NAME="AEN9655"
  54100. ></A
  54101. ><P
  54102. ><B
  54103. >Beispiel 3. <B
  54104. CLASS="function"
  54105. >in_array()</B
  54106. > mit einem Array als needle</B
  54107. ></P
  54108. ><TABLE
  54109. BORDER="0"
  54110. BGCOLOR="#E0E0E0"
  54111. CELLPADDING="5"
  54112. ><TR
  54113. ><TD
  54114. ><PRE
  54115. CLASS="php"
  54116. ><?php
  54117. $a = array(array('p', 'h'), array('p', 'r'), 'o');
  54118.  
  54119. if (in_array(array ('p', 'h'), $a)) {
  54120.     echo "'ph' wurde gefunden\n";
  54121. }
  54122. if (in_array(array ('f', 'i'), $a)) {
  54123.     echo "'fi' wurde nicht gefunden\n";
  54124. }
  54125. if (in_array('o', $a)) {
  54126.     echo "'o' wurde gefunden\n";
  54127. }
  54128. ?>
  54129.  
  54130. /* Ausgabe:
  54131.  
  54132.   'ph' wurde gefunden
  54133.   'o' wurde gefunden
  54134. */</PRE
  54135. ></TD
  54136. ></TR
  54137. ></TABLE
  54138. ></DIV
  54139. ></TD
  54140. ></TR
  54141. ></TABLE
  54142. >
  54143.     </P
  54144. ><P
  54145. >      Siehe auch <A
  54146. HREF="#function.array-search"
  54147. ><B
  54148. CLASS="function"
  54149. >array_search()</B
  54150. ></A
  54151. >.
  54152.     </P
  54153. ></DIV
  54154. ><H1
  54155. ><A
  54156. NAME="function.key"
  54157. ></A
  54158. >key</H1
  54159. ><DIV
  54160. CLASS="refnamediv"
  54161. ><A
  54162. NAME="AEN9662"
  54163. ></A
  54164. ><P
  54165. >    (PHP 3, PHP 4 , PHP 5)</P
  54166. >key -- 
  54167.      Liefert einen Schlⁿssel eines assoziativen Arrays
  54168.     </DIV
  54169. ><DIV
  54170. CLASS="refsect1"
  54171. ><A
  54172. NAME="AEN9665"
  54173. ></A
  54174. ><H2
  54175. >Beschreibung</H2
  54176. >mixed <B
  54177. CLASS="methodname"
  54178. >key</B
  54179. > ( array array)<BR
  54180. ></BR
  54181. ><P
  54182. >      <B
  54183. CLASS="function"
  54184. >key()</B
  54185. > liefert das Index Element der aktuellen
  54186.      Position im Array.
  54187.     </P
  54188. ><P
  54189. >      Siehe auch <A
  54190. HREF="#function.current"
  54191. ><B
  54192. CLASS="function"
  54193. >current()</B
  54194. ></A
  54195. > und <A
  54196. HREF="#function.next"
  54197. ><B
  54198. CLASS="function"
  54199. >next()</B
  54200. ></A
  54201. >.
  54202.     </P
  54203. ></DIV
  54204. ><H1
  54205. ><A
  54206. NAME="function.krsort"
  54207. ></A
  54208. >krsort</H1
  54209. ><DIV
  54210. CLASS="refnamediv"
  54211. ><A
  54212. NAME="AEN9679"
  54213. ></A
  54214. ><P
  54215. >    (PHP 3>= 3.0.13, PHP 4 , PHP 5)</P
  54216. >krsort -- 
  54217.      Sortiert ein Array nach Schlⁿsseln in umgekehrter Reihenfolge
  54218.     </DIV
  54219. ><DIV
  54220. CLASS="refsect1"
  54221. ><A
  54222. NAME="AEN9682"
  54223. ></A
  54224. ><H2
  54225. >Beschreibung</H2
  54226. >int <B
  54227. CLASS="methodname"
  54228. >krsort</B
  54229. > ( array array [, int sort_flags])<BR
  54230. ></BR
  54231. ><P
  54232. >      Sortiert ein Array nach Schlⁿsseln in umgekehrter Reihenfolge,
  54233.      wobei die Zuordnungen zwischen Schlⁿssel und Wert erhalten
  54234.      bleiben. Dies ist hauptsΣchlich bei assoziativen Arrays
  54235.      hilfreich.
  54236.     </P
  54237. ><P
  54238. >      <TABLE
  54239. WIDTH="100%"
  54240. BORDER="0"
  54241. CELLPADDING="0"
  54242. CELLSPACING="0"
  54243. CLASS="EXAMPLE"
  54244. ><TR
  54245. ><TD
  54246. ><DIV
  54247. CLASS="example"
  54248. ><A
  54249. NAME="AEN9695"
  54250. ></A
  54251. ><P
  54252. ><B
  54253. >Beispiel 1. <B
  54254. CLASS="function"
  54255. >krsort()</B
  54256. ></B
  54257. ></P
  54258. ><TABLE
  54259. BORDER="0"
  54260. BGCOLOR="#E0E0E0"
  54261. CELLPADDING="5"
  54262. ><TR
  54263. ><TD
  54264. ><PRE
  54265. CLASS="php"
  54266. ><?php
  54267. $fruits = array ("d"=>"Zitrone", "a"=>"Orange", "b"=>"Banane", "c"=>"Apfel");
  54268. krsort ($fruits);
  54269. reset ($fruits);
  54270. while (list ($key, $val) = each ($fruits)) {
  54271.     echo "$key = $val\n";
  54272. }
  54273. ?></PRE
  54274. ></TD
  54275. ></TR
  54276. ></TABLE
  54277. ><P
  54278. >        Dieses Beispiel wⁿrde folgendes ausgeben:
  54279.       </P
  54280. ><TABLE
  54281. BORDER="0"
  54282. BGCOLOR="#E0E0E0"
  54283. CELLPADDING="5"
  54284. ><TR
  54285. ><TD
  54286. ><PRE
  54287. CLASS="screen"
  54288. >d = Zitrone
  54289. c = Apfel
  54290. b = Banane
  54291. a = Orange</PRE
  54292. ></TD
  54293. ></TR
  54294. ></TABLE
  54295. ></DIV
  54296. ></TD
  54297. ></TR
  54298. ></TABLE
  54299. >
  54300.     </P
  54301. ><P
  54302. >      Sie k÷nnen das Verhalten der Sortierung mittels dem optionalen
  54303.      Parameter <VAR
  54304. CLASS="parameter"
  54305. >sort_flags</VAR
  54306. > beeinflussen, fⁿr
  54307.      Details siehe <A
  54308. HREF="#function.sort"
  54309. ><B
  54310. CLASS="function"
  54311. >sort()</B
  54312. ></A
  54313. >.
  54314.     </P
  54315. ><P
  54316. >      Siehe auch <A
  54317. HREF="#function.asort"
  54318. ><B
  54319. CLASS="function"
  54320. >asort()</B
  54321. ></A
  54322. >, <A
  54323. HREF="#function.arsort"
  54324. ><B
  54325. CLASS="function"
  54326. >arsort()</B
  54327. ></A
  54328. >,
  54329.      <A
  54330. HREF="#function.ksort"
  54331. ><B
  54332. CLASS="function"
  54333. >ksort()</B
  54334. ></A
  54335. >, <A
  54336. HREF="#function.sort"
  54337. ><B
  54338. CLASS="function"
  54339. >sort()</B
  54340. ></A
  54341. >,
  54342.      <A
  54343. HREF="#function.natsort"
  54344. ><B
  54345. CLASS="function"
  54346. >natsort()</B
  54347. ></A
  54348. > und <A
  54349. HREF="#function.rsort"
  54350. ><B
  54351. CLASS="function"
  54352. >rsort()</B
  54353. ></A
  54354. >.
  54355.     </P
  54356. ></DIV
  54357. ><H1
  54358. ><A
  54359. NAME="function.ksort"
  54360. ></A
  54361. >ksort</H1
  54362. ><DIV
  54363. CLASS="refnamediv"
  54364. ><A
  54365. NAME="AEN9712"
  54366. ></A
  54367. ><P
  54368. >    (PHP 3, PHP 4 , PHP 5)</P
  54369. >ksort -- Sortiert ein Array nach Schlⁿsseln</DIV
  54370. ><DIV
  54371. CLASS="refsect1"
  54372. ><A
  54373. NAME="AEN9715"
  54374. ></A
  54375. ><H2
  54376. >Beschreibung</H2
  54377. >int <B
  54378. CLASS="methodname"
  54379. >ksort</B
  54380. > ( array array [, int sort_flags])<BR
  54381. ></BR
  54382. ><P
  54383. >      Sortiert ein Array nach Schlⁿsseln, wobei die Zuordnungen
  54384.      zwischen Schlⁿssel und Wert erhalten bleiben. Dies ist
  54385.      hauptsΣchlich bei assoziativen Arrays hilfreich.
  54386.     </P
  54387. ><P
  54388. >      <TABLE
  54389. WIDTH="100%"
  54390. BORDER="0"
  54391. CELLPADDING="0"
  54392. CELLSPACING="0"
  54393. CLASS="EXAMPLE"
  54394. ><TR
  54395. ><TD
  54396. ><DIV
  54397. CLASS="example"
  54398. ><A
  54399. NAME="AEN9728"
  54400. ></A
  54401. ><P
  54402. ><B
  54403. >Beispiel 1. <B
  54404. CLASS="function"
  54405. >ksort()</B
  54406. ></B
  54407. ></P
  54408. ><TABLE
  54409. BORDER="0"
  54410. BGCOLOR="#E0E0E0"
  54411. CELLPADDING="5"
  54412. ><TR
  54413. ><TD
  54414. ><PRE
  54415. CLASS="php"
  54416. ><?php
  54417. $fruits = array ("d"=>"Zitrone", "a"=>"Orange", "b"=>"Banane", "c"=>"Apfel");
  54418. ksort ($fruits);
  54419. reset ($fruits);
  54420. while (list ($key, $val) = each ($fruits)) {
  54421.     echo "$key = $val\n";
  54422. }
  54423. ?></PRE
  54424. ></TD
  54425. ></TR
  54426. ></TABLE
  54427. ><P
  54428. >        Dieses Beispiel wⁿrde folgendes ausgeben:
  54429.       </P
  54430. ><TABLE
  54431. BORDER="0"
  54432. BGCOLOR="#E0E0E0"
  54433. CELLPADDING="5"
  54434. ><TR
  54435. ><TD
  54436. ><PRE
  54437. CLASS="screen"
  54438. >a = Orange
  54439. b = Banane
  54440. c = Apfel
  54441. d = Zitrone</PRE
  54442. ></TD
  54443. ></TR
  54444. ></TABLE
  54445. ></DIV
  54446. ></TD
  54447. ></TR
  54448. ></TABLE
  54449. >
  54450.     </P
  54451. ><P
  54452. >      Sie k÷nnen das Verhalten der Sortierung mittels dem optionalen
  54453.      Parameter <VAR
  54454. CLASS="parameter"
  54455. >sort_flags</VAR
  54456. > beeinflussen, fⁿr
  54457.      Details siehe <A
  54458. HREF="#function.sort"
  54459. ><B
  54460. CLASS="function"
  54461. >sort()</B
  54462. ></A
  54463. >.
  54464.     </P
  54465. ><P
  54466. >      Siehe auch <A
  54467. HREF="#function.asort"
  54468. ><B
  54469. CLASS="function"
  54470. >asort()</B
  54471. ></A
  54472. >, <A
  54473. HREF="#function.arsort"
  54474. ><B
  54475. CLASS="function"
  54476. >arsort()</B
  54477. ></A
  54478. >,
  54479.      <A
  54480. HREF="#function.krsort"
  54481. ><B
  54482. CLASS="function"
  54483. >krsort()</B
  54484. ></A
  54485. >, <A
  54486. HREF="#function.uksort"
  54487. ><B
  54488. CLASS="function"
  54489. >uksort()</B
  54490. ></A
  54491. >,
  54492.      <A
  54493. HREF="#function.sort"
  54494. ><B
  54495. CLASS="function"
  54496. >sort()</B
  54497. ></A
  54498. >, <A
  54499. HREF="#function.natsort"
  54500. ><B
  54501. CLASS="function"
  54502. >natsort()</B
  54503. ></A
  54504. > und
  54505.      <A
  54506. HREF="#function.rsort"
  54507. ><B
  54508. CLASS="function"
  54509. >rsort()</B
  54510. ></A
  54511. >.
  54512.     </P
  54513. ><DIV
  54514. CLASS="note"
  54515. ><BLOCKQUOTE
  54516. CLASS="note"
  54517. ><P
  54518. ><B
  54519. >Anmerkung: </B
  54520. >
  54521.       Der zweite Parameter wurde mit PHP 4 eingefⁿhrt.
  54522.      </P
  54523. ></BLOCKQUOTE
  54524. ></DIV
  54525. ></DIV
  54526. ><H1
  54527. ><A
  54528. NAME="function.list"
  54529. ></A
  54530. >list</H1
  54531. ><DIV
  54532. CLASS="refnamediv"
  54533. ><A
  54534. NAME="AEN9748"
  54535. ></A
  54536. ><P
  54537. >    (PHP 3, PHP 4, PHP 5 )</P
  54538. >list -- 
  54539.      Weist Variablen zu, als wΣren sie ein Array
  54540.     </DIV
  54541. ><DIV
  54542. CLASS="refsect1"
  54543. ><A
  54544. NAME="AEN9751"
  54545. ></A
  54546. ><H2
  54547. >Beschreibung</H2
  54548. >void <B
  54549. CLASS="methodname"
  54550. >list</B
  54551. > ( mixed ...)<BR
  54552. ></BR
  54553. ><P
  54554. >      Wie <A
  54555. HREF="#function.array"
  54556. ><B
  54557. CLASS="function"
  54558. >array()</B
  54559. ></A
  54560. > ist auch dies keine wirkliche
  54561.      Funktion, sondern ein Sprachkonstrukt. <B
  54562. CLASS="function"
  54563. >list()</B
  54564. >
  54565.      wird verwendet, um eine Liste von Variablen innerhalb einer
  54566.      Operation zuzuweisen.
  54567.     </P
  54568. ><DIV
  54569. CLASS="note"
  54570. ><BLOCKQUOTE
  54571. CLASS="note"
  54572. ><P
  54573. ><B
  54574. >Anmerkung: </B
  54575. >
  54576.       <B
  54577. CLASS="function"
  54578. >list()</B
  54579. > funktioniert nur bei numerischen Arrays und
  54580.       basiert auf der Annahme, dass die numerischen Indizes bei 0 beginnen.
  54581.      </P
  54582. ></BLOCKQUOTE
  54583. ></DIV
  54584. ><P
  54585. >      <TABLE
  54586. WIDTH="100%"
  54587. BORDER="0"
  54588. CELLPADDING="0"
  54589. CELLSPACING="0"
  54590. CLASS="EXAMPLE"
  54591. ><TR
  54592. ><TD
  54593. ><DIV
  54594. CLASS="example"
  54595. ><A
  54596. NAME="AEN9766"
  54597. ></A
  54598. ><P
  54599. ><B
  54600. >Beispiel 1. <B
  54601. CLASS="function"
  54602. >list()</B
  54603. ></B
  54604. ></P
  54605. ><TABLE
  54606. BORDER="0"
  54607. BGCOLOR="#E0E0E0"
  54608. CELLPADDING="5"
  54609. ><TR
  54610. ><TD
  54611. ><PRE
  54612. CLASS="php"
  54613. ><?php
  54614.  
  54615. $info = array('coffee', 'brown', 'caffeine');
  54616.  
  54617. // Auflisten aller Variablen
  54618. list($drink, $color, $power) = $info;
  54619. print "$drink is $color and $power makes it special.\n";
  54620.  
  54621. // Ein paar davon auflisten
  54622. list($drink, , $power) = $info;
  54623. print "$drink has $power.\n";
  54624.  
  54625. // Oder nur die dritte ausgeben
  54626. list( , , $power) = $info;
  54627. print "I need $power!\n";
  54628.  
  54629. ?></PRE
  54630. ></TD
  54631. ></TR
  54632. ></TABLE
  54633. ></DIV
  54634. ></TD
  54635. ></TR
  54636. ></TABLE
  54637. >
  54638.     </P
  54639. ><P
  54640. >      <TABLE
  54641. WIDTH="100%"
  54642. BORDER="0"
  54643. CELLPADDING="0"
  54644. CELLSPACING="0"
  54645. CLASS="EXAMPLE"
  54646. ><TR
  54647. ><TD
  54648. ><DIV
  54649. CLASS="example"
  54650. ><A
  54651. NAME="AEN9771"
  54652. ></A
  54653. ><P
  54654. ><B
  54655. >Beispiel 2. <B
  54656. CLASS="function"
  54657. >list()</B
  54658. ></B
  54659. ></P
  54660. ><TABLE
  54661. BORDER="0"
  54662. BGCOLOR="#E0E0E0"
  54663. CELLPADDING="5"
  54664. ><TR
  54665. ><TD
  54666. ><PRE
  54667. CLASS="php"
  54668. ><table>
  54669.  <tr>
  54670.   <th>Mitarbeitername</th>
  54671.   <th>Gehalt</th>
  54672.  </tr>
  54673.  
  54674. <?php
  54675.  
  54676. $result = mysql_query ("SELECT id, name, salary FROM employees",$conn);
  54677. while (list ($id, $name, $salary) = mysql_fetch_row ($result)) {
  54678.     print (" <tr>\n".
  54679.            "  <td><a href=\"info.php?id=$id\">$name</a></td>\n".
  54680.            "  <td>$salary</td>\n".
  54681.            " </tr>\n");
  54682. }
  54683.  
  54684. ?>
  54685.  
  54686. </table></PRE
  54687. ></TD
  54688. ></TR
  54689. ></TABLE
  54690. ></DIV
  54691. ></TD
  54692. ></TR
  54693. ></TABLE
  54694. >
  54695.     </P
  54696. ><DIV
  54697. CLASS="warning"
  54698. ><P
  54699. ></P
  54700. ><TABLE
  54701. CLASS="warning"
  54702. BORDER="1"
  54703. WIDTH="100%"
  54704. ><TR
  54705. ><TD
  54706. ALIGN="CENTER"
  54707. ><B
  54708. >Warnung</B
  54709. ></TD
  54710. ></TR
  54711. ><TR
  54712. ><TD
  54713. ALIGN="LEFT"
  54714. ><P
  54715. >       <B
  54716. CLASS="function"
  54717. >list()</B
  54718. > weist die Werte von rechts beginnend zu.
  54719.       Wenn Sie einfache Variablen benutzen, brauchen Sie sich nicht darum
  54720.       zu kⁿmmern. Wenn Sie jedoch Arrays mit Indizes verwenden, erwarten Sie
  54721.       gew÷hnlich die Reihenfolge der Indizes in dem Array genau so, wie Sie
  54722.       sie in <B
  54723. CLASS="function"
  54724. >list()</B
  54725. > geschrieben haben (von links nach
  54726.       rechts), was jedoch nicht der Fall ist. Es wird in der umgekehrten
  54727.       Reihenfolge zugewiesen.
  54728.      </P
  54729. ></TD
  54730. ></TR
  54731. ></TABLE
  54732. ></DIV
  54733. ><P
  54734. >      <TABLE
  54735. WIDTH="100%"
  54736. BORDER="0"
  54737. CELLPADDING="0"
  54738. CELLSPACING="0"
  54739. CLASS="EXAMPLE"
  54740. ><TR
  54741. ><TD
  54742. ><DIV
  54743. CLASS="example"
  54744. ><A
  54745. NAME="AEN9780"
  54746. ></A
  54747. ><P
  54748. ><B
  54749. >Beispiel 3. <B
  54750. CLASS="function"
  54751. >list()</B
  54752. > mit Array Indizes verwenden</B
  54753. ></P
  54754. ><TABLE
  54755. BORDER="0"
  54756. BGCOLOR="#E0E0E0"
  54757. CELLPADDING="5"
  54758. ><TR
  54759. ><TD
  54760. ><PRE
  54761. CLASS="php"
  54762. ><?php
  54763.  
  54764. $info = array('coffee', 'brown', 'caffeine');
  54765.  
  54766. list($a[0], $a[1], $a[2]) = $info;
  54767.  
  54768. var_dump($a);
  54769.  
  54770. ?></PRE
  54771. ></TD
  54772. ></TR
  54773. ></TABLE
  54774. ><P
  54775. >        Die Ausgabe (Beachten Sie die Reihenfolge der Elemente, verglichen mit
  54776.        der in <B
  54777. CLASS="function"
  54778. >list()</B
  54779. > eingetragenen Reihenfolge):
  54780.       </P
  54781. ><TABLE
  54782. BORDER="0"
  54783. BGCOLOR="#E0E0E0"
  54784. CELLPADDING="5"
  54785. ><TR
  54786. ><TD
  54787. ><PRE
  54788. CLASS="screen"
  54789. >array(3) {
  54790.   [2]=>
  54791.   string(8) "caffeine"
  54792.   [1]=>
  54793.   string(5) "brown"
  54794.   [0]=>
  54795.   string(6) "coffee"
  54796. }</PRE
  54797. ></TD
  54798. ></TR
  54799. ></TABLE
  54800. ></DIV
  54801. ></TD
  54802. ></TR
  54803. ></TABLE
  54804. >
  54805.     </P
  54806. ><P
  54807. >      Siehe auch <A
  54808. HREF="#function.each"
  54809. ><B
  54810. CLASS="function"
  54811. >each()</B
  54812. ></A
  54813. >, <A
  54814. HREF="#function.array"
  54815. ><B
  54816. CLASS="function"
  54817. >array()</B
  54818. ></A
  54819. >
  54820.      und <A
  54821. HREF="#function.extract"
  54822. ><B
  54823. CLASS="function"
  54824. >extract()</B
  54825. ></A
  54826. >.
  54827.     </P
  54828. ></DIV
  54829. ><H1
  54830. ><A
  54831. NAME="function.natcasesort"
  54832. ></A
  54833. >natcasesort</H1
  54834. ><DIV
  54835. CLASS="refnamediv"
  54836. ><A
  54837. NAME="AEN9792"
  54838. ></A
  54839. ><P
  54840. >    (PHP 4 , PHP 5)</P
  54841. >natcasesort -- 
  54842.      Sortiert ein Array in "natⁿrlicher Reihenfolge",
  54843.      Gro▀/Kleinschreibung wird ignoriert
  54844.     </DIV
  54845. ><DIV
  54846. CLASS="refsect1"
  54847. ><A
  54848. NAME="AEN9795"
  54849. ></A
  54850. ><H2
  54851. >Beschreibung</H2
  54852. >void <B
  54853. CLASS="methodname"
  54854. >natcasesort</B
  54855. > ( array array)<BR
  54856. ></BR
  54857. ><P
  54858. >      Diese Funktion implementiert einen Sortieralgorithmus, welcher
  54859.      alphanumerische Zeichenketten reiht, wie es auch ein Mensch tun
  54860.      wⁿrde. Das wird als "natⁿrliche Reihenfolge" bezeichnet.
  54861.     </P
  54862. ><P
  54863. >      <B
  54864. CLASS="function"
  54865. >natcasesort()</B
  54866. > arbeitet wie
  54867.      <A
  54868. HREF="#function.natsort"
  54869. ><B
  54870. CLASS="function"
  54871. >natsort()</B
  54872. ></A
  54873. >, nur dass es die
  54874.      Gro▀/Kleinschreibung ignoriert. Ein Beispiel fⁿr den Unterschied
  54875.      zwischen diesem und dem normalen Sortieralgorithmus fⁿr Strings
  54876.      eines Computers finden Sie in <A
  54877. HREF="#function.natsort"
  54878. ><B
  54879. CLASS="function"
  54880. >natsort()</B
  54881. ></A
  54882. >.
  54883.     </P
  54884. ><P
  54885. >      Detailliertere Informationen finden Sie auf Martin Pool's <A
  54886. HREF="http://sourcefrog.net/projects/natsort/"
  54887. TARGET="_top"
  54888. >Natural Order String Comparison</A
  54889. >
  54890.      Seite.
  54891.     </P
  54892. ><P
  54893. >      Siehe auch <A
  54894. HREF="#function.sort"
  54895. ><B
  54896. CLASS="function"
  54897. >sort()</B
  54898. ></A
  54899. >,
  54900.      <A
  54901. HREF="#function.natsort"
  54902. ><B
  54903. CLASS="function"
  54904. >natsort()</B
  54905. ></A
  54906. >,
  54907.      <A
  54908. HREF="#function.strnatcmp"
  54909. ><B
  54910. CLASS="function"
  54911. >strnatcmp()</B
  54912. ></A
  54913. > und
  54914.      <A
  54915. HREF="#function.strnatcasecmp"
  54916. ><B
  54917. CLASS="function"
  54918. >strnatcasecmp()</B
  54919. ></A
  54920. >.
  54921.     </P
  54922. ></DIV
  54923. ><H1
  54924. ><A
  54925. NAME="function.natsort"
  54926. ></A
  54927. >natsort</H1
  54928. ><DIV
  54929. CLASS="refnamediv"
  54930. ><A
  54931. NAME="AEN9816"
  54932. ></A
  54933. ><P
  54934. >    (PHP 4 , PHP 5)</P
  54935. >natsort -- 
  54936.      Sortiert ein Array in "natⁿrlicher Reihenfolge"
  54937.     </DIV
  54938. ><DIV
  54939. CLASS="refsect1"
  54940. ><A
  54941. NAME="AEN9819"
  54942. ></A
  54943. ><H2
  54944. >Beschreibung</H2
  54945. >void <B
  54946. CLASS="methodname"
  54947. >natsort</B
  54948. > ( array array)<BR
  54949. ></BR
  54950. ><P
  54951. >      Diese Funktion implementiert einen Sortieralgorithmus, welcher
  54952.      alphanumerische Zeichenketten reiht, wie es auch ein Mensch tun
  54953.      wⁿrde. Hier ein Beispiel fⁿr den Unterschied zwischen diesem und
  54954.      dem normalen Sortieralgorithmus fⁿr Strings eines Computers
  54955.      (verwendet in <A
  54956. HREF="#function.sort"
  54957. ><B
  54958. CLASS="function"
  54959. >sort()</B
  54960. ></A
  54961. >):
  54962.     </P
  54963. ><P
  54964. >      <TABLE
  54965. WIDTH="100%"
  54966. BORDER="0"
  54967. CELLPADDING="0"
  54968. CELLSPACING="0"
  54969. CLASS="EXAMPLE"
  54970. ><TR
  54971. ><TD
  54972. ><DIV
  54973. CLASS="example"
  54974. ><A
  54975. NAME="AEN9830"
  54976. ></A
  54977. ><P
  54978. ><B
  54979. >Beispiel 1. <B
  54980. CLASS="function"
  54981. >natsort()</B
  54982. ></B
  54983. ></P
  54984. ><TABLE
  54985. BORDER="0"
  54986. BGCOLOR="#E0E0E0"
  54987. CELLPADDING="5"
  54988. ><TR
  54989. ><TD
  54990. ><PRE
  54991. CLASS="php"
  54992. ><?php
  54993. $array1 = $array2 = array ("img12.png", "img10.png", "img2.png", "img1.png");
  54994. sort ($array1);
  54995. echo "Standardsortierung\n";
  54996. print_r ($array1);
  54997.  
  54998. natsort ($array2);
  54999. echo "\nSortieren mit natⁿrlicher Reihenfolge\n";
  55000. print_r ($array2);
  55001. ?></PRE
  55002. ></TD
  55003. ></TR
  55004. ></TABLE
  55005. ><P
  55006. >        Der obige Code wird folgendes anzeigen:
  55007.       </P
  55008. ><TABLE
  55009. BORDER="0"
  55010. BGCOLOR="#E0E0E0"
  55011. CELLPADDING="5"
  55012. ><TR
  55013. ><TD
  55014. ><PRE
  55015. CLASS="screen"
  55016. >Standardsortierung
  55017. Array
  55018. (
  55019.     [0] => img1.png
  55020.     [1] => img10.png
  55021.     [2] => img12.png
  55022.     [3] => img2.png
  55023. )
  55024.  
  55025. Sortieren mit natⁿrlicher Reihenfolge
  55026. Array
  55027. (
  55028.     [3] => img1.png
  55029.     [2] => img2.png
  55030.     [1] => img10.png
  55031.     [0] => img12.png
  55032. )</PRE
  55033. ></TD
  55034. ></TR
  55035. ></TABLE
  55036. ><P
  55037. >        Detailliertere Informationen finden Sie auf Martin Pool's <A
  55038. HREF="http://sourcefrog.net/projects/natsort/"
  55039. TARGET="_top"
  55040. >Natural Order String Comparison</A
  55041. >
  55042.        Seite.
  55043.       </P
  55044. ></DIV
  55045. ></TD
  55046. ></TR
  55047. ></TABLE
  55048. >
  55049.     </P
  55050. ><DIV
  55051. CLASS="note"
  55052. ><BLOCKQUOTE
  55053. CLASS="note"
  55054. ><P
  55055. ><B
  55056. >Anmerkung: </B
  55057. >
  55058.       Wenn Sie die Index/Wert Assoziationen beibehalten wollen, denken Sie
  55059.       an die Verwendung von <VAR
  55060. CLASS="literal"
  55061. >uasort($arr, 'strnatcmp')</VAR
  55062. >.
  55063.      </P
  55064. ></BLOCKQUOTE
  55065. ></DIV
  55066. ><P
  55067. >      Siehe auch <A
  55068. HREF="#function.natcasesort"
  55069. ><B
  55070. CLASS="function"
  55071. >natcasesort()</B
  55072. ></A
  55073. >,
  55074.      <A
  55075. HREF="#function.strnatcmp"
  55076. ><B
  55077. CLASS="function"
  55078. >strnatcmp()</B
  55079. ></A
  55080. > und
  55081.      <A
  55082. HREF="#function.strnatcasecmp"
  55083. ><B
  55084. CLASS="function"
  55085. >strnatcasecmp()</B
  55086. ></A
  55087. >.
  55088.     </P
  55089. ></DIV
  55090. ><H1
  55091. ><A
  55092. NAME="function.next"
  55093. ></A
  55094. >next</H1
  55095. ><DIV
  55096. CLASS="refnamediv"
  55097. ><A
  55098. NAME="AEN9846"
  55099. ></A
  55100. ><P
  55101. >    (PHP 3, PHP 4 , PHP 5)</P
  55102. >next -- 
  55103.      Rⁿckt den internen Zeiger eines Arrays vor
  55104.     </DIV
  55105. ><DIV
  55106. CLASS="refsect1"
  55107. ><A
  55108. NAME="AEN9849"
  55109. ></A
  55110. ><H2
  55111. >Beschreibung</H2
  55112. >mixed <B
  55113. CLASS="methodname"
  55114. >next</B
  55115. > ( array array)<BR
  55116. ></BR
  55117. ><P
  55118. >      Diese Funktion gibt das nΣchste Element des Arrays zurⁿck, auf
  55119.      das der interne Zeiger des Arrays gerade zeigt. Sind keine
  55120.      Elemente mehr vorhanden, wird <TT
  55121. CLASS="constant"
  55122. ><B
  55123. >FALSE</B
  55124. ></TT
  55125. > zurⁿckgegeben.
  55126.     </P
  55127. ><P
  55128. >      <B
  55129. CLASS="function"
  55130. >next()</B
  55131. > verhΣlt sich Σhnlich wie
  55132.      <A
  55133. HREF="#function.current"
  55134. ><B
  55135. CLASS="function"
  55136. >current()</B
  55137. ></A
  55138. >, mit einem Unterschied. Der interne
  55139.      Zeiger wird um ein Element vorgerⁿckt, bevor das Element
  55140.      zurⁿckgegeben wird, d.h. es wird das nΣchste Element
  55141.      zurⁿckgegeben, und der interne Zeiger um eins erh÷ht. Zeigt der
  55142.      interne Zeiger hinter das Ende der Elementliste, wird <TT
  55143. CLASS="constant"
  55144. ><B
  55145. >FALSE</B
  55146. ></TT
  55147. >
  55148.      zurⁿckgegeben.
  55149.      <DIV
  55150. CLASS="warning"
  55151. ><P
  55152. ></P
  55153. ><TABLE
  55154. CLASS="warning"
  55155. BORDER="1"
  55156. WIDTH="100%"
  55157. ><TR
  55158. ><TD
  55159. ALIGN="CENTER"
  55160. ><B
  55161. >Warnung</B
  55162. ></TD
  55163. ></TR
  55164. ><TR
  55165. ><TD
  55166. ALIGN="LEFT"
  55167. ><P
  55168. >        EnthΣlt das Array leere Elemente oder Elemente mit dem
  55169.        Schlⁿssel 0, wird fⁿr diese Elemente ebenfalls <TT
  55170. CLASS="constant"
  55171. ><B
  55172. >FALSE</B
  55173. ></TT
  55174. >
  55175.        zurⁿckgegeben. Um ein Array, das leere Elemente oder Elemente
  55176.        mit dem Schlⁿssel 0 enthalten k÷nnte richtig durchzugehen,
  55177.        verwenden Sie die Funktion <A
  55178. HREF="#function.each"
  55179. ><B
  55180. CLASS="function"
  55181. >each()</B
  55182. ></A
  55183. >.
  55184.       </P
  55185. ></TD
  55186. ></TR
  55187. ></TABLE
  55188. ></DIV
  55189. >
  55190.     </P
  55191. ><P
  55192. >      Siehe auch <A
  55193. HREF="#function.current"
  55194. ><B
  55195. CLASS="function"
  55196. >current()</B
  55197. ></A
  55198. >,
  55199.      <A
  55200. HREF="#function.end"
  55201. ><B
  55202. CLASS="function"
  55203. >end()</B
  55204. ></A
  55205. >, <A
  55206. HREF="#function.prev"
  55207. ><B
  55208. CLASS="function"
  55209. >prev()</B
  55210. ></A
  55211. > und
  55212.      <A
  55213. HREF="#function.reset"
  55214. ><B
  55215. CLASS="function"
  55216. >reset()</B
  55217. ></A
  55218. >.
  55219.     </P
  55220. ></DIV
  55221. ><H1
  55222. ><A
  55223. NAME="function.pos"
  55224. ></A
  55225. >pos</H1
  55226. ><DIV
  55227. CLASS="refnamediv"
  55228. ><A
  55229. NAME="AEN9873"
  55230. ></A
  55231. ><P
  55232. >    (PHP 3, PHP 4 , PHP 5)</P
  55233. >pos -- Liefert das aktuelle Element eines Arrays</DIV
  55234. ><DIV
  55235. CLASS="refsect1"
  55236. ><A
  55237. NAME="AEN9876"
  55238. ></A
  55239. ><H2
  55240. >Beschreibung</H2
  55241. >mixed <B
  55242. CLASS="methodname"
  55243. >pos</B
  55244. > ( array array)<BR
  55245. ></BR
  55246. ><P
  55247. >      Dies ist nur ein <A
  55248. HREF="#aliases"
  55249. >Alias</A
  55250. >
  55251.      fⁿr die Funktion <A
  55252. HREF="#function.current"
  55253. ><B
  55254. CLASS="function"
  55255. >current()</B
  55256. ></A
  55257. >.
  55258.     </P
  55259. ><P
  55260. >      Siehe auch
  55261.      <A
  55262. HREF="#function.end"
  55263. ><B
  55264. CLASS="function"
  55265. >end()</B
  55266. ></A
  55267. >, <A
  55268. HREF="#function.next"
  55269. ><B
  55270. CLASS="function"
  55271. >next()</B
  55272. ></A
  55273. >,
  55274.      <A
  55275. HREF="#function.prev"
  55276. ><B
  55277. CLASS="function"
  55278. >prev()</B
  55279. ></A
  55280. > und <A
  55281. HREF="#function.reset"
  55282. ><B
  55283. CLASS="function"
  55284. >reset()</B
  55285. ></A
  55286. >.
  55287.     </P
  55288. ></DIV
  55289. ><H1
  55290. ><A
  55291. NAME="function.prev"
  55292. ></A
  55293. >prev</H1
  55294. ><DIV
  55295. CLASS="refnamediv"
  55296. ><A
  55297. NAME="AEN9893"
  55298. ></A
  55299. ><P
  55300. >    (PHP 3, PHP 4 , PHP 5)</P
  55301. >prev -- 
  55302.      Verkleinert den internen Zeiger eines Arrays
  55303.     </DIV
  55304. ><DIV
  55305. CLASS="refsect1"
  55306. ><A
  55307. NAME="AEN9896"
  55308. ></A
  55309. ><H2
  55310. >Beschreibung</H2
  55311. >mixed <B
  55312. CLASS="methodname"
  55313. >prev</B
  55314. > ( array array)<BR
  55315. ></BR
  55316. ><P
  55317. >      Liefert das Element vor der Position des Arrays, auf die der
  55318.      interne Zeiger gerade zeigt. Sind keine Elemente mehr vorhanden,
  55319.      wird <TT
  55320. CLASS="constant"
  55321. ><B
  55322. >FALSE</B
  55323. ></TT
  55324. > zurⁿckgegeben.
  55325.      <DIV
  55326. CLASS="warning"
  55327. ><P
  55328. ></P
  55329. ><TABLE
  55330. CLASS="warning"
  55331. BORDER="1"
  55332. WIDTH="100%"
  55333. ><TR
  55334. ><TD
  55335. ALIGN="CENTER"
  55336. ><B
  55337. >Warnung</B
  55338. ></TD
  55339. ></TR
  55340. ><TR
  55341. ><TD
  55342. ALIGN="LEFT"
  55343. ><P
  55344. >        EnthΣlt das Array leere Elemente, wird fⁿr diese ebenfalls
  55345.        <TT
  55346. CLASS="constant"
  55347. ><B
  55348. >FALSE</B
  55349. ></TT
  55350. > zurⁿckgegeben. Um ein Array mit leeren Elementen
  55351.        richtig durchzugehen, verwenden Sie die Funktion
  55352.        <A
  55353. HREF="#function.each"
  55354. ><B
  55355. CLASS="function"
  55356. >each()</B
  55357. ></A
  55358. >.
  55359.       </P
  55360. ></TD
  55361. ></TR
  55362. ></TABLE
  55363. ></DIV
  55364. >
  55365.     </P
  55366. ><P
  55367. >      <B
  55368. CLASS="function"
  55369. >prev()</B
  55370. > verhΣlt sich wie
  55371.      <A
  55372. HREF="#function.next"
  55373. ><B
  55374. CLASS="function"
  55375. >next()</B
  55376. ></A
  55377. >, nur dass hier der interne Zeiger um
  55378.      eine Position zurⁿck, und nicht nach vorne gerⁿckt wird.
  55379.     </P
  55380. ><P
  55381. >      Siehe auch <A
  55382. HREF="#function.current"
  55383. ><B
  55384. CLASS="function"
  55385. >current()</B
  55386. ></A
  55387. >,
  55388.      <A
  55389. HREF="#function.end"
  55390. ><B
  55391. CLASS="function"
  55392. >end()</B
  55393. ></A
  55394. >, <A
  55395. HREF="#function.next"
  55396. ><B
  55397. CLASS="function"
  55398. >next()</B
  55399. ></A
  55400. > und
  55401.      <A
  55402. HREF="#function.reset"
  55403. ><B
  55404. CLASS="function"
  55405. >reset()</B
  55406. ></A
  55407. >.
  55408.     </P
  55409. ></DIV
  55410. ><H1
  55411. ><A
  55412. NAME="function.range"
  55413. ></A
  55414. >range</H1
  55415. ><DIV
  55416. CLASS="refnamediv"
  55417. ><A
  55418. NAME="AEN9919"
  55419. ></A
  55420. ><P
  55421. >    (PHP 3>= 3.0.8, PHP 4 , PHP 5)</P
  55422. >range -- 
  55423.      Erstellt ein Array mit einem Bereich von Elementen
  55424.     </DIV
  55425. ><DIV
  55426. CLASS="refsect1"
  55427. ><A
  55428. NAME="AEN9922"
  55429. ></A
  55430. ><H2
  55431. >Beschreibung</H2
  55432. >array <B
  55433. CLASS="methodname"
  55434. >range</B
  55435. > ( int low, int high [, int step])<BR
  55436. ></BR
  55437. ><P
  55438. >      <B
  55439. CLASS="function"
  55440. >range()</B
  55441. > gibt ein Array mit Elementen im
  55442.      Bereich von <VAR
  55443. CLASS="parameter"
  55444. >low</VAR
  55445. > bis
  55446.      <VAR
  55447. CLASS="parameter"
  55448. >high</VAR
  55449. > zurⁿck. Wenn low > high, wird die
  55450.      Sequenz von high nach low sein.
  55451.     </P
  55452. ><DIV
  55453. CLASS="note"
  55454. ><BLOCKQUOTE
  55455. CLASS="note"
  55456. ><P
  55457. ><B
  55458. >Neuer Parameter: </B
  55459. >
  55460.       Der optionale Parameter <VAR
  55461. CLASS="parameter"
  55462. >step</VAR
  55463. > wurde in 5.0.0 eingefⁿhrt.
  55464.      </P
  55465. ></BLOCKQUOTE
  55466. ></DIV
  55467. ><P
  55468. >      Ist ein <VAR
  55469. CLASS="parameter"
  55470. >step</VAR
  55471. > Wert angegeben, wird es Schrittweite
  55472.      zwischen den Elementen in der Sequenz verwendet. <VAR
  55473. CLASS="parameter"
  55474. >step</VAR
  55475. >
  55476.      sollte als positive Zahl angegeben werden. Ist <VAR
  55477. CLASS="parameter"
  55478. >step</VAR
  55479. >
  55480.      nicht angegeben, wird automatisch der Wert 1 angenommen.
  55481.     </P
  55482. ><P
  55483. >      <TABLE
  55484. WIDTH="100%"
  55485. BORDER="0"
  55486. CELLPADDING="0"
  55487. CELLSPACING="0"
  55488. CLASS="EXAMPLE"
  55489. ><TR
  55490. ><TD
  55491. ><DIV
  55492. CLASS="example"
  55493. ><A
  55494. NAME="AEN9949"
  55495. ></A
  55496. ><P
  55497. ><B
  55498. >Beispiel 1. <B
  55499. CLASS="function"
  55500. >range()</B
  55501. ></B
  55502. ></P
  55503. ><TABLE
  55504. BORDER="0"
  55505. BGCOLOR="#E0E0E0"
  55506. CELLPADDING="5"
  55507. ><TR
  55508. ><TD
  55509. ><PRE
  55510. CLASS="php"
  55511. ><?php
  55512. // array(0,1,2,3,4,5,6,7,8,9,10,11,12)
  55513. foreach(range(0, 12) as $number) {
  55514.     echo $number;
  55515. }
  55516.  
  55517. // Der Parameter step wurde in PHP 5.0.0 eingefⁿhrt
  55518. // array(0,10,20,30,40,50,60,70,80,90,100)
  55519. foreach(range(0, 100, 10) as $number) {
  55520.     echo $number;
  55521. }
  55522.  
  55523. // Die Verwendung von Zeichenfolgen wurde in 4.1.0 eingefⁿhrt
  55524. // array('a','b','c','d','e','f','g','h','i');
  55525. foreach(range('a', 'i') as $letter) {
  55526.     echo $letter;
  55527. }
  55528. // array('c','b','a');
  55529. foreach(range('c', 'a') as $letter) {
  55530.     echo $letter;
  55531. }
  55532. ?></PRE
  55533. ></TD
  55534. ></TR
  55535. ></TABLE
  55536. ></DIV
  55537. ></TD
  55538. ></TR
  55539. ></TABLE
  55540. >
  55541.     </P
  55542. ><DIV
  55543. CLASS="note"
  55544. ><BLOCKQUOTE
  55545. CLASS="note"
  55546. ><P
  55547. ><B
  55548. >Anmerkung: </B
  55549. >
  55550.       Vor der Version 4.1.0 hat die Funktion <B
  55551. CLASS="function"
  55552. >range()</B
  55553. > nur
  55554.       aufsteigende Integer Arrays erstellt. Die Unterstⁿtzung fⁿr Zeichenfolgen
  55555.       und Arrays in absteigender Reihenfolge wurde in 4.1.0 hinzugefⁿgt. Werte
  55556.       mit Zeichenfolgen sind auf eine LΣnge von 1 limitiert. Wird eine LΣnge
  55557.       gr÷▀er als 1 eingegeben, wird nur das erste Zeichen verwendet.
  55558.      </P
  55559. ></BLOCKQUOTE
  55560. ></DIV
  55561. ><DIV
  55562. CLASS="caution"
  55563. ><P
  55564. ></P
  55565. ><TABLE
  55566. CLASS="caution"
  55567. BORDER="1"
  55568. WIDTH="100%"
  55569. ><TR
  55570. ><TD
  55571. ALIGN="CENTER"
  55572. ><B
  55573. >Achtung</B
  55574. ></TD
  55575. ></TR
  55576. ><TR
  55577. ><TD
  55578. ALIGN="LEFT"
  55579. ><P
  55580. >       In den PHP Versionen 4.1.0 bis 4.3.2 werden numerische Zeichenfolgen von
  55581.       <B
  55582. CLASS="function"
  55583. >range()</B
  55584. > als Strings, und nicht als integer gesehen.
  55585.       Stattdessen werden diese fⁿr Zeichenfolgen genutzt, z.B. wird
  55586.       <VAR
  55587. CLASS="literal"
  55588. >"4242"</VAR
  55589. > als <VAR
  55590. CLASS="literal"
  55591. >"4"</VAR
  55592. > betrachtet.
  55593.      </P
  55594. ></TD
  55595. ></TR
  55596. ></TABLE
  55597. ></DIV
  55598. ><P
  55599. >      Siehe auch <A
  55600. HREF="#function.shuffle"
  55601. ><B
  55602. CLASS="function"
  55603. >shuffle()</B
  55604. ></A
  55605. > und
  55606.      <A
  55607. HREF="#control-structures.foreach"
  55608. >foreach</A
  55609. >.
  55610.     </P
  55611. ></DIV
  55612. ><H1
  55613. ><A
  55614. NAME="function.reset"
  55615. ></A
  55616. >reset</H1
  55617. ><DIV
  55618. CLASS="refnamediv"
  55619. ><A
  55620. NAME="AEN9965"
  55621. ></A
  55622. ><P
  55623. >    (PHP 3, PHP 4 , PHP 5)</P
  55624. >reset -- 
  55625.      Setzt den internen Zeiger eines Arrays auf sein erstes Element
  55626.     </DIV
  55627. ><DIV
  55628. CLASS="refsect1"
  55629. ><A
  55630. NAME="AEN9968"
  55631. ></A
  55632. ><H2
  55633. >Beschreibung</H2
  55634. >mixed <B
  55635. CLASS="methodname"
  55636. >reset</B
  55637. > ( array array)<BR
  55638. ></BR
  55639. ><P
  55640. >      <B
  55641. CLASS="function"
  55642. >reset()</B
  55643. > setzt den internen Zeiger von
  55644.      <VAR
  55645. CLASS="parameter"
  55646. >array</VAR
  55647. > auf das erste Element, und gibt den Wert
  55648.      des ersten Arrayelements zurⁿck.
  55649.     </P
  55650. ><P
  55651. >      Siehe auch <A
  55652. HREF="#function.current"
  55653. ><B
  55654. CLASS="function"
  55655. >current()</B
  55656. ></A
  55657. >,
  55658.      <A
  55659. HREF="#function.each"
  55660. ><B
  55661. CLASS="function"
  55662. >each()</B
  55663. ></A
  55664. >, <A
  55665. HREF="#function.next"
  55666. ><B
  55667. CLASS="function"
  55668. >next()</B
  55669. ></A
  55670. > und
  55671.      <A
  55672. HREF="#function.prev"
  55673. ><B
  55674. CLASS="function"
  55675. >prev()</B
  55676. ></A
  55677. >.
  55678.     </P
  55679. ></DIV
  55680. ><H1
  55681. ><A
  55682. NAME="function.rsort"
  55683. ></A
  55684. >rsort</H1
  55685. ><DIV
  55686. CLASS="refnamediv"
  55687. ><A
  55688. NAME="AEN9985"
  55689. ></A
  55690. ><P
  55691. >    (PHP 3, PHP 4 , PHP 5)</P
  55692. >rsort -- 
  55693.      Sortiert ein Array in umgekehrter Reihenfolge
  55694.     </DIV
  55695. ><DIV
  55696. CLASS="refsect1"
  55697. ><A
  55698. NAME="AEN9988"
  55699. ></A
  55700. ><H2
  55701. >Beschreibung</H2
  55702. >void <B
  55703. CLASS="methodname"
  55704. >rsort</B
  55705. > ( array array [, int sort_flags])<BR
  55706. ></BR
  55707. ><P
  55708. >      Diese Funktion sortiert ein Array in umgekehrter Reihenfolge (vom
  55709.      h÷chsten zum niedrigsten Wert).
  55710.     </P
  55711. ><P
  55712. >      <TABLE
  55713. WIDTH="100%"
  55714. BORDER="0"
  55715. CELLPADDING="0"
  55716. CELLSPACING="0"
  55717. CLASS="EXAMPLE"
  55718. ><TR
  55719. ><TD
  55720. ><DIV
  55721. CLASS="example"
  55722. ><A
  55723. NAME="AEN10001"
  55724. ></A
  55725. ><P
  55726. ><B
  55727. >Beispiel 1. <B
  55728. CLASS="function"
  55729. >rsort()</B
  55730. ></B
  55731. ></P
  55732. ><TABLE
  55733. BORDER="0"
  55734. BGCOLOR="#E0E0E0"
  55735. CELLPADDING="5"
  55736. ><TR
  55737. ><TD
  55738. ><PRE
  55739. CLASS="php"
  55740. ><?php
  55741. $fruits = array ("Zitrone", "Orange", "Banane", "Apfel");
  55742. rsort ($fruits);
  55743. reset ($fruits);
  55744. while (list ($key, $val) = each ($fruits)) {
  55745.     echo "$key = $val\n";
  55746. }
  55747. ?></PRE
  55748. ></TD
  55749. ></TR
  55750. ></TABLE
  55751. ><P
  55752. >        Dieses Beispiel wⁿrde folgendes ausgeben:
  55753.       </P
  55754. ><TABLE
  55755. BORDER="0"
  55756. BGCOLOR="#E0E0E0"
  55757. CELLPADDING="5"
  55758. ><TR
  55759. ><TD
  55760. ><PRE
  55761. CLASS="screen"
  55762. >0 = Zitrone
  55763. 1 = Orange
  55764. 2 = Banane
  55765. 3 = Apfel</PRE
  55766. ></TD
  55767. ></TR
  55768. ></TABLE
  55769. ></DIV
  55770. ></TD
  55771. ></TR
  55772. ></TABLE
  55773. >
  55774.     </P
  55775. ><P
  55776. >      Die Frⁿchte wurden in umgekehrter alphabetischer Reihenfolge
  55777.      sortiert.
  55778.     </P
  55779. ><P
  55780. >      Sie k÷nnen das Verhalten der Sortierung mittels dem optionalen
  55781.      Parameter <VAR
  55782. CLASS="parameter"
  55783. >sort_flags</VAR
  55784. > beeinflussen, fⁿr
  55785.      Details siehe <A
  55786. HREF="#function.sort"
  55787. ><B
  55788. CLASS="function"
  55789. >sort()</B
  55790. ></A
  55791. >.
  55792.     </P
  55793. ><P
  55794. >      Siehe auch <A
  55795. HREF="#function.arsort"
  55796. ><B
  55797. CLASS="function"
  55798. >arsort()</B
  55799. ></A
  55800. >,
  55801.      <A
  55802. HREF="#function.asort"
  55803. ><B
  55804. CLASS="function"
  55805. >asort()</B
  55806. ></A
  55807. >, <A
  55808. HREF="#function.ksort"
  55809. ><B
  55810. CLASS="function"
  55811. >ksort()</B
  55812. ></A
  55813. >,
  55814.      <A
  55815. HREF="#function.sort"
  55816. ><B
  55817. CLASS="function"
  55818. >sort()</B
  55819. ></A
  55820. > und <A
  55821. HREF="#function.usort"
  55822. ><B
  55823. CLASS="function"
  55824. >usort()</B
  55825. ></A
  55826. >.
  55827.     </P
  55828. ></DIV
  55829. ><H1
  55830. ><A
  55831. NAME="function.shuffle"
  55832. ></A
  55833. >shuffle</H1
  55834. ><DIV
  55835. CLASS="refnamediv"
  55836. ><A
  55837. NAME="AEN10018"
  55838. ></A
  55839. ><P
  55840. >    (PHP 3>= 3.0.8, PHP 4 , PHP 5)</P
  55841. >shuffle -- Mischt die Elemente eines Arrays</DIV
  55842. ><DIV
  55843. CLASS="refsect1"
  55844. ><A
  55845. NAME="AEN10021"
  55846. ></A
  55847. ><H2
  55848. >Beschreibung</H2
  55849. >void <B
  55850. CLASS="methodname"
  55851. >shuffle</B
  55852. > ( array array)<BR
  55853. ></BR
  55854. ><P
  55855. >      Diese Funktion mischt die Reihenfolge der Elemente eines Arrays
  55856.      zufΣllig (shuffle). Benutzen Sie <A
  55857. HREF="#function.srand"
  55858. ><B
  55859. CLASS="function"
  55860. >srand()</B
  55861. ></A
  55862. >, um
  55863.      den Startwert fⁿr den Zufallsgenerator festzulegen.
  55864.      <TABLE
  55865. WIDTH="100%"
  55866. BORDER="0"
  55867. CELLPADDING="0"
  55868. CELLSPACING="0"
  55869. CLASS="EXAMPLE"
  55870. ><TR
  55871. ><TD
  55872. ><DIV
  55873. CLASS="example"
  55874. ><A
  55875. NAME="AEN10031"
  55876. ></A
  55877. ><P
  55878. ><B
  55879. >Beispiel 1. <B
  55880. CLASS="function"
  55881. >shuffle()</B
  55882. ></B
  55883. ></P
  55884. ><TABLE
  55885. BORDER="0"
  55886. BGCOLOR="#E0E0E0"
  55887. CELLPADDING="5"
  55888. ><TR
  55889. ><TD
  55890. ><PRE
  55891. CLASS="php"
  55892. ><?php
  55893. $numbers = range (1,20);
  55894. srand ((float)microtime()*1000000);
  55895. shuffle ($numbers);
  55896. while (list (, $number) = each ($numbers)) {
  55897.     echo "$number ";
  55898. }
  55899. ?></PRE
  55900. ></TD
  55901. ></TR
  55902. ></TABLE
  55903. ></DIV
  55904. ></TD
  55905. ></TR
  55906. ></TABLE
  55907. >
  55908.     </P
  55909. ><DIV
  55910. CLASS="note"
  55911. ><BLOCKQUOTE
  55912. CLASS="note"
  55913. ><P
  55914. ><B
  55915. >Anmerkung: </B
  55916. >Seit PHP 4.2.0 besteht keine
  55917. Notwendigkeit mehr, den Zufallsgenerator fⁿr Zahlen mit
  55918. <A
  55919. HREF="#function.srand"
  55920. ><B
  55921. CLASS="function"
  55922. >srand()</B
  55923. ></A
  55924. > oder <A
  55925. HREF="#function.mt-srand"
  55926. ><B
  55927. CLASS="function"
  55928. >mt_srand()</B
  55929. ></A
  55930. > zu fⁿttern, das
  55931. geschieht nun automatisch.</P
  55932. ></BLOCKQUOTE
  55933. ></DIV
  55934. ><P
  55935. >      Siehe auch <A
  55936. HREF="#function.arsort"
  55937. ><B
  55938. CLASS="function"
  55939. >arsort()</B
  55940. ></A
  55941. >,
  55942.      <A
  55943. HREF="#function.asort"
  55944. ><B
  55945. CLASS="function"
  55946. >asort()</B
  55947. ></A
  55948. >, <A
  55949. HREF="#function.ksort"
  55950. ><B
  55951. CLASS="function"
  55952. >ksort()</B
  55953. ></A
  55954. >,
  55955.      <A
  55956. HREF="#function.rsort"
  55957. ><B
  55958. CLASS="function"
  55959. >rsort()</B
  55960. ></A
  55961. >, <A
  55962. HREF="#function.sort"
  55963. ><B
  55964. CLASS="function"
  55965. >sort()</B
  55966. ></A
  55967. > und
  55968.      <A
  55969. HREF="#function.usort"
  55970. ><B
  55971. CLASS="function"
  55972. >usort()</B
  55973. ></A
  55974. >.
  55975.     </P
  55976. ></DIV
  55977. ><H1
  55978. ><A
  55979. NAME="function.sizeof"
  55980. ></A
  55981. >sizeof</H1
  55982. ><DIV
  55983. CLASS="refnamediv"
  55984. ><A
  55985. NAME="AEN10047"
  55986. ></A
  55987. >sizeof -- Alias fⁿr <A
  55988. HREF="#function.count"
  55989. ><B
  55990. CLASS="function"
  55991. >count()</B
  55992. ></A
  55993. ></DIV
  55994. ><DIV
  55995. CLASS="refsect1"
  55996. ><A
  55997. NAME="AEN10051"
  55998. ></A
  55999. ><H2
  56000. >Beschreibung</H2
  56001. ><P
  56002. >      Diese Funktion ist ein Alias fⁿr <A
  56003. HREF="#function.count"
  56004. ><B
  56005. CLASS="function"
  56006. >count()</B
  56007. ></A
  56008. >.
  56009.     </P
  56010. ></DIV
  56011. ><H1
  56012. ><A
  56013. NAME="function.sort"
  56014. ></A
  56015. >sort</H1
  56016. ><DIV
  56017. CLASS="refnamediv"
  56018. ><A
  56019. NAME="AEN10056"
  56020. ></A
  56021. ><P
  56022. >    (PHP 3, PHP 4 , PHP 5)</P
  56023. >sort -- Sortiert ein Array</DIV
  56024. ><DIV
  56025. CLASS="refsect1"
  56026. ><A
  56027. NAME="AEN10059"
  56028. ></A
  56029. ><H2
  56030. >Beschreibung</H2
  56031. >void <B
  56032. CLASS="methodname"
  56033. >sort</B
  56034. > ( array array [, int sort_flags])<BR
  56035. ></BR
  56036. ><P
  56037. >      Diese Funktion sortiert ein Array. Die Elemente werden
  56038.      aufsteigend vom niedrigsten zum h÷chsten Wert sortiert.
  56039.     </P
  56040. ><P
  56041. >      <TABLE
  56042. WIDTH="100%"
  56043. BORDER="0"
  56044. CELLPADDING="0"
  56045. CELLSPACING="0"
  56046. CLASS="EXAMPLE"
  56047. ><TR
  56048. ><TD
  56049. ><DIV
  56050. CLASS="example"
  56051. ><A
  56052. NAME="AEN10072"
  56053. ></A
  56054. ><P
  56055. ><B
  56056. >Beispiel 1. <B
  56057. CLASS="function"
  56058. >sort()</B
  56059. ></B
  56060. ></P
  56061. ><TABLE
  56062. BORDER="0"
  56063. BGCOLOR="#E0E0E0"
  56064. CELLPADDING="5"
  56065. ><TR
  56066. ><TD
  56067. ><PRE
  56068. CLASS="php"
  56069. ><?php
  56070.  
  56071. $fruits = array ("Zitrone", "Orange", "Banane", "Apfel");
  56072. sort ($fruits);
  56073. reset ($fruits);
  56074. while (list ($key, $val) = each ($fruits)) {
  56075.     echo "fruits[".$key."] = ".$val."\n";
  56076. }
  56077.  
  56078. ?></PRE
  56079. ></TD
  56080. ></TR
  56081. ></TABLE
  56082. ><P
  56083. >        Dieses Beispiel wⁿrde folgendes anzeigen:
  56084.       </P
  56085. ><TABLE
  56086. BORDER="0"
  56087. BGCOLOR="#E0E0E0"
  56088. CELLPADDING="5"
  56089. ><TR
  56090. ><TD
  56091. ><PRE
  56092. CLASS="screen"
  56093. >fruits[0] = Apfel
  56094. fruits[1] = Banane
  56095. fruits[2] = Orange
  56096. fruits[3] = Zitrone</PRE
  56097. ></TD
  56098. ></TR
  56099. ></TABLE
  56100. ></DIV
  56101. ></TD
  56102. ></TR
  56103. ></TABLE
  56104. >
  56105.     </P
  56106. ><P
  56107. >      Die Frⁿchte wurden in alphabetischer Reihenfolge sortiert.
  56108.     </P
  56109. ><P
  56110. >      Der optionale zweite Parameter <VAR
  56111. CLASS="parameter"
  56112. >sort_flags</VAR
  56113. >
  56114.      kann benutzt werden, um das Sortierverhalten mit den folgenden
  56115.      Flags zu beeinflussen.
  56116.     </P
  56117. ><P
  56118. >      Flags fⁿr Sortiertypen:
  56119.      <P
  56120. ></P
  56121. ><UL
  56122. ><LI
  56123. ><P
  56124. >SORT_REGULAR - Vergleiche EintrΣge normal</P
  56125. ></LI
  56126. ><LI
  56127. ><P
  56128. >SORT_NUMERIC - Vergleiche EintrΣge numerisch</P
  56129. ></LI
  56130. ><LI
  56131. ><P
  56132. >SORT_STRING - Vergleiche EintrΣge als Strings</P
  56133. ></LI
  56134. ></UL
  56135. >
  56136.     </P
  56137. ><DIV
  56138. CLASS="note"
  56139. ><BLOCKQUOTE
  56140. CLASS="note"
  56141. ><P
  56142. ><B
  56143. >Anmerkung: </B
  56144. >
  56145.       Der zweite Parameter wurde in PHP 4 eingefⁿhrt.
  56146.      </P
  56147. ></BLOCKQUOTE
  56148. ></DIV
  56149. ><P
  56150. >      Siehe auch <A
  56151. HREF="#function.arsort"
  56152. ><B
  56153. CLASS="function"
  56154. >arsort()</B
  56155. ></A
  56156. >,
  56157.      <A
  56158. HREF="#function.asort"
  56159. ><B
  56160. CLASS="function"
  56161. >asort()</B
  56162. ></A
  56163. >, <A
  56164. HREF="#function.ksort"
  56165. ><B
  56166. CLASS="function"
  56167. >ksort()</B
  56168. ></A
  56169. >,
  56170.      <A
  56171. HREF="#function.natsort"
  56172. ><B
  56173. CLASS="function"
  56174. >natsort()</B
  56175. ></A
  56176. >, <A
  56177. HREF="#function.natcasesort"
  56178. ><B
  56179. CLASS="function"
  56180. >natcasesort()</B
  56181. ></A
  56182. >,
  56183.      <A
  56184. HREF="#function.rsort"
  56185. ><B
  56186. CLASS="function"
  56187. >rsort()</B
  56188. ></A
  56189. >, <A
  56190. HREF="#function.usort"
  56191. ><B
  56192. CLASS="function"
  56193. >usort()</B
  56194. ></A
  56195. >,
  56196.      <A
  56197. HREF="#function.array-multisort"
  56198. ><B
  56199. CLASS="function"
  56200. >array_multisort()</B
  56201. ></A
  56202. > und
  56203.      <A
  56204. HREF="#function.uksort"
  56205. ><B
  56206. CLASS="function"
  56207. >uksort()</B
  56208. ></A
  56209. >.
  56210.     </P
  56211. ></DIV
  56212. ><H1
  56213. ><A
  56214. NAME="function.uasort"
  56215. ></A
  56216. >uasort</H1
  56217. ><DIV
  56218. CLASS="refnamediv"
  56219. ><A
  56220. NAME="AEN10102"
  56221. ></A
  56222. ><P
  56223. >    (PHP 3>= 3.0.4, PHP 4 , PHP 5)</P
  56224. >uasort -- 
  56225.      Sortiert ein Array mittels einer benutzerdefinierten
  56226.      Vergleichsfunktion und behΣlt Indexassoziationen bei.
  56227.     </DIV
  56228. ><DIV
  56229. CLASS="refsect1"
  56230. ><A
  56231. NAME="AEN10105"
  56232. ></A
  56233. ><H2
  56234. >Beschreibung</H2
  56235. >void <B
  56236. CLASS="methodname"
  56237. >uasort</B
  56238. > ( array array, callback cmp_function)<BR
  56239. ></BR
  56240. ><P
  56241. >      Diese Funktion sortiert ein Array so, dass die Beziehung der
  56242.      Indices zu den Arrayelementen beibehalten bleibt. Dies wird
  56243.      hauptsΣchlich bei assoziativen Arrays angewandt, wenn die
  56244.      aktuelle Reihenfolge der Arrayelemente signifikant ist. Die
  56245.      Vergleichsfunktion wird vom Benutzer definiert.
  56246.     </P
  56247. ><DIV
  56248. CLASS="note"
  56249. ><BLOCKQUOTE
  56250. CLASS="note"
  56251. ><P
  56252. ><B
  56253. >Anmerkung: </B
  56254. >
  56255.       Siehe <A
  56256. HREF="#function.usort"
  56257. ><B
  56258. CLASS="function"
  56259. >usort()</B
  56260. ></A
  56261. > und <A
  56262. HREF="#function.uksort"
  56263. ><B
  56264. CLASS="function"
  56265. >uksort()</B
  56266. ></A
  56267. >
  56268.       fⁿr Beispiele von benutzerdefinierten Vergleichsfunktionen
  56269.      </P
  56270. ></BLOCKQUOTE
  56271. ></DIV
  56272. ><P
  56273. >      Siehe auch <A
  56274. HREF="#function.usort"
  56275. ><B
  56276. CLASS="function"
  56277. >usort()</B
  56278. ></A
  56279. >, <A
  56280. HREF="#function.uksort"
  56281. ><B
  56282. CLASS="function"
  56283. >uksort()</B
  56284. ></A
  56285. >,
  56286.      <A
  56287. HREF="#function.sort"
  56288. ><B
  56289. CLASS="function"
  56290. >sort()</B
  56291. ></A
  56292. >, <A
  56293. HREF="#function.asort"
  56294. ><B
  56295. CLASS="function"
  56296. >asort()</B
  56297. ></A
  56298. >,
  56299.      <A
  56300. HREF="#function.arsort"
  56301. ><B
  56302. CLASS="function"
  56303. >arsort()</B
  56304. ></A
  56305. >, <A
  56306. HREF="#function.ksort"
  56307. ><B
  56308. CLASS="function"
  56309. >ksort()</B
  56310. ></A
  56311. >,
  56312.      und <A
  56313. HREF="#function.rsort"
  56314. ><B
  56315. CLASS="function"
  56316. >rsort()</B
  56317. ></A
  56318. >.
  56319.     </P
  56320. ></DIV
  56321. ><H1
  56322. ><A
  56323. NAME="function.uksort"
  56324. ></A
  56325. >uksort</H1
  56326. ><DIV
  56327. CLASS="refnamediv"
  56328. ><A
  56329. NAME="AEN10130"
  56330. ></A
  56331. ><P
  56332. >    (PHP 3>= 3.0.4, PHP 4 , PHP 5)</P
  56333. >uksort -- 
  56334.      Sortiert ein Array nach Schlⁿsseln mittels einer
  56335.      benutzerdefinierten Vergleichsfunktion.
  56336.     </DIV
  56337. ><DIV
  56338. CLASS="refsect1"
  56339. ><A
  56340. NAME="AEN10133"
  56341. ></A
  56342. ><H2
  56343. >Beschreibung</H2
  56344. >void <B
  56345. CLASS="methodname"
  56346. >uksort</B
  56347. > ( array array, callback cmp_function)<BR
  56348. ></BR
  56349. ><P
  56350. >      Diese Funktion sortiert die Schlⁿssel eines Arrays mittels einer
  56351.      benutzerdefinierten Vergleichsfunktion. Soll das Array nach nicht
  56352.      trivialen Kriterien sortiert werden, sollten Sie diese Funktion
  56353.      verwenden.
  56354.     </P
  56355. ><P
  56356. >      <TABLE
  56357. WIDTH="100%"
  56358. BORDER="0"
  56359. CELLPADDING="0"
  56360. CELLSPACING="0"
  56361. CLASS="EXAMPLE"
  56362. ><TR
  56363. ><TD
  56364. ><DIV
  56365. CLASS="example"
  56366. ><A
  56367. NAME="AEN10146"
  56368. ></A
  56369. ><P
  56370. ><B
  56371. >Beispiel 1. <B
  56372. CLASS="function"
  56373. >uksort()</B
  56374. ></B
  56375. ></P
  56376. ><TABLE
  56377. BORDER="0"
  56378. BGCOLOR="#E0E0E0"
  56379. CELLPADDING="5"
  56380. ><TR
  56381. ><TD
  56382. ><PRE
  56383. CLASS="php"
  56384. >function cmp ($a, $b) {
  56385.     if ($a == $b) return 0;
  56386.     return ($a > $b) ? -1 : 1;
  56387. }
  56388.  
  56389. $a = array (4 => "vier", 3 => "drei", 20 => "zwanzig", 10 => "zehn");
  56390.  
  56391. uksort ($a, "cmp");
  56392.  
  56393. while (list ($key, $value) = each ($a)) {
  56394.     echo "$key: $value\n";
  56395. }</PRE
  56396. ></TD
  56397. ></TR
  56398. ></TABLE
  56399. ><P
  56400. >        Dieses Beispiel wⁿrde folgendes ausgeben:
  56401.       </P
  56402. ><TABLE
  56403. BORDER="0"
  56404. BGCOLOR="#E0E0E0"
  56405. CELLPADDING="5"
  56406. ><TR
  56407. ><TD
  56408. ><PRE
  56409. CLASS="screen"
  56410. >20: zwanzig
  56411. 10: zehn
  56412. 4: vier
  56413. 3: drei</PRE
  56414. ></TD
  56415. ></TR
  56416. ></TABLE
  56417. ></DIV
  56418. ></TD
  56419. ></TR
  56420. ></TABLE
  56421. >
  56422.     </P
  56423. ><P
  56424. >      Siehe auch <A
  56425. HREF="#function.usort"
  56426. ><B
  56427. CLASS="function"
  56428. >usort()</B
  56429. ></A
  56430. >, <A
  56431. HREF="#function.uasort"
  56432. ><B
  56433. CLASS="function"
  56434. >uasort()</B
  56435. ></A
  56436. >,
  56437.      <A
  56438. HREF="#function.sort"
  56439. ><B
  56440. CLASS="function"
  56441. >sort()</B
  56442. ></A
  56443. >, <A
  56444. HREF="#function.asort"
  56445. ><B
  56446. CLASS="function"
  56447. >asort()</B
  56448. ></A
  56449. >,
  56450.      <A
  56451. HREF="#function.arsort"
  56452. ><B
  56453. CLASS="function"
  56454. >arsort()</B
  56455. ></A
  56456. >, <A
  56457. HREF="#function.ksort"
  56458. ><B
  56459. CLASS="function"
  56460. >ksort()</B
  56461. ></A
  56462. >,
  56463.      <A
  56464. HREF="#function.natsort"
  56465. ><B
  56466. CLASS="function"
  56467. >natsort()</B
  56468. ></A
  56469. > und <A
  56470. HREF="#function.rsort"
  56471. ><B
  56472. CLASS="function"
  56473. >rsort()</B
  56474. ></A
  56475. >.
  56476.     </P
  56477. ></DIV
  56478. ><H1
  56479. ><A
  56480. NAME="function.usort"
  56481. ></A
  56482. >usort</H1
  56483. ><DIV
  56484. CLASS="refnamediv"
  56485. ><A
  56486. NAME="AEN10162"
  56487. ></A
  56488. ><P
  56489. >    (PHP 3>= 3.0.3, PHP 4 , PHP 5)</P
  56490. >usort -- 
  56491.      Sortiert ein Array nach Werten mittels einer benutzerdefinierten
  56492.      Vergleichsfunktion.
  56493.     </DIV
  56494. ><DIV
  56495. CLASS="refsect1"
  56496. ><A
  56497. NAME="AEN10165"
  56498. ></A
  56499. ><H2
  56500. >Beschreibung</H2
  56501. >void <B
  56502. CLASS="methodname"
  56503. >usort</B
  56504. > ( array array, callback cmp_function)<BR
  56505. ></BR
  56506. ><P
  56507. >      Diese Funktion sortiert ein Array nach seinen Werten mittels
  56508.      einer benutzerdefinierten Vergleichsfunktion. Soll das Array nach
  56509.      nicht trivialen Kriterien sortiert werden, sollten Sie diese
  56510.      Funktion verwenden.
  56511.     </P
  56512. ><P
  56513. >      Die Vergleichsfunktion muss einen Integer zurⁿckgeben, der
  56514.      kleiner, gleich, oder gr÷▀er ist als <TT
  56515. CLASS="constant"
  56516. ><B
  56517. >NULL</B
  56518. ></TT
  56519. >, wenn fⁿr das erste
  56520.      Argument auch angenommen wird, dass es kleiner, gleich, oder
  56521.      gr÷▀er ist als das zweite. 
  56522.     </P
  56523. ><P
  56524. >      <DIV
  56525. CLASS="note"
  56526. ><BLOCKQUOTE
  56527. CLASS="note"
  56528. ><P
  56529. ><B
  56530. >Anmerkung: </B
  56531. >
  56532.        Sind zwei Elemente gleich, ist deren Reihenfolge nicht definiert. Bis zu
  56533.        PHP 4.0.6 wⁿrde die benutzerdefinierte Funktion die originΣre Reihenfolge
  56534.        beibehalten, doch seit der Einfⁿhrung des neuen Sortieralgorhythmus mit
  56535.        4.1.0 ist dies nicht mehr der Fall, da es keine effiziente L÷sung dafⁿr
  56536.        gibt.
  56537.       </P
  56538. ></BLOCKQUOTE
  56539. ></DIV
  56540. >
  56541.     </P
  56542. ><P
  56543. >      <TABLE
  56544. WIDTH="100%"
  56545. BORDER="0"
  56546. CELLPADDING="0"
  56547. CELLSPACING="0"
  56548. CLASS="EXAMPLE"
  56549. ><TR
  56550. ><TD
  56551. ><DIV
  56552. CLASS="example"
  56553. ><A
  56554. NAME="AEN10183"
  56555. ></A
  56556. ><P
  56557. ><B
  56558. >Beispiel 1. <B
  56559. CLASS="function"
  56560. >usort()</B
  56561. ></B
  56562. ></P
  56563. ><TABLE
  56564. BORDER="0"
  56565. BGCOLOR="#E0E0E0"
  56566. CELLPADDING="5"
  56567. ><TR
  56568. ><TD
  56569. ><PRE
  56570. CLASS="php"
  56571. ><?php
  56572. function cmp ($a, $b) {
  56573.     if ($a == $b) return 0;
  56574.     return ($a < $b) ? -1 : 1;
  56575. }
  56576.  
  56577. $a = array (3, 2, 5, 6, 1);
  56578.  
  56579. usort ($a, "cmp");
  56580.  
  56581. while (list ($key, $value) = each ($a)) {
  56582.     echo "$key: $value\n";
  56583. }
  56584. ?></PRE
  56585. ></TD
  56586. ></TR
  56587. ></TABLE
  56588. ><P
  56589. >        Dieses Beispiel wⁿrde folgendes anzeigen:
  56590.       </P
  56591. ><TABLE
  56592. BORDER="0"
  56593. BGCOLOR="#E0E0E0"
  56594. CELLPADDING="5"
  56595. ><TR
  56596. ><TD
  56597. ><PRE
  56598. CLASS="screen"
  56599. >0: 1
  56600. 1: 2
  56601. 2: 3
  56602. 3: 5
  56603. 4: 6</PRE
  56604. ></TD
  56605. ></TR
  56606. ></TABLE
  56607. ></DIV
  56608. ></TD
  56609. ></TR
  56610. ></TABLE
  56611. >
  56612.     </P
  56613. ><DIV
  56614. CLASS="note"
  56615. ><BLOCKQUOTE
  56616. CLASS="note"
  56617. ><P
  56618. ><B
  56619. >Anmerkung: </B
  56620. >
  56621.       Offensichtlich wⁿrde <A
  56622. HREF="#function.sort"
  56623. ><B
  56624. CLASS="function"
  56625. >sort()</B
  56626. ></A
  56627. > fⁿr diesen
  56628.       einfachen Fall besser passen.
  56629.      </P
  56630. ></BLOCKQUOTE
  56631. ></DIV
  56632. ><P
  56633. >      <TABLE
  56634. WIDTH="100%"
  56635. BORDER="0"
  56636. CELLPADDING="0"
  56637. CELLSPACING="0"
  56638. CLASS="EXAMPLE"
  56639. ><TR
  56640. ><TD
  56641. ><DIV
  56642. CLASS="example"
  56643. ><A
  56644. NAME="AEN10193"
  56645. ></A
  56646. ><P
  56647. ><B
  56648. >Beispiel 2. 
  56649.        <B
  56650. CLASS="function"
  56651. >usort()</B
  56652. > mit einem mehrdimensionalen Array
  56653.       </B
  56654. ></P
  56655. ><TABLE
  56656. BORDER="0"
  56657. BGCOLOR="#E0E0E0"
  56658. CELLPADDING="5"
  56659. ><TR
  56660. ><TD
  56661. ><PRE
  56662. CLASS="php"
  56663. ><?php
  56664. function cmp ($a, $b) {
  56665.     return strcmp($a["fruit"], $b["fruit"]);
  56666. }
  56667.  
  56668. $fruits[0]["fruit"] = "Zitronen";
  56669. $fruits[1]["fruit"] = "─pfel";
  56670. $fruits[2]["fruit"] = "Trauben";
  56671.  
  56672. usort($fruits, "cmp");
  56673.  
  56674. while (list ($key, $value) = each ($fruits)) {
  56675.     echo "\$fruits[$key]: " . $value["fruit"] . "\n";
  56676. }
  56677. ?></PRE
  56678. ></TD
  56679. ></TR
  56680. ></TABLE
  56681. ><P
  56682. >        Wird ein mehrdimensionales Array sortiert, enthalten $a und $b
  56683.        Referenzen zu dem ersten Index des Arrays.
  56684.       </P
  56685. ><P
  56686. >        Dieses Beispiel wⁿrde folgendes anzeigen:
  56687.       </P
  56688. ><TABLE
  56689. BORDER="0"
  56690. BGCOLOR="#E0E0E0"
  56691. CELLPADDING="5"
  56692. ><TR
  56693. ><TD
  56694. ><PRE
  56695. CLASS="screen"
  56696. >$fruits[0]: ─pfel
  56697. $fruits[1]: Trauben
  56698. $fruits[2]: Zitronen</PRE
  56699. ></TD
  56700. ></TR
  56701. ></TABLE
  56702. ></DIV
  56703. ></TD
  56704. ></TR
  56705. ></TABLE
  56706. >
  56707.     </P
  56708. ><P
  56709. >      <TABLE
  56710. WIDTH="100%"
  56711. BORDER="0"
  56712. CELLPADDING="0"
  56713. CELLSPACING="0"
  56714. CLASS="EXAMPLE"
  56715. ><TR
  56716. ><TD
  56717. ><DIV
  56718. CLASS="example"
  56719. ><A
  56720. NAME="AEN10201"
  56721. ></A
  56722. ><P
  56723. ><B
  56724. >Beispiel 3. 
  56725.        <B
  56726. CLASS="function"
  56727. >usort()</B
  56728. > mit Verwendung einer Member Funktion eines Objektes
  56729.       </B
  56730. ></P
  56731. ><TABLE
  56732. BORDER="0"
  56733. BGCOLOR="#E0E0E0"
  56734. CELLPADDING="5"
  56735. ><TR
  56736. ><TD
  56737. ><PRE
  56738. CLASS="php"
  56739. ><?php
  56740. class TestObj {
  56741.     var $name;
  56742.  
  56743.     function TestObj($name)
  56744.     {
  56745.         $this->name = $name;
  56746.     }
  56747.  
  56748.     /* Dies ist die statische Vergleichsfunktion: */
  56749.     function cmp_obj($a, $b)
  56750.     {
  56751.         $al = strtolower($a->name);
  56752.         $bl = strtolower($b->name);
  56753.         if ($al == $bl) return 0;
  56754.         return ($al > $bl) ? +1 : -1;
  56755.     }
  56756. }
  56757.  
  56758. $a[] = new TestObj("c");
  56759. $a[] = new TestObj("b");
  56760. $a[] = new TestObj("d");
  56761.  
  56762. uasort($a, array ("TestObj", "cmp_obj"));
  56763.  
  56764. foreach ($a as $item) {
  56765.     print $item->name."\n";
  56766. }
  56767. ?></PRE
  56768. ></TD
  56769. ></TR
  56770. ></TABLE
  56771. ><P
  56772. >        Dieses Beispiel wⁿrde folgendes anzeigen:
  56773.       </P
  56774. ><TABLE
  56775. BORDER="0"
  56776. BGCOLOR="#E0E0E0"
  56777. CELLPADDING="5"
  56778. ><TR
  56779. ><TD
  56780. ><PRE
  56781. CLASS="screen"
  56782. >b
  56783. c
  56784. d</PRE
  56785. ></TD
  56786. ></TR
  56787. ></TABLE
  56788. ></DIV
  56789. ></TD
  56790. ></TR
  56791. ></TABLE
  56792. >
  56793.     </P
  56794. ><P
  56795. >      Siehe auch <A
  56796. HREF="#function.uasort"
  56797. ><B
  56798. CLASS="function"
  56799. >uasort()</B
  56800. ></A
  56801. >,
  56802.      <A
  56803. HREF="#function.uksort"
  56804. ><B
  56805. CLASS="function"
  56806. >uksort()</B
  56807. ></A
  56808. >, <A
  56809. HREF="#function.sort"
  56810. ><B
  56811. CLASS="function"
  56812. >sort()</B
  56813. ></A
  56814. >,
  56815.      <A
  56816. HREF="#function.asort"
  56817. ><B
  56818. CLASS="function"
  56819. >asort()</B
  56820. ></A
  56821. >,
  56822.      <A
  56823. HREF="#function.arsort"
  56824. ><B
  56825. CLASS="function"
  56826. >arsort()</B
  56827. ></A
  56828. >,<A
  56829. HREF="#function.ksort"
  56830. ><B
  56831. CLASS="function"
  56832. >ksort()</B
  56833. ></A
  56834. >,
  56835.      <A
  56836. HREF="#function.natsort"
  56837. ><B
  56838. CLASS="function"
  56839. >natsort()</B
  56840. ></A
  56841. > und <A
  56842. HREF="#function.rsort"
  56843. ><B
  56844. CLASS="function"
  56845. >rsort()</B
  56846. ></A
  56847. >.
  56848.     </P
  56849. ></DIV
  56850. ></DIV
  56851. ><DIV
  56852. CLASS="reference"
  56853. ><A
  56854. NAME="ref.aspell"
  56855. ></A
  56856. ><DIV
  56857. CLASS="TITLEPAGE"
  56858. ><H1
  56859. CLASS="title"
  56860. >III. Aspell Funktionen [veraltet]</H1
  56861. ><DIV
  56862. CLASS="PARTINTRO"
  56863. ><A
  56864. NAME="AEN10219"
  56865. ></A
  56866. ><DIV
  56867. CLASS="section"
  56868. ><H2
  56869. CLASS="section"
  56870. ><A
  56871. NAME="aspell.intro"
  56872. >Einfⁿhrung</A
  56873. ></H2
  56874. ><P
  56875. >     Die <B
  56876. CLASS="function"
  56877. >aspell()</B
  56878. > Funktionen erlauben es ein Wort
  56879.     auf korrekte Rechtschreibung zu prⁿfen und Alternativen
  56880.     anzubieten.
  56881.    </P
  56882. ><DIV
  56883. CLASS="note"
  56884. ><BLOCKQUOTE
  56885. CLASS="note"
  56886. ><P
  56887. ><B
  56888. >Anmerkung: </B
  56889. >
  56890.      Diese Erweiterung wurde aus <VAR
  56891. CLASS="literal"
  56892. >PHP</VAR
  56893. > entfernt und steht seit
  56894.      der Version 4.3.0 nicht mehr zur Verfⁿgung. Falls Sie eine
  56895.      Rechtschreibprⁿfung mit PHP benutzen wollen, verwenden Sie statt dessen die
  56896.      <A
  56897. HREF="#ref.pspell"
  56898. >Pspell Funktionen</A
  56899. >. Diese nutzen die Pspell
  56900.      Bibliothek und arbeiten mit neueren Versionen von Aspell zusammen.
  56901.     </P
  56902. ></BLOCKQUOTE
  56903. ></DIV
  56904. ></DIV
  56905. ><DIV
  56906. CLASS="section"
  56907. ><HR><H2
  56908. CLASS="section"
  56909. ><A
  56910. NAME="aspell.requirements"
  56911. >Anforderungen</A
  56912. ></H2
  56913. ><P
  56914. >      Aspell arbeitet nur mit ziemlich alten (bis .27.* oder so) Versionen der
  56915.      Aspell Bibliothek zusammen. Weder dieses Modul noch jene Versionen der
  56916.      Aspell Bibliothek werden nicht mehr lΣnger unterstⁿtzt.Sie ben÷tigen die
  56917.      aspell-Bibliothek von: <A
  56918. HREF="http://aspell.sourceforge.net/"
  56919. TARGET="_top"
  56920. >http://aspell.sourceforge.net/</A
  56921. >.
  56922.     </P
  56923. ></DIV
  56924. ><DIV
  56925. CLASS="section"
  56926. ><HR><H2
  56927. CLASS="section"
  56928. ><A
  56929. NAME="aspell.installation"
  56930. >Installation</A
  56931. ></H2
  56932. ><P
  56933. >   Diese Funktionen stehen nur zur Verfⁿgung, wenn Sie <VAR
  56934. CLASS="literal"
  56935. >PHP</VAR
  56936. >
  56937.   mit der Option <VAR
  56938. CLASS="option"
  56939. >--with-aspell=[DIR]</VAR
  56940. >
  56941.   konfiguriert haben.
  56942.  </P
  56943. ></DIV
  56944. ><DIV
  56945. CLASS="section"
  56946. ><HR><H2
  56947. CLASS="section"
  56948. ><A
  56949. NAME="aspell.seealso"
  56950. >Siehe auch</A
  56951. ></H2
  56952. ><P
  56953. >      Siehe auch <A
  56954. HREF="#ref.pspell"
  56955. >pspell</A
  56956. >.
  56957.     </P
  56958. ></DIV
  56959. ></DIV
  56960. ><DIV
  56961. CLASS="TOC"
  56962. ><DL
  56963. ><DT
  56964. ><B
  56965. >Inhaltsverzeichnis</B
  56966. ></DT
  56967. ><DT
  56968. ><A
  56969. HREF="#function.aspell-check-raw"
  56970. >aspell_check-raw</A
  56971. > -- 
  56972.      ▄berprⁿft ein Wort genauso wie es ⁿbergeben wird [veraltet]
  56973.     </DT
  56974. ><DT
  56975. ><A
  56976. HREF="#function.aspell-check"
  56977. >aspell_check</A
  56978. > -- ▄berprⁿft ein Wort [veraltet]</DT
  56979. ><DT
  56980. ><A
  56981. HREF="#function.aspell-new"
  56982. >aspell_new</A
  56983. > -- LΣdt ein neues W÷rterbuch [veraltet]</DT
  56984. ><DT
  56985. ><A
  56986. HREF="#function.aspell-suggest"
  56987. >aspell_suggest</A
  56988. > -- SchlΣgt m÷gliche Schreibweisen vor [veraltet]</DT
  56989. ></DL
  56990. ></DIV
  56991. ></DIV
  56992. ><H1
  56993. ><A
  56994. NAME="function.aspell-check-raw"
  56995. ></A
  56996. >aspell_check-raw</H1
  56997. ><DIV
  56998. CLASS="refnamediv"
  56999. ><A
  57000. NAME="AEN10242"
  57001. ></A
  57002. ><P
  57003. >    (PHP 3>= 3.0.7, PHP 4  <= 4.2.3)</P
  57004. >aspell_check-raw -- 
  57005.      ▄berprⁿft ein Wort genauso wie es ⁿbergeben wird [veraltet]
  57006.     </DIV
  57007. ><DIV
  57008. CLASS="refsect1"
  57009. ><A
  57010. NAME="AEN10245"
  57011. ></A
  57012. ><H2
  57013. >Beschreibung</H2
  57014. >boolean <B
  57015. CLASS="methodname"
  57016. >aspell_check_raw</B
  57017. > ( int W÷rterbuchkennung, string Wort)<BR
  57018. ></BR
  57019. ><P
  57020. >      <A
  57021. HREF="#function.aspell-check-raw"
  57022. ><B
  57023. CLASS="function"
  57024. >aspell_check_raw()</B
  57025. ></A
  57026. > ⁿberprⁿft die
  57027.      Rechtschreibung eines Wortes ohne die Gro▀/Kleinschreibung zu
  57028.      variieren oder das Wort in irgendeiner Weise zu kⁿrzen. Liefert
  57029.      <TT
  57030. CLASS="constant"
  57031. ><B
  57032. >TRUE</B
  57033. ></TT
  57034. >, wenn das Wort korrekt ist und sonst <TT
  57035. CLASS="constant"
  57036. ><B
  57037. >FALSE</B
  57038. ></TT
  57039. >.
  57040.     </P
  57041. ><P
  57042. >      <TABLE
  57043. WIDTH="100%"
  57044. BORDER="0"
  57045. CELLPADDING="0"
  57046. CELLSPACING="0"
  57047. CLASS="EXAMPLE"
  57048. ><TR
  57049. ><TD
  57050. ><DIV
  57051. CLASS="example"
  57052. ><A
  57053. NAME="AEN10261"
  57054. ></A
  57055. ><P
  57056. ><B
  57057. >Beispiel 1. <A
  57058. HREF="#function.aspell-check-raw"
  57059. ><B
  57060. CLASS="function"
  57061. >aspell_check_raw()</B
  57062. ></A
  57063. ></B
  57064. ></P
  57065. ><TABLE
  57066. BORDER="0"
  57067. BGCOLOR="#E0E0E0"
  57068. CELLPADDING="5"
  57069. ><TR
  57070. ><TD
  57071. ><PRE
  57072. CLASS="php"
  57073. ><?php
  57074. $aspell_link = aspell_new("english");
  57075.  
  57076. if (aspell_check_raw($aspell_link, "test")) {
  57077.     echo "Gⁿltige Schreibweise";
  57078. } else {
  57079.     echo "Bedaure, falsche Schreibweise";
  57080. }
  57081. ?></PRE
  57082. ></TD
  57083. ></TR
  57084. ></TABLE
  57085. ></DIV
  57086. ></TD
  57087. ></TR
  57088. ></TABLE
  57089. >
  57090.     </P
  57091. ></DIV
  57092. ><H1
  57093. ><A
  57094. NAME="function.aspell-check"
  57095. ></A
  57096. >aspell_check</H1
  57097. ><DIV
  57098. CLASS="refnamediv"
  57099. ><A
  57100. NAME="AEN10266"
  57101. ></A
  57102. ><P
  57103. >    (PHP 3>= 3.0.7, PHP 4  <= 4.2.3)</P
  57104. >aspell_check -- ▄berprⁿft ein Wort [veraltet]</DIV
  57105. ><DIV
  57106. CLASS="refsect1"
  57107. ><A
  57108. NAME="AEN10269"
  57109. ></A
  57110. ><H2
  57111. >Beschreibung</H2
  57112. >boolean <B
  57113. CLASS="methodname"
  57114. >aspell_check</B
  57115. > ( int W÷rterbuchkennung, string Wort)<BR
  57116. ></BR
  57117. ><P
  57118. >      <B
  57119. CLASS="function"
  57120. >aspell_check()</B
  57121. > ⁿberprⁿft die Rechtschreibung
  57122.      eines Wortes und liefert <TT
  57123. CLASS="constant"
  57124. ><B
  57125. >TRUE</B
  57126. ></TT
  57127. >, wenn das Wort korrekt ist,
  57128.      ansonsten <TT
  57129. CLASS="constant"
  57130. ><B
  57131. >FALSE</B
  57132. ></TT
  57133. >.
  57134.     </P
  57135. ><P
  57136. >      <TABLE
  57137. WIDTH="100%"
  57138. BORDER="0"
  57139. CELLPADDING="0"
  57140. CELLSPACING="0"
  57141. CLASS="EXAMPLE"
  57142. ><TR
  57143. ><TD
  57144. ><DIV
  57145. CLASS="example"
  57146. ><A
  57147. NAME="AEN10285"
  57148. ></A
  57149. ><P
  57150. ><B
  57151. >Beispiel 1. aspell_check</B
  57152. ></P
  57153. ><TABLE
  57154. BORDER="0"
  57155. BGCOLOR="#E0E0E0"
  57156. CELLPADDING="5"
  57157. ><TR
  57158. ><TD
  57159. ><PRE
  57160. CLASS="php"
  57161. ><?php
  57162. $aspell_link = aspell_new("english");
  57163.  
  57164. if (aspell_check($aspell_link, "testt")) {
  57165.     echo "Gⁿltige Schreibweise";
  57166. } else {
  57167.     echo "Bedaure, falsche Schreibweise";
  57168. }
  57169. ?></PRE
  57170. ></TD
  57171. ></TR
  57172. ></TABLE
  57173. ></DIV
  57174. ></TD
  57175. ></TR
  57176. ></TABLE
  57177. >
  57178.     </P
  57179. ></DIV
  57180. ><H1
  57181. ><A
  57182. NAME="function.aspell-new"
  57183. ></A
  57184. >aspell_new</H1
  57185. ><DIV
  57186. CLASS="refnamediv"
  57187. ><A
  57188. NAME="AEN10289"
  57189. ></A
  57190. ><P
  57191. >    (PHP 3>= 3.0.7, PHP 4  <= 4.2.3)</P
  57192. >aspell_new -- LΣdt ein neues W÷rterbuch [veraltet]</DIV
  57193. ><DIV
  57194. CLASS="refsect1"
  57195. ><A
  57196. NAME="AEN10292"
  57197. ></A
  57198. ><H2
  57199. >Beschreibung</H2
  57200. >int <B
  57201. CLASS="methodname"
  57202. >aspell_new</B
  57203. > ( string master, string personal)<BR
  57204. ></BR
  57205. ><P
  57206. >      <B
  57207. CLASS="function"
  57208. >aspell_new()</B
  57209. > ÷ffnet ein neues W÷rterbuch und
  57210.      liefert eine W÷rterbuchkennung zurⁿck, die von anderen
  57211.      aspell-Funktionen gebraucht wird. Liefert <TT
  57212. CLASS="constant"
  57213. ><B
  57214. >FALSE</B
  57215. ></TT
  57216. > bei einem Fehler.
  57217.     </P
  57218. ><P
  57219. >      <TABLE
  57220. WIDTH="100%"
  57221. BORDER="0"
  57222. CELLPADDING="0"
  57223. CELLSPACING="0"
  57224. CLASS="EXAMPLE"
  57225. ><TR
  57226. ><TD
  57227. ><DIV
  57228. CLASS="example"
  57229. ><A
  57230. NAME="AEN10307"
  57231. ></A
  57232. ><P
  57233. ><B
  57234. >Beispiel 1. aspell_new</B
  57235. ></P
  57236. ><TABLE
  57237. BORDER="0"
  57238. BGCOLOR="#E0E0E0"
  57239. CELLPADDING="5"
  57240. ><TR
  57241. ><TD
  57242. ><PRE
  57243. CLASS="php"
  57244. ><?php
  57245. $aspell_link = aspell_new("english");
  57246. ?></PRE
  57247. ></TD
  57248. ></TR
  57249. ></TABLE
  57250. ></DIV
  57251. ></TD
  57252. ></TR
  57253. ></TABLE
  57254. >
  57255.     </P
  57256. ></DIV
  57257. ><H1
  57258. ><A
  57259. NAME="function.aspell-suggest"
  57260. ></A
  57261. >aspell_suggest</H1
  57262. ><DIV
  57263. CLASS="refnamediv"
  57264. ><A
  57265. NAME="AEN10311"
  57266. ></A
  57267. ><P
  57268. >    (PHP 3>= 3.0.7, PHP 4  <= 4.2.3)</P
  57269. >aspell_suggest -- SchlΣgt m÷gliche Schreibweisen vor [veraltet]</DIV
  57270. ><DIV
  57271. CLASS="refsect1"
  57272. ><A
  57273. NAME="AEN10314"
  57274. ></A
  57275. ><H2
  57276. >Beschreibung</H2
  57277. >array <B
  57278. CLASS="methodname"
  57279. >aspell_suggest</B
  57280. > ( int W÷rterbuchkennung, string Wort)<BR
  57281. ></BR
  57282. ><P
  57283. >      <B
  57284. CLASS="function"
  57285. >aspell_suggest()</B
  57286. > liefert ein Array mit
  57287.      m÷glichen Schreibweisen eines ⁿbergebenen Wortes.
  57288.     </P
  57289. ><P
  57290. >      <TABLE
  57291. WIDTH="100%"
  57292. BORDER="0"
  57293. CELLPADDING="0"
  57294. CELLSPACING="0"
  57295. CLASS="EXAMPLE"
  57296. ><TR
  57297. ><TD
  57298. ><DIV
  57299. CLASS="example"
  57300. ><A
  57301. NAME="AEN10328"
  57302. ></A
  57303. ><P
  57304. ><B
  57305. >Beispiel 1. <B
  57306. CLASS="function"
  57307. >aspell_suggest()</B
  57308. ></B
  57309. ></P
  57310. ><TABLE
  57311. BORDER="0"
  57312. BGCOLOR="#E0E0E0"
  57313. CELLPADDING="5"
  57314. ><TR
  57315. ><TD
  57316. ><PRE
  57317. CLASS="php"
  57318. ><?php
  57319. $aspell_link = aspell_new("english");
  57320.  
  57321. if (!aspell_check($aspell_link, "test")) {
  57322.     $suggestions = aspell_suggest($aspell_link, "test");
  57323.  
  57324.     foreach ($suggestions as $suggestion) {
  57325.         echo "M÷gliche Schreibweisen: $suggestion<br />\n";
  57326.     }
  57327. }
  57328. ?></PRE
  57329. ></TD
  57330. ></TR
  57331. ></TABLE
  57332. ></DIV
  57333. ></TD
  57334. ></TR
  57335. ></TABLE
  57336. >
  57337.     </P
  57338. ></DIV
  57339. ></DIV
  57340. ><DIV
  57341. CLASS="reference"
  57342. ><A
  57343. NAME="ref.bc"
  57344. ></A
  57345. ><DIV
  57346. CLASS="TITLEPAGE"
  57347. ><H1
  57348. CLASS="title"
  57349. >IV. Mathematische Funktionen mit beliebiger Genauigkeit</H1
  57350. ><DIV
  57351. CLASS="PARTINTRO"
  57352. ><A
  57353. NAME="AEN10335"
  57354. ></A
  57355. ><DIV
  57356. CLASS="section"
  57357. ><H2
  57358. CLASS="section"
  57359. ><A
  57360. NAME="bc.intro"
  57361. >Einfⁿhrung</A
  57362. ></H2
  57363. ><P
  57364. >     Fⁿr beliebig genaue mathematische Operationen bietet PHP den Binary Calculator.
  57365.     Unterstⁿtzt werden Zahlen beliebiger LΣnge und Genauigkeit, die als String vorliegen.
  57366.    </P
  57367. ></DIV
  57368. ><DIV
  57369. CLASS="section"
  57370. ><HR><H2
  57371. CLASS="section"
  57372. ><A
  57373. NAME="bc.requirements"
  57374. >Anforderungen</A
  57375. ></H2
  57376. ><P
  57377. >      Seit PHP 4.0.4 ist libbcmath in PHP enthalten. Sie brauchen keine
  57378.      externen Bibliotheken fⁿr diese Erweiterung.
  57379.     </P
  57380. ></DIV
  57381. ><DIV
  57382. CLASS="section"
  57383. ><HR><H2
  57384. CLASS="section"
  57385. ><A
  57386. NAME="bc.installation"
  57387. >Installation</A
  57388. ></H2
  57389. ><P
  57390. >   In PHP 4 sind diese Funktionen nur verfⁿgbar, wenn <VAR
  57391. CLASS="literal"
  57392. >PHP</VAR
  57393. >
  57394.   mit <VAR
  57395. CLASS="option"
  57396. >--enable-bcmath</VAR
  57397. > konfiguriert wurde.
  57398.   In PHP 3 sind diese Funktionen nur verfⁿgbar, wenn <VAR
  57399. CLASS="literal"
  57400. >PHP</VAR
  57401. >
  57402.   nicht mit <VAR
  57403. CLASS="option"
  57404. >--disable-bcmath</VAR
  57405. > konfiguriert
  57406.   wurde.
  57407.  </P
  57408. ><P
  57409. >Die Windowsversion von PHP enthΣlt diese
  57410. Erweiterung. Um diese Funktionen zu verwenden, mⁿssen Sie keine zusΣtzlichen
  57411. Erweiterungen aktivieren.</P
  57412. ></DIV
  57413. ><DIV
  57414. CLASS="section"
  57415. ><HR><H2
  57416. CLASS="section"
  57417. ><A
  57418. NAME="bc.configuration"
  57419. >Laufzeit Konfiguration</A
  57420. ></H2
  57421. ><P
  57422. > Das Verhalten dieser Funktionen wird
  57423. durch Einstellungen in der <TT
  57424. CLASS="filename"
  57425. >php.ini</TT
  57426. > beeinflusst.</P
  57427. ><P
  57428. >  <DIV
  57429. CLASS="table"
  57430. ><A
  57431. NAME="AEN10355"
  57432. ></A
  57433. ><P
  57434. ><B
  57435. >Tabelle 1. BC math Konfigurations-Optionen</B
  57436. ></P
  57437. ><TABLE
  57438. BORDER="1"
  57439. CLASS="CALSTABLE"
  57440. ><COL><COL><COL><THEAD
  57441. ><TR
  57442. ><TH
  57443. >Name</TH
  57444. ><TH
  57445. >Standard</TH
  57446. ><TH
  57447. >VerΣnderbar</TH
  57448. ></TR
  57449. ></THEAD
  57450. ><TBODY
  57451. ><TR
  57452. ><TD
  57453. >bcmath.scale</TD
  57454. ><TD
  57455. >0</TD
  57456. ><TD
  57457. >PHP_INI_ALL</TD
  57458. ></TR
  57459. ></TBODY
  57460. ></TABLE
  57461. ></DIV
  57462. >
  57463.   Weitere Details und die Definition der PHP_INI_* Konstanten sind unter
  57464.   <A
  57465. HREF="#function.ini-set"
  57466. ><B
  57467. CLASS="function"
  57468. >ini_set()</B
  57469. ></A
  57470. > zu finden.
  57471.  </P
  57472. ><P
  57473. >Hier eine kurze ErklΣrung der
  57474. Konfigurationsoptionen:</P
  57475. ><P
  57476. >   <P
  57477. ></P
  57478. ><DIV
  57479. CLASS="variablelist"
  57480. ><DL
  57481. ><DT
  57482. ><A
  57483. NAME="ini.bcmath.scale"
  57484. ></A
  57485. ><VAR
  57486. CLASS="parameter"
  57487. >bcmath.scale</VAR
  57488. >
  57489.      <A
  57490. HREF="#language.types.integer"
  57491. ><B
  57492. CLASS="type"
  57493. >integer</B
  57494. ></A
  57495. ></DT
  57496. ><DD
  57497. ><P
  57498. >       Anzahl der Dezimalstellen fⁿr alle bcmath Funktionen. Siehe auch
  57499.       <A
  57500. HREF="#function.bcscale"
  57501. ><B
  57502. CLASS="function"
  57503. >bcscale()</B
  57504. ></A
  57505. >.
  57506.      </P
  57507. ></DD
  57508. ></DL
  57509. ></DIV
  57510. >
  57511.  </P
  57512. ></DIV
  57513. ><DIV
  57514. CLASS="section"
  57515. ><HR><H2
  57516. CLASS="section"
  57517. ><A
  57518. NAME="bc.resources"
  57519. >Resource Typen</A
  57520. ></H2
  57521. ><P
  57522. >Diese Erweiterung definiert keine Resource-Typen.</P
  57523. ></DIV
  57524. ><DIV
  57525. CLASS="section"
  57526. ><HR><H2
  57527. CLASS="section"
  57528. ><A
  57529. NAME="bc.constants"
  57530. >Vordefinierte Konstanten</A
  57531. ></H2
  57532. ><P
  57533. >Diese Erweiterung definiert keine Konstanten.</P
  57534. ></DIV
  57535. ></DIV
  57536. ><DIV
  57537. CLASS="TOC"
  57538. ><DL
  57539. ><DT
  57540. ><B
  57541. >Inhaltsverzeichnis</B
  57542. ></DT
  57543. ><DT
  57544. ><A
  57545. HREF="#function.bcadd"
  57546. >bcadd</A
  57547. > -- Addition zweier Zahlen beliebiger Genauigkeit.</DT
  57548. ><DT
  57549. ><A
  57550. HREF="#function.bccomp"
  57551. >bccomp</A
  57552. > -- 
  57553.      Vergleich zweier Zahlen beliebiger Genauigkeit.
  57554.     </DT
  57555. ><DT
  57556. ><A
  57557. HREF="#function.bcdiv"
  57558. >bcdiv</A
  57559. > -- Division zweier Zahlen beliebiger Genauigkeit.</DT
  57560. ><DT
  57561. ><A
  57562. HREF="#function.bcmod"
  57563. >bcmod</A
  57564. > -- 
  57565.      Modulo zweier Zahlen mit beliebiger Genauigkeit.
  57566.     </DT
  57567. ><DT
  57568. ><A
  57569. HREF="#function.bcmul"
  57570. >bcmul</A
  57571. > -- 
  57572.      Multiplikation zweier Zahlen beliebiger Genauigkeit.
  57573.     </DT
  57574. ><DT
  57575. ><A
  57576. HREF="#function.bcpow"
  57577. >bcpow</A
  57578. > -- 
  57579.      Potenz mit beliebiger Genauigkeit.
  57580.     </DT
  57581. ><DT
  57582. ><A
  57583. HREF="#function.bcpowmod"
  57584. >bcpowmod</A
  57585. > -- 
  57586.      Raise an arbitrary precision number to another, reduced by a specified modulus.
  57587.     </DT
  57588. ><DT
  57589. ><A
  57590. HREF="#function.bcscale"
  57591. >bcscale</A
  57592. > -- 
  57593.      Setzt die Genauigkeit aller BC math-Funktionen.
  57594.     </DT
  57595. ><DT
  57596. ><A
  57597. HREF="#function.bcsqrt"
  57598. >bcsqrt</A
  57599. > -- 
  57600.      Quadratwurzel mit beliebiger Genauigkeit.
  57601.     </DT
  57602. ><DT
  57603. ><A
  57604. HREF="#function.bcsub"
  57605. >bcsub</A
  57606. > -- 
  57607.      Subtrahiert zwei Zahlen mit beliebiger Genauigkeit.
  57608.     </DT
  57609. ></DL
  57610. ></DIV
  57611. ></DIV
  57612. ><H1
  57613. ><A
  57614. NAME="function.bcadd"
  57615. ></A
  57616. >bcadd</H1
  57617. ><DIV
  57618. CLASS="refnamediv"
  57619. ><A
  57620. NAME="AEN10386"
  57621. ></A
  57622. ><P
  57623. >    (PHP 3, PHP 4 , PHP 5)</P
  57624. >bcadd -- Addition zweier Zahlen beliebiger Genauigkeit.</DIV
  57625. ><DIV
  57626. CLASS="refsect1"
  57627. ><A
  57628. NAME="AEN10389"
  57629. ></A
  57630. ><H2
  57631. >Beschreibung</H2
  57632. >string <B
  57633. CLASS="methodname"
  57634. >bcadd</B
  57635. > ( string linker Operand, string rechter Operand [, int Genauigkeit])<BR
  57636. ></BR
  57637. ><P
  57638. >      Addiert den <VAR
  57639. CLASS="parameter"
  57640. >linken Operanden</VAR
  57641. > zu dem
  57642.      <VAR
  57643. CLASS="parameter"
  57644. >rechten Operanden</VAR
  57645. > und liefert die Summe
  57646.      als Zeichenkette. Der optionale Parameter
  57647.      <VAR
  57648. CLASS="parameter"
  57649. >Genauigkeit</VAR
  57650. > kann angegeben werden, um die Anzahl
  57651.      der Nachkommastellen im Ergebnis zu bestimmen.
  57652.     </P
  57653. ><P
  57654. >      <TABLE
  57655. WIDTH="100%"
  57656. BORDER="0"
  57657. CELLPADDING="0"
  57658. CELLSPACING="0"
  57659. CLASS="EXAMPLE"
  57660. ><TR
  57661. ><TD
  57662. ><DIV
  57663. CLASS="example"
  57664. ><A
  57665. NAME="AEN10408"
  57666. ></A
  57667. ><P
  57668. ><B
  57669. >Beispiel 1. <B
  57670. CLASS="function"
  57671. >bcadd()</B
  57672. > Beispiel</B
  57673. ></P
  57674. ><TABLE
  57675. BORDER="0"
  57676. BGCOLOR="#E0E0E0"
  57677. CELLPADDING="5"
  57678. ><TR
  57679. ><TD
  57680. ><PRE
  57681. CLASS="php"
  57682. ><?php
  57683.  
  57684. $a = 1.234;
  57685. $b = 5;
  57686.  
  57687. echo bcadd($a, $b);     // 6
  57688. echo bcadd($a, $b, 4);  // 6.2340
  57689.  
  57690. ?></PRE
  57691. ></TD
  57692. ></TR
  57693. ></TABLE
  57694. ></DIV
  57695. ></TD
  57696. ></TR
  57697. ></TABLE
  57698. >
  57699.     </P
  57700. ><P
  57701. >      Siehe auch <A
  57702. HREF="#function.bcsub"
  57703. ><B
  57704. CLASS="function"
  57705. >bcsub()</B
  57706. ></A
  57707. >.
  57708.     </P
  57709. ></DIV
  57710. ><H1
  57711. ><A
  57712. NAME="function.bccomp"
  57713. ></A
  57714. >bccomp</H1
  57715. ><DIV
  57716. CLASS="refnamediv"
  57717. ><A
  57718. NAME="AEN10415"
  57719. ></A
  57720. ><P
  57721. >    (PHP 3, PHP 4 , PHP 5)</P
  57722. >bccomp -- 
  57723.      Vergleich zweier Zahlen beliebiger Genauigkeit.
  57724.     </DIV
  57725. ><DIV
  57726. CLASS="refsect1"
  57727. ><A
  57728. NAME="AEN10418"
  57729. ></A
  57730. ><H2
  57731. >Beschreibung</H2
  57732. >int <B
  57733. CLASS="methodname"
  57734. >bccomp</B
  57735. > ( string linker Operand, string rechter Operand [, int Genauigkeit])<BR
  57736. ></BR
  57737. ><P
  57738. >      Vergleicht den <VAR
  57739. CLASS="parameter"
  57740. >linken Operanden</VAR
  57741. > mit dem
  57742.      <VAR
  57743. CLASS="parameter"
  57744. >rechten Operanden</VAR
  57745. > und liefert das Ergebnis
  57746.      als Integer-Wert. Der optionale Parameter <VAR
  57747. CLASS="parameter"
  57748. >Genauigkeit</VAR
  57749. >
  57750.      bestimmt die Anzahl der Nachkommastellen, die fⁿr den Vergleich
  57751.      ausgewertet werden. Der Rⁿckgabewert ist 0, wenn die beiden Operanden
  57752.      gleich sind. Wenn der <VAR
  57753. CLASS="parameter"
  57754. >linke Operand</VAR
  57755. > gr÷▀er ist
  57756.      als der <VAR
  57757. CLASS="parameter"
  57758. >rechte Operand</VAR
  57759. >, wird +1 zurⁿckgeliefert;
  57760.      wenn der <VAR
  57761. CLASS="parameter"
  57762. >linke Operand</VAR
  57763. >
  57764.      kleiner ist als der <VAR
  57765. CLASS="parameter"
  57766. >rechte Operand</VAR
  57767. > wird
  57768.      -1 zurⁿckgeliefert.
  57769.     </P
  57770. ><P
  57771. >      <TABLE
  57772. WIDTH="100%"
  57773. BORDER="0"
  57774. CELLPADDING="0"
  57775. CELLSPACING="0"
  57776. CLASS="EXAMPLE"
  57777. ><TR
  57778. ><TD
  57779. ><DIV
  57780. CLASS="example"
  57781. ><A
  57782. NAME="AEN10441"
  57783. ></A
  57784. ><P
  57785. ><B
  57786. >Beispiel 1. <B
  57787. CLASS="function"
  57788. >bccomp()</B
  57789. > Beispiel</B
  57790. ></P
  57791. ><TABLE
  57792. BORDER="0"
  57793. BGCOLOR="#E0E0E0"
  57794. CELLPADDING="5"
  57795. ><TR
  57796. ><TD
  57797. ><PRE
  57798. CLASS="php"
  57799. ><?php
  57800. echo bccomp('1', '2') . "\n";
  57801.  
  57802. echo bccomp('1.00001', '1', 3) . "\n";
  57803. echo bccomp('1.00001', '1', 5);
  57804. ?></PRE
  57805. ></TD
  57806. ></TR
  57807. ></TABLE
  57808. ><P
  57809. >        Das obige Beispiel gibt folgendes aus:
  57810.       </P
  57811. ><TABLE
  57812. BORDER="0"
  57813. BGCOLOR="#E0E0E0"
  57814. CELLPADDING="5"
  57815. ><TR
  57816. ><TD
  57817. ><PRE
  57818. CLASS="screen"
  57819. >-1
  57820. 0
  57821. 1</PRE
  57822. ></TD
  57823. ></TR
  57824. ></TABLE
  57825. ></DIV
  57826. ></TD
  57827. ></TR
  57828. ></TABLE
  57829. >
  57830.     </P
  57831. ></DIV
  57832. ><H1
  57833. ><A
  57834. NAME="function.bcdiv"
  57835. ></A
  57836. >bcdiv</H1
  57837. ><DIV
  57838. CLASS="refnamediv"
  57839. ><A
  57840. NAME="AEN10448"
  57841. ></A
  57842. ><P
  57843. >    (PHP 3, PHP 4 , PHP 5)</P
  57844. >bcdiv -- Division zweier Zahlen beliebiger Genauigkeit.</DIV
  57845. ><DIV
  57846. CLASS="refsect1"
  57847. ><A
  57848. NAME="AEN10451"
  57849. ></A
  57850. ><H2
  57851. >Beschreibung</H2
  57852. >string <B
  57853. CLASS="methodname"
  57854. >bcdiv</B
  57855. > ( string linker Operand, string rechter Operand [, int Genauigkeit])<BR
  57856. ></BR
  57857. ><P
  57858. >      Dividiert den <VAR
  57859. CLASS="parameter"
  57860. >linken Operanden</VAR
  57861. > durch den
  57862.      <VAR
  57863. CLASS="parameter"
  57864. >rechten Operanden</VAR
  57865. >. Der optionale Parameter
  57866.      <VAR
  57867. CLASS="parameter"
  57868. >Genauigkeit</VAR
  57869. > legt die Anzahl der
  57870.      Nachkommastellen im Ergebnis fest.
  57871.     </P
  57872. ><P
  57873. >      <TABLE
  57874. WIDTH="100%"
  57875. BORDER="0"
  57876. CELLPADDING="0"
  57877. CELLSPACING="0"
  57878. CLASS="EXAMPLE"
  57879. ><TR
  57880. ><TD
  57881. ><DIV
  57882. CLASS="example"
  57883. ><A
  57884. NAME="AEN10470"
  57885. ></A
  57886. ><P
  57887. ><B
  57888. >Beispiel 1. <B
  57889. CLASS="function"
  57890. >bcdiv()</B
  57891. > Beispiel</B
  57892. ></P
  57893. ><TABLE
  57894. BORDER="0"
  57895. BGCOLOR="#E0E0E0"
  57896. CELLPADDING="5"
  57897. ><TR
  57898. ><TD
  57899. ><PRE
  57900. CLASS="php"
  57901. ><?php
  57902.  
  57903. echo bcdiv(105, 6.55957, 3);  // 16.007
  57904.  
  57905. ?></PRE
  57906. ></TD
  57907. ></TR
  57908. ></TABLE
  57909. ></DIV
  57910. ></TD
  57911. ></TR
  57912. ></TABLE
  57913. >
  57914.     </P
  57915. ><P
  57916. >      Siehe auch <A
  57917. HREF="#function.bcmul"
  57918. ><B
  57919. CLASS="function"
  57920. >bcmul()</B
  57921. ></A
  57922. >.
  57923.     </P
  57924. ></DIV
  57925. ><H1
  57926. ><A
  57927. NAME="function.bcmod"
  57928. ></A
  57929. >bcmod</H1
  57930. ><DIV
  57931. CLASS="refnamediv"
  57932. ><A
  57933. NAME="AEN10477"
  57934. ></A
  57935. ><P
  57936. >    (PHP 3, PHP 4 , PHP 5)</P
  57937. >bcmod -- 
  57938.      Modulo zweier Zahlen mit beliebiger Genauigkeit.
  57939.     </DIV
  57940. ><DIV
  57941. CLASS="refsect1"
  57942. ><A
  57943. NAME="AEN10480"
  57944. ></A
  57945. ><H2
  57946. >Beschreibung</H2
  57947. >string <B
  57948. CLASS="methodname"
  57949. >bcmod</B
  57950. > ( string linker Operand, string Modulus)<BR
  57951. ></BR
  57952. ><P
  57953. >      Liefert den <VAR
  57954. CLASS="parameter"
  57955. >linken Operanden</VAR
  57956. > modulo
  57957.      <VAR
  57958. CLASS="parameter"
  57959. >Modulus</VAR
  57960. >.
  57961.     </P
  57962. ><P
  57963. >      <TABLE
  57964. WIDTH="100%"
  57965. BORDER="0"
  57966. CELLPADDING="0"
  57967. CELLSPACING="0"
  57968. CLASS="EXAMPLE"
  57969. ><TR
  57970. ><TD
  57971. ><DIV
  57972. CLASS="example"
  57973. ><A
  57974. NAME="AEN10495"
  57975. ></A
  57976. ><P
  57977. ><B
  57978. >Beispiel 1. <B
  57979. CLASS="function"
  57980. >bcmod()</B
  57981. > Beispiel</B
  57982. ></P
  57983. ><TABLE
  57984. BORDER="0"
  57985. BGCOLOR="#E0E0E0"
  57986. CELLPADDING="5"
  57987. ><TR
  57988. ><TD
  57989. ><PRE
  57990. CLASS="php"
  57991. ><?php
  57992. echo bcmod(4, 2) . "\n";
  57993. echo bcmod(2, 4);
  57994. ?></PRE
  57995. ></TD
  57996. ></TR
  57997. ></TABLE
  57998. ><P
  57999. >        Das obige Beispiel gibt folgendes aus:
  58000.       </P
  58001. ><TABLE
  58002. BORDER="0"
  58003. BGCOLOR="#E0E0E0"
  58004. CELLPADDING="5"
  58005. ><TR
  58006. ><TD
  58007. ><PRE
  58008. CLASS="screen"
  58009. >0
  58010. 2</PRE
  58011. ></TD
  58012. ></TR
  58013. ></TABLE
  58014. ></DIV
  58015. ></TD
  58016. ></TR
  58017. ></TABLE
  58018. >
  58019.     </P
  58020. ><P
  58021. >      Siehe auch <A
  58022. HREF="#function.bcdiv"
  58023. ><B
  58024. CLASS="function"
  58025. >bcdiv()</B
  58026. ></A
  58027. >.
  58028.     </P
  58029. ></DIV
  58030. ><H1
  58031. ><A
  58032. NAME="function.bcmul"
  58033. ></A
  58034. >bcmul</H1
  58035. ><DIV
  58036. CLASS="refnamediv"
  58037. ><A
  58038. NAME="AEN10504"
  58039. ></A
  58040. ><P
  58041. >    (PHP 3, PHP 4 , PHP 5)</P
  58042. >bcmul -- 
  58043.      Multiplikation zweier Zahlen beliebiger Genauigkeit.
  58044.     </DIV
  58045. ><DIV
  58046. CLASS="refsect1"
  58047. ><A
  58048. NAME="AEN10507"
  58049. ></A
  58050. ><H2
  58051. >Beschreibung</H2
  58052. >string <B
  58053. CLASS="methodname"
  58054. >bcmul</B
  58055. > ( string linker Operand, string rechter Operand [, int Genauigkeit])<BR
  58056. ></BR
  58057. ><P
  58058. >      Multipliziert den <VAR
  58059. CLASS="parameter"
  58060. >linken Operanden</VAR
  58061. > mit dem
  58062.      <VAR
  58063. CLASS="parameter"
  58064. >rechten Operanden</VAR
  58065. >. Der optionale Parameter
  58066.      <VAR
  58067. CLASS="parameter"
  58068. >Genauigkeit</VAR
  58069. > legt die Anzahl der
  58070.      Nachkommastellen im Ergebnis fest.
  58071.     </P
  58072. ><P
  58073. >      <TABLE
  58074. WIDTH="100%"
  58075. BORDER="0"
  58076. CELLPADDING="0"
  58077. CELLSPACING="0"
  58078. CLASS="EXAMPLE"
  58079. ><TR
  58080. ><TD
  58081. ><DIV
  58082. CLASS="example"
  58083. ><A
  58084. NAME="AEN10526"
  58085. ></A
  58086. ><P
  58087. ><B
  58088. >Beispiel 1. <B
  58089. CLASS="function"
  58090. >bcmul()</B
  58091. > Beispiel</B
  58092. ></P
  58093. ><TABLE
  58094. BORDER="0"
  58095. BGCOLOR="#E0E0E0"
  58096. CELLPADDING="5"
  58097. ><TR
  58098. ><TD
  58099. ><PRE
  58100. CLASS="php"
  58101. ><?php
  58102. echo bcmul(1.34747474747, 35, 3) . "\n";
  58103. echo bcmul(2, 4);
  58104. ?></PRE
  58105. ></TD
  58106. ></TR
  58107. ></TABLE
  58108. ><P
  58109. >        Das obige Beispiel gibt folgendes aus:
  58110.       </P
  58111. ><TABLE
  58112. BORDER="0"
  58113. BGCOLOR="#E0E0E0"
  58114. CELLPADDING="5"
  58115. ><TR
  58116. ><TD
  58117. ><PRE
  58118. CLASS="screen"
  58119. >47.162
  58120. 8</PRE
  58121. ></TD
  58122. ></TR
  58123. ></TABLE
  58124. ></DIV
  58125. ></TD
  58126. ></TR
  58127. ></TABLE
  58128. >
  58129.     </P
  58130. ><P
  58131. >      Siehe auch <A
  58132. HREF="#function.bcdiv"
  58133. ><B
  58134. CLASS="function"
  58135. >bcdiv()</B
  58136. ></A
  58137. >.
  58138.     </P
  58139. ></DIV
  58140. ><H1
  58141. ><A
  58142. NAME="function.bcpow"
  58143. ></A
  58144. >bcpow</H1
  58145. ><DIV
  58146. CLASS="refnamediv"
  58147. ><A
  58148. NAME="AEN10535"
  58149. ></A
  58150. ><P
  58151. >    (PHP 3, PHP 4 , PHP 5)</P
  58152. >bcpow -- 
  58153.      Potenz mit beliebiger Genauigkeit.
  58154.     </DIV
  58155. ><DIV
  58156. CLASS="refsect1"
  58157. ><A
  58158. NAME="AEN10538"
  58159. ></A
  58160. ><H2
  58161. >Beschreibung</H2
  58162. >string <B
  58163. CLASS="methodname"
  58164. >bcpow</B
  58165. > ( string x, string y [, int Genauigkeit])<BR
  58166. ></BR
  58167. ><P
  58168. >      Potenziert <VAR
  58169. CLASS="parameter"
  58170. >x</VAR
  58171. > mit <VAR
  58172. CLASS="parameter"
  58173. >y</VAR
  58174. >.
  58175.      Der optionale Parameter <VAR
  58176. CLASS="parameter"
  58177. >Genauigkeit</VAR
  58178. > legt
  58179.      die Anzahl der Nachkommastellen im Ergebnis fest.
  58180.     </P
  58181. ><P
  58182. >      <TABLE
  58183. WIDTH="100%"
  58184. BORDER="0"
  58185. CELLPADDING="0"
  58186. CELLSPACING="0"
  58187. CLASS="EXAMPLE"
  58188. ><TR
  58189. ><TD
  58190. ><DIV
  58191. CLASS="example"
  58192. ><A
  58193. NAME="AEN10557"
  58194. ></A
  58195. ><P
  58196. ><B
  58197. >Beispiel 1. <B
  58198. CLASS="function"
  58199. >bcpow()</B
  58200. > Beispiel</B
  58201. ></P
  58202. ><TABLE
  58203. BORDER="0"
  58204. BGCOLOR="#E0E0E0"
  58205. CELLPADDING="5"
  58206. ><TR
  58207. ><TD
  58208. ><PRE
  58209. CLASS="php"
  58210. ><?php
  58211.  
  58212. echo bcpow(4.2, 3, 2); // 74.08
  58213.  
  58214. ?></PRE
  58215. ></TD
  58216. ></TR
  58217. ></TABLE
  58218. ></DIV
  58219. ></TD
  58220. ></TR
  58221. ></TABLE
  58222. >
  58223.     </P
  58224. ><P
  58225. >      Siehe auch <A
  58226. HREF="#function.bcpowmod"
  58227. ><B
  58228. CLASS="function"
  58229. >bcpowmod()</B
  58230. ></A
  58231. > und <A
  58232. HREF="#function.bcsqrt"
  58233. ><B
  58234. CLASS="function"
  58235. >bcsqrt()</B
  58236. ></A
  58237. >.
  58238.     </P
  58239. ></DIV
  58240. ><H1
  58241. ><A
  58242. NAME="function.bcpowmod"
  58243. ></A
  58244. >bcpowmod</H1
  58245. ><DIV
  58246. CLASS="refnamediv"
  58247. ><A
  58248. NAME="AEN10565"
  58249. ></A
  58250. ><P
  58251. >    (PHP 5)</P
  58252. >bcpowmod -- 
  58253.      Raise an arbitrary precision number to another, reduced by a specified modulus.
  58254.     </DIV
  58255. ><DIV
  58256. CLASS="refsect1"
  58257. ><A
  58258. NAME="AEN10568"
  58259. ></A
  58260. ><H2
  58261. >Beschreibung</H2
  58262. >string <B
  58263. CLASS="methodname"
  58264. >bcpowmod</B
  58265. > ( string x, string y, string modulus [, int scale])<BR
  58266. ></BR
  58267. ><P
  58268. >      Benutzen Sie diese schnelle Exponentialmethode um
  58269.      <VAR
  58270. CLASS="parameter"
  58271. >x</VAR
  58272. > mit <VAR
  58273. CLASS="parameter"
  58274. >y</VAR
  58275. > unter
  58276.      Berⁿcksichtigung des Modulo <VAR
  58277. CLASS="parameter"
  58278. >modulus</VAR
  58279. > zu potenzieren.
  58280.      Der optionale Parameter <VAR
  58281. CLASS="parameter"
  58282. >scale</VAR
  58283. > legt die Anzahl der
  58284.      Nachkommastellen im Ergebnis fest.
  58285.     </P
  58286. ><P
  58287. >      Die folgenden zwei Anweisungen sind funktional identisch.
  58288.      Die Variante mit <B
  58289. CLASS="function"
  58290. >bcpowmod()</B
  58291. > ist schneller und
  58292.      akzeptiert gr÷▀ere Parameter.
  58293.      <DIV
  58294. CLASS="informalexample"
  58295. ><P
  58296. ></P
  58297. ><A
  58298. NAME="AEN10592"
  58299. ></A
  58300. ><TABLE
  58301. BORDER="0"
  58302. BGCOLOR="#E0E0E0"
  58303. CELLPADDING="5"
  58304. ><TR
  58305. ><TD
  58306. ><PRE
  58307. CLASS="php"
  58308. ><?php
  58309. $a = bcpowmod($x, $y, $mod);
  58310.  
  58311. $b = bcmod(bcpow($x, $y), $mod);
  58312.  
  58313. // $a und $b sind genau gleich.
  58314.  
  58315. ?></PRE
  58316. ></TD
  58317. ></TR
  58318. ></TABLE
  58319. ><P
  58320. ></P
  58321. ></DIV
  58322. >
  58323.     </P
  58324. ><P
  58325. >      <DIV
  58326. CLASS="note"
  58327. ><BLOCKQUOTE
  58328. CLASS="note"
  58329. ><P
  58330. ><B
  58331. >Anmerkung: </B
  58332. >
  58333.        Die Verwendung von nicht-natⁿrlichen Zahlen kann zu unerwarteten
  58334.        Ergebnissen fⁿhren, weil diese Funktion die Modulodivision verwendet.
  58335.        Eine natⁿrliche Zahl ist jede ganzzahlige positive Zahl die ungleich
  58336.        Null ist.
  58337.       </P
  58338. ></BLOCKQUOTE
  58339. ></DIV
  58340. >
  58341.     </P
  58342. ><P
  58343. >      Siehe auch <A
  58344. HREF="#function.bcpow"
  58345. ><B
  58346. CLASS="function"
  58347. >bcpow()</B
  58348. ></A
  58349. > und
  58350.      <A
  58351. HREF="#function.bcmod"
  58352. ><B
  58353. CLASS="function"
  58354. >bcmod()</B
  58355. ></A
  58356. >.
  58357.     </P
  58358. ></DIV
  58359. ><H1
  58360. ><A
  58361. NAME="function.bcscale"
  58362. ></A
  58363. >bcscale</H1
  58364. ><DIV
  58365. CLASS="refnamediv"
  58366. ><A
  58367. NAME="AEN10601"
  58368. ></A
  58369. ><P
  58370. >    (PHP 3, PHP 4 , PHP 5)</P
  58371. >bcscale -- 
  58372.      Setzt die Genauigkeit aller BC math-Funktionen.
  58373.     </DIV
  58374. ><DIV
  58375. CLASS="refsect1"
  58376. ><A
  58377. NAME="AEN10604"
  58378. ></A
  58379. ><H2
  58380. >Beschreibung</H2
  58381. >bool <B
  58382. CLASS="methodname"
  58383. >bcscale</B
  58384. > ( int Genauigkeit)<BR
  58385. ></BR
  58386. ><P
  58387. >      Diese Funktionen legt die Standard-Genauigkeit aller in der Folge
  58388.      aufgerufenden BC math-Funktionen fest, die nicht explizit die
  58389.      Genauigkeit durch den optionalen Parameter setzen. Gibt bei Erfolg <TT
  58390. CLASS="constant"
  58391. ><B
  58392. >TRUE</B
  58393. ></TT
  58394. > zurⁿck, im Fehlerfall <TT
  58395. CLASS="constant"
  58396. ><B
  58397. >FALSE</B
  58398. ></TT
  58399. >.
  58400.     </P
  58401. ><P
  58402. >      <TABLE
  58403. WIDTH="100%"
  58404. BORDER="0"
  58405. CELLPADDING="0"
  58406. CELLSPACING="0"
  58407. CLASS="EXAMPLE"
  58408. ><TR
  58409. ><TD
  58410. ><DIV
  58411. CLASS="example"
  58412. ><A
  58413. NAME="AEN10616"
  58414. ></A
  58415. ><P
  58416. ><B
  58417. >Beispiel 1. <B
  58418. CLASS="function"
  58419. >bcscale()</B
  58420. > Beispiel</B
  58421. ></P
  58422. ><TABLE
  58423. BORDER="0"
  58424. BGCOLOR="#E0E0E0"
  58425. CELLPADDING="5"
  58426. ><TR
  58427. ><TD
  58428. ><PRE
  58429. CLASS="php"
  58430. ><?php
  58431.  
  58432. // Genauigkeit festlegen : 3
  58433. bcscale(3);
  58434. echo bcdiv(105, 6.55957); // 16.007
  58435.  
  58436. // Das gleiche Ergebnis ohne bcscale()
  58437. echo bcdiv(105, 6.55957, 3); // 16.007
  58438.  
  58439. ?></PRE
  58440. ></TD
  58441. ></TR
  58442. ></TABLE
  58443. ></DIV
  58444. ></TD
  58445. ></TR
  58446. ></TABLE
  58447. >
  58448.     </P
  58449. ></DIV
  58450. ><H1
  58451. ><A
  58452. NAME="function.bcsqrt"
  58453. ></A
  58454. >bcsqrt</H1
  58455. ><DIV
  58456. CLASS="refnamediv"
  58457. ><A
  58458. NAME="AEN10621"
  58459. ></A
  58460. ><P
  58461. >    (PHP 3, PHP 4 , PHP 5)</P
  58462. >bcsqrt -- 
  58463.