PHP Manual

Stig Sæther Bakken
Alexander Aulbach
Egon Schmid
Jim Winstead
Lars Torben Wilson
Rasmus Lerdorf
Zeev Suraski

Edited by

Stig Sæther Bakken
Egon Schmid

¹ø¿ª :

Ȳ¿øÈñ (Home Page: http://php.morosolution.com E-Mail: regina@morosolution.com)
(ÀÌ ±ÛÀº Ȳ¿øÈñ °³ÀÎÀÌ ¹ø¿ªÇÑ ³»¿ëÀÔ´Ï´Ù. ±ÛÀÇ ¿À¿ª¿¡ µû¸¥ Ã¥ÀÓÀ» ÁöÁö ¾Ê½À´Ï´Ù. ±ÛÀÇ À߸øµÈ ºÎºÐÀº ¿¬¶ôÇØ ÁÖ½Ã¸é °¨»çÇÏ°Ú½À´Ï´Ù.)

Copyright ¨Ï 1997, 1998, 1999, 2000 by the PHP Documentation Group

Copyright (¿ªÀÚÁÖ : ¿ø¹®ÀÇ ¹ýÀûÀÎ È¿·Â¹®Á¦·Î ¹ø¿ªÇÏÁö ¾Ê½À´Ï´Ù. ³»¿ëÀº GPLÀ» µû¸£°í ÀÖ´Ù´Â ³»¿ëÀÔ´Ï´Ù.)

This manual is © Copyright 1997, 1998, 1999, 2000 by the PHP Documentation Group. The members of this group are listed on the front page of this manual.

This manual can be redistributed under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.


Dedication

Â÷·Ê
¼­¹®
ÀÌ ¸Å´º¾ó¿¡ ´ëÇÏ¿©
I. Getting Started
1. ¼Ò°³ (Introduction)
2. ¼³Ä¡ (Installation)
3. ¼³Á¤ (Configuration)
4. º¸¾È (Security)
II. Language Reference
5. ±âº»¹®¹ý (Basic syntax)
6. º¯¼öÇüÅ (Types)
7. º¯¼ö (Variables)
8. »ó¼ö (Constants)
9. Ç¥Çö½Ä (Expressions)
10. ¿¬»êÀÚ (Operators)
11. Á¦¾î ±¸Á¶ (Control Structures)
12. ÇÔ¼ö (Functions)
13. Ŭ·¡½º¿Í °´Ã¼ (Classes and Objects)
III. ±â´É (Features)
14. Error handling
15. Creating GIF images
16. HTTP authentication with PHP
17. Cookies
18. Handling file uploads
19. Using remote files
20. Connection handling
21. Persistent database connections
IV. ÇÔ¼ö ¸ñ·Ï (Function Reference)
I. Apache-specific functions
II. Arbitrary precision mathematics functions
III. Array functions
IV. Aspell functions
V. Calendar functions
VI. COM support functions for Windows
VII. Class/Object Functions
VIII. ClibPDF functions
IX. Cybercash payment functions
X. DOM XML functions
XI. Compression functions
XII. Database (dbm-style) abstraction layer functions
XIII. Date and Time functions
XIV. dBase functions
XV. dbm functions
XVI. Directory functions
XVII. Dynamic Loading functions
XVIII. Encryption functions
XIX. filePro functions
XX. Filesystem functions
XXI. Forms Data Format functions
XXII. FTP functions
XXIII. GNU Gettext
XXIV. Hash functions
XXV. HTTP functions
XXVI. Hyperwave functions
XXVII. Image functions
XXVIII. IMAP, POP3, and NNTP functions
XXIX. Informix functions
XXX. InterBase functions
XXXI. LDAP functions
XXXII. Mail functions
XXXIII. Mathematical functions
XXXIV. MCAL functions
XXXV. Microsoft SQL Server functions
XXXVI. Miscellaneous functions
XXXVII. mSQL functions
XXXVIII. MySQL functions
XXXIX. Network functions
XL. NIS functions
XLI. ODBC functions
XLII. Oracle functions
XLIII. Oracle 8 functions
XLIV. PDF functions
XLV. Perl-compatible Regular Expression functions
XLVI. PHP options & information
XLVII. POSIX functions
XLVIII. PostgreSQL functions
XLIX. Program Execution functions
L. GNU Recode functions
LI. Regular expression functions
LII. Semaphore and shared memory functions
LIII. Session handling functions
LIV. SNMP functions
LV. String functions
LVI. Shockwave Flash functions
LVII. Sybase functions
LVIII. URL functions
LIX. Variable functions
LX. Vmailmgr functions
LXI. WDDX functions
LXII. XML parser functions
V. ºÎ·Ï (Appendixes)
A. Migrating from PHP/FI 2.0 to PHP 3.0
B. PHP development
C. The PHP Debugger


¼­¹®

PHP Version 3.0Àº HTML¿¡ ³»ÀåµÇ¾î µ¿ÀÛÇÏ´Â ½ºÅ©¸³Æ® ¾ð¾îÀÌ´Ù.(HTML-embedded scripting language) PHP´Â C¿Í Java, PerlµîÀ¸·ÎºÎÅÍ ¸¹Àº ¹®Àå Çü½ÄÀ» ºô·Á¾²°í ÀÖ°í, ¸î°¡Áö´Â °íÀ¯ÇÑ °Íµµ ÀÖ´Ù. ÀÌ ¾ð¾îÀÇ ¸ñÀûÀº À¥°³¹ßÀÚµéÀÌ µ¿ÀûÀÎ À¥¹®¼­¸¦ ºü¸£°í ½±°Ô ÀÛ¼ºÇÒ ¼ö ÀÖµµ·Ï ÇÏ´Â °ÍÀÌ´Ù.


ÀÌ ¸Å´º¾ó¿¡ ´ëÇÏ¿©

¿ø·¡ ¿µ¹® ¸Å´º¾óÀº DocBook DTDÀ» »ç¿ëÇÑ SGML·Î ÀÛ¼ºµÇ¾î ÀÖ°í, formattingÀ» À§Çؼ­´Â DSSSL (Document Style and Semantics Specification Language)À» »ç¿ëÇÏ°í ÀÖ´Ù. ¶ÇÇÑ Tex¿Í RTF¹öÁ¯µµ ÀÖÀ¸³ª, ÇÑ±Û ¹®¼­´Â ¿ªÀÚÀÇ ÆíÀǸ¦ À§ÇØ ÀÏ´Ü HTML¸¸À» »ç¿ëÇϵµ·Ï ÇÏ°Ú´Ù.


I. Getting Started

Table of Contents
1. ¼Ò°³ (Introduction)
2. ¼³Ä¡ (Installation)
3. ¼³Á¤ (Configuration)
4. º¸¾È (Security)


Chapter 1. ¼Ò°³ (Introduction)


PHP¶õ ¹«¾ùÀΰ¡?

PHP´Â server-side HTML-embedded scripting languageÀÔ´Ï´Ù.

°£´ÜÇÑ ´äÀÌÁö¸¸, ¹«¾ùÀ» ÀǹÌÇÒ±î? ´ÙÀ½ ¿¹¸¦ º¸ÀÚ. :

Example 1-1. An introductory example

<html><head><title>Example</title>
<body>
<?php echo "Hi, I'm a PHP script!"; ?>
</body></html>
 

PerlÀ̳ª C¿Í°°Àº ´Ù¸¥ ¾ð¾î¿Í ´Ù¸£°Ô HTMLÀ» Ãâ·ÂÇϴµ¥ ¸¹Àº ¸í·É¾î°¡ ÇÊ¿ä¾ø´Ù. ¿©·¯ºÐÀº HTML³»¿¡ ¿©·¯ºÐÀÌ ÇÏ°íÀÚ ÇÏ´Â ÀÏ(À§ÀÇ °æ¿ì´Â ÇÑÁÙÀÇ ¹®ÀÚ¿­ Ãâ·Â)¿¡ ´ëÇÑ ½ºÅ©¸³Æ®¸¦ Àû¾îÁÖ¸é µÈ´Ù. PHP ÄÚµå´Â ƯÁ¤ÇÑ ½ÃÀÛ/³¡ ÅÂÅ©»çÀÌ¿¡ µé¾î°¡°Ô µÇ´Âµ¥ ÀÌ Å±״ "PHP ¸ðµå"·Î µé¾î°¡°Å³ª ³ª¿À°Ô ÇÏ´Â °ÍÀÌ´Ù.

PHP°¡ client-side Javascript °°Àº °Í°ú ±¸º°µÇ´Â °ÍÀº ÀÌ Äڵ尡 ¼­¹ö¿¡¼­ ½ÇÇàµÈ´Ù´Â °ÍÀÌ´Ù.


PHP´Â ¹«¾ùÀ» ÇÒ ¼ö Àִ°¡?

°¡Àå ±âº»ÀûÀÎ ·¹º§¿¡¼­, PHP´Â CGI ÇÁ·Î±×·¥¿¡¼­ ÇÒ ¼ö ÀÖ´Â ¸ðµç °ÍÀ» ÇÒ ¼ö ÀÖ´Ù. form data¸¦ °¡Á®¿À°í, µ¿ÀûÀÎ À¥ÆäÀÌÁö¸¦ ¸¸µé°Å³ª, Cookie¸¦ º¸³»°í ¹ÞÀ» ¼öµµ ÀÖ´Ù.

¾Æ¸¶ PHPÀÇ °¡Àå °­·ÂÇÏ°í °ü½É°¡´Â ºÎºÐÀº database¿ÍÀÇ ¿¬µ¿ºÎºÐÀÏ °ÍÀÌ´Ù. PHP¸¦ »ç¿ëÇÏ¸é ¿©·¯ºÐÀº DatabaseÀÇ Data¸¦ »ç¿ëÇÑ Web page¸¦ ³î¶øµµ·Ï °£´ÜÈ÷ ¸¸µé ¼ö ÀÖ´Ù. ´ÙÀ½¿¡ ³ª¿À´Â DB serverµéÀ» ÇöÀç »ç¿ëÇÒ ¼ö ÀÖ´Ù. :

Adabas D

InterBase

Solid

dBase

mSQL

Sybase

Empress

MySQL

Velocis

FilePro

Oracle

Unix dbm

Informix

PostgreSQL

 

 

PHP´Â IMAP³ª SNMP, NNTP, POP3, HTTPµîÀÇ ÇÁ·ÎÅäÄݵéÀ» »ç¿ëÇؼ­ ´Ù¸¥ ¼­ºñ½ºµé¿¡ ´ëÇØ Á¢±ÙÇÏ¿© µ¥ÀÌÅ͸¦ ±³È¯ÇÒ ¼ö ÀÖ´Ù. ½ÉÁö¾î´Â raw network ¼ÒÄÏÀ» »ç¿ëÇϸé, ±×¿ÜÀÇ ÇÁ·ÎÅäÄݵéÀ» »ç¿ëÇÒ ¼öµµ ÀÖ´Ù.


PHPÀÇ ¿ª»ç

PHP´Â 1994³â °¡À» Rasmus Lerdorf°¡ óÀ½ °í¾ÈÇÏ¿´´Ù. óÀ½ ºñ°ø°³ÆÇÀº ±×ÀÇ È¨ÆäÀÌÁö¿¡ »ç¿ëµÇ¾ú°í, ¿ÜºÎ¿¡ »ç¿ëµÈ °ÍÀº 1995³â ÃʺÎÅÍ »ç¿ëµÇ¾î Personal Home Page Tools¶ó°í ºÒ¸®°Ô µÇ¾ú´Ù. ÀÌ°ÍÀº ¸î °³ÀÇ Æ¯º°ÇÑ ¸ÅÅ©·Î¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Â ´Ü¼øÇÑ Æļ­(¸í·É Çؼ®±â) ¿£Áø°ú ¹æ¸í·ÏÀ̳ª Ä«¿îÅÍ °°ÀÌ È¨ÆäÀÌÁöÀÇ µÚ¿¡¼­ °øÅëÀûÀ¸·Î »ç¿ëÇÒ ¼ö ÀÖ´Â ¸î °³ÀÇ °£´ÜÇÑ À¯Æ¿¸®Æ¼·Î ±¸¼ºµÇ¾ú´Ù. ÀÌ Æļ­°¡ 1995³â Á߹ݿ¡ ÀçÀÛ¼ºµÇ¾î PHP/FI Version 2¶ó°í ¸í¸íµÇ¾ú´Ù. FI´Â Rasmus°¡ ÀÛ¼ºÇÑ html Çü½ÄÀÇ µ¥ÀÌÅ͸¦ Çؼ®ÇÒ ¼ö ÀÖ´Â º°µµÀÇ ÆÐÅ°Áö´Ù. ±×´Â ÀÌ µÎ°¡Áö¸¦ ÇÕÄ¡°í mSQLÀ» Áö¿øÇϵµ·ÏÇÏ¿© PHP/FI¸¦ ź»ý½ÃÄ×´Ù. PHP/FI´Â ºü¸¥ ¼Óµµ·Î ¹ßÀüÇÏ¿´°í, ¸¹Àº »ç¶÷µéÀÌ ÀÌ¿¡ °øÇåÇÏ¿´´Ù.

Á¤È®ÇÑ Åë°è´Â ¾øÁö¸¸ 1996³â ÈÄ¹Ý PHP/FI´Â Àü¼¼°èÀûÀ¸·Î ÃÖ¼ÒÇÑ 15,000°³ ÀÌ»óÀÇ À¥»çÀÌÆ®¿¡¼­ »ç¿ëµÇ´Â °ÍÀ¸·Î ÃßÁ¤µÇ¾ú°í, 1997³â Á߹ݿ¡ ±×¼ö´Â 50,000À¸·Î ´Ã¾î³µ´Ù. 1997³â Áß¹Ý PHP´Â ¶Ç´Ù¸¥ Áß¿äÇÑ º¯È­¸¦ °¡Á®¿Ô´Ù. À̶§ºÎÅÍ PHP´Â RasmusÀÇ °³ÀÎÀÌ ¾Æ´Ñ ÆÀ¿¡ ÀÇÇØ °³¹ßµÇ°í ÀÖ´Ù. »õ Æļ­´Â Zeev Suraski¿Í Andi Gutmans°¡ Àç ÀÛ¼ºµÇ¾ú°í, PHP Version 3¶ó´Â À̸§À¸·Î ³ªÅ¸³µ´Ù. ¸¹Àº PHP/FIÀÇ ±â´ÉµéÀÌ ¿Å°Ü¿Ô°í, ±×¿Ü¿¡µµ ¸¹Àº ±â´ÉµéÀÌ »õ·Î ÀÛ¼ºµÇ¾ú´Ù.

1998³â Áß¹ÝÀÎ ÇöÀç PHP/FI³ª PHP3´Â C2ÀÇ StrongHold web server³ª RedHat Linux°°Àº ¿©·¯ »ó¾÷ÀûÀÎ Á¦Ç°°ú ÇÔ²² Á¦°øµÇ°í ÀÖÀ¸¸ç, Àü¼¼°èÀûÀ¸·Î ÃÖ¼ÒÇÑ 150,000°³ÀÇ À¥»çÀÌÆ®°¡ »ç¿ëÇÏ°í ÀÖ´Ù. ÀÌ ¼ö´Â ÀÎÅͳݿ¡¼­ Netscape's flagship Enterprise serverÀÇ »ç¿ë¼öº¸´Ù ¸¹´Ù.

ÀÌ ±ÛÀÌ ¾²¿©Áö°í ÀÖ´Â °¡¿îµ¥, PHPÀÇ Â÷±â ¹öÀüÀÌ Á¦À۵ǰí ÀÖ´Ù. »õ·Î¿î PHP´Â Zend °°Àº È¿À²ÀûÀÎ ½ºÅ©¸³Æ® ¿£Áø°ú ApacheÀÌ¿ÜÀÇ À¥¼­¹ö¿¡¼­µµ ¸ðµâ·Î ½ÇÇàµÉ ¼ö ÀÖµµ·Ï Á¦À۵ǰí ÀÖ´Ù.


Chapter 2. ¼³Ä¡ (Installation)


ÃֽŠ¹öÀü ³»·Á¹Þ±â (Downloading the latest version)

¿©·¯ºÐÀº ÃֽŹöÀüÀÇ ¼Ò½º¿Í (À©µµ¿ìÁ Æ÷ÇÔÇÑ)¿©·¯ Ç÷§ÆûÀÇ ¹èÆ÷ÆÇÀ» http://www.php.net¿¡¼­ ³»·Á ¹ÞÀ» ¼ö ÀÖ´Ù.


Unix¿¡¼­ ¼Ò½º·Î ¼³Ä¡ (Installing From Source on UNIX)

ÀÌ ÀåÀº PHP¸¦ ¼³Ä¡ÇÏ°í ¼³Á¤ÇÏ´Â ¹æ¹ý¿¡ ´ëÇØ ¼³¸íÇÏ°í ÀÖ´Ù. ÇÊ¿äÇÑ Áö½Ä°ú ¼ÒÇÁÆ®¿þ¾î :


ºü¸¥ ¼³Ä¡ ¹æ¹ý (Apache Module Version)

 

  1 
  2 1.  gunzip apache_1.3.x.tar.gz
  3 2.  tar xvf apache_1.3.x.tar
  4 3.  gunzip php-3.0.x.tar.gz
  5 4.  tar xvf php-3.0.x.tar
  6 5.  cd apache_1.3.x
  7 6.  ./configure --prefix=/www
  8 7.  cd ../php-3.0.x
  9 8.  ./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars
 10 9.  make
 11 10. make install
 12 11. cd ../apache_1.3.x
 13 12. ./configure --prefix=/www --activate-module=src/modules/php3/libphp3.a
 14 13. make
 15 14. make install
 16 
 17      ÀÌ ´Ü°è ´ë½Å httpd ÀÌÁø ÆÄÀÏÀ» ±âÁ¸ÀÇ ÆÄÀÏ¿¡ µ¤¾î ¾µ ¼öµµ ÀÖ´Ù.
 18      ÀÌ ÀÛ¾÷À» ÇÏ·Á¸é ¿ì¼± httpd ¼­¹ö¸¦ ²ô´Â °ÍÀ» ÀØÁö ¸»µµ·Ï ÇÏÀÚ.
 19
 20 
 21 15. cd ../php-3.0.x
 22 16. cp php3.ini-dist /usr/local/lib/php3.ini
 23 
 24      ¿©·¯ºÐÀº ÀÌÁ¦ PHPÀÇ ¼³Á¤À» °íÄ¡±âÀ§ÇØ /usr/local/lib/php3.ini¸¦ ¼öÁ¤ÇÏ¸é µÈ´Ù.
 25      ¸¸¾à ÀÌ ÆÄÀÏÀÇ À§Ä¡¸¦ ¿Å±â°í ½Í´Ù¸é À§ÀÇ 8´Ü°è¿¡¼­ --with-config-file=/path ¿É¼ÇÀ» ÁØ´Ù.
 26 
 27 
 28 17. Edit your httpd.conf or srm.conf file and add: 
 29       
 30             AddType application/x-httpd-php3 .php3
 31  
 32     ¿©±â¼­ ¿©·¯ºÐÀº .php3¿Ü¿¡ ´Ù¸¥ È®ÀåÀÚ¸¦ »ç¿ëÇÒ ¼öµµ ÀÖ´Ù.
 33     ÇÏÁö¸¸ ¸¹Àº »ç¶÷µéÀÌ »ç¿ëÇϴ´ë·Î ±×³É .php3¸¦ »ç¿ëÇÒ °ÍÀ» ±ÇÇÑ´Ù.
 34
 35 18. ÀϹÝÀûÀÎ ¹æ½Ä´ë·Î Apache ¼­¹ö¸¦ ½ÃÀÛÇÑ´Ù. 
 36     (¹Ýµå½Ã stop°ú startÇÏ¿© Àç½Ãµ¿ÇÏ¿©¾ßÇÑ´Ù. 
 37      HUPÀ̳ª USR1°°Àº signalÀ» ÁÖ´Â µîÀÇ reload¸¸ Çؼ­´Â ¼Ò¿ëÀÌ ¾ø´Ù.)
 38       



¼³Á¤ (Configuration)

PHP¸¦ ¼³Á¤ÇÏ´Â ¹æ¹ý¿¡´Â Å©°Ô µÎ°¡Áö°¡ ÀÖ´Ù.

´ÙÀ½Àº ¿©·¯ °¡Áö ¼³Á¤ ¿É¼ÇµéÀÇ ÀÚ¼¼ÇÑ ³»¿ëÀÌ´Ù.


Apache ¸ðµâ

PHP¸¦ ¾ÆÆÄÄ¡ ¸ðµâ·Î ¸¸µé·Á¸é, "Build as an Apache module?"ÀÇ Áú¹®¿¡ "yes"·Î ´äÇÏ°í, Apache ¹èÆ÷º»ÀÇ base µð·ºÅ丮¸¦ ¸í½ÃÇØ ÁÖ¸é µÈ´Ù. (configure¿¡¼­´Â --with-apache=DIR ¿É¼ÇÀ» ÁÖ¸é µÈ´Ù.) ¸¸¾à ¿©·¯ºÐÀÇ Apache ¼Ò½ºÀÇ ¹èÆ÷º»À» /usr/local/src/apache_1.3.3¿¡ Ç®¾î ³õ¾Ò´Ù¸é, ÀÌ µð·ºÅ丮°¡ Apache ¹èÆ÷º»ÀÇ base µð·ºÅ丮°¡ µÈ´Ù. ±âº» µð·ºÅ丮´Â /usr/local/etc/httpdÀÌ´Ù.


fhttpd ¸ðµâ

PHP¸¦ fhttpd ¸ðµâ·Î ¸¸µé·Á¸é, "Build as an fhttpd module?"ÀÇ Áú¹®¿¡ "yes"·Î ´äÇÏ°í, fhttpd ¼Ò½ºÀÇ base µð·ºÅ丮¸¦ ¸í½ÃÇØ ÁÖ¸é µÈ´Ù. (configure¿¡¼­´Â --with-fhttpd=DIR ¿É¼ÇÀ» ÁÖ¸é µÈ´Ù.) ±âº» µð·ºÅ丮´Â /usr/local/src/fhttpdÀÌ´Ù. ¿©·¯ºÐÀÌ fhttpd¸¦ ¿î¿µÁß¿¡ ÀÖ´Ù¸é, ÀÌ ¸ðµâ·Î ¸¸µé¾î ½ÇÇàÇÏ´Â °ÍÀÌ ´õ ÁÁÀº ¼º´ÉÀ» Á¦°øÇϸç, ¶ÇÇÑ Á¦¾î¿Í ¿ø°Ý ½ÇÇà ´É·Âµµ Çâ»óµÈ´Ù.


CGI version

PHP´Â ±âº»ÀûÀ¸·Î CGI ÇÁ·Î±×·¥À¸·Î ¸¸µé¾î Áø´Ù. ¸¸¾à ¿©·¯ºÐÀÌ PHP°¡ ¸ðµâ·Î Á¦°øµÇ´Â À¥ ¼­¹ö¸¦ ¿î¿µÁßÀ̶ó¸é, ÇØ´ç ¸ðµâ·Î »ç¿ëÇÏ´Â °ÍÀÌ ÀϹÝÀûÀ¸·Î ÁÁÀº ¼º´ÉÀ» ³¾ ¼ö ÀÖ´Ù. ÇÏÁö¸¸, CGI ¹öÀüÀº ¾ÆÆÄÄ¡ »ç¿ëÀڵ鿡°Ô ´Ù¸¥ user-id¸¦ »ç¿ëÇÏ¿© º°µµÀÇ PHP-enabled ÆäÀÌÁö¸¦ ½ÇÇàÇÒ ¼ö ÀÖµµ·Ï ÇØ ÁØ´Ù. ¸¸¾à PHP¸¦ CGI·Î ½ÇÇàÇÏ°í ½Í´Ù¸é Security chapter¸¦ ¹Ýµå½Ã Àо±â ¹Ù¶õ´Ù.


Database Áö¿ø ¿É¼Ç

PHP´Â ´ÙÀ½ÀÇ databaseµé¿¡ ´ëÇÑ °íÀ¯ÀÇ Áö¿øÀ» Á¦°øÇÑ´Ù. (ODBCµµ Á¦°øÇÑ´Ù.)


Adabas D

      --with-adabas=DIR

Adabas D Áö¿øÀ¸·Î ÄÄÆÄÀÏÇÑ´Ù. DIRÀº Adabas D°¡ ¼³Ä¡µÈ DirectoryÀÌ°í, ±âº»°ªÀº /usr/local/adabasdÀÌ´Ù.

Adabas home page


dBase

      --with-dbase

DBaseÁö¿øÀ¸·Î ÄÄÆÄÀÏ ÇÑ´Ù. º°µµÀÇ ¶óÀ̺귯¸®´Â ÇÊ¿ä ¾ø´Ù.


filePro

      --with-filepro 

¹øµéµÈ Àбâ Àü¿ë filePro(bundled read-only filePro)¸¦ Áö¿øÇϵµ·Ï ÇØ ÁØ´Ù. º°µµÀÇ ¶óÀ̺귯¸®´Â ÇÊ¿ä ¾ø´Ù.


mSQL

      --with-msql=DIR     

mSQLÀ» Áö¿øÇϵµ·Ï ÇÑ´Ù. DIRÀº mSQLÀÌ ¼³Ä¡µÈ µð·ºÅ丮ÀÌ°í ±âº»°ªÀº /usr/local/HughesÀÌ´Ù. ÀÌ µð·ºÅ丮´Â mSQL 2.0 ¹èÆ÷º»ÀÇ ±âº» µð·ºÅ丮ÀÌ´Ù. configure´Â ÇöÀç ÀÛµ¿ÁßÀÎ mSQLÀÇ ¹öÀüÀ» ÀÚµ¿À¸·Î ŽÁöÇÏ¿© 1.0°ú 2.0Áß Çϳª¸¦ Áö¿øÇϵµ·Ï ÇÑ´Ù. ¸¸¾à PHP°¡ mSQL 1.0Áö¿øÀ¸·Î ÄÄÆÄÀϵǾú´Ù¸é, ¿©·¯ºÐÀº mSQL 2.0 database´Â »ç¿ëÇÏÁö ¸øÇÑ´Ù. ¸¶Âù°¡Áö·Î 2.0À¸·Î ÄÄÆÄÀÏ µÇ¾ú´Ù¸é 1.0 database´Â »ç¿ëÇÒ ¼ö ¾ø´Ù.

See also mSQL Configuration Directives in the configuration file.

mSQL home page


MySQL

      --with-mysql=DIR     

MySQLÀ» Áö¿øÇϵµ·Ï ÇÑ´Ù. DIRÀº MySQLÀÌ ¼³Ä¡µÈ µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /usr/localÀÌ´Ù. ÀÌ µð·ºÅ丮´Â MySQL ¹èÆ÷º»ÀÇ ±âº» µð·ºÅ丮 ÀÌ´Ù.

See also MySQL Configuration Directives in the configuration file.

MySQL home page


iODBC

      --with-iodbc=DIR     

iODBCÁö¿øÀ» Æ÷ÇÔÇϵµ·Ï ÇÑ´Ù. ÀÌ ±â´ÉÀº iODBC µå¶óÀ̹ö °ü¸®ÀÚ¸¦ À§ÇØ ¸Ç ¸ÕÀú °³¹ßµÇ¾ú´Âµ¥, ÀÌ iODBC µå¶óÀ̹ö °ü¸®ÀÚ ¸¹Àº UNIXÇÏ¿¡¼­ µ¹¾Æ°¡´Â ¹«·á ¹èÆ÷°¡ °¡´ÉÇÑ ODBC µå¶óÀ̹ö °ü¸®ÀÚÀÌ´Ù. DIRÀº iODBC°¡ ¼³Ä¡µÈ µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /usr/localÀÌ´Ù.

FreeODBC home page or iODBC home page


OpenLink ODBC

      --with-openlink=DIR 

OpenLink ODBC Áö¿øÀ» Æ÷ÇÔÇϵµ·Ï ÇÑ´Ù. DIRÀº OpenLink ODBC°¡ ¼³Ä¡µÈ µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /usr/local/openlinkÀÌ´Ù.

OpenLink Software's home page


Oracle

      --with-oracle=DIR     

¿À¶óŬ Áö¿øÀ» Æ÷ÇÔÇϵµ·Ï ÇÑ´Ù. ¿À¶óŬ ¹öÀü 7.0¿¡¼­ 7.3±îÁö´Â µ¿ÀÛÀ» Å×½ºÆ®ÇÏ¿© ¹®Á¦°¡ ¾ø¾ú´Ù. DIRÀº ORACLE_HOME µð·ºÅ丮ÀÌ´Ù. ¿À¶óŬ ȯ°æÀÌ ÀÌ¹Ì ¼³Á¤µÇ¾î ÀÖ´Ù¸é, DIRÀ» ¹Ýµå½Ã Á¤ÇØÁÙ ÇÊ¿ä´Â ¾ø´Ù.

Oracle home page


PostgreSQL

      --with-pgsql=DIR     

IPostgreSQLÁö¿øÀ» Æ÷ÇÔÇϵµ·Ï ÇÑ´Ù. DIRÀº PostgreSQLÀÌ ¼³Ä¡µÈ base µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /usr/local/pgsqlÀÌ´Ù.

See also Postgres Configuration Directives in the configuration file.

PostgreSQL home page


Solid

      --with-solid=DIR     

SolidÁö¿øÀ» Æ÷ÇÔÇϵµ·Ï ÇÑ´Ù. =DIRÀº Solid°¡ ¼³Ä¡µÈ µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /usr/local/solidÀÌ´Ù.

Solid home page


Sybase

      --with-sybase=DIR     

SybaseÁö¿øÀ» Æ÷ÇÔÇϵµ·Ï ÇÑ´Ù. DIRÀº Sybase°¡ ¼³Ä¡µÈ µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /home/sybaseÀÌ´Ù.

See also Sybase Configuration Directives in the configuration file.

Sybase home page


Sybase-CT

      --with-sybase-ct=DIR     

Sybase-CTÁö¿øÀ» Æ÷ÇÔÇϵµ·Ï ÇÑ´Ù. DIRÀº Sybase-CT°¡ ¼³Ä¡µÈ µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /home/sybaseÀÌ´Ù.

See also Sybase-CT Configuration Directives in the configuration file.


Velocis

      --with-velocis=DIR     

VelocisÁö¿øÀ» Æ÷ÇÔÇϵµ·Ï ÇÑ´Ù. DIRÀº Velocis°¡ ¼³Ä¡µÈ µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /usr/local/velocisÀÌ´Ù.

Velocis home page


A custom ODBC library

      --with-custom-odbc=DIR     

»ç¿ëÀÚ ÁöÁ¤ÀÇ ODBC ¶óÀ̺귯¸® Áö¿øÀ» Æ÷ÇÔÇϵµ·Ï ÇÑ´Ù. DIRÀº base µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /usr/localÀÌ´Ù.

ÀÌ ¿É¼ÇÀ» »ç¿ëÇÏ·Á¸é ¿©·¯ºÐÀº configure ½ºÅ©¸³Æ®¸¦ ½ÇÇàÇÒ ¶§ CUSTOM_ODBC_LIBS¸¦ ÀÌ¹Ì Á¤ÀÇÇØ ÁÖ¾ú¾î¾ß ÇÑ´Ù. ¶ÇÇÑ, ¿©·¯ºÐÀÇ include path¿¡´Â ÀûÇÕÇÑ odbc.h¶ó´Â Çì´õ ÆÄÀÏÀÌ ¹Ýµå½Ã ÀÖ¾î¾ß ÇÑ´Ù. ¸¸¾à ¾ø´Ù¸é, ¿©·¯ºÐÀÌ ¸¸µé¾î¼­ Æ÷ÇÔ½ÃÄÑ¾ß ÇÑ´Ù. Çì´õ¿¡´Â Á» Ưº°ÇÑ Á¤ÀǵéÀÌ ÇÊ¿äÇÏ°Ô µÇ´Âµ¥, ƯÈ÷ ±×°ÍÀÌ multiplatformÀÏ °æ¿ì´Â »ó¼¼È÷ Àû¾îÁÖ¾î¾ß ÇÑ´Ù. ±× Á¤ÀÇ´ÂCFLAGS ¿É¼Ç¿¡ Àû¾îÁØ´Ù.

¿¹¸¦µé¾î ´ÙÀ½°ú °°Àº ¿É¼ÇÀ¸·Î QNX ÇÏ¿¡¼­ Sybase SQL Anywhere¸¦ »ç¿ëÇÒ¼ö ÀÖ´Ù. : CFLAGS=-DODBC_QNX LDFLAGS=-lunix CUSTOM_ODBC_LIBS="-ldblib -lodbc" ./configure --with-custom-odbc=/usr/lib/sqlany50


Unified ODBC

      --disable-unified-odbc 

Unified ODBC ¸ðµâÀ» »ç¿ëÇÏÁö ¾Êµµ·ÏÇÑ´Ù. ÀÌ Unified ODBC ¸ðµâÀº Solid³ª Adabas D°°Àº ODBC±â ¹ÝÀÇ ÀÎÅÍÆäÀ̽º(ODBC-based interface)¸¦ °¡Áö°í ÀÖ´Â ¸ðµç databaseÀÇ °øÅëÀÇ interfaceÀÌ´Ù. ¶ÇÇÑ ÀÌ ¸ðµâÀº º¸ÅëÀÇ ODBC ¶óÀ̺귯¸®¸¦ À§ÇØ µ¿ÀÛÇÑ´Ù. ÀÌ ¿É¼ÇÀº iODBC¿Í Solid, Adabas D, Sybase SQL Anywhere¿¡¼­ ½ÃÇèÀ» °ÅÃÆ´Ù. ÀÌ ¿É¼ÇÀ» »ç¿ëÇÏ·Á ¸é À§ÀÇ ¸ðµâµé Áß Çϳª(¹Ýµå½Ã Çϳª¸¸)°Å³ª, vELOCIS ¸ðµâÀÌ enabledµÇ¾î Àְųª custom ODBC library°¡ ¼³Á¤µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù. Áï, ÀÌ ¿É¼ÇÀº ´ÙÀ½°ú °°Àº ¿É¼ÇÁß Çϳª°¡ »ç¿ëµÇ¾úÀ» °æ¿ì¸¸ »ç¿ëÀÌ °¡´ÉÇÏ´Ù. : --with-iodbc, --with-solid, --with-adabas, --with-velocis, --with-custom-odbc.

See also Unified ODBC Configuration Directives in the configuration file.


LDAP

      --with-ldap=DIR     

LDAP (Lightweight Directory Access Protocol) Áö¿øÀ» Æ÷ÇÔÇÑ´Ù. DIRÀº LDAP°¡ ¼³Ä¡µÈ base µð·ºÅ丮ÀÌ°í, ±âº»°ªÀº /usr/local/ldapÀÌ´Ù.

LDAP¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ¼³¸íÀº RFC1777 °ú RFC1778¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.


±âŸ ¼³Á¤ ¿É¼Ç


--with-mcrypt=DIR

      --with-mcrypt

mcrypt ¶óÀ̺귯¸®¸¦ Æ÷ÇÔÇÑ´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº mcrypt documentationÀ» º¸ÀÚ. DIR ¿É¼ÇÀ» ÁְԵǸé PHP´Â DIR/include¿¡¼­ mcrypt.h¸¦ ã´Â´Ù.


--enable-sysvsem

      --enable-sysvsem

´ëºÎºÐÀÇ UNIX¿¡¼­ Áö¿øÇÏ´Â Sys V ¼¼¸¶Æ÷¾îÀÇ Áö¿øÀ» Æ÷ÇÔÇÑ´Ù. ÀÚ¼¼ÇÑ Á¤º¸´Â Semaphore and Shared Memory documentationÀ» ÀÐ¾î º¸µµ·Ï ÇÑ´Ù.


--enable-sysvshm

      --enable-sysvshm

´ëºÎºÐÀÇ UNIX¿¡¼­ Áö¿øÇÏ´Â Sys V ÀÇ °øÀ¯ ¸Þ¸ð¸®(shared memory) Áö¿øÀ» Æ÷ÇÔÇÑ´Ù. ÀÚ¼¼ÇÑ Á¤º¸´Â Semaphore and Shared Memory documentationÀ» ÀÐ¾î º¸µµ·Ï ÇÑ´Ù.


--with-xml

      --with-xml     

James ClarkÀÇ expat library¸¦ »ç¿ëÇÑ, ¾ÆÁ÷ °øÀιÞÁö ¸øÇÑ XML parser¸¦ »ç¿ëÇϵµ·Ï ÇÑ´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº XML function referenceÀ» º¸ÀÚ.


--enable-maintainer-mode

      --enable-maintainer-mode

PHP°³¹ßÀÚµéÀ» À§ÇÑ ÄÄÆÄÀÏ·¯ ÁÖÀÇ ¸Þ½ÃÁö³ª, extra dependencie ¸Þ½ÃÁöµîÀ» Ãâ·ÂÇÏ°Ô ÇÑ´Ù.


--with-system-regex

      --with-system-regex

Á¤±Ô Ç¥Çö½Ä(regular expression) ¶óÀ̺귯¸®¸¦ PHP¿Í °°ÀÌ Á¦°øµÈ °ÍÀÌ ¾Æ´Ñ, ½Ã½ºÅÛÀÇ °ÍÀ» »ç¿ëÇϵµ·Ï ÇÑ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ PHP¸¦ ¼­¹ö ¸ðµâ·Î ¸¸µç´Ù¸é, ¿©·¯ºÐÀº ¼­¹ö¸¦ ¸¸µé ¶§¿Í °°Àº ¶óÀ̺귯¸®¸¦ PHP¸¦ ¸¸µé ¶§µµ »ç¿ëÇÏ¿©¾ß ÇÑ´Ù. ¸¸¾à ½Ã½ºÅÛÀÇ ¶óÀ̺귯¸®°¡ ¿©·¯ºÐÀÌ ¿øÇϴ Ưº°ÇÑ ±â´ÉÀ» °¡Áö°í ÀÖ´Ù¸é ÀÌ ¿É¼ÇÀ» Enable½ÃÅ°µµ·Ï ÇÏÀÚ. ±×·¯³ª, °¡´ÉÇϸé PHP¿Í °°ÀÌ Á¦°øµÈ ¶óÀ̺귯¸®¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ±ÇÀåµÈ´Ù.


--with-config-file-path

      --with-config-file-path=DIR     

PHP°¡ ½ÃÀÛµÉ ¶§ »ç¿ëÇÒ configuration file(php3.ini)À» ãÀ» µð·ºÅ丮¸¦ Á¤ÇØÁØ´Ù.


--with-exec-dir

      --with-exec-dir=DIR     

¾ÈÀü ¸ðµå(safe mode)ÀÏ ¶§, ¿©±â¼­ ÁöÁ¤ÇØ ÁØ =DIR¾ÈÀÇ ½ÇÇà ÆÄÀϸ¸ ½ÇÇàÀÌ °¡´ÉÇÏ´Ù. ±âº»°ªÀº /usr/local/binÀÌ´Ù. ÀÌ ¿É¼ÇÀº ´ÜÁö Default°ªÀ» ÁöÁ¤ÇØ ÁÖ´Â °Í »ÓÀÌ°í, configuration fileÀÇ safe_mode_exec_dir Áö½ÃÀÚ¿¡ ÀÇÇؼ­ ³ªÁß¿¡ ¹Ù²ð ¼ö ÀÖ´Ù.


--disable-debug

      --disable-debug     

¶óÀ̺귯¸®³ª ½ÇÇà ÆÄÀÏ¿¡ µð¹ö±× Á¤º¸¸¦ Æ÷ÇÔ½ÃÅ°Áö ¾Ê´Â´Ù. µð¹ö±× Á¤º¸´Â ¹ö±×ÀÇ À§Ä¡¸¦ Á¤È®ÇÏ°Ô ³ªÅ¸³»´Âµ¥ µµ¿òÀ» ÁØ´Ù. µû¶ó¼­, PHP°¡ alpha³ª beta»óÅÂÀÏ °æ¿ì¿¡´Â µð¹ö±× Á¤º¸¸¦ Æ÷ÇÔ½ÃÅ°´Â °ÍÀÌ ÁÁ´Ù.


--enable-safe-mode

      --enable-safe-mode     

±âº»°ªÀ¸·Î "¾ÈÀü ¸ðµå"(safe mode)¸¦ ÁöÁ¤ÇÑ´Ù. ¾ÈÀü ¸ðµå´Â ¹®¼­ÀÇ root¿¡ ÀÖ´Â ÆÄÀϸ¸À» ¿­¼ö ÀÖ°Ô ÇÏ´Â µî, PHP°¡ ÇÒ ¼ö ÀÖ´Â ÀÛ¾÷¿¡ ¿©·¯ °¡Áö Á¦¾àÀ» °¡ÇÑ´Ù. ´õ ÀÚ¼¼ÇÑ Á¤º¸´Â Security chapter¸¦ Àо±â ¹Ù¶õ´Ù. CGI»ç¿ëÀÚµéÀº ¾ðÁ¦³ª secure mode¿¡¼­ »ç¿ëÇÏ¿©¾ß ÇÑ´Ù. ÀÌ ¿É¼ÇÀº ´ÜÁö Default °ªÀ» Á¤ÇÏ´Â °Í »ÓÀÌ°í, ÈÄ¿¡ configuration fileÀÇ safe_mode Áö½ÃÀÚ¿¡ ÀÇÇØ Enable/Disable µÉ ¼ö ÀÖ´Ù.


--enable-track-vars

      --enable-track-vars     

HTTP_GET_VARS, HTTP_POST_VARS, HTTP_COOKIE_VARS ¹è¿­¿¡ µé¾îÀÖ´Â GET / POST / cookie º¯¼öµéÀÌ ¾îµð¼­ ¿Ô´ÂÁö ±â¾ïÇÏ°í ÀÖ°Ô ¸¸µç´Ù. ÀÌ ¿É¼ÇÀº ´ÜÁö Default °ªÀ» Á¤ÇÏ´Â °Í »ÓÀÌ°í, ÈÄ¿¡ configuration fileÀÇ track_vars Áö½ÃÀÚ¿¡ ÀÇÇØ Enable/Disable µÉ ¼ö ÀÖ´Ù.


--enable-magic-quotes

      --enable-magic-quotes     

magic quotesÀÇ ±âº»°ªÀ» Enable·Î ÇÑ´Ù. ÀÌ ¿É¼ÇÀº ´ÜÁö Default °ªÀ» Á¤ÇÏ´Â °Í »ÓÀÌ°í, ÈÄ¿¡ configuration fileÀÇ magic_quotes_runtimeÁö½ÃÀÚ¿¡ ÀÇÇØ Enable/Disable µÉ ¼ö ÀÖ´Ù.

magic_quotes_gpc ¿Í magic_quotes_sybase Áö½ÃÀÚ¸¦ ÂüÁ¶ÇÏ¿© º¸±â ¹Ù¶õ´Ù.


--enable-debugger

      --enable-debugger     

³»ÀåµÈ PHP µð¹ö°Å Áö¿øÀ» °¡´ÉÇÏ°Ô ÇÑ´Ù. ÀÌ ±â´ÉÀº ¾ÆÁ÷ ½ÇÇèÀûÀÎ »óÅÂÀÌ´Ù.

configuration fileÀÇ Debugger Configuration Áö½ÃÀÚ¸¦ »ìÆ캸ÀÚ.


--enable-discard-path

      --enable-discard-path     

¸¸¾à ÀÌ°ÍÀÌ EnabledµÇ¸é, PHP CGI ½ÇÇàÆÄÀÏÀÌ À¥ Æ®¸® ¹Û¿¡ ¾ÈÀüÇÏ°Ô À§Ä¡ÇÒ ¼ö ÀÖ°Ô µÇ¾î »ç¿ëÀÚµéÀÌ .htaccess security¸¦ ÇÇÇÒ ¼ö ¾ø°Ô µÈ´Ù. ÀÚ¼¼ÇÑ »çÇ×Àº section in the security chapter¸¦ Àо±â ¹Ù¶õ´Ù.


--enable-bcmath

      --enable-bcmath     

bc Çü½ÄÀÇ ¼öÀÇ Á¤¹Ðµµ(precision)¸¦ ¸¶À½´ë·Î Á¶Á¤ÇÒ ¼ö ÀÖ´Â ¼öÇÐ ÇÔ¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù.

See also the bcmath.scale option in the configuration file.


--enable-force-cgi-redirect

      --enable-force-cgi-redirect     

³»ºÎÀûÀÎ ¼­¹ö ¸®µð·ºÆ®(internal server redirects) ½Ã¿¡ º¸¾È °Ë»ç(security check)¸¦ Çϵµ·Ï ÇÑ´Ù. ¿©·¯ºÐÀÌ Apache¿Í ÇÔ²² CGI ¹öÀüÀ» »ç¿ëÇÑ´Ù¸é ¹Ýµå½Ã ÀÌ ¿É¼ÇÀ» »ç¿ëÇÏ¿©¾ß ÇÑ´Ù.

GI binaryÇüÅ·ΠPHP¸¦ »ç¿ëÇÒ ¶§, PHP´Â ±âº»ÀûÀ¸·Î ±×°ÍÀÌ ¸®µð·º¼ÇÀ¸·Î »ç¿ëµÇ¾ú´Â°¡¸¦ ¿ì¼± °Ë»çÇÑ´Ù(¿¹¸¦ µé¾î, Apache¿¡¼­ Action directives¸¦ »ç¿ëÇÑ °æ¿ìÀÌ´Ù). ÀÌ ¿É¼ÇÀ» »ç¿ëÇϸé http://my.host/cgi-bin/php/secret/doc.html°ú °°Àº ¹æ¹ýÀ¸·Î PHP binary¸¦ Á÷Á¢ È£ÃâÇÏ¿© Ç¥ÁØ web server authentication ÀýÂ÷¸¦ ȸÇÇÇÏ´Â ¹æ¹ýÀ» »ç¿ëÇÒ ¼ö ¾ø°Ô µÈ´Ù. ÀÌ ¿¹´Â http://my.host/secret/doc.html¿¡ Á¢±ÙÇÒ ¼ö ÀÖÁö¸¸, httpd°¡ /secretµð·ºÅ丮¿¡ ¼³Á¤ÇÑ ¾î¶°ÇÑ º¸¾È ¼³Á¤¿¡µµ ¿µÇâÀ» ¹ÞÁö ¾Ê°Ô µÈ´Ù.

ÀÌ ¿É¼ÇÀ» EnableÇÏÁö ¾ÊÀ¸¸é httpddÀÇ º¸¾È°ú ÀÎÁõ ¼³Á¤À» üũÇÏÁö ¾Ê°í, ȸÇÇ°¡ °¡´ÉÇÏ°Ô µÈ´Ù. ÀÌ ¿É¼ÇÀº ¼­¹ö ¼ÒÇÁÆ®¿þ¾î°¡ ¾ÈÀüÇÑ ¸®µð·º¼ÇÀÌ µÇ¾î ÀÖ´Ù´Â °ÍÀ» ³ªÅ¸³»´Â °ÍÀÌ ºÒ°¡´ÉÇÏ°í, document root¿Í »ç¿ëÀÚ µð·ºÅ丮 ¾Æ·¡ÀÇ ¸ðµç ÆÄÀÏÀÌ ´©±¸¿¡°Ô³ª °³¹æµÇ¾î ÀÖÀ» ¶§¸¸ »ç¿ëÇÏÀÚ.

ÀÌ ¿É¼Ç¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ¼³¸íÀº section in the security chapterÀ» Àо±â ¹Ù¶õ´Ù


--disable-short-tags

      --disable-short-tags     

short form <? ?> PHP ű×ÀÇ »ç¿ëÀ» ºÒ°¡´ÉÇÏ°Ô ÇÑ´Ù. ¿©·¯ºÐÀº PHP¿Í XMLÀ» ÇÔ²² »ç¿ëÇÒ °æ¿ì short formÀÇ »ç¿ëÀ» ºÒ°¡´ÉÇÏ°Ô ÇÏ¿©¾ß ÇÑ´Ù. ªÀº ű×ÀÇ »ç¿ëÀÌ ºÒ°¡´ÉÇÏ´Ù¸é, PHPÀÇ ÄÚµå´Â ű״ <?php ?> »ÓÀÌ´Ù. ÀÌ ¿É¼ÇÀº ´ÜÁö Default °ªÀ» Á¤ÇÏ´Â °Í »ÓÀÌ°í, ÈÄ¿¡ configuration fileÀÇ short_open_tag Áö½ÃÀÚ¿¡ ÀÇÇØ Enable/Disable µÉ ¼ö ÀÖ´Ù.


--enable-url-includes

      --enable-url-includes     

include()ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© PHP¿¡¼­ Á÷Á¢ ´Ù¸¥ HTTP³ª FTP¼­¹ö¿¡ ÀÖ´Â Äڵ带 ½ÇÇà½Ãų¼ö ÀÖµµ·Ï ÇÑ´Ù.

See also the include_path option in the configuration file.


--disable-syntax-hl

      --disable-syntax-hl 

syntax highlighting ±â´ÉÀ» ²ö´Ù.


CPPFLAGS and LDFLAGS

PHP¸¦ ¼³Ä¡ÇÒ ¶§ ´Ù¸¥ µð·ºÅ丮¿¡ ÀÖ´Â Çì´õ³ª ¶óÀ̺귯¸®¸¦ ã¾Æ¼­ ¸¸µé·Á¸é, CPPFLAGS ¿Í LDFLAGS ȯ°æº¯¼ö¸¦ °¢°¢ ¼öÁ¤ÇØ ÁÖ¾î¾ß ÇÑ´Ù. ¿©·¯ºÐÀÌ ÀϹÝÀûÀÎ ½©À» »ç¿ëÇÏ°í ÀÖ´Ù¸é ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÏ´Â °ÍÀÌ °¡´ÉÇÒ °ÍÀÌ´Ù. LDFLAGS=-L/my/lib/dir CPPFLAGS=-I/my/include/dir ./configure


Building

PHPÀÇ ¼³Á¤ÀÌ ¿Ï·áµÇ¸é ¿©·¯ºÐÀº PHP ¶óÀ̺귯¸®³ª CGI ½ÇÇà ÆÄÀÏÀ» »ý¼ºÇÒ Áغñ°¡ ³¡³­ °ÍÀÌ´Ù. make ¸í·ÉÀ¸·Î ¿©·¯ºÐÀº ±×°ÍÀ» ¸¸µé ¼ö ÀÖ´Ù. ¸¸¾à ¸¸µé ¼ö ¾ø°í ±× ÀÌÀ¯¸¦ ¸ð¸¦ °æ¿ì¿¡´Â Problems sectionÀ» »ìÆ캸±â ¹Ù¶õ´Ù.

( ¿ªÀÚÁÖ : PHP¸¦ Apache ¸ðµâ·Î ¸¸µé¾ú´Ù¸é restart°¡ ¾Æ´Ñ stopÈÄ startÇÏ¿©¾ß ÇÕ´Ï´Ù.)


Testing

PHP¸¦ CGI ÇÁ·Î±×·¥ ÇüÅ·Π¸¸µé¾ú´Ù¸é, ¿©·¯ºÐÀº make test¶ó°í ÀÔ·ÂÇÏ¿© Å×½ºÆ®ÇØ º¼ ¼ö ÀÖ´Ù. ÀÌ ¹æ¹ýÀº °á°ú¹°À» Å×½ºÆ®ÇÏ´Â ¾ðÁ¦³ª ÁÁÀº ¹æ¹ýÀÌ´Ù. ÀÌ ¹æ¹ýÀº ¿©·¯ºÐÀÇ ½Ã½ºÅÛ È¯°æ¿¡¼­ ³ªÁß¿¡ ¹®Á¦·Î °ñÄ¡ ½âÀÌÁö ¾Ê°í ¹Ì¸® PHPÀÇ ¹®Á¦¸¦ ¹ß°ßÇÒ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù.


Benchmarking

PHP¸¦ CGI ÇÁ·Î±×·¥ ÇüÅ·Π¸¸µé¾ú´Ù¸é, ¿©·¯ºÐÀº make bench¶ó°í ÀÔ·ÂÇÏ¿© º¥Ä¡¸¶Å© Å×½ºÆ®¸¦ ÇÒ ¼ö ÀÖ´Ù. ¾ÈÀü ¸ðµå(safe mode)ÀÇ ±âº»°ªÀÌ on µÇ¾î ÀÖÀ» ¶§´Â, ÀÛ¾÷ÀÌ Çã¿ëµÈ 30ÃÊ º¸´Ù ¸¹ÀÌ °É¸®°Ô µÇ¸é º¥Ä¡¸¶Å©¸¦ ³¡³¾ ¼ö ¾ø´Ù. ÀÌ°ÍÀº ¾ÈÀü ¸ðµå¿¡¼­´Â set_time_limit() ÇÔ¼ö¸¦ »ç¿ëÇÒ ¼ö ¾ø±â ¶§¹®ÀÌ´Ù. ½ºÅ©¸³Æ®¿¡¼­ max_execution_timeÀ» Á¶ÀýÇÏ¿© ÀÌ ½Ã°£ °£°ÝÀ» Á¶ÀýÇÑ´Ù. make bench´Â configuration fileÀ» ¹«½ÃÇÑ´Ù.


PHP Installation Guide for Windows

ÀÌ ¼³Ä¡ ¾È³»¼­´Â ¿©·¯ºÐ¿¡°Ô PHP¸¦ Windows 9x/NT À¥¼­¹ö¿¡¼­ ¼³Ä¡ÇÏ°í ¼³Á¤Çϴµ¥ µµ¿òÀ» ÁÙ °ÍÀÔ´Ï´Ù. ÀÌ ¾È³»¼­´Â Bob Silva¿¡ ÀÇÇØ ÀÛ¼ºµÇ¾ú½À´Ï´Ù. µû¶ó¼­ °¡Àå ÃÖ½ÅÀÇ °³Á¤ÆÇÀº http://www.umesd.k12.or.us/php/win32install.html¿¡¼­ ãÀ» ¼ö ÀÖÀ» °ÍÀÔ´Ï´Ù.

ÀÌ ¾È³»¼­´Â ´ÙÀ½°ú °°Àº À¥¼­¹ö¸¦ ´ë»óÀ¸·Î ÇÕ´Ï´Ù.


ÀϹÝÀûÀÎ ¼³Ä¡ °úÁ¤

À¥ ¼­¹öÀÇ Á¾·ù¿Í °ü°è¾øÀÌ ´ÙÀ½ÀÇ ¼³Ä¡ °úÁ¤µéÀÌ ¿Ï·áµÇ¾î¾ß ÇÑ´Ù.

PHP È®ÀåÀ» À§ÇÑ DLLµéÀº 'php3_'·Î ½ÃÀÛÇÑ´Ù. ÀÌ°ÍÀº PHP È®ÀåÀ» À§ÇÑ DLLµé°ú ÀÚüÀûÀÎ Áö¿øÀ» À§ÇÑ DLLµé°£ÀÇ È¥¶õÀ» ¹æÁöÇϱâ À§Çؼ­ÀÌ´Ù.


Windows 95/98/NT¿Í PWS/IIS 3

ÀÌ ¼­¹öµé¿¡¼­ÀÇ ¼³Á¤Àº ¹èÆ÷ÆÇÀÇ INF ÆÄÀÏ(php_iis_reg.inf)À» »ç¿ëÇÏ´Â °ÍÀ» ±ÇÇÑ´Ù. ¿©·¯ºÐÀº ÀÌ ÆÄÀÏÀ» ¼öÁ¤ÇÏ¿© ¿©·¯ºÐÀÌ ¿øÇÏ´Â PHP ¼³Ä¡ µð·ºÅ丮¿Í È®Àå ³»¿ëµéÀ» ¼³Á¤ÇÒ ¼ö ÀÖ´Ù. ¸¸¾à ¼öµ¿À¸·Î ¼³Á¤ÇÏ°í ½Í´Ù¸é ´ÙÀ½°ú °°ÀÌ ÇÕ´Ï´Ù.

ÁÖÀÇ : ÀÌ °úÁ¤Àº À©µµ¿ìÀÇ resistry¸¦ Á÷Á¢ ´Ù·ì´Ï´Ù. ÇϳªÀÇ ½Ç¼ö°¡ ¿©·¯ºÐÀÇ ½Ã½ºÅÛ Àüü¸¦ ºÒ¾ÈÇÑ »óÅ·Π¸¸µé ¼ö ÀÖ½À´Ï´Ù. ¿ì¸®´Â ¿©·¯ºÐÀÌ registry¸¦ ÆíÁýÇϱâ Àü¿¡ ¹Ýµå½Ã ÆíÁý ÀüÀÇ registry¸¦ ¹é¾÷ÇØ ³õÀ» °Í. PHP °³¹ßÆÀÀº ¾î¶°ÇÑ registryÀÇ Æļյµ Ã¥ÀÓÁöÁö ¾Ê½À´Ï´Ù. ¸¸¾à registry¿¡ ¼Õ»óÀÌ °¥ °æ¿ì OS¸¦ »õ·Î ±ò±â Àü¿¡´Â ºÎÆõÇÁö ¾ÊÀ» ¼öµµ ÀÖ½À´Ï´Ù.

PWS¿Í IIS 3 »ç¿ëÀÚµéÀº ÇöÀç ¿ÏÀüÇÑ ¿î¿µÁßÀÎ ½Ã½ºÅÛÀ» °®°í ÀÖ½À´Ï´Ù. IIS 3 »ç¿ëÀÚµéÀº Steven Genusa°¡ ÀÛ¼ºÇÑ ½ºÅ©¸³Æ® ¸ÊÀ» ¼³Á¤ÇÏ´Â ¸Å·ÂÀûÀÎ toolÀ» »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.


Windows NT¿Í IIS 4

PHP¸¦ IIS 4°¡ ¿î¿µÁßÀÎ NT Server¿¡ ¼³Ä¡ÇÏ·Á¸é ´ÙÀ½ °úÁ¤À» µû¸¥´Ù.


Windows 9x/NT¿Í Apache 1.3.x

Apache¸¦ PHP CGI binary¿Í ÇÔ²² ½ÇÇàÇϵµ·Ï ¼³Á¤ÇÏ·Á¸é srm.confÀ̳ª httpd.conf¸¦ ´ÙÀ½°ú °°ÀÌ ¼öÁ¤ÇÏ¿©¾ß ÇÑ´Ù.

ºñ·Ï ApacheÇÏ¿¡¼­ PHPÀÇ ¼³Á¤ÀÌ ¾à°£ Â÷ÀÌ°¡ ÀÖÀ»Áö ¸ð¸£Áö¸¸, ÀÌ ¼³Á¤Àº Ãʺ¸ÀÚµµ ÇÒ ¼ö ÀÖÀ» Á¤µµ·Î ½±´Ù. ¿©±â¿¡ ³ª¿Â °Í ÀÌ»óÀÇ ¼³Á¤ Áö½ÃÀÚ´Â Apache Docs¸¦ ÂüÁ¶Çϵµ·Ï ÇÏÀÚ.

¼Ò½º ÄÚµå ÇÏÀ̶óÀÌÆà ±â´É(¼Ò½º¿¡ »ö±òÀ» ³Ö¾î¼­ º¸±â ÁÁ°Ô Ãâ·ÂÇØ ÁÖ´Â ±â´É)À» »ç¿ëÇϱâ À§Çؼ­´Â ´ÙÀ½°ú °°Àº ³»¿ëÀ» °¡Áö´Â ½ºÅ©¸³Æ®¸¦ ¸¸µé¾îÁÖ¸é µÈ´Ù. : <?php show_source ("original_php_script.php3"); ?>. ¿©±â¼­ original_php_script.php3¸¦ ¿©·¯ºÐÀÌ ¿øÇÏ´Â ¼Ò½º ÄÚµåÀÇ À̸§À¸·Î ¹Ù²ãÁÖ¸é µÈ´Ù.

Note: Win-Apache¿¡¼­ "c:\directory\file.ext"¿Í °°ÀÌ path¿¡ »ç¿ëµÇ´Â ¸ðµç ¹é½½·¡½Ã(\)´Â ÀÏ¹Ý ½½·¡½Ã(/)·Î ¹Ù²ã¾ß ÇÕ´Ï´Ù.


Windows¿¡¼­ Omni HTTPd 2.0b1

ÀÌ ¼³Á¤Àº ¸Å¿ì ½¬¿î ÆíÀÌ´Ù.

Step 1: Omni server¸¦ ¼³Ä¡ÇÑ´Ù.

Step 2: system trayÀÇ Çª¸¥»ö OmniHTTPd ¾ÆÀÌÄÜ¿¡¼­ ¿À¸¥ÂÊ ¹öÆ°À» Ŭ¸¯ÇÏ¿© Properties(µî·ÏÁ¤º¸)¸¦ ¼±ÅÃÇÑ´Ù.

Step 3: Web Server Global SettingsÀ» Ŭ¸¯ÇÑ´Ù.

Step 4: 'External' ÅÇ¿¡¼­ ´ÙÀ½À» ÀÔ·ÂÇÑ´Ù. : virtual = .php3 | actual = c:\path-to-php-dir\php.exe

Step 5: Mime ÅÇ¿¡¼­ ´ÙÀ½À» ÀÔ·ÂÇÑ´Ù. : virtual = wwwserver/stdcgi | actual = .php3

Step 6: OK¸¦ Ŭ¸¯ÇÑ´Ù.

PHPÀÇ ¸ðµç È®ÀåÀÚ¿¡ ´ëÇØ steps 2 - 6À» ¹Ýº¹ÇÑ´Ù.


PHP Modules

Table 2-1. PHP Modules

php3_calendar.dll

Calendar conversion functions

php3_crypt.dll

Crypt functions

php3_dbase.dll

DBase functions

php3_dbm.dll

GDBM emulation via Berkely DB2 library

php3_filepro.dll

READ ONLY access to filepro databases

php3_gd.dll

GD Library functions for gif manipulation

php3_hyperwave.dll

HyperWave functions

php3_imap4r2.dll

IMAP 4 functions

php3_ldap.dll

LDAP functions

php3_msql1.dll

mSQL 1 client

php3_msql2.dll

mSQL 2 client

php3_mssql.dll

MSSQL client (requires MSSQL DB-Libraries)

php3_mysql.dll

MySQL functions

php3_nsmail.dll

Netscape mail functions

php3_oci73.dll

Oracle functions

php3_snmp.dll

SNMP get and walk functions (NT only!)

php3_zlib.dll

ZLib functions


Problems?


Read the FAQ

ÀϺΠÁú¹®µéÀº °øÅëÀûÀÎ °ÍÀÌ ¸¹´Ù. PHP FAQ¿¡ ÀÌ °øÅëÀûÀÎ Áú¹®µéÀÌ ¸ð¿©ÀÖÀ¸´Ï ã¾Æº¸ÀÚ. ÀÌ ¹®¼­´Â http://www.php.net/FAQ.php3¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.

(¿ªÀÚÁÖ : FAQÀÇ ¹ø¿ªº»Àº http://w3.to/regina/FAQ.htm¿¡ ¹ø¿ªµÇ¾î ÀÖÀ¸³ª ÃÖ½ÅÆÇÀº ¾Æ´Ï´Ù.)


Bug reports

¸¸¾à ¿©·¯ºÐÀÌ Bug¶ó°í »ý°¢µÇ´Â °ÍÀÌ ¹ß°ßµÉ °æ¿ì ÀÌ°ÍÀ» ¹Ýµå½Ã º¸°íÇØ Áֱ⠹ٶõ´Ù. PHPÀÇ °³¹ßÀÚµéÀº ¾Æ¸¶ ±× ¹ö±×¿¡ ´ëÇØ ¿©·¯ºÐÀÌ ¾Ë·ÁÁÖ±â Àü¿¡´Â ¸ð¸£°í ÀÖÀ» °ÍÀÌ´Ù. ¿©·¯ºÐÀÇ ¹ö±× ·¹Æ÷Æ®·Î ±× ¹ö±×µéÀ» ÀâÀ» ¼ö ÀÖ´Ù. ¹ö±× º¸°í¿ë ÆûÀÌ PHP »çÀÌÆ®¿¡ ÀÖ´Ù. ÁÖ¿ä ¾ç½ÄÀº http://ca.php.net/bugs.php3¿¡¼­ ãÀ» ¼ö ÀÖÀ» °ÍÀÌ´Ù. (¿ªÀÚÁÖ: ¹ö±× ·¹Æ÷Æ®´Â ¿µ¾î·Î ½á¾ß °ÚÁö¿ä. Hi)


Other problems

¸¸¾à ¿©·¯ºÐÀÌ ¾ÆÁ÷µµ °í»ýÇÏ°í ÀÖ´Ù¸é, PHPÀÇ ¸ÞÀϸµ ¸®½ºÆ®(mailing list)°¡ µµ¿òÀ» ÁÙ ¼ö ÀÖÀ» °ÍÀÌ´Ù. ¿©·¯ºÐÀÌ ¸¸¾à ¾î¶² Áú¹®À» Çϱâ Àü¿¡ ¿ì¼± º¸°ü ¹®¼­(archive)¸¦ ã¾Æº¸¾Æ °°Àº ¹®Á¦¿¡ ´ëÇÑ ÇØ´äÀÌ ÀÖ´ÂÁö ã¾Æº¸´Â °ÍÀ» ÀØÁö ¸»µµ·Ï ÇÏÀÚ. º¸°ü ¹®¼­´Â http://www.php.net/¿¡¼­ ã¾Æ º¼ ¼ö ÀÖ´Ù. PHP ¸ÞÀϸµ ¸®½ºÆ®¿¡ Âü°¡ÇÏ·Á¸é php3-subscribe@lists.php.netÀ¸·Î ºó ÆíÁö¸¦ Çϳª º¸³»¸é µÈ´Ù. mailing list ÁÖ¼Ò´Â php3@lists.php.netÀÌ´Ù.

¸¸¾à ¿©·¯ºÐÀÌ mailing list¸¦ ÅëÇؼ­ ¾î¶² µµ¿òÀ» ¹Þ°í ½Í´Ù¸é, Áú¹®½Ã¿¡ ÀÚ¼¼ÇÏ°í ¸íÈ®ÇÑ Áú¹®°ú ÇÔ²², ¿©·¯ºÐÀÇ ¿î¿µ ȯ°æ¿¡ ´ëÇÑ ¼¼ºÎÇ׸ñÀ» ÷ºÎÇÏ´Â °ÍÀÌ ÁÁ´Ù (¿î¿µÃ¼°è, PHP ¹öÀü, À¥¼­¹öÀÇ Á¾·ù¿Í ¹öÀü, PHP¸¦ CGI·Î ¾²°í ÀÖ´ÂÁö ¸ðµâ·Î ¾²°í ÀÖ´ÂÁö µî). ¶ÇÇÑ ¿©·¯ºÐÀÌ ´ç¸éÇÑ ¹®Á¦¸¦ ÀçÇöÇÒ ¼ö ÀÖ´Â Äڵ带 Æ÷ÇÔ½ÃÅ°¸é ´õ¿í ÁÁ´Ù. (¿ªÀÚÁÖ: À̰͵µ ´ç¿¬È÷ ¿µ¾î·Î ½á¾ß °ÚÁö¿ä. Hi)


Chapter 3. ¼³Á¤(Configuration)


The configuration file

¼³Á¤ ÆÄÀÏ(configuration file)Àº (PHP 3.0¿¡¼­´Â php3.ini ÀÌ°í, PHP 4.0¿¡¼­´Â php.ini ÀÌ´Ù.) PHP°¡ ½ÃÀÛµÉ ¶§ ÀÐÇôÁø´Ù. ¼­¹ö ¸ðµâ ÇüÅÂÀÇ PHP´Â ÀÌ ÀÛ¾÷À» ¼­¹ö°¡ ½ÇÇà µÉ ¶§ Çѹø¸¸ ÇÏ°Ô µÈ´Ù. CGIÇüÅÂÀÇ °æ¿ì´Â ºÒ·ÁÁú ¶§¸¶´Ù ¸Å¹ø ÀϾ´Ù.

PHP¸¦ ¾ÆÆÄÄ¡ ¸ðµâ·Î »ç¿ëÇÒ ¶§´Â, PHPÀÇ ¼³Á¤À» Apache configuration ÆÄÀÏ°ú .htaccess ÆÄÀÏ¿¡¼­ ÁöÁ¤ÇÏ¿© ¼³Á¤ÇÒ ¼öµµ ÀÖ´Ù.

PHP 3.0¿¡¼­´Â, PHPÀÇ Áö½ÃÀÚ(directive)µé°ú ÀÏÄ¡ÇÏ´Â Apache httpd.conf Áö½ÃÀÚ°¡ ÀÖ´Ù. httpd.conf¿¡¼­ÀÇ Áö½ÃÀÚ À̸§Àº php3.iniÀÇ Áö½ÃÀÚ À̸§ ¾Õ¿¡ "php3_"¸¦ ºÙÀÎ °ÍÀÌ´Ù.

PHP 4.0¿¡¼­´Â ´ÙÀ½°ú °°Àº ¸î °³ÀÇ Apache Áö½ÃÀÚ¸¸À¸·Î PHP ¼³Á¤À» ¹Ù²Ü ¼ö ÀÖ´Ù.

php_value name value
ÁöÁ¤µÈ º¯¼ö¿¡ ¿øÇÏ´Â °ªÀ» ¼³Á¤ÇÑ´Ù.
php_flag name on|off
Boolean °ªÀ» °¡Áö´Â ¼³Á¤ ¿É¼ÇÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù.
php_admin_value name value
ÁöÁ¤µÈ º¯¼ö¿¡ ¿øÇÏ´Â °ªÀ» ¼³Á¤ÇÑ´Ù. "Admin" À¸·Î ÁöÁ¤µÈ ¼³Á¤Àº main Apache ¼³Á¤ÆÄÀÏ¿¡¼­¸¸ ¼³Á¤ÀÌ °¡´ÉÇÏ´Ù. .htaccess ÆÄÀÏ¿¡¼­ ±× ³»¿ëÀ» º¯°æÇÏ´Â °ÍÀº ºÒ°¡´ÉÇÏ´Ù.
php_admin_flag name on|off
Boolean °ªÀ» °¡Áö´Â ¼³Á¤ ¿É¼ÇÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù.

( ¿ªÀÚÁÖ : PHP¸¦ ¾ÆÆÄÄ¡ ¸ðµâ·Î »ç¿ëÇÒ °æ¿ì httpd.conf¿¡ Àû¾îÁØ ¿É¼Ç¸¸ ÀÛµ¿ÇÑ´Ù°í ÇÑ´Ù. )
( ¿ªÀÚÁÖ : httpd.conf¿¡ ¿É¼ÇÀ» Àû´Â ¹æ¹ýÀº Á¶±Ý ´Ù¸£´Ù. "="À» »ç¿ëÇÏÁö¸»°í ±×³É ÇÑÄ­À» ¶ç°í Àû¾îÁÖ¸é µÈ´Ù.
include_path ¿É¼ÇÀ» ¼³Á¤ÇÏ´Â ¿¹´Â ´ÙÀ½°ú °°´Ù. php3_include_path .:/home/httpd/php-lib )

ÇöÀç ¼³Á¤µÈ ¼³Á¤°ªÀº phpinfo()ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© È®ÀÎÇØ º¼ ¼ö ÀÖ´Ù. ¶ÇÇÑ °³°³ÀÇ ¼³Á¤ ³»¿ëÀ» È®ÀÎÇϱâ À§Çؼ­´Â get_cfg_var()ÇÔ¼ö¸¦ »ç¿ëÇÏ¸é µÈ´Ù.


General Configuration Directives

asp_tags boolean
ÀϹÝÀûÀÎ <?php ?> Åà ´ë½Å¿¡ ASP ½ºÅ¸ÀÏÀÇ <% %> ÅÃÀ» Ãß°¡ÀûÀ¸·Î »ç¿ëÇÒ ¼ö ÀÖµµ·Ï ÇÑ´Ù. ¶ÇÇÑ º¯¼ö°ª Ãâ·Â¹®ÀÎ <%= $value %> ÇüÅÂÀÇ Áö¿øµµ Æ÷ÇÔÇÑ´Ù. ÀÚ¼¼ÇÑ Á¤º¸´Â Escaping from HTML ºÎºÐÀ» ÂüÁ¶ÇÏÀÚ.

Note: ASP-style tags Áö¿øÀº 3.0.4 ¹öÀü¿¡¼­ Ãß°¡µÇ¾ú´Ù.

auto_append_file string
main ÆÄÀÏ ÈÄ¿¡ ÀÚµ¿À¸·Î Çؼ®µÉ ÆÄÀÏÀÇ À̸§À» ¸í½ÃÇÑ´Ù. ±× ÆÄÀÏÀº include()ÇÔ¼ö¸¦ ÅëÇؼ­ Æ÷ÇԵǹǷΠinclude_path Áö½ÃÀÚ°¡ »ç¿ëµÈ´Ù.

none °ªÀ» ÁÖ°Ô µÇ¸é auto-appendingÀÌ disableµÈ´Ù.

NOTE: ¸¸¾à ½ºÅ©¸³Æ®°¡ exit()·Î Á¾·áµÇ°Ô µÇ¸é auto-append´Â ÀϾÁö ¾Ê´Â´Ù.

auto_prepend_file string
main ÆÄÀÏ Àü¿¡ ÀÚµ¿À¸·Î Çؼ®µÉ ÆÄÀÏÀÇ À̸§À» ¸í½ÃÇÑ´Ù. ±× ÆÄÀÏÀº include() ÇÔ¼ö¸¦ ÅëÇؼ­ Æ÷ÇԵǹǷΠinclude_path Áö½ÃÀÚ°¡ »ç¿ëµÈ´Ù.

none °ªÀ» ÁÖ°Ô µÇ¸é auto-prependingÀÌ disableµÈ´Ù.

 
cgi_ext string
 
 
display_errors boolean
ÀÌ °áÁ¤ÀÚ(determine)´Â ¿¡·¯°¡ »ý°åÀ» ¶§ HTML Á¶°¢ÀÇ Ãâ·ÂÀ» ½ºÅ©¸°À¸·Î º¸ÀÏ °ÍÀΰ¡ ¾Æ´Ñ°¡¸¦ °áÁ¤ÇÑ´Ù.
 
doc_root string
PHPÀÇ "root directory"¸¦ ÁöÁ¤ÇÑ´Ù. ¹Ýµå½Ã °ªÀ» °¡Á®¾ß ÇÑ´Ù. PHP°¡ ¾ÈÀü¸ðµå(safe mode)·Î ¼³Á¤µÇ¾î ÀÖÀ» °æ¿ì, ÀÌ µð·ºÅ丮 ¹Û¿¡ ÀÖ´Â ÆÄÀÏÀº »ç¿ëÇÒ ¼ö ¾ø´Ù.
 
engine boolean
ÀÌ Áö½ÃÀÚ´Â ¾ÆÆÄÄ¡ ¸ðµâ ¹öÀüÀÇ PHP¿¡¼­¸¸ À¯È¿ÇÏ´Ù. ÀÌ°ÍÀº »çÀÌÆ®¿¡¼­ µð·ºÅ丮 ´ÜÀ§³ª, Virtual ¼­¹ö ´ÜÀ§¸¦ ±â¹ÝÀ¸·Î PHP ÆÄ½Ì ±â´ÉÀ» ÄѰųª ²ôµµ·Ï ÇÑ´Ù. httpd.conf ÆÄÀÏÀÇ Àû´çÇÑ À§Ä¡¿¡ php3_engine off¶ó°í ¸í½ÃÇÔÀ¸·Î½á, PHP¸¦ °¡´ÉÇϰųª ºÒ°¡´ÉÇÏ°Ô ÇÒ ¼ö ÀÖ´Ù.
 
error_log string
½ºÅ©¸³Æ® ¿¡·¯°¡ ·Î±×µÉ ÆÄÀÏ À̸§À» Á¤ÇÑ´Ù. ·Î±× ÆÄÀÏ·Î ½Ã½ºÅÛ ·Î±×¸¦ »ç¿ëÇϱâ À§Çؼ­ syslog¶ó´Â Ưº°ÇÑ °ªÀÌ ÀÌ¿ëµÈ´Ù. À¯´Ð½º¿¡¼­´Â syslog(3)ÀÌ°í, Windows NT¿¡¼­´Â Event log°¡ µÈ´Ù. Windows 95¿¡¼­´Â ½Ã½ºÅÛ ·Î±×¸¦ Áö¿øÇÏÁö ¾Ê´Â´Ù.
 
error_reporting integer
¿¡·¯ ·¹Æ÷ÆÃÀÇ ·¹º§À» ¼³Á¤ÇÑ´Ù. ÀÌ ÆĶó¸ÞŸ °ªÀº ºñÆ® ´ÜÀ§·Î ¼³Á¤ÇÑ´Ù. ´ÙÀ½ Áß¿¡ ¿øÇÏ´Â ¿¡·¯ ·¹Æ÷Æà ·¹º§ÀÇ °ªÀ» ´õÇØÁÖ¸é µÈ´Ù.

Table 3-1. Error Reporting Levels

bit value

enabled reporting

1

normal errors

2

normal warnings

4

parser errors

8

non-critical style-related warnings

±âº»°ªÀº 7 ÀÌ´Ù(normal errors¿Í normal warnings, parser errors°¡ ·¹Æ÷Æ® µÈ´Ù).

 
open_basedir string
PHP°¡ ¿­¾îº¼ ¼ö ÀÖ´Â ÆÄÀÏÀ» ƯÁ¤ µð·ºÅ丮 ÀÌÇÏ·Î Á¦ÇÑÇÑ´Ù.

¿¹¸¦ µé¾î ¾î¶² ½ºÅ©¸³Æ®°¡ fopenÀ̳ª gzopenÀ¸·Î ÆÄÀÏÀ» ¿­·Á°í ÇÒ ¶§ ±× ÆÄÀÏÀÌ ÁöÁ¤µÈ À§Ä¡¿¡ Àִ°¡ °Ë»çÇÑ´Ù. ¸¸¾à ÆÄÀÏÀÌ ÁöÁ¤µÈ µð·ºÆ¼¸®¹Û¿¡ ÀÖ´Ù¸é, PHP´Â ÀÌ ¿­±â µ¿ÀÛÀ» °ÅºÎÇÑ´Ù. ¸ðµç symbolic linkµéÀº ¿ø·¡ÀÇ À̸§À¸·Î ¹Ù²î¾î Çؼ®µÈ´Ù. µû¶ó¼­ ÀÌ Á¦ÇÑÀ» ÇÇÇϱâ À§ÇØ symbolic link¸¦ »ç¿ëÇÏ´Â °ÍÀ» ¹æÁöÇÒ ¼ö ÀÖ´Ù.

.À̶ó´Â ÁöÁ¤µÈ °ªÀ» ÁÖ¸é ½ºÅ©¸³Æ® ÆÄÀÏÀÌ ÀÖ´Â µð·ºÅ丮°¡ base-directory·Î ÁöÁ¤µÈ´Ù.

Windows¿¡¼­´Â ¼¼¹ÌÄÝ·Ð(;)À» »ç¿ëÇÏ°í, ´Ù¸¥ OS¿¡¼­´Â ÄÝ·Ð(:)À¸·Î ±¸ºÐÇÑ´Ù. As an Apache module, open_basedir paths from parent directories are now automatically inherited

NOTE: PHP 3.0.7 ºÎÅÍ, ÇÑ °³ ÀÌ»óÀÇ µð·ºÅ丮¸¦ ÁöÁ¤ÇÒ ¼ö ÀÖµµ·Ï µÇ¾ú´Ù.

±âº»°ªÀº ¸ðµç ÆÄÀÏÀ» ¿­ ¼ö ÀÖ´Â °ÍÀÌ´Ù.

 
gpc_order string
GET / POST / COOKIE º¯¼öµéÀÇ Çؼ® ¼ø¼­¸¦ Á¤ÇÑ´Ù. ±âº»°ªÀº "GPC"ÀÌ´Ù. ¿¹¸¦µé¾î "GP"¶ó°í ¼³Á¤ÇÑ´Ù¸é, PHP´Â cookieµéÀº ¿ÏÀüÈ÷ ¹«½ÃÇÏ°í, °°Àº À̸§À» °¡Áö POST º¯¼ö°¡ ÀÖ´Â GET º¯¼ö´Â POST º¯¼öÀÇ °ªÀ¸·Î µ¤¾î ¾²¿©Áö°Ô µÈ´Ù.
 
ignore_user_abort string
±âº»°ªÀº OffÀÌ´Ù. ¸¸¾à ÀÌ °ªÀÌ OnÀ̸é, ¿ø°Ý Ŭ¶óÀ̾ðÆ®°¡ Áß°£¿¡ ¿¬°áÀ» ²÷¾îµµ ½ºÅ©¸³Æ®°¡ ³¡±îÁö ¼öÇàµÈ´Ù.

See also ignore_user_abort().

 
include_path string
require()¿Í include(), fopen_with_path() ÇÔ¼öµéÀÌ »ç¿ëÇÏ´Â ÆÄÀÏÀ» ãÀ» À§Ä¡(path)¸¦ ¸í½ÃÇÑ´Ù. stringÀÇ Çü½ÄÀº ½Ã½ºÅÛ È¯°æº¯¼öÀÎ PATH ÀÇ ¼³Á¤°ú ºñ½ÁÇÏ´Ù. UNIX¿¡¼­´Â ÄÝ·ÐÀ¸·Î ³ª´µ¾îÁø µð·ºÅ丮µéÀÇ ¸®½ºÆ®ÀÌ°í, Windows¿¡¼­´Â ¼¼¹ÌÄÝ·ÐÀ» »ç¿ëÇÑ´Ù.

Example 3-1. UNIX include_path

  1 
  2 include_path=.:/home/httpd/php-lib
  3 

Example 3-2. Windows include_path

  1 
  2 include_path=".;c:\www\phplib"
  3 

±âº»°ªÀº .ÀÌ´Ù. (ÇöÀç µð·ºÅ丮¸¸)

 
isapi_ext string
 
 
log_errors boolean
½ºÅ©¸³Æ® ¿¡·¯ ¸Þ½ÃÁö°¡ ¼­¹öÀÇ ¿¡·¯ ·Î±×¿¡ ·Î±×µÇ´Â °¡¸¦ Á¤ÇÑ´Ù. ÀÌ ¿É¼ÇÀº ¼­¹ö¿¡ µû¶ó ´Ù¸£°Ô µ¿ÀÛÇÑ´Ù.
 
magic_quotes_gpc boolean
GPC (Get/Post/Cookie) µ¿ÀÛ Áß¿¡ ÀϾ´Â magic_quotes ±â´ÉÀ» ¼³Á¤ÇÑ´Ù. magic_quotes°¡ ¼³Á¤µÇ¾î ÀÖÀ¸¸é GPC¿¡¼­ ÀÔ·ÂµÈ ¸ðµç ' (single-quote)¿Í " (double quote), \ (backslash), NUL µéÀÇ ¾Õ¿¡ ¹é½½·¡½Ã(\)°¡ ÀÚµ¿À¸·Î ºÙ°Ô µÈ´Ù. ¶ÇÇÑ, magic_quotes_sybaseµµ °°ÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é '(single-quote)´Â ¹é½½·¡½Ã(\)°¡ ¾Æ´Ñ single-quote(')°¡ ¾Õ¿¡ ºÙ°Ô µÈ´Ù.
 
magic_quotes_runtime boolean
¸¸¾à magic_quotes_runtimeÀÌ ¼³Á¤µÇ¾î ÀÖ´Ù¸é, database¿Í text ÆÄÀÏ¿¡¼­ ÀÐ¾î µéÀÌ´Â ¸ðµç µ¥ÀÌÅÍ¿¡ ÀÖ´Â ' (single-quote)¿Í " (double quote), \ (backslash), NUL µéÀÇ ¾Õ¿¡ ¹é½½·¡½Ã(\)¸¦ ºÙÀ̵µ·Ï ÇÑ´Ù. ¶ÇÇÑ, magic_quotes_sybaseµµ °°ÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é '(single-quote)´Â ¹é½½·¡½Ã(\)°¡ ¾Æ´Ñ single-quote(')°¡ ¾Õ¿¡ ºÙ°Ô µÈ´Ù.
 
magic_quotes_sybase boolean
¸¸¾à magic_quotes_gpc³ª magic_quotes_runtime ÀÌ ¼³Á¤µÇ¾î ÀÖ°í, magic_quotes_sybaseµµ °°ÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é '(single-quote)´Â ¹é½½·¡½Ã(\)°¡ ¾Æ´Ñ single-quote(')°¡ ¾Õ¿¡ ºÙ°Ô µÈ´Ù.
 
max_execution_time integer
±¸¹®Çؼ®±â(parser)°¡ ÇÑ ½ºÅ©¸³Æ®¸¦ ó¸®Çϴµ¥ °É¸®´Â ÃÖ´ë ½Ã°£À» ¼³Á¤ÇÑ´Ù. ÀÌ°ÍÀº ºÒ¿ÏÀüÇÑ ½ºÅ©¸³Æ®·ÎºÎÅÍ ¼­¹ö°¡ ¸ðµÎ Á¡À¯´çÇÏ´Â °ÍÀ» ¹æÁöÇϴµ¥ µµ¿òÀÌ µÈ´Ù.
 
memory_limit integer
ÇÑ ½ºÅ©¸³Æ®°¡ ÇÒ´ç¹ÞÀ» ¼ö ÀÖ´Â ¸Þ¸ð¸®ÀÇ ÃÖ´ë Å©±â¸¦ ÁöÁ¤ÇÑ´Ù. ÀÌ°ÍÀº ºÒ¿ÏÀüÇÑ ½ºÅ©¸³Æ®·ÎºÎÅÍ ¼­¹ö ÀüüÀÇ ¸Þ¸ð¸®°¡ ÀâÇô ¸ÔÈ÷´Â °ÍÀ» ¹æÁöÇÑ´Ù.
 
nsapi_ext string
 
 
short_open_tag boolean
PHPÀÇ Open ű׷Πshort form (<? ?>)ÀÇ »ç¿ëÀ» Çã°¡Çϰųª ºÒÇãÇÑ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ PHP¿Í XMLÀ» ÇÔ²² »ç¿ëÇÑ´Ù¸é short formÀÇ »ç¿ëÀ» ºÒ°¡´ÉÇÏ°Ô ÇÏ¿©¾ß ÇÑ´Ù. ªÀº ű×ÀÇ »ç¿ëÀÌ ºÒ°¡´ÉÇÏ´Ù¸é, PHPÀÇ Open ű׷δ long form(<?php ?>)¸¸À» »ç¿ëÇÏ¿©¾ß ÇÑ´Ù.
 
sql.safe_mode boolean
 
 
track_errors boolean
ÀÌ Áö½ÃÀÚ°¡ ¼³Á¤µÇ¾î ÀÖÀ¸¸é $php_errormsgÀ̶ó´Â Àü¿ª º¯¼ö¿¡ ¸¶Áö¸·À¸·Î ¹ß»ýÇÑ ¿¡·¯ ¸Þ½ÃÁö°¡ µé¾îÀÖ°Ô µÈ´Ù.
 
track_vars boolean
ÀÌ Áö½ÃÀÚ°¡ ¼³Á¤µÇ¸é, °¢°¢ HTTP_GET_VARS, HTTP_POST_VARS, HTTP_COOKIE_VARSÀÇ Àü¿ª ¹è¿­¿¡ GET / POST / cookie º¯¼öµéÀÇ ÀÔ·ÂÀ» ÀúÀåÇÏ°Ô µÈ´Ù.
 
upload_tmp_dir string
ÆÄÀÏ ¾÷·Îµå½Ã ÆÄÀÏÀ» ÀúÀåÇÒ Àӽà µð·ºÅ丮¸¦ ÁöÁ¤ÇÑ´Ù. PHP°¡ µ¿ÀÛÇϰԵǴ User ID¿¡ ´ëÇØ ¾²±â ±ÇÇÑÀÌ ÀÖ¾î¾ß ÇÑ´Ù.
 
user_dir string
PHP ÆÄÀϵéÀ» À§ÇÑ »ç¿ëÀÚÀÇ È¨ µð·ºÅ丮ÀÇ base À̸§À» ÁöÁ¤ÇÑ´Ù. (Ex. public_html)
 
warn_plus_overloading boolean
ÀÌ°ÍÀÌ ¼³Á¤µÇ¸é, ¹®ÀÚ¿­¿¡ ´õÇϱâ(+) ¿¬»êÀÚ°¡ »ç¿ëµÉ ¶§ PHP°¡ ÁÖÀÇ ¸Þ½ÃÁö¸¦ Ãâ·ÂÇÏ°Ô ¸¸µç´Ù. ÀÌ ¿É¼ÇÀº ½ºÅ©¸³Æ®ÀÇ ´õÇϱ⠿¬»êÀÚ¸¦ ¹®ÀÚ¿­ concatenator(.)·Î ´Ù½Ã ÀÛ¼ºÇϴµ¥ µµ¿òÀ» ÁØ´Ù.


Mail Configuration Directives

SMTP string
Windowsȯ°æ¿¡¼­ PHP°¡ »ç¿ëÇÒ SMTP ¼­¹öÀÇ DNS À̸§À̳ª IP ¹øÈ£. mail() ÇÔ¼ö·Î ÆíÁö¸¦ º¸³»·Á¸é ÀÌ ¿É¼ÇÀ» ¹Ýµå½Ã ¼³Á¤ÇØ ÁÖ¾î¾ß ÇÑ´Ù.
 
sendmail_from string
Windowsȯ°æ¿¡¼­ PHP°¡ ÆíÁö¸¦ º¸³¾ ¶§ "From:"¿¡ »ç¿ëµÉ ¸ÞÀÏ ¾îµå·¹½º.
 
sendmail_path string
sendmail ÇÁ·Î±×·¥À» ãÀ» Path. º¸ÅëÀº/usr/sbin/sendmail À̳ª /usr/lib/sendmail ¿¡ ÀÖ´Ù. configure ÇÁ·Î±×·¥ÀÌ sendmailÀÇ À§Ä¡¸¦ ã¾Æ ÀÌ°ÍÀ» ±âº»°ªÀ¸·Î ¼³Á¤ÇØ ÁÖÁö¸¸, ±×°ÍÀÌ ÀßµÇÁö ¾Ê¾Ò°Å³ª ¿À·ù°¡ ÀÖÀ» ¶§, ¿©·¯ºÐÀº ¿©±â¼­ Á÷Á¢ ÁöÁ¤ÇØ ÁÙ ¼ö ÀÖ´Ù.

sendmailÀ» »ç¿ëÇÏÁö ¾Ê´Â ½Ã½ºÅÛÀÇ °æ¿ì ÇöÀç Á¦°øµÇ°í ÀÖ´Â ´Ù¸¥ ¸ÞÀÏ ½Ã½ºÅÛÀÇ sendmail ȣȯ ¸í·É(wrapper/replacement)À¸·Î ¼³Á¤ÇØ ÁÖ¾î¾ß ÇÑ´Ù. ¿¹¸¦µé¾î Qmail »ç¿ëÀÚ´Â º¸Åë /var/qmail/bin/sendmail·Î ¼³Á¤ÇØ ÁÖ¸é µÈ´Ù.


Safe Mode Configuration Directives

safe_mode boolean
PHP¸¦ ¾ÈÀü ¸ðµå(safe mode)·Î ÀÛµ¿µÇ°Å ÇÑ´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº Security chapter¸¦ »ìÆ캸±â ¹Ù¶õ´Ù.
 
safe_mode_exec_dir string
PHP°¡ ¾ÈÀü ¸ðµå¿¡¼­ ÀÛµ¿ÇÒ ¶§, system() À̳ª ±âŸ ´Ù¸¥ ÇÁ·Î±×·¥À» ½ÇÇà ½ÃÅ°´Â ÇÔ¼öµéÀº ÀÌ µð·ºÅ丮¿¡ ÀÖ´Â ÇÁ·Î±×·¥ÀÌ ¾Æ´Ï¸é ÀÛ¾÷À» °ÅºÎÇÑ´Ù.


Debugger Configuration Directives

debugger.host string
µð¹ö°Å°¡ »ç¿ëÇÒ hostÀÇ DNS name À̳ª IP address
 
debugger.port string
µð¹ö°Å°¡ »ç¿ëÇÒ Port ¹øÈ£
 
debugger.enabled boolean
µð¹ö°Å¸¦ ÀÛµ¿½ÃŲ´Ù.


Extension Loading Directives

enable_dl boolean
ÀÌ Áö½ÃÀÚ´Â PHP¸¦ ¾ÆÆÄÄ¡ ¸ðµâ·Î ½ÇÇàÇÒ ¶§¸¸ È¿·ÂÀ» °¡Áø´Ù. ¿©·¯ºÐÀº PHP¿¡¼­ dl() À» »ç¿ëÇÏ¿© extensionÀ» dynamic loadingÇÏ´Â ±â´ÉÀ» virtual server³ª µð·ºÅ丮 º°·Î °¡´ÉÇÏ°Ô Çϰųª ºÒ°¡´ÉÇÏ°Ô ÇÒ ¼ö ÀÖ´Ù.

dynamic loadingÀ» ºÒ°¡´ÉÇÏ°Ô Çϴ ù ¹ø ° ÀÌÀ¯´Â º¸¾È»óÀÇ ÀÌÀ¯ÀÌ´Ù. dynamic loading¿¡¼­´Â ¸ðµç safe_mode ¼³Á¤°ú open_basedir ¼³Á¤ÀÌ ¹«½ÃµÉ ¼ö Àֱ⠶§¹®ÀÌ´Ù.

±âº»°ªÀº ¸ðµç dynamic loadingÀ» Çã¿ëÇÏ´Â °ÍÀÌ´Ù. ´Ü, safe-mode¸¦ »ç¿ëÇÏ´Â Áß¿¡´Â Ç×»ó dl()ÀÇ »ç¿ëÀÌ ºÒ°¡´ÉÇØ Áø´Ù.

 
extension_dir string
µ¿ÀûÀ¸·Î ÀûÀç °¡´ÉÇÑ(dynamically loadable) extensionÀ» ãÀ» µð·ºÅ丮¸¦ ¼³Á¤ÇÑ´Ù.
 
extension string
PHP°¡ ½ÃÀÛµÉ ¶§ ·ÎµåÇÒ dynamically loadable extensionµéÀ» ¼³Á¤ÇÑ´Ù.


MySQL Configuration Directives

mysql.allow_persistent boolean
¿µ±¸À¸·Î(persistent) MySQLÀ» Á¢¼ÓÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù.
 
mysql.default_host string
µ¥ÀÌÅͺ£À̽º ¼­¹ö¿¡ ¿¬°áÇÒ ¶§ º°µµÀÇ host ÁöÁ¤ÀÌ ¾øÀ» °æ¿ì »ç¿ëµÇ´Â ±âº» ¼­¹ö È£½ºÆ®¸¦ ÁöÁ¤ÇÑ´Ù.
 
mysql.default_user string
µ¥ÀÌÅͺ£À̽º ¼­¹ö¿¡ ¿¬°áÇÒ ¶§ º°µµÀÇ »ç¿ëÀÚ ID ÁöÁ¤ÀÌ ¾øÀ» °æ¿ì »ç¿ëµÇ´Â ±âº» »ç¿ëÀÚ ID¸¦ ÁöÁ¤ÇÑ´Ù.
 
mysql.default_password string
µ¥ÀÌÅͺ£À̽º ¼­¹ö¿¡ ¿¬°áÇÒ ¶§ º°µµÀÇ ¾ÏÈ£ ÁöÁ¤ÀÌ ¾øÀ» °æ¿ì »ç¿ëµÇ´Â ±âº» ¾ÏÈ£¸¦ ÁöÁ¤ÇÑ´Ù.
 
mysql.max_persistent integer
ÇÁ·Î¼¼½º´ç ¿µ±¸ÀûÀÎ(persistent) MySQL Á¢¼ÓÀÇ ÃÖ´ë °³¼ö
 
mysql.max_links integer
¿µ±¸ÀûÀÎ(persistent) Á¢¼ÓÀ» Æ÷ÇÔÇÑ ÇÁ·Î¼¼½º´ç MySQL Á¢¼ÓÀÇ ÃÖ´ë °³¼ö


mSQL Configuration Directives

msql.allow_persistent boolean
¿µ±¸ÀûÀ¸·Î(persistent) mSQLÀ» Á¢¼ÓÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù.
 
msql.max_persistent integer
ÇÁ·Î¼¼½º´ç ¿µ±¸ÀûÀÎ(persistent) mSQL Á¢¼ÓÀÇ ÃÖ´ë °³¼ö
 
msql.max_links integer
¿µ±¸ÀûÀÎ(persistent) Á¢¼ÓÀ» Æ÷ÇÔÇÑ ÇÁ·Î¼¼½º´ç mSQL Á¢¼ÓÀÇ ÃÖ´ë °³¼ö


Postgres Configuration Directives

pgsql.allow_persistent boolean
¿µ±¸ÀûÀ¸·Î(persistent) Postgres¸¦ Á¢¼ÓÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù.
 
pgsql.max_persistent integer
ÇÁ·Î¼¼½º´ç ¿µ±¸ÀûÀÎ(persistent) Postgres Á¢¼ÓÀÇ ÃÖ´ë °³¼ö
 
pgsql.max_links integer
¿µ±¸ÀûÀÎ(persistent) Á¢¼ÓÀ» Æ÷ÇÔÇÑ ÇÁ·Î¼¼½º´ç Postgres Á¢¼ÓÀÇ ÃÖ´ë °³¼ö


Sybase Configuration Directives

sybase.allow_persistent boolean
¿µ±¸ÀûÀ¸·Î(persistent) Sybase¸¦ Á¢¼ÓÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù.
 
sybase.max_persistent integer
ÇÁ·Î¼¼½º´ç ¿µ±¸ÀûÀÎ(persistent) Sybase Á¢¼ÓÀÇ ÃÖ´ë °³¼ö
 
sybase.max_links integer
¿µ±¸ÀûÀÎ(persistent) Á¢¼ÓÀ» Æ÷ÇÔÇÑ ÇÁ·Î¼¼½º´ç Sybase Á¢¼ÓÀÇ ÃÖ´ë °³¼ö


Sybase-CT Configuration Directives

sybct.allow_persistent boolean
¿µ±¸ÀûÀ¸·Î(persistent) Sybase-CT¸¦ Á¢¼ÓÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù.
 
sybct.max_persistent integer
ÇÁ·Î¼¼½º´ç ¿µ±¸ÀûÀÎ(persistent) Sybase-CT Á¢¼ÓÀÇ ÃÖ´ë °³¼ö
 
sybct.max_links integer
¿µ±¸ÀûÀÎ(persistent) Á¢¼ÓÀ» Æ÷ÇÔÇÑ ÇÁ·Î¼¼½º´ç Sybase-CT Á¢¼ÓÀÇ ÃÖ´ë °³¼ö
 
sybct.min_server_severity integer
severity¸¦ °¡Áö´Â ¼­¹ö ¸Þ½ÃÁö °³¼ö°¡ sybct.min_server_severity¿¡ ¼³Á¤ÇÑ °ªº¸´Ù Å©°Å³ª °°¾ÆÁö¸é warningÀ» ·¹Æ÷Æ®ÇÑ´Ù. ÀÌ °ªÀº ½ºÅ©¸³Æ®¿¡¼­ sybase_min_server_severity()ÇÔ¼ö¸¦ ÅëÇØ ¼³Á¤ÇÒ ¼öµµ ÀÖ´Ù. ±âº» °ªÀº 10ÀÌ´Ù.
 
sybct.min_client_severity integer
severity¸¦ °¡Áö´Â Ŭ¶óÀ̾ðÆ® ¶óÀ̺귯¸® ¸Þ½ÃÁö °³¼ö°¡ sybct.min_server_severity¿¡ ¼³Á¤ÇÑ °ªº¸´Ù Å©°Å³ª °°¾ÆÁö¸é warningÀ» ·¹Æ÷Æ®ÇÑ´Ù. ÀÌ °ªÀº ½ºÅ©¸³Æ®¿¡¼­ sybase_min_client_severity()ÇÔ¼ö¸¦ ÅëÇØ ¼³Á¤ÇÒ ¼öµµ ÀÖ´Ù. ±âº» °ªÀº 10ÀÌ´Ù.
 
sybct.login_timeout integer
¼­¹ö¿¡ ¿¬°áÀ» ½ÃµµÇÏ°í ±â´Ù¸®´Â ÃÖ´ë ½Ã°£. ´ÜÀ§´Â ÃÊÀÌ°í ÁöÁ¤µÈ ½Ã°£¿¡ ¿¬°áÀÌ ¿Ï·áµÇÁö ¸øÇÏ¸é ¿¬°á µ¿ÀÛÀº ½ÇÆÐÇÏ´Â °ÍÀÌ´Ù. ¸¸¾à ¿¬°á½Ãµµ Áß max_execution_timeÀÇ ¼³Á¤À» ÃÊ°úÇÏ°Ô µÇ¸é ½ºÅ©¸³Æ®´Â ¿¬°á ½ÇÆи¦ ¾Ë¸®±â Àü¿¡ Á¾·áµÇ¾î ¹ö¸°´Ù. ±âº»°ªÀº 1ºÐÀÌ´Ù.
 
sybct.timeout integer
select_db³ª queryµîÀÇ ¸í·ÉÀ» ÁÖ°í ÀÀ´äÀ» ±â´Ù¸®´Â ÃÖ´ë ½Ã°£. ´ÜÀ§´Â ÃÊÀÌ°í ÁöÁ¤µÈ ½Ã°£¾È¿¡ ÀÀ´äÀÌ ¾øÀ¸¸é ÀÌ µ¿ÀÛÀº ½ÇÆÐÇÏ´Â °ÍÀÌ´Ù. ¸¸¾à ¿¬°á½Ãµµ Áß max_execution_timeÀÇ ¼³Á¤À» ÃÊ°úÇÏ°Ô µÇ¸é ½ºÅ©¸³Æ®´Â µ¿ÀÛ ½ÇÆи¦ ¾Ë¸®±â Àü¿¡ Á¾·áµÇ¾î ¹ö¸°´Ù. ±âº»°ªÀº ¾ø°í, ¹«ÇÑÁ¤ ±â´Ù¸®´Â °ÍÀÌ´Ù.
 
sybct.hostname string
sp_who¿¡ ÀÇÇØ Ç¥½ÃµÉ ¿¬°áÀ» ¿äûÇÏ´Â hostÀÇ À̸§. ±âº»°ªÀº ¾ø´Ù.


Informix Configuration Directives

ifx.allow_persistent boolean
¿µ±¸ÀûÀ¸·Î(persistent) Informix¸¦ Á¢¼ÓÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù.
 
ifx.max_persistent integer
ÇÁ·Î¼¼½º´ç ¿µ±¸ÀûÀÎ(persistent) Informix Á¢¼ÓÀÇ ÃÖ´ë °³¼ö
 
ifx.max_links integer
¿µ±¸ÀûÀÎ(persistent) Á¢¼ÓÀ» Æ÷ÇÔÇÑ ÇÁ·Î¼¼½º´ç Informix Á¢¼ÓÀÇ ÃÖ´ë °³¼ö
 
ifx.default_host string
ifx_connect()À̳ª ifx_pconnect() ÇÔ¼ö¿¡ È£½ºÆ®°¡ ÁöÁ¤µÇÁö ¾Ê¾ÒÀ» °æ¿ì »ç¿ëÇÒ ±âº» È£½ºÆ®.
 
ifx.default_user string
ifx_connect()À̳ª ifx_pconnect() ÇÔ¼ö¿¡ user id°¡ ÁöÁ¤µÇÁö ¾Ê¾ÒÀ» °æ¿ì »ç¿ëÇÒ ±âº» user id.
 
ifx.default_password string
ifx_connect()À̳ª ifx_pconnect() ÇÔ¼ö¿¡ password°¡ ÁöÁ¤µÇÁö ¾Ê¾ÒÀ» °æ¿ì »ç¿ëÇÒ ±âº» password.
 
ifx.blobinfile boolean
Set to true if you want to return blob columns in a file, false if you want them in memory. You can override the setting at runtime with ifx_blobinfile_mode().
 
ifx.textasvarchar boolean
select ¹®¿¡¼­ TEXT Ä÷³ÀÇ ³»¿ëÀ» ÀϹÝÀûÀÎ ¹®ÀÚ¿­·Î ¹ÝȯÇÏ°í ½Í´Ù¸é True, blob id ÆĶó¸ÞÅ͸¦ »ç¿ëÇÏ°í ½Í´Ù¸é False¸¦ ¼³Á¤ÇÑ´Ù. ÀÌ ¼³Á¤Àº ifx_textasvarchar() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ½ÇÇà Áß º¯°æÇÒ ¼ö ÀÖ´Ù.
 
ifx.byteasvarchar boolean
select ¹®¿¡¼­ BYTE Ä÷³ÀÇ ³»¿ëÀ» ÀϹÝÀûÀÎ ¹®ÀÚ¿­·Î ¹ÝȯÇÏ°í ½Í´Ù¸é True, blob id ÆĶó¸ÞÅ͸¦ »ç¿ëÇÏ°í ½Í´Ù¸é False¸¦ ¼³Á¤ÇÑ´Ù. ÀÌ ¼³Á¤Àº ifx_textasvarchar() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ½ÇÇà Áß º¯°æÇÒ ¼ö ÀÖ´Ù.
 
ifx.charasvarchar boolean
µ¥ÀÌÅ͸¦ °¡Á®¿Ã ¶§ CHAR Ä÷³ÀÇ µÚÂÊ °ø¹éÀ» ÀÚµ¿À¸·Î À߶󳻷Á¸é True¸¦ ¼³Á¤ÇÑ´Ù.
 
ifx.nullformat boolean
NULL Ä÷³¿¡ ´ëÇÏ¿© "NULL"À̶ó´Â ¹®ÀÚ¿­À» ¹ÝȯÇÏ·Á¸é True, °ø¹é ¹®ÀÚ¿­("")À» ¹ÝȯÇÏ·Á¸é False¸¦ ¼³Á¤ÇÑ´Ù. ÀÌ ¼³Á¤Àº ifx_nullformat() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ½ÇÇà Áß º¯°æÇÒ ¼ö ÀÖ´Ù.


BC Math Configuration Directives

bcmath.scale integer
bc ¼öÇÐ ÇÔ¼öµéÀÌ »ç¿ëÇÏ´Â ½ÊÁø ÀÚ¸®¼ö.


Browser Capability Configuration Directives

browscap string
browser ±â´É(capabilities) ÆÄÀÏÀÇ À̸§


Unified ODBC Configuration Directives

uodbc.default_db string
odbc_connect()³ª odbc_pconnect()¿¡¼­ noneÀ¸·Î ¼³Á¤µÇ¾î ÀÖÀ» ¶§ »ç¿ëÇÒ ODBC Data Source¸¦ ÁöÁ¤ÇÑ´Ù.
 
uodbc.default_user string
odbc_connect()³ª odbc_pconnect()¿¡¼­ noneÀ¸·Î ¼³Á¤µÇ¾î ÀÖÀ» ¶§ »ç¿ëÇÒ User À̸§À» ÁöÁ¤ÇÑ´Ù.
 
uodbc.default_pw string
odbc_connect()³ª odbc_pconnect()¿¡¼­ noneÀ¸·Î ¼³Á¤µÇ¾î ÀÖÀ» ¶§ »ç¿ëÇÒ Password¸¦ ÁöÁ¤ÇÑ´Ù.
 
uodbc.allow_persistent boolean
¿µ±¸ÀûÀ¸·Î(persistent) ODBC¸¦ Á¢¼ÓÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù.
 
uodbc.max_persistent integer
ÇÁ·Î¼¼½º´ç ¿µ±¸ÀûÀÎ(persistent) ODBC Á¢¼ÓÀÇ ÃÖ´ë °³¼ö
 
uodbc.max_links integer
¿µ±¸ÀûÀÎ(persistent) Á¢¼ÓÀ» Æ÷ÇÔÇÑ ÇÁ·Î¼¼½º´ç ODBC Á¢¼ÓÀÇ ÃÖ´ë °³¼ö


Chapter 4. º¸¾È (Security)

PHP´Â °­·ÂÇÑ ¾ð¾îÀ̵ð. ±× ÀÎÅÍÇÁ¸®ÅÍ´Â À¥¼­¹öÀÇ ¸ðµâ·Î µÇ¾î ÀÖ°Ç CGI binary·Î µÇ¾î ÀÖ°Ç °£¿¡, ÆÄÀÏÀ» »ç¿ëÇÒ ¼ö ÀÖ°í, ´Ù¸¥ ¸í·ÉÀ̳ª ÇÁ·Î±×·¥À» ½ÇÇàÇÒ ¼ö ÀÖ°í, ¼­¹ö·Î ³×Æ®¿÷ ¿¬°áÀ» ÇÒ ¼öµµ ÀÖ´Ù. ÀÌ·± Ư¼ºµéÀº ±âº»ÀûÀ¸·Î ¾î¶² ÇÁ·Î±×·¥ÀÌµç ½ÇÇà½ÃÄÑ À¥¼­¹ö¸¦ ºÒ¾ÈÇÑ »óÅ·Π¸¸µé ¼ö ÀÖ´Ù. PHP´Â ºÐ¸íÈ÷ PerlÀ̳ª Cº¸´Ù Á»´õ ¾ÈÀüÇÑ CGI ÇÁ·Î±×·¥À» ¸¸µé ¼ö ÀÖ´Ù. ÄÄÆÄÀϽóª ½ÇÇà½Ã ¼³Á¤ ¿É¼ÇµéÀ» ÀûÀýÈ÷ ¼±ÅÃÇÔÀ¸·Î, ¿©·¯ºÐÀº ¿øÇÏ´Â Á¤µµÀÇ ÀÚÀ¯·Î¿ò°ú º¸¾È»óÀÇ Á¦¾àÀ» Á¶È­½Ãų ¼ö ÀÖ´Ù.

PHP´Â ¼ö¸¹Àº ¹æ¹ýÀ¸·Î ÀÌ¿ëÀÌ °¡´ÉÇÏ°í, ÀÌ¿¡ µû¸¥ ¿©·¯ °¡Áö ¼³Á¤ ¿É¼ÇÀÌ ÀÖÀ» ¼ö ÀÖ´Ù. ¸¹Àº ¿É¼Ç ¼±Åà »çÇ×µéÀº PHP¸¦ º¸´Ù ¸¹Àº ¸ñÀûÀ¸·Î »ç¿ëÇÒ ¼ö ÀÖµµ·Ï ÇÏÁö¸¸, ÀÌ ¿É¼ÇµéÀÇ Á¶ÇÕ°ú ¼­¹öÀÇ ¼³Á¤¿¡ µû¶ó º¸¾È»óÀÇ ÇãÁ¡À» ³ëÃâ½Ãų ¼öµµ ÀÖ´Ù. ÀÌ ÀåÀº ´Ù¸¥ ¿É¼ÇÀÇ Á¶ÇÕ ¹æ¹ý°ú ÀÌ°ÍÀ» ¾ÈÀüÇÏ°Ô »ç¿ëÇÏ´Â »óȲÀ» ¼³¸íÇÑ´Ù.


CGI binary


°¡´ÉÇÑ °ø°Ý (Possible attacks)

CGI binary ÇüÅÂÀÇ PHP´Â ¾î¶² ÀÌÀ¯·Î ¼­¹ö ¼ÒÇÁÆ®¿þ¾î(¾ÆÆÄÄ¡ °°Àº)ÀÇ ¸ðµâ·Î »ç¿ëµÇ±â¸¦ ¿øÇÏÁö ¾Ê´Â °æ¿ì¿¡ »ç¿ëÇÒ ¼ö ÀÖ°í, PHP¸¦ ´Ù¸¥ Á¾·ùÀÇ CGI wrapper¿Í ÇÔ²² ¾ÈÀüÇÑ chroot¿Í setuid ȯ°æÀ» ¸¸µé¾î ³»´Â °÷¿¡ ¶§¿¡ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ÀÌ ¼³Á¤Àº º¸Åë ½ÇÇàÇÒ PHP binary¸¦ À¥¼­¹öÀÇ cgi-binµð·ºÅ丮¿¡ ¼³Ä¡ÇØ¾ß ÇÑ´Ù. CERT ±Ç°í»çÇ× CA-96.11¿¡ µû¸£¸é ¸ðµç ÀÎÅÍÇÁ¸®Å͵éÀº cgi-bin¿¡ ¼³Ä¡Çϵµ·Ï ±Ç°íµÈ´Ù. ºñ·Ï PHP binary°¡ µ¶¸³ÀûÀÎ ÀÎÅÍÇÁ¸®ÅÍ·Î »ç¿ëµÈ´Ù ÇÒÁö¶óµµ, PHP´Â ÀÌ ¼³Á¤ÀÌ ¸¸µé¾î³¾ °¡´ÉÇÑ °ø°ÝÀ» ´ÙÀ½°ú °°ÀÌ ¸·¾Æ³»µµ·Ï ¼³°èµÇ¾î ÀÖ´Ù. :


Case 1: °ø¿ë ÆÄÀϸ¸ Á¦°øÇϱâ (only public files served)

¸¸¾à ¿©·¯ºÐÀÇ ¼­¹ö°¡ password ³ª ip ±âÁØÀÇ Á¢±Ù ÅëÁ¦¿¡ °üÇÑ ¾î¶°ÇÑ »çÇ×µµ ¾ø´Ù¸é, ÀÌ·¯ÇÑ ¼³Á¤ ¿É¼ÇµéÀº ÇÊ¿ä ¾ø´Ù. ¸¸¾à ¿©·¯ºÐÀÇ À¥¼­¹ö°¡ ¸®µð·ºÆ®¸¦ Çã¿ëÇÏÁö ¾Ê°Å³ª, ¼­¹ö°¡ ÇØ´ç ¿ä±¸°¡ ¾ÈÀüÇÏ°Ô ¸®µð·ºÆ®µÈ ¿ä±¸ÀÎÁö ´ëÇØ PHP binary¿Í Åë½ÅÇÒ ¼ö ÀÖ´Â ¹æ¹ýÀÌ ¾øÀ» °æ¿ì, ¿©·¯ºÐÀº ½ºÅ©¸³Æ®¸¦ ¼³Á¤Çϱâ À§ÇØ --disable-force-cgi-redirect ¿É¼ÇÀ» ¸í½ÃÇÒ ¼ö ÀÖ´Ù. ¿©·¯ºÐÀº ¿©ÀüÈ÷ ¿©·¯ºÐÀÇ PHP ½ºÅ©¸³Æ®°¡, http://my.host/cgi-bin/php/dir/script.php3ó·³ Á÷Á¢ Á¢±ÙÇÏ´Â °Íµµ ¾Æ´Ï°í http://my.host/dir/script.php3°°ÀÌ ¸®µð·º¼Ç¿¡ ÀÇÇؼ­µµ ¾Æ´Ñ, ´Ù¸¥ ¹ÏÁö ¸øÇÒ ¹æ¹ý¿¡ ÀÇÇØ ºÒ·Á Áú ¶§¸¦ ´ëºñÇÏ¿© ´ëÃ¥À» °­±¸ÇØ µÎ¾î¾ß ÇÕ´Ï´Ù.

¸®µð·º¼ÇÀº ¿¹¸¦µé¾î Apache¿¡¼­´Â AddHandle°ú Action Áö½ÃÀÚ¸¦ »ç¿ëÇÏ¿© ¼³Á¤ÇÒ ¼ö ÀÖ½À´Ï´Ù. (¾Æ·¡¸¦ º¸¼¼¿ä.)


Case 2: --enable-force-cgi-redirect ¿É¼Ç »ç¿ë (using --enable-force-cgi-redirect)

ÀÌ ÄÄÆÄÀϽÃÀÇ ¿É¼ÇÀº »ç¿ëÀÚ°¡ http://my.host/cgi-bin/php/secretdir/script.php3¿Í °°ÀÌ PHP¸¦ Á÷Á¢ È£ÃâÇÏ´Â °ÍÀ» ¸·¾ÆÁØ´Ù. ´ë½Å, ÀÌ ¸ðµå¿¡¼­ PHP´Â ±×°ÍÀÌ À¥¼­¹öÀÇ ¸®µð·ºÆ® ±ÔÄ¢À» Åë°úÇÑ °æ¿ì¿¡¸¸ parse ÀÛ¾÷À» ÇÒ °ÍÀÌ´Ù.

ÀϹÝÀûÀ¸·Î ¾ÆÆÄÄ¡ ¼³Á¤¿¡¼­ ¸®µð·ºÆ® ¼³Á¤Àº ´ÙÀ½°ú °°ÀÌ Áö½ÃÀÚ¸¦ »ç¿ëÇÏ¿© ÇÑ´Ù. :

Action php3-script /cgi-bin/php
AddHandler php3-script .php3

ÀÌ ¿É¼ÇÀº ¾ÆÆÄÄ¡ À¥¼­¹ö¿¡¼­ ½ÃÇèÀ» °ÅÃÆ°í, ¾ÆÆÄÄ¡´Â ¸®µð·ºÆ®µÈ ¿ä±¸¿¡ ´ëÇؼ­´Â REDIRECT_STATUS ¶ó´Â ºñ Ç¥ÁØ CGI ȯ°æ º¯¼ö¸¦ ¼³Á¤ÇÑ´Ù. ¸¸¾à ´ç½ÅÀÇ À¥¼­¹ö°¡ ¹®¼­ ¿ä±¸°¡ Á÷Á¢(direct)ÀÎÁö ¸®µð·ºÆ®(redirect)ÀÎÁö ±¸º°ÇÒ ¼ö ÀÖ´Â ¹æ¹ýÀ» Á¦°øÇÏÁö ¾Ê´Â´Ù¸é ¿©·¯ºÐÀº ÀÌ ¿É¼ÇÀ» »ç¿ëÇÒ ¼ö ¾ø´Ù. µû¶ó¼­, ¿©·¯ºÐÀº ÀÌ ¹®¼­¿¡ ¾º¿©Á® ÀÖ´Â CGI ¹öÀüÀÇ ´Ù¸¥ ½ÇÇà ¹æ¹ýÀ» »ç¿ëÇØ¾ß ÇÒ °ÍÀÌ´Ù.


Case 3: doc_root³ª user_dirÀÇ ¼³Á¤ (setting doc_root or user_dir)

À¥¼­¹ö ¹®¼­ µð·ºÅ丮¿¡ script³ª ½ÇÇàÆÄÀÏ °°Àº Active content¸¦ Æ÷ÇÔÇÏ´Â °ÍÀº Á¾Á¾ ºÒ¾ÈÇÏ´Ù°í »ý°¢µÇ¾î Áø´Ù. ¸¸¾à ¾à°£ÀÇ ¼³Á¤ ¿À·ù·Î ½ºÅ©¸³Æ®°¡ ½ÇÇàµÇÁö ¾Ê°í HTML ¹®¼­Ã³·³ ±×´ë·Î Ãâ·Â µÈ´Ù¸é, °¢Á¾ ÁöÀû Àç»êÀ̳ª Password°°Àº º¸¾È»óÀÇ Á¤º¸°¡ ´©¼³µÇ´Â °á°ú°¡ ÃÊ·¡µÉ Áöµµ ¸ð¸¥´Ù. ±×·¯¹Ç·Î ¸¹Àº ½Ã½ºÅÛ °ü¸®ÀÚµéÀº ½ºÅ©¸³Æ®¸¦ À§ÇÑ º°µµÀÇ µð·ºÅ丮¸¦ ¸¸µé¾î ³õ°í, ÀÌ µð·ºÅ丮´Â PHP CGI¸¦ ÅëÇؼ­¸¸ Á¢±ÙÀÌ °¡´ÉÇϵµ·Ï ¸¸µé¾î ³õ¾Æ ½ÇÇàÀº °¡´ÉÇÏÁö¸¸ º¸¿©ÁöÁö´Â ¾Êµµ·Ï ÇÑ´Ù.

¶ÇÇÑ, ÀüÀå¿¡¼­ ±â¼úÇÑ ¹Ù¿Í °°ÀÌ, ¿ä±¸°¡ ¸®µð·ºÆ®µÈ °ÍÀÌ ¾Æ´Ï¶ó°í È®ÀÎÇØÁÖ´Â ¹æ¹ýÀÌ ¾ø´Ù¸é, À¥ ¹®¼­ÀÇ root¿Í´Â ´Ù¸¥ ½ºÅ©¸³Æ®ÀÇ doc_root¸¦ ¼³Á¤ÇØ ÁÖ´Â °ÍÀÌ ¹Ýµå½Ã ÇÊ¿äÇÏ´Ù.

¿©·¯ºÐÀº php3.iniÀÇ doc_root Áö½ÃÀÚ¸¦ ¼³Á¤Çϰųª, PHP_DOCUMENT_ROOT¶ó´Â ȯ°æº¯¼ö °ª¿¡ ¼³Á¤ÇØ ÁÖ¾î, PHP ½ºÅ©¸³Æ® ¹®¼­ÀÇ root¸¦ ¼³Á¤ÇÒ ¼ö ÀÖ´Ù. ¸¸¾à ÀÌ°ÍÀÌ ¼³Á¤µÇ¾î ÀÖ´Ù¸é, CGI ¹öÀüÀÇ PHP´Â ¾ðÁ¦³ª ÀÌ doc_root¿Í request¿¡ ÀÖ´Â °æ·Î Á¤º¸¸¦ °¡Áö°í Á¢±ÙÇÏ·Á´Â ÆÄÀÏÀÇ À̸§À» ¸¸µç´Ù. µû¶ó¼­ ¿©·¯ºÐÀº ÀÌ µð·ºÅ丮 ¹Û¿¡¼­´Â ¾î¶°ÇÑ ½ºÅ©¸³Æ®µµ ½ÇÇàµÉ ¼ö ¾øµµ·Ï ¸¸µé°Ô µÈ´Ù. (¾Æ·¡¿¡ ÀÖ´Â user_dir ¸¸Àº ¿¹¿ÜÀÌ´Ù)

ÀÌ°÷¿¡¼­ ¶Ç Çϳª »ç¿ëÇÒ ¼ö ÀÖ´Â ¿É¼ÇÀº user_dirÀÌ´Ù. user_dirÀÌ ¼³Á¤µÇ¾î ÀÖÁö ¾ÊÀ¸¸é Á¢±Ù °¡´ÉÇÑ ÆÄÀÏÀ» doc_root¿¡ ÀÖ´Â °Í »ÓÀÌ´Ù. http://my.host/~user/doc.php3°°Àº url·Î´Â user home directory¿¡ ÀÖ´Â ÆÄÀÏÀ» ¿­ ¼ö ¾ø´Ù. ´ÜÁö doc_root¾Æ·¡ÀÇ ~user/doc.php3 ÆÄÀÏÀ» ºÎ¸¦ »ÓÀÌ´Ù. (¹°·Ð Æ¿µ¥[~]·Î ½ÃÀÛÇÏ´Â "~user"¶ó´Â µð·ºÅ丮ÀÌ´Ù.)

¸¸¾à user_dirÀÌ ¿¹¸¦ µé¾î public_php·Î ¼³Á¤µÇ¾î ÀÖ´Ù¸é, http://my.host/~user/doc.php3¿Í °°Àº ¿ä±¸´Â userÀÇ home µð·ºÅ丮 ¹ØÀÇ public_php¶ó´Â µð·ºÅ丮 ¹ØÀÇ doc.php3¶ó´Â ÆÄÀÏÀ» È£Ãâ ÇÒ °ÍÀÌ´Ù. ¸¸¾à »ç¿ëÀÚÀÇ homeÀÌ /home/user¶ó¸é, ½ÇÇàµÇ´Â ÆÄÀÏÀº /home/user/public_php/doc.php3ÀÌ µÈ´Ù.

user_dir È®ÀåÀº doc_root ¼³Á¤°ú °ü·Ã¾øÀÌ ¹ß»ýÇϹǷÎ, ¿©·¯ºÐÀº document root¿Í user directory Á¢±Ù ÅëÁ¦¸¦ º°µµ·Î ÇÒ ¼ö ÀÖ´Ù.


Case 4: À¥ Æ®¸® ¹Û¿¡ PHP parser (PHP parser outside of web tree)

¸Å¿ì ½Å·ÚÇÒ¼ö ÀÖ´Â ¿É¼ÇÀ¸·Î PHP parser binary¸¦ À¥ Æ®¸® ¹Û¿¡´Ù µÎ´Â ¹æ¹ýÀÌ´Ù. ¿¹¸¦ µé¾î /usr/local/bin °°Àº °÷¿¡ µÐ´Ù. ÀÌ ¿É¼ÇÀÇ ½ÇÁúÀûÀÎ ´ÜÁ¡Àº, ¸ðµç PHP ÅÃÀ» Æ÷ÇÔÇÏ°í ÀÖ´Â ÆÄÀÏÀÇ Ã¹¹ø° ¶óÀο¡ ´ÙÀ½°ú ºñ½ÁÇÏ°Ô Àû¾îÁÖ´Â °Í »ÓÀÌ´Ù. :

#!/usr/local/bin/php

¶ÇÇÑ ÆÄÀÏÀ» ½ÇÇà °¡´ÉÀ¸·Î ¸¸µé¾î ÁÖ¾î¾ß ÇÑ´Ù. Áï, ÀÚ½ÅÀÇ ½ÇÇàÀ» À§Çؼ­ #! shell-escape ¸ÞÄ«´ÏÁòÀ» »ç¿ëÇÏ´Â PerlÀ̳ª sh ȤÀº ´Ù¸¥ ½ºÅ©¸³Æ® ¾ð¾î¿Í °°Àº ¹æ½ÄÀ¸·Î ´Ù·ç´Â °ÍÀÌ´Ù.

ÀÌ ¼³Á¤¿¡¼­ PHP°¡ PATH_INFO¿Í PATH_TRANSLATEDÁ¤º¸¸¦ ¿Ã¹Ù¸£°Ô ´Ù·ç·Á¸é, php parser°¡ --enable-discard-path ¼³Á¤ ¿É¼ÇÀ¸·Î ÄÄÆÄÀÏ µÇ¾î¾ß ÇÑ´Ù.


Apache module

PHP°¡ ¾ÆÆÄÄ¡ÀÇ ¸ðµâ·Î »ç¿ëµÉ ¶§´Â ¾ÆÆÄÄ¡ÀÇ »ç¿ëÀÚ permissionÀ» °è½Â¹Þ´Â´Ù. (ÀϹÝÀûÀ¸·Î "nobody"·Î ¼³Á¤µÇ¾î ÀÖ´Ù.)


II. Language Reference

Table of Contents
5. ±âº»¹®¹ý (Basic syntax)
6. º¯¼öÇüÅ (Types)
7. º¯¼ö (Variables)
8. »ó¼ö (Constants)
9. Ç¥Çö½Ä (Expressions)
10. ¿¬»êÀÚ (Operators)
11. Á¦¾î ±¸Á¶ (Control Structures)
12. ÇÔ¼ö (Functions)
13. Ŭ·¡½º¿Í °´Ã¼ (Classes and Objects)


Chapter 5. ±âº» ¹®¹ý(Basic Syntax)


HTML·ÎºÎÅÍ ºüÁ®³ª¿À±â(Escaping from HTML)

HTML·ÎºÎÅÍ ºüÁ®³ª¿Í "PHP code mode"·Î µé¾î°¡´Â ¹æ¹ýÀº ´ÙÀ½ 4°¡Áö°¡ ÀÖ´Ù :

 

Example 5-1. Ways of escaping from HTML

  1 
  2 1.  <? echo ("this is the simplest, an SGML processing instruction\n"); ?>
  3  
  4 2.  <?php echo("if you want to serve XML documents, do like this\n"); ?>
  5 
  6 3.  <script language="php"> 
  7         echo ("some editors (like FrontPage) don't
  8               like processing instructions");
  9     </script>
 10 
 11 4.  <% echo ("You may optionally use ASP-style tags"); %>
 12     <%= $variable; # This is a shortcut for "<%echo .." %>
 13       

ù ¹ø° ¹æ¹ýÀº short tags°¡ enableµÇ¾î ÀÖ¾î¾ß »ç¿ë°¡´ÉÇÏ´Ù. short_tags()¸¦ È£ÃâÇϰųª, short_tags run-time ¼³Á¤¿¡¼­ °¡´ÉÇÏ°í, ÄÄÆÄÀϽÿ¡ --enable-short-tags ¿É¼ÇÀ» ÁÖ¾î ÄÄÆÄÀÏÇÏ¿© enableÇÒ ¼öµµ ÀÖ´Ù.

³× ¹ø° ¹æ¹ýÀº ASP-style tags°¡ enableµÇ¾î ÀÖ¾î¾ß »ç¿ë°¡´ÉÇÏ´Ù. asp_tags run-time ¼³Á¤¿¡¼­ °¡´ÉÇÏ°í, ÄÄÆÄÀϽÿ¡ --enable-asp_tags ¿É¼ÇÀ» ÁÖ¾î ÄÄÆÄÀÏÇÏ¿© enableÇÒ ¼öµµ ÀÖ´Ù.

Note: ASP-style tags´Â 3.0.4ºÎÅÍ Áö¿øµÈ´Ù.

´Ý´Â °ýÈ£´Â newlineÀ» Æ÷ÇÔÇÑ´Ù.


¸í·É ±¸ºÐ (Instruction separation)

°¢°¢ÀÇ ¸í·ÉÀº C³ª Perl°ú ¸¶Âù°¡Áö·Î ±¸ºÐµÈ´Ù. °¢ ¹®ÀåÀº ;(¼¼¹ÌÄÝ·Ð)À¸·Î Á¾·áµÈ´Ù.

PHPÀÇ Á¾·áÅÃÀÎ ?>´Â ¹®ÀåÀÇ ³¡À̶ó´Â Àǹ̵µ ÇÔ²² °¡Áö°í ÀÖ´Ù. µû¶ó¼­ ´ÙÀ½ µÎ °³ÀÇ ¹®ÀåÀº µ¿ÀÏÇÏ´Ù.

  1 
  2 <?php
  3     echo "This is a test";
  4 ?>
  5 
  6 <?php echo "This is a test" ?>
  7       

 


ÁÖ¼®¹® (Comments)

PHP´Â 'C'¿Í 'C++', Unix shell ÇüÅÂÀÇ ÁÖ¼®¹®À» Á¦°øÇÑ´Ù. ¿¹¸¦ µé¾î :

  1 
  2 <?php
  3     echo "This is a test"; // This is a one-line c++ style comment
  4     /* This is a multi line comment
  5        yet another line of comment */
  6     echo "This is yet another test";
  7     echo "One Final Test"; # This is shell-style style comment
  8 ?>
  9      

"one-line" ÁÖ¼®¹®Àº ¶óÀÎÀÇ ³¡À̳ª, Çö php ÄÚµå ºí·ÏÀÇ ³¡¿¡¼­ ³¡³­´Ù.

  1 
  2 <h1>This is an <?# echo "simple";?> example.</h1>
  3 <p>The header above will say 'This is an example'.
  4 

'C' ÇüÅÂÀÇ ÁÖ¼®¹®Àº Áߺ¹Çؼ­ »ç¿ëÇÏÁö ¸»¾Æ¾ß ÇÑ´Ù.

  1 
  2 <?php
  3  /* 
  4     echo "This is a test"; /* ÀÌ ÁÖ¼®¹®Àº ¹®Á¦°¡ µÈ´Ù. */
  5  */
  6 ?>
  7     
    


Chapter 6. º¯¼ö ÇüÅ (Types)

PHP´Â ´ÙÀ½ ÇüÅÂÀÇ typeÀ» Áö¿øÇÑ´Ù. :

( ¿ªÀÚÁÖ : ³»ºÎÀûÀ¸·Î´Â ÇÔ¼ö¿Í Ŭ·¡½ºµµ º¯¼ö·Î Á¤ÀǵDZâ´Â ÇÏÁö¸¸ À̰͵éÀº ÀϹÝÀûÀÎ º¯¼ö·Î üũµÇÁö ¾Ê´Â´Ù. )

º¯¼öŸÀÔÀº º¸Åë ÇÁ·Î±×·¡¸Ó°¡ ¼±ÅÃÇÒ ÇÊ¿ä°¡ ¾ø´Ù. ´ë½Å, PHP°¡ ½ÇÇàÁß¿¡ º¯¼öÀÇ °ªÀÇ ³»¿ë¿¡ µû¶ó ÀÚµ¿ÀûÀ¸·Î ¹Ù²Ù¾î ÁØ´Ù.

¸¸¾à ¿©·¯ºÐÀÌ Æ¯Á¤ÇÑ º¯¼ö ŸÀÔÀ¸·Î ÁöÁ¤ÇÏ°í ½Í´Ù¸é º¯¼ö¸¦ cast Çϰųª, settype() ÇÔ¼ö¸¦ »ç¿ëÇÑ´Ù.

Á¾Á¾ º¯¼öµéÀº ½ÇÇà½Ã ¾î¶² ŸÀÔÀ¸·Î µÇ¾î ÀÖ´À³Ä¿¡ µû¶ó ƯÁ¤ÇÑ »óȲ¿¡¼­ ¿øÇÏ´Â ´ë·Î µ¿ÀÛÇÏÁö ¾ÊÀ» ¶§°¡ ÀÖ´Ù. Type Juggling ÆíÀ» º¸¸é ÀÚ¼¼È÷ ¾Ë ¼ö ÀÖ´Ù.


Á¤¼öÇü (Integers)

Á¤¼öÇüÀº ´ÙÀ½°ú °°Àº ÇüÅÂÀÇ ¹®ÀåÀ¸·Î ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù.

  1 
  2 $a = 1234; # decimal number
  3 $a = -123; # a negative number
  4 $a = 0123; # octal number (equivalent to 83 decimal)
  5 $a = 0x12; # hexadecimal number (equivalent to 18 decimal)
  6      

 


½Ç¼öÇü (Floating point numbers)

½Ç¼öÇü("doubles")Àº ´ÙÀ½°ú °°Àº ÇüÅÂÀÇ ¹®ÀåÀ¸·Î ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù.

  1  
  2 $a = 1.234; $a = 1.2e3;
  3      

 


¹®ÀÚ¿­ (Strings)

¹®ÀÚ¿­Àº µÎ °³ÀÇ delimiters¸¦ »ç¿ëÇØ ³ªÅ¸³½´Ù.

¹®ÀÚ¿­ÀÌ Å« µû¿ÈÇ¥(")·Î µÑ·¯½ÎÀÌ°Ô Ç¥½ÃµÇ¸é, ´ÙÀ½°ú °°ÀÌ Æ¯¼ö ¹®ÀÚµéÀ» Æ÷ÇÔÇÒ ¼ö ÀÖ´Ù. C³ª Perl¿¡¼­Ã³·³ ¹é½½·¡½Ã(\)¸¦ »ç¿ëÇÏ¿© Ư¼ö ±âÈ£¸¦ Ç¥½ÃÇÏ°Ô µÈ´Ù.

Table 6-1. Escaped characters

sequence

meaning

\n

newline

\r

carriage

\t

horizontal tab

\\

backslash

\$

dollar sign

\"

double-quote

¶§·Î´Â ´Ù¸¥ escape¸¦ »ç¿ëÇÒ ¼ö ÀÖÁö¸¸, worningÀÌ ¹ß»ýÇÏ°Ô µÈ´Ù.

¹®ÀÚ¿­À» Ç¥ÇöÇÏ´Â ¶Ç ´Ù¸¥ ¹æ¹ýÀº Å« µû¿ÈÇ¥(") ´ë½Å ÀÛÀº µû¿ÈÇ¥(')¸¦ »ç¿ëÇÏ´Â °ÍÀÌ´Ù. ÀÌ°ÍÀº \\°ú \'ÀÇ µÎ °³¸¸À» ¹é½½·¡½Ã ó¸®ÇÏ°í ³ª¸ÓÁö´Â ±×³É µÐ´Ù. ÀÛÀº µû¿ÈÇ¥¸¦ »ç¿ëÇÏ´Â ¹®ÀÚ¿­ ³»¿¡¼­´Â º¯¼ö¸¦ »ç¿ëÇÏ¿© ±× °ªÀ» Ãâ·ÂÇÏ´Â ±â´ÉÀ» »ç¿ëÇÒ ¼ö ¾ø´Ù.

¹®ÀÚ¿­À» ¼±¾ðÇÏ´Â ´Ù¸¥ ¹æ¹ýÀº  here doc ±¸¹®("<<<")À» »ç¿ëÇÏ´Â °ÍÀÌ´Ù. <<< µÚ¿¡ Àû´çÇÑ identifier¸¦ Àû¾îÁÖ°í, ¿øÇÏ´Â ¹®ÀÚ¿­ÀÇ ³»¿ëÀ» ÀûÀº ÈÄ¿¡, ¾Õ¿¡ ÀûÀº identifier·Î ¹®ÀÚ¿­À» ³¡¸ËÀ¸¸é µÈ´Ù. ³¡¸Ë´Â identifier´Â ÇØ´ç ¶óÀÎÀÇ Ã¹¹ø° Ä­¿¡¼­ ½ÃÀÛÇØ¾ß ÇÑ´Ù.

Example 6-1. Here doc string quoting example

  1 
  2 $str = <<<EOD
  3 Example of string
  4 spanning multiple lines
  5 using heredoc syntax.
  6 EOD;
  7      

Note: Here docÀº PHP 4¿¡¼­ºÎÅÍ Áö¿øµÈ´Ù.

¹®ÀÚ¿­Àº '.' (Á¡) ¿¬»êÀÚ·Î ¿¬°áÇÒ ¼ö ÀÖ´Ù. '+' (´õÇϱâ) ¿¬»êÀÚ´Â »ç¿ëÇÒ ¼ö ¾ø´Ù. ÀÚ¼¼ÇÑ Á¤º¸´Â String operators ºÎºÐÀ» ÂüÁ¶Çϱ⠹ٶõ´Ù.

¹®ÀÚ¿­³»ÀÇ °³°³ÀÇ ¹®ÀÚ´Â, C ¾ð¾î¿¡¼­ÀÇ ¹®ÀÚÀÇ ¹è¿­·ÎµÈ ¹®ÀÚ¿­Ã³·³ ¹è¿­¿¡ ¼ýÀÚ À妽º¸¦ ÅëÇØ Á¢±ÙÀÌ °¡´ÉÇÏ´Ù. ¾Æ·¡ ±× ¿¹°¡ ÀÖ´Ù.

Example 6-2. Some string examples

  1 
  2 <?php
  3 /* Assigning a string. */
  4 $str = "This is a string";
  5 
  6 /* Appending to it. */
  7 $str = $str . " with some more text";
  8 
  9 /* Another way to append, includes an escaped newline. */
 10 $str .= " and a newline at the end.\n";
 11 
 12 /* This string will end up being '<p>Number: 9</p>' */
 13 $num = 9;
 14 $str = "<p>Number: $num</p>";
 15 
 16 /* This one will be '<p>Number: $num</p>' */
 17 $num = 9;
 18 $str = '<p>Number: $num</p>';
 19 
 20 /* Get the first character of a string  */
 21 $str = 'This is a test.';
 22 $first = $str[0];
 23 
 24 /* Get the last character of a string. */
 25 $str = 'This is still a test.';
 26 $last = $str[strlen($str)-1];
 27 ?>	  
 28      

 


¹®ÀÚ¿­ º¯È¯ (String conversion)

¹®ÀÚ¿­ÀÌ ¼ýÀÚ·Î ´Ù·ç¾îÁú ¶§, °á°ú °ª°ú typeÀº ´ÙÀ½°ú °°ÀÌ °áÁ¤µÈ´Ù.

¸¸¾à ¹®ÀÚ¿­ ¾È¿¡ '.' À̳ª 'e', 'E'ÀÇ ¹®ÀÚ°¡ ÀÖÀ» °æ¿ì ±× typeÀº doubleÀÌ µÈ´Ù. ±×·¸Áö ¾Ê´Ù¸é Á¤¼ö °ªÀÌ´Ù

±× °ªÀº ¹®ÀÚ¿­ÀÇ °¡´ÉÇÑ ºÎºÐ±îÁö¸¸ »ç¿ëµÈ´Ù. ¹®ÀÚ¿­ÀÌ ¿Ã¹Ù¸¥ ¼ýÀÚ µ¥ÀÌÅÍ·Î ½ÃÀÛÇÏÁö ¾ÊÀ¸¸é ±× °ªÀº 0ÀÌ´Ù. ¿Ã¹Ù¸¥ ¼ýÀÚ µ¥ÀÌÅÍ´Â '+'/'-', '0'-'9','.'°ú ¼ýÀÚ µÚÀÇ 'e'³ª 'E' Ç¥½ÃÀÌ´Ù.

ù ¹ø° Ç¥Çö½ÄÀÌ stringÀÎ °æ¿ì, º¯¼öÀÇ typeÀº ù ¹ø°°¡ ¾Æ´Ñ µÎ ¹ø° Ç¥Çö½Ä¿¡ ÀÇÇØ °áÁ¤µÈ´Ù.

  1 
  2 $foo = 1 + "10.5";              // $foo is double (11.5)
  3 $foo = 1 + "-1.3e3";            // $foo is double (-1299)
  4 $foo = 1 + "bob-1.3e3";         // $foo is integer (1)
  5 $foo = 1 + "bob3";              // $foo is integer (1)
  6 $foo = 1 + "10 Small Pigs";     // $foo is integer (11)
  7 $foo = 1 + "10 Little Piggies"; // $foo is integer (11)
  8 $foo = "10.0 pigs " + 1;        // $foo is integer (11)
  9 $foo = "10.0 pigs " + 1.0;      // $foo is double (11)     
 10      

ÀÌ º¯È¯¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ¼³¸íÀºUnix manual pageÀÇ strtod(3)À» º¸¾Æ¶ó.

¸¸¾à ¿©·¯ºÐÀÌ À§ÀÇ ¿¹Á¦¸¦ ½ÇÁ¦ ½ÇÇèÇÏ°íÀÚ ÇÑ´Ù¸é, À§ÀÇ ¿¹Á¦¸¦ À߶ó ºÙÀÎ ÈÄ¿¡, ¾î¶² ÀÏÀÌ ÀϾ´Â °¡¸¦ ¾Ë±â À§ÇØ ¾Æ·¡ÀÇ ÁÙÀ» »ðÀÔÇÑ´Ù.

  1 
  2 echo "\$foo==$foo; type is " . gettype( $foo ) . "<br>\n";
  3       

 


¹è¿­ (Arrays)

¹è¿­À» ½ÇÁ¦·Î hash tables (associative arrays) °ú indexed arrays (vectors)ÀÇ µÎ°¡Áö·Î µ¿½Ã¿¡ »ç¿ëµÈ´Ù.


ÀÏÂ÷¿ø ¹è¿­ (Single Dimension Arrays)

PHP´Â scalar ¹è¿­°ú associative ¹è¿­ÀÇ µÎ °¡Áö¸¦ Áö¿øÇÑ´Ù. »ç½Ç µÎ °¡ÁöÀÇ Â÷ÀÌ´Â ¾ø´Ù. ¿©·¯ºÐÀº list()³ª array() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ¹è¿­À» ¸¸µé°Å³ª, °¢ ¿ø¼ÒÀÇ °ªÀ» Á¤ÇØ ÁÖ¾î ¹è¿­À» ¸¸µé ¼ö ÀÖ´Ù.

  1  
  2 $a[0] = "abc"; 
  3 $a[1] = "def"; 
  4 $b["foo"] = 13;
  5       

¶ÇÇÑ ´ÙÀ½°ú °°ÀÌ º¯¼ö¿¡ °ªÀ» ´õÇØÁÖ´Â °Í¸¸À¸·Î ¹è¿­À» ¸¸µé ¼öµµ ÀÖ´Ù.

  1  
  2 $a[] = "hello"; // $a[2] == "hello"
  3 $a[] = "world"; // $a[3] == "world" 
  4       

¹è¿­Àº Á¤·ÄÀ» ¿øÇÏ´Â Çü½Ä¿¡ µû¶ó asort(), arsort(), ksort(), rsort(), sort(), uasort(), usort(), uksort() ÇÔ¼öµéÀ» ÀÌ¿ëÇØ ¼ø¼­´ë·Î Á¤·ÄÇÒ ¼ö ÀÖ´Ù.

count() ÇÔ¼ö¸¦ »ç¿ëÇÏ¸é ¹è¿­ÀÇ ¿ø¼Ò °³¼ö¸¦ ¼¿ ¼ö ÀÖ´Ù.

next()¿Í prev() ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© ¹è¿­ÀÇ ³»¿ëÀ» Ž»öÇÒ ¼ö ÀÖ´Ù. ¹è¿­ÀÇ ³»¿ëÀ» Ž»öÇÏ´Â ¹æ¹ýÀ¸·Î each() ÇÔ¼ö¸¦ »ç¿ëÇÒ ¼öµµ ÀÖ´Ù.


´ÙÂ÷¿ø ¹è¿­ (Multi-Dimensional Arrays)

´ÙÂ÷¿ø ¹è¿­À̶ó ÇÏ´õ¶óµµ ½ÇÁ¦·Î ¸Å¿ì °£´ÜÇÑ´Ù. ¹è¿­ÀÇ °¢ Â÷¿ø¿¡ ´ëÇÏ¿© ´ÜÁö [key]°ªÀ» µÚ¾î ºÙ¿©ÁÖ¸é µÈ´Ù.

  1  
  2 $a[1]      = $f;               # one dimensional examples
  3 $a["foo"]  = $f;   
  4 
  5 $a[1][0]     = $f;             # two dimensional
  6 $a["foo"][2] = $f;             # (you can mix numeric and associative indices)
  7 $a[3]["bar"] = $f;             # (you can mix numeric and associative indices)
  8 
  9 $a["foo"][4]["bar"][0] = $f;   # four dimensional!
 10       

PHP3¿¡¼­, ¹®ÀÚ¿­ ³»¿¡¼­ ´ÙÂ÷¿ø ¹è¿­ÀÇ °ªÀ» Á÷Á¢ Á¢±ÙÇÏ´Â °ÍÀº ºÒ°¡´ÉÇÏ´Ù. ¿¹¸¦µé¾î ´ÙÀ½°ú °°Àº ¹®ÀåÀº ¿øÇÏ´Â °á°ú¸¦ ¾òÁö ¸øÇÒ °ÍÀÌ´Ù.

  1  
  2 $a[3]['bar'] = 'Bob';
  3 echo "This won't work: $a[3][bar]";
  4       

PHP3¿¡¼­ À§ÀÇ Ãâ·ÂÀº won't work: Array[bar] ÀÏ °ÍÀÌ´Ù. ¿øÇÏ´Â °á°ú¸¦ ¾òÀ¸·Á¸é ¹®ÀÚ¿­ ¿¬°á ¿¬»êÀÚ(.)¸¦ »ç¿ëÇÏ¿©¾ß ÇÒ °ÍÀÌ´Ù.

  1 
  2 $a[3]['bar'] = 'Bob';
  3 echo "This will work: " . $a[3][bar];
  4       

PHP4¿¡¼­´Â Á¢±ÙÇÏ·Á´Â ¹è¿­½ÄÀ» Áß°ýÈ£({})·Î µÑ·¯½ÓÀ¸·Î½á ÀÌ°ÍÀ» °¡´ÉÇÏ°Ô ÇÒ ¼öµµ ÀÖ´Ù.

  1 
  2 $a[3]['bar'] = 'Bob';
  3 echo "This will work: {$a[3][bar]}";
  4       

¿©·¯ °¡Áö ¹æ¹ýÀ¸·Î ÀÌ ´ÙÂ÷¿ø ¹è¿­¿¡ °ªÀ» ³ÖÀ» ¼ö ÀÖÀ¸³ª, associative ¹è¿­¿¡ °ªÀ» ÀúÀåÇÏ´Â °£´ÜÇÑ ¹æ¹ýÀ¸·Î array() ¸í·ÉÀ» »ç¿ëÇÏ´Â ¹æ¹ýÀÌ ÀÖ´Ù. ¿ì¼± ´ÙÀ½ÀÇ µÎ°¡Áö ÄÚµå´Â ÀÏÂ÷¿ø ¹è¿­¿¡ °ªÀ» ÀúÀåÇÏ´Â ¹æ¹ýÀ¸·Î °á°ú´Â µ¿ÀÏÇÏ´Ù.

  1  
  2 # Example 1:
  3 
  4 $a["color"]	= "red";
  5 $a["taste"]	= "sweet";
  6 $a["shape"]	= "round";
  7 $a["name"]	= "apple";
  8 $a[3]		= 4;
  9 
 10 # Example 2:
 11 $a = array(
 12      "color" => "red",
 13      "taste" => "sweet",
 14      "shape" => "round",
 15      "name"  => "apple",
 16      3       => 4
 17 );
 18       

array() ÇÔ¼ö´Â ´ÙÂ÷¿ø ¹è¿­¿¡ ´ëÇؼ­µµ ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÒ ¼ö ÀÖ´Ù. :

  1  
  2 <?
  3 $a = array(
  4      "apple"  => array(
  5           "color"  => "red",
  6           "taste"  => "sweet",
  7           "shape"  => "round"
  8      ),
  9      "orange"  => array(
 10           "color"  => "orange",
 11           "taste"  => "tart",
 12           "shape"  => "round"
 13      ),
 14      "banana"  => array(
 15           "color"  => "yellow",
 16           "taste"  => "paste-y",
 17           "shape"  => "banana-shaped"
 18      )
 19 );
 20 
 21 echo $a["apple"]["taste"];    # will output "sweet"
 22 ?>
 23       
 


°´Ã¼ (Objects)


°´Ã¼ ÃʱâÈ­ (Object Initialization)

°´Ã¼(Object)¸¦ ÃʱâÈ­ÇÏ´Â ¹æ¹ýÀº new ¸í·ÉÀ» »ç¿ëÇÏ¿© object¸¦ º¯¼ö¿¡ ÀνºÅϽº ½ÃÅ°´Â °ÍÀÌ´Ù.

  1 
  2 class foo {
  3     function do_foo () { 
  4         echo "Doing foo."; 
  5     }
  6 }
  7 
  8 $bar = new foo;
  9 $bar->do_foo();
 10       
 


Type Àüȯ (Type juggling)

PHP´Â º¯¼ö ¼±¾ð¿¡ À־ ¸íÈ®ÇÑ Á¤ÀǸ¦ ÇÒ ÇÊ¿äµµ ¾ø°í Áö¿øÇÏÁöµµ ¾Ê´Â´Ù. º¯¼öÀÇ Çü½ÄÀº º¯¼ö°¡ »ç¿ëµÇ´Â ¹®Àå ¼Ó¿¡¼­ °áÁ¤µÈ´Ù. ´Ù¸¥ ¸»·Î Çϸé, ¸¸¾à ¿©·¯ºÐÀÌ varÀ̶ó´Â º¯¼ö¿¡ ¹®ÀÚ¿­ °ªÀ» ÇÒ´çÇϸé var´Â ¹®ÀÚ¿­ º¯¼ö°¡ µÇ´Â °ÍÀÌ°í, Á¤¼ö °ªÀ» ÇÒ´çÇϸé Á¤¼ö º¯¼ö°¡ µÇ´Â °ÍÀÌ´Ù.

PHPÀÇ ÀÚµ¿ Çü º¯È¯ ¿¹´Â '+' ¿¬»ê¿¡¼­ ãÀ» ¼ö ÀÖ´Ù. ¾î¶² ÇÑ ÇÇ ¿¬»êÀÚ°¡ doubleÀÌ¸é ³ª¸ÓÁö ¸ðµç ÇÇ¿¬»êÀÚÀÇ Çüµµ double·Î ¹Ù²î¾î °á°úµµ doubleÇüÀÌ µÈ´Ù. ¸¸¾à ÇÇ¿¬»êÀÚµéÀÌ Á¤¼öÇüÀÌ¸é °á°úµµ Á¤¼öÇüÀÌ´Ù. ¿©±â¼­ Áß¿äÇÑ °ÍÀº ÇÇ¿¬»êÀÚ ÀÚ½ÅÀÇ ÇüÀº ¹Ù²îÁö ¾Ê´Â´Ù´Â °ÍÀÌ´Ù.

  1 
  2 $foo = "0";  // $foo is string (ASCII 48)
  3 $foo++;      // $foo is the string "1" (ASCII 49)
  4 $foo += 1;   // $foo is now an integer (2)
  5 $foo = $foo + 1.3;  // $foo is now a double (3.3)
  6 $foo = 5 + "10 Little Piggies"; // $foo is integer (15)
  7 $foo = 5 + "10 Small Pigs";     // $foo is integer (15)
  8      

¸¶Áö¸· µÎ °³ÀÇ ¿¹°¡ ÀǾÆÇÑ »ç¶÷Àº String conversionÀ» º¸±â ¹Ù¶õ´Ù.

¸¸¾à º¯¼ö¸¦ ¾î¶² ƯÁ¤ÇÑ typeÀ¸·Î ÁöÁ¤ÇÏ¿© °è»êµÇ°Ô ÇÏ°í ½Í´Ù¸é, Type casting ÆíÀ» º¸±â ¹Ù¶õ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ º¯¼öÀÇ typeÀ» ¹Ù²Ù°í ½Í´Ù¸é settype().À» º¸±â ¹Ù¶õ´Ù.

¸¸¾à ¿©·¯ºÐÀÌ À§ÀÇ ¿¹Á¦¸¦ ½ÇÁ¦ ½ÇÇèÇÏ°íÀÚ ÇÑ´Ù¸é, À§ÀÇ ¿¹Á¦¸¦ À߶ó ºÙÀÎ ÈÄ¿¡, ¾î¶² ÀÏÀÌ ÀϾ´Â °¡¸¦ ¾Ë±â À§ÇØ ¾Æ·¡ÀÇ ÁÙÀ» »ðÀÔÇÑ´Ù.

  1 
  2 echo "\$foo==$foo; type is " . gettype( $foo ) . "<br>\n";
  3      

Note: ¹è¿­·ÎÀÇ ÀÚµ¿ º¯È¯Àº ÇöÀç Á¤ÀǵǾî ÀÖÁö ¾Ê´Ù.

  1 
  2 $a = 1;       // $a is an integer
  3 $a[0] = "f";  // $a becomes an array, with $a[0] holding "f"
  4       

À§ÀÇ ¿¹¿¡¼­´Â $aÀÇ °á°ú°¡ ù ¹ø° ¿ä¼Ò·Î 'f'¸¦ °¡Áö´Â ¹è¿­ÀÌ µÉ °ÍÀ̶ó°í ¾Ë ¼ö ÀÖ´Ù. ÇÏÁö¸¸ ´ÙÀ½À» º¸ÀÚ. :

  1 
  2 $a = "1";     // $a is a string
  3 $a[0] = "f";  // What about string offsets? What happens?
  4       

PHP°¡ ¹®ÀÚ¿­³»ÀÇ ¹®ÀÚ¸¦ indexingÇؼ­ Á¢±ÙÇÏ´Â °ÍÀÌ °¡´ÉÇϹǷΠÀ§ÀÇ ¿¹Á¦´Â $aÀÇ ¹®ÀÚ¿­ÀÇ Ã¹ ¹ø° ¹®ÀÚ¸¦ "f"·Î Ç϶ó´Â °ÍÀÎÁö, $a¸¦ "f"¶ó´Â ¹®ÀÚ¿­À» ù ¹ø° ¿ø¼Ò·Î °¡Áø ¹è¿­·Î ¸¸µé¶ó´Â °ÍÀÎÁö ¾Ë ¼ö ¾ø´Ù.

ÀÌ·± ÀÌÀ¯¿¡¼­ PHP 3.0.12 ¿Í PHP 4.0b3-RC4¿¡¼­´Â ÀÌ ºÎºÐ¿¡¼­ÀÇ ÀÚµ¿ º¯È¯Àº Á¤ÀǵǾî ÀÖÁö ¾Ê´Ù. ÀÌ ¹®Á¦ÀÇ ÇØ°áÀº ÇöÀç ³íÀÇÁßÀÌ´Ù.


Type casting

PHPÀÇ Type castingÀº C¿¡¼­¿Í °°Àº ¹æ¹ýÀ¸·Î ÇÑ´Ù : º¯È¯ÇÏ·Á´Â º¯¼ö ¾Õ¿¡ ¿øÇÏ´Â type À̸§À» °ýÈ£ ¾È¿¡ ½áÁÖ¸é µÈ´Ù.

  1 
  2 $foo = 10;   // $foo is an integer
  3 $bar = (double) $foo;   // $bar is a double
  4       

´ÙÀ½°ú °°Àº º¯È¯ÀÌ °¡´ÉÇÏ´Ù. :

ÅÇ°ú °ø¹éÀº °ýÈ£¾È¿¡¼­´Â ¹«½ÃµÈ´Ù. Áï ´ÙÀ½ µÎ °³ÀÇ ¹®ÀåÀº µ¿ÀÏÇÏ´Ù. :

  1 
  2 $foo = (int) $bar;
  3 $foo = ( int ) $bar;
  4       

ƯÁ¤ ŸÀÔ°£ÀÇ Çüº¯È¯Àº ±× °á°ú¸¦ ¸íÈ®ÇÏ°Ô ¾Ë ¼ö ¾ø´Â °æ¿ì°¡ ÀÖ´Ù. ´ÙÀ½°ú °°Àº ³»¿ëµéÀ» ¾Ë¾ÆµÎµµ·Ï ÇÏÀÚ.

½ºÄ®¶ó°ªÀ̳ª ¹®ÀÚ¿­À» ¹è¿­·Î Çü º¯È¯Çϸé, ±× °ªÀº ÇØ´ç ¹è¿­ÀÇ Ã¹ ¹ø° ¿ø¼ÒÀÇ °ªÀÌ µÈ´Ù.

  1 
  2 $var = 'ciao';
  3 $arr = (array) $var;
  4 echo $arr[0];  // outputs 'ciao'  
  5       

½ºÄ®¶ó°ªÀ̳ª ¹®ÀÚ¿­À» °´Ã¼·Î Çü º¯È¯Çϸé, ±× °ªÀº ÇØ´ç °´Ã¼ÀÇ 'scalar'¶ó´Â ¼Ó¼ºÀÇ °ªÀÌ µÈ´Ù.

  1 
  2 $var = 'ciao';
  3 $obj = (object) $var;
  4 echo $obj->scalar;  // outputs 'ciao'
  5       

 


Chapter 7. º¯¼ö (Variables)


¹Ì¸® Á¤ÀÇµÈ º¯¼ö (Predefined variables)

PHP´Â ¸ðµç ½ºÅ©¸³Æ®¿¡ ±×°ÍÀÌ ½ÇÇà µÉ ¶§ ´Ù¼öÀÇ ¹Ì¸® Á¤ÀÇµÈ º¯¼öµéÀ» Á¦°øÇÑ´Ù. ÀÌ º¯¼öµéÁß ¼­¹öÀÇ Á¾·ù³ª ¹öÀü, ±âŸ ´Ù¸¥ ¿äÀÎÀ¸·ÎÀÎÇØ ´Þ¶óÁö´Â ¸¹Àº º¯¼öµéÀÌ ÀÌ°÷¿¡ ¹®¼­È­ µÇÁö ¾Ê¾Ò´Ù. ¶ÇÇÑ ÀÌ º¯¼öµéÁß ¸¹Àº °ÍÀÌ PHP°¡ command-lineÀ¸·Î µ¿ÀÛÇÒ ¶§´Â »ç¿ëÇÒ ¼ö ¾ø´Ù.

ÀÌ·± ¿©·¯ ¿äÀεéÀÌ ÀÖÁö¸¸ ÀÌ°÷¿¡¼­´Â °¡Àå ÀϹÝÀûÀΠȯ°æÀÎ Apache (1.3.6)¿¡¼­ ¸ðµâ·Î PHP3¸¦ ¼³Ä¡ÇÑ È¯°æ¿¡¼­ÀÇ ¹Ì¸® Á¤ÀÇµÈ º¯¼öµéÀ» »ìÆ캸µµ·Ï ÇÏÀÚ.

¿©·¯ºÐÀÌ »ç¿ëÇÏ´Â ½Ã½ºÅÛÀÇ ¸ðµç ¹Ì¸® Á¤ÀÇµÈ º¯¼öµéÀ» º¸·Á¸é phpinfo() ÇÔ¼ö¸¦ »ç¿ëÇϵµ·ÏÇÏÀÚ. (ÀÌ ÇÔ¼ö´Â ´Ù¸¥ ¿©·¯ À¯¿ëÇÑ Á¤º¸µµ ¾Ë·ÁÁØ´Ù.)

Note: ÀÌ ¸ñ·ÏÀº ¿ÏÀüÇÏÁö ¾Ê´Ù. (¿Ïº®ÇÒ »ý°¢µµ ¾ø´Ù.) ÀÌ ¸ñ·ÏÀº ´Ü¼øÈ÷ ¿©·¯ºÐÀÇ ½ºÅ©¸³Æ®¿¡¼­ ¾î¶² Á¾·ùÀÇ ¹Ì¸® Á¤ÀÇµÈ º¯¼öµéÀÌ »ç¿ëµÉ ¼ö Àִ°¡ÀÇ ¿¹½ÃÀÏ »ÓÀÌ´Ù.

Apache variables

ÀÌ º¯¼öµéÀº Apache À¥¼­¹ö·ÎºÎÅÍ »ý¼ºµÈ °ÍÀÌ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ´Ù¸¥ À¥¼­¹ö¸¦ »ç¿ëÇÏ°í ÀÖ´Ù¸é ÀÌ¿Í µ¿ÀÏÇÑ º¯¼öµéÀÌ »ý¼ºµÈ´Ù°í º¸ÀåÇÒ ¼ö ¾ø´Ù. ¾Æ¸¶µµ ÀϺδ ¾ø¾îÁö°í, ¿©±â¿¡ ÀÖ´Â º¯¼öµéÀÌ »õ·Î »ý±æ °ÍÀÌ´Ù. ¿©±â¿¡ ÀÖ´Â º¯¼öÁß ´Ù¼ö´Â CGI 1.1 specification¿¡¼­ ³ª¿Â °ÍÀÌ°í, ±× ³»¿ë´ë·Î »ç¿ëµÈ´Ù.

ÀÌ°÷ÀÇ º¯¼öÁß PHP°¡ command lineÀ¸·Î µ¿ÀÛÇÒ °æ¿ì »ç¿ëµÉ ¼ö ÀÖ´Â º¯¼ö´Â °ÅÀÇ ¾ø´Ù.

GATEWAY_INTERFACE
¼­¹ö°¡ »ç¿ëÇÏ°í ÀÖ´Â CGI specificationÀÇ revision. ¿¹: 'CGI/1.1'.
 
SERVER_NAME
ÇöÀç ½ºÅ©¸³Æ®°¡ ½ÇÇàµÇ°í Àִ ȣ½ºÆ®ÀÇ À̸§. ¸¸¾à ½ºÅ©¸³Æ®°¡ °¡»ó È£½ºÆ®¿¡¼­ ½ÇÇàµÇ°í ÀÖ´Ù¸é, ÀÌ °ªÀº °¡»ó È£½ºÆ®·Î Á¤ÀÇµÈ °ªÀÌ µÉ °ÍÀÌ´Ù.
 
SERVER_SOFTWARE
¿ä±¸¿¡´ëÇÑ ´ë´äÀÇ Çì´õ¿¡ »ç¿ëÇÒ ¼­¹ö identification ¹®ÀÚ¿­
 
SERVER_PROTOCOL
ÆäÀÌÁö°¡ ¿ä±¸µÇ¾îÁú ¶§ »ç¿ëÇÑ ÇÁ·ÎÅäÄÝÀÇ À̸§°ú ¸®ºñÁ¯. ¿¹: 'HTTP/1.0';
 
REQUEST_METHOD
ÇØ´ç ÆäÀÌÁö¸¦ ¿ä±¸ÇÒ ¶§ »ç¿ëÇÑ ¹æ¹ý(method). ¿¹: 'GET', 'HEAD', 'POST', 'PUT'.
 
QUERY_STRING
ÇØ´ç ÆäÀÌÁö¸¦ Á¢±ÙÇÒ ¶§ »ç¿ëµÈ query string.
 
DOCUMENT_ROOT
ÇöÀç ½ºÅ©¸³Æ®°¡ »øÇàÁßÀÎ document root µð·ºÅ丮. ¼­¹öÀÇ ¼³Á¤ ÆÄÀÏ¿¡ Á¤ÀǵǾî ÀÖ´Ù.
 
HTTP_ACCEPT

Contents of the Accept: header from the current request, if there is one.

HTTP_ACCEPT_CHARSET

Contents of the Accept-Charset: header from the current request, if there is one. Example: 'iso-8859-1,*,utf-8'.

HTTP_ENCODING

Contents of the Accept-Encoding: header from the current request, if there is one. Example: 'gzip'.

HTTP_ACCEPT_LANGUAGE

Contents of the Accept-Language: header from the current request, if there is one. Example: 'en'.

HTTP_CONNECTION

Contents of the Connection: header from the current request, if there is one. Example: 'Keep-Alive'.

HTTP_HOST

Contents of the Host: header from the current request, if there is one.

HTTP_REFERER

The address of the page (if any) which referred the browser to the current page. This is set by the user's browser; not all browsers will set this.

HTTP_USER_AGENT

Contents of the User_Agent: header from the current request, if there is one. This is a string denoting the browser software being used to view the current page; i.e. Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser() to tailor your page's functionality to the capabilities of the user's browser.

REMOTE_ADDR

The IP address from which the user is viewing the current page.

REMOTE_PORT

The port being used on the user's machine to communicate with the web server.

SCRIPT_FILENAME

The absolute pathname of the currently executing script.

SERVER_ADMIN

The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host.

SERVER_PORT

The port on the server machine being used by the web server for communication. For default setups, this will be '80'; using SSL, for instance, will change this to whatever your defined secure HTTP port is.

SERVER_SIGNATURE

String containing the server version and virtual host name which are added to server-generated pages, if enabled.

PATH_TRANSLATED

Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.

SCRIPT_NAME

Contains the current script's path. This is useful for pages which need to point to themselves.

REQUEST_URI

The URI which was given in order to access this page; for instance, '/index.html'.

Environment variables

These variables are imported into PHP's global namespace from the environment under which the PHP parser is running. Many are provided by the shell under which PHP is running and different systems are likely running different kinds of shells, a definitive list is impossible. Please see your shell's documentation for a list of defined environment variables.

Other environment variables include the CGI variables, placed there regardless of whether PHP is running as a server module or CGI processor.

PHP variables

These variables are created by PHP itself.

argv

Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters. When called via the GET method, this will contain the query string.

argc

Contains the number of command line parameters passed to the script (if run on the command line).

PHP_SELF

The filename of the currently executing script, relative to the document root. If PHP is running as a command-line processor, this variable is not available.

HTTP_COOKIE_VARS

An associative array of variables passed to the current script via HTTP cookies. Only available if variable tracking has been turned on via either the track_vars configuration directive or the <?php_track_vars?> directive.

HTTP_GET_VARS

An associative array of variables passed to the current script via the HTTP GET method. Only available if variable tracking has been turned on via either the track_vars configuration directive or the <?php_track_vars?> directive.

HTTP_POST_VARS

An associative array of variables passed to the current script via the HTTP POST method. Only available if variable tracking has been turned on via either the track_vars configuration directive or the <?php_track_vars?> directive.


º¯¼ö »ç¿ë ¹üÀ§ (Variable Scope)

º¯¼ö°¡ »ç¿ë°¡´ÉÇÑ °÷Àº ±× º¯¼ö°¡ ¼±¾ðµÈ °÷ ¾È¿¡¼­ ¸¸ÀÌ´Ù. PHP º¯¼öÀÇ ´ëºÎºÐÀº ÇÑ °³ÀÇ ¹üÀ§(single scope)¸¸À» °¡Áö°í ÀÖ´Ù. ÀÌ ¹üÀ§´Â include³ª require ÆÄÀÏ¿¡µµ µ¿ÀÏÇÏ°Ô Àû¿ëµÈ´Ù. ¿¹¸¦µé¾î :

  1 
  2 $a = 1;
  3 include "b.inc";
  4     

À§¿¡¼­ $aº¯¼ö´Â b,inc ½ºÅ©¸³Æ®¿¡¼­µµ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

±âº»ÀûÀ¸·Î ÇÔ¼ö ¾È¿¡¼­ ¼±¾ðµÈ °ÍÀº ÇÔ¼ö ¾È¿¡¼­¸¸ »ç¿ëµÇ´Â Áö¿ª º¯¼öÀÌ´Ù. ¶ÇÇÑ ÇÔ¼ö ¾È¿¡¼­ »ç¿ëµÇ´Â ÇÔ¼öµéÀº ±âº»ÀûÀ¸·Î Áö¿ª º¯¼ö¶ó°í °¡Á¤ÇÏ°í ã°Ô µÈ´Ù. ¿¹¸¦ µé¾î:

  1  
  2 $a = 1; /* global scope */ 
  3 
  4 Function Test () { 
  5     echo $a; /* reference to local scope variable */ 
  6 } 
  7 
  8 Test ();
  9     

ÀÌ ½ºÅ©¸³Æ®´Â ÇÔ¼ö ¾ÈÀÇ $a º¯¼ö¸¦ Áö¿ªº¯¼ö·Î °¡Á¤ÇÏ¿´°í, Áö¿ªº¯¼ö $a¿¡´Â ¾Æ¹« °ªµµ ´ëÀÔµÇÁö ¾Ê¾Ò±â ¶§¹®¿¡ ¾Æ¹«·± Ãâ·Âµµ ³ªÅ¸³ªÁö ¾Ê´Â´Ù. ÀÌ°ÍÀº C¿Í´Â ¾à°£ Â÷ÀÌ°¡ ³ª´Â ºÎºÐÀÌ´Ù. PHP¿¡¼­ Àü¿ªº¯¼ö¸¦ »ç¿ëÇÏ·Á¸é »ç¿ëÇÏ°í ½ÍÀº Àü¿ª º¯¼ö¸¦ ÇÔ¼ö ¾È¿¡ global ¼±¾ðÀ» ÇØ ÁÖ¾î¾ß ÇÑ´Ù. ¿¹¸¦ µé¾î :

  1 
  2 $a = 1;
  3 $b = 2;
  4 
  5 Function Sum () {
  6     global $a, $b;
  7 
  8     $b = $a + $b;
  9 } 
 10 
 11 Sum ();
 12 echo $b;
 13     

À§ÀÇ ½ºÅ©¸³Æ®´Â "3"À» Ãâ·ÂÇÒ °ÍÀÌ´Ù. ÇÔ¼ö ³»¿¡¼­ $a and $b¸¦ global·Î ¼±¾ðÇßÀ¸¹Ç·Î, ÀÌ ÇÔ¼ö³»ÀÇ $a, $b´Â Àü¿ª º¯¼ö¸¦ ÂüÁ¶ÇÏ°Ô µÈ´Ù. ÇÔ¼ö ³»¿¡¼­ ´Ù·ê ¼ö ÀÖ´Â Àü¿ªº¯¼öÀÇ °³¼ö¿¡´Â Á¦ÇÑÀÌ ¾ø´Ù.

Àü¿ª º¯¼ö¸¦ ÂüÁ¶ÇÏ´Â µÎ ¹ø° ¹æ¹ýÀº PHP¿¡¼­ Ưº°È÷ Á¤ÀÇÇÏ°í ÀÖ´Â $GLOBALS¶ó´Â ¹è¿­À» »ç¿ëÇÏ´Â °ÍÀÌ´Ù. À§ÀÇ ¿¹¸¦ ´ÙÀ½°ú °°ÀÌ ¹Ù²ã ¾µ ¼ö ÀÖ´Ù. :

  1 
  2 $a = 1;
  3 $b = 2;
  4 
  5 Function Sum () {
  6     global $a, $b;
  7 
  8     $b = $a + $b;
  9 } 
 10 
 11 Sum ();
 12 echo $b;
 13     

$GLOBALS ¹è¿­Àº º¯¼öÀ̸§ÀÌ Key°¡ µÇ°í, ±× º¯¼öÀÇ ³»¿ëÀÌ °ªÀÌ µÇ´Â ¿ø¼Ò¸¦ °¡Áø associative ¹è¿­ÀÌ´Ù.

º¯¼ö ¹üÀ§¿¡¼­ ¶Ç ´Ù¸¥ Áß¿äÇÑ °ÍÀº Á¤Àû º¯¼ö(static variable)ÀÌ´Ù. Á¤Àû º¯¼ö´Â Áö¿ª ÇÔ¼ö ³»¿¡¼­¸¸ Á¸ÀçÇÏÁö¸¸ Áö¿ª ÇÔ¼ö°¡ Á¾·áµÇ¾îµµ ±× °ªÀ» Àоî¹ö¸®Áö ¾Ê°í °¡Áö°í ÀÖ´Ù. ´ÙÀ½ ¿¹¸¦ º¸ÀÚ :

  1 
  2 Function Test () {
  3     $a = 0;
  4     echo $a;
  5     $a++;
  6 }
  7     

À§ÀÇ ÇÔ¼ö´Â Test()¸¦ ºÎ¸¦ ¶§ ¸¶´Ù $a°¡ 0À¸·Î ´ëÀԵǹǷΠ0À» Ãâ·ÂÇÑ´Ù.

  1 
  2 Function Test () {
  3     static $a = 0;
  4     echo $a;
  5     $a++;
  6 }
  7     

À§ÀÇ ÇÔ¼ö´Â Test()¸¦ ºÎ¸¦ ¶§¸¶´Ù óÀ½¿¡´Â 0, ´ÙÀ½¿¡´Â 1, ±× ´ÙÀ½¿¡´Â 2ÇÏ´Â ½ÄÀ¸·Î Çϳª¾¿ Áõ°¡µÈ ¼ö¸¦ Ãâ·ÂÇØ ÁØ´Ù. Áï, $aÀÇ °ªÀÌ º¸Á¸µÇ´Â °ÍÀÌ´Ù.

¶ÇÇÑ Á¤Àû º¯¼ö´Â ´ÙÀ½°ú °°ÀÌ recursion¿¡¼­ ¹Ýµå½Ã ÇÊ¿äÇÏ´Ù. Àç±ÍÀûÀÎ ÇÔ¼ö´Â ÀÚ±â ÀÚ½ÅÀÇ ÇÔ¼ö¸¦ È£ÃâÇÏ´Â °ÍÀ» ¸»ÇÑ´Ù. Àç±ÍÀûÀÎ ÇÔ¼ö¸¦ »ç¿ëÇÒ ¶§´Â ¹«ÇÑ ·çÇÁ¿¡ ºüÁú ¼ö Àֱ⠶§¹®¿¡ ¸Å¿ì ÁÖÀǸ¦ ¿äÇÑ´Ù. µû¶ó¼­ ¿©·¯ºÐÀº Àç±Í È£ÃâÀ» ³¡³»´Â ÀûÀýÇÑ ¹æ¹ýÀ» ¸¶·ÃÇØ µÎ¾î¾ß ÇÑ´Ù. ´ÙÀ½ÀÇ °£´ÜÇÑ ¿¹Á¦´Â 10¹øÀÇ Àç±ÍÀû È£ÃâÀ» ÇÑ´Ù. :

  1 
  2 Function Test () {
  3     static $a = 0;
  4     echo $a;
  5     $a++;
  6 }
  7     

 


°¡º¯ º¯¼ö (Variable variables)

°¡²û º¯¼öÀÇ À̸§À» º¯°æÇÒ ¼ö ÀÖ´Ù¸é Æí¸®ÇÏ´Ù°í ´À³¥ ¶§°¡ ÀÖ´Ù. ÀÌ°÷¿¡¼­´Â º¯¼öÀÇ À̸§À» ¹Ù²Ù¾î »ç¿ëÇÏ´Â ¹æ¹ýÀ» ¾Ë¾Æº¸ÀÚ. º¸ÅëÀÇ º¯¼ö ¼±¾ðÀº ´ÙÀ½°ú °°´Ù. :

  1 
  2 $a = "hello";
  3     

¿©±â¼­ ÀÌ °¡º¯ º¯¼öÀº º¯¼öÀÇ °ªÀ» °¡Áú ¼öµµ ÀÖ°í, ¶ÇÇÑ ÀÌ °ªÀ» º¯¼öÀÇ À̸§À¸·Î ´Ù·ê ¼öµµ ÀÖ´Ù. À§ÀÇ ¿¹¿¡¼­ hello´Â $$¸¦ ¾Õ¿¡ ºÙÀÌ¸é º¯¼ö À̸§À¸·Î »ç¿ëÇÒ ¼ö ÀÖ´Â °ÍÀÌ´Ù. ¿¹ :

  1 
  2 $$a = "world";
  3     

ÀÌ·¸°Ô Çϸé PHPÀÇ symbol tree¿¡´Â "hello"¶ó´Â °ªÀ» °¡Áö´Â $a¿Í "world"¶ó´Â °ªÀ» °¡Áö´Â $helloÀÇ µÎ °³ÀÇ º¯¼ö°¡ »ý±â°Ô µÈ´Ù. ±×·¯¹Ç·Î ´ÙÀ½°ú °°Àº ¹®ÀåÀº :

  1 
  2 echo "$a ${$a}";
  3     

´ÙÀ½ ¹®Àå°ú ¶È °°Àº Ãâ·ÂÀ» ³ªÅ¸³»°Ô µÈ´Ù.:

  1 
  2 echo "$a $hello";
  3     

ie. µÑÀÇ Ãâ·Â: hello world.

°¡º¯ º¯¼ö¸¦ ¹è¿­°ú ÇÔ²² »ç¿ëÇÏ·Á¸é, ÇÑ°¡Áö ¸ðÈ£¼º ¹®Á¦¸¦ ÇØ°áÇØ¾ß ÇÑ´Ù. ±×°ÍÀº, ¸¸¾à ¿©·¯ºÐÀÌ $$a[1]À̶ó°í ½èÀ¸¸é, $a[1]À» ÇϳªÀÇ º¯¼ö·Î º¼ °ÍÀÎÁö, ¾Æ´Ï¸é $$a¸¦ º¯¼ö·Î º¸°í ±× º¯¼ö¿¡ [1]ÀÇ À妽º¸¦ ÇØ ÁÙ °ÍÀΰ¡ ÇÏ´Â ¹®Á¦ÀÌ´Ù. ´ÙÀ½°ú °°ÀÌ ÇÏ¿© ¸ðÈ£¼ºÀ» ÇØ°áÇÏÀÚ. ÀüÀÚÀÇ °æ¿ì ${$a[1]}¶ó°í ¾²°í, ÈÄÀÚÀÇ °æ¿ì´Â ${$a}[1]¶ó°í ¾²¸é µÈ´Ù. ( ¿ªÀÚÁÖ: °¡º¯ º¯¼ö¸¦ ³ªÅ¸³¾ ¶§´Â Ç×»ó { }·Î µÑ·¯ ½Î´Â °ÍÀÌ º¸±â ÁÁ°í ¿À·ùµµ ¾ø¾Ù ¼ö ÀÖ´Ù.)


PHP ¹Û¿¡¼­ ¿Â º¯¼öµé (Variables from outside PHP)

HTML Forms (GET and POST)

ÆûÀÌ PHP ½ºÅ©¸³Æ®·Î submitµÇ¸é Æû¿¡ ÀÖ´Â ¸ðµç ³»¿ëµéÀÌ ÀÚµ¿ÀûÀ¸·Î ¸¸µé¾îÁø PHP º¯¼ö·Î µé¾î¿Â´Ù. ´ÙÀ½ÀÇ ÆûÀ» º¸ÀÚ :

Example 7-1. Simple form variable

  1 
  2 <form action="foo.php3" method="post">
  3     Name: <input type="text" name="name"><br>
  4     <input type="submit">
  5 </form>
  6       

À§ÀÇ ÆûÀÌ submitµÇ¸é PHP´Â $nameº¯¼ö¸¦ ¸¸µé°í, ÀÌ º¯¼ö¿¡ ÆûÀÇ Name: Çʵ忡 ÀÔ·ÂµÈ ¸ðµç ³»¿ëÀ» ÀúÀåÇÑ´Ù.

PHP´Â Æû¿¡ 1Â÷¿ø ¹è¿­ º¯¼öµµ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ¿¹¸¦µé¾î, ¿©·¯ºÐÀº ¿©·¯ º¯¼ö¸¦ ÇÔ²² »ç¿ëÇÏ´Â ±×·ì °ü·Ã º¯¼ö(group related variables)³ª multi select º¯¼öÀÇ ³»¿ëµéÀ» °Ë»öÇÒ ¼ö ÀÖ´Ù. :

Example 7-2. More complex form variables

  1 
  2 <form action="array.php" method="post">
  3     Name: <input type="text" name="personal[name]"><br>
  4     Email: <input type="text" name="personal[email]"><br>
  5     Beer: <br>
  6     <select multiple name="beer[]">
  7         <option value="warthog">Warthog
  8         <option value="guinness">Guinness
  9         <option value="stuttgarter">Stuttgarter Schwabenbräu
 10         </select>
 11     <input type="submit">
 12 </form>
 13       

¸¸¾à track_vars ¼³Á¤ÀÌ on µÇ¾î Àְųª, <?php_track_vars?> Áö½ÃÀÚ°¡ ¼³Á¤µÇ¾î ÀÖ´Ù¸é, POST³ª GETÀ¸·Î Àü¼ÛµÇ´Â ¸ðµç º¯¼öµé°ú ±× ³»¿ëÀº Àü¿ª ¹è¿­ º¯¼öÀÎ $HTTP_POST_VARS°ú $HTTP_GET_VARS¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.


IMAGE SUBMITÀÇ º¯¼ö À̸§

ÆûÀº submitÇÒ ¶§ ÀϹÝÀûÀ¸·Î »ç¿ëÇÏ´Â submit ¹öÆ°´ë½Å ´ÙÀ½°ú °°ÀÌ ±×¸²À» »ç¿ëÇÒ ¼öµµ ÀÖ´Ù. :

  1 
  2 <input type=image src="image.gif" name="sub">

»ç¿ëÀÚ°¡ image¸¦ Ŭ¸¯Çϸé, ÆûÀº sub_x¿Í sub_yÀÇ µÎ °³ÀÇ º¯¼ö°¡ Ãß°¡µÇ¾î ¼­¹ö¿¡ Àü¼ÛµÈ´Ù. ÀÌ µÎ º¯¼ö´Â À̹ÌÁö¿¡¼­ »ç¿ëÀÚ°¡ clickÇÑ À§Ä¡ Á¤º¸¸¦ ´ã°í ÀÖ´Ù. ÀϺΠºê¶ó¿ìÀú¿¡¼­´Â ¹ØÁÙ(_)´ë½Å ¸¶Ä§Ç¥(.)¸¦ »ç¿ëÇÏ´Â °æ¿ìµµ Àִµ¥, PHP´Â ÀÌ·± °æ¿ì ÀÚµ¿ÀûÀ» ¸¶Ä§Ç¥(.)¸¦ ¹ØÁÙ(_)·Î ¹Ù²ãÁØ´Ù.


HTTP Cookies

PHP´Â HTTP ÄíÅ°¸¦ Netscape's SpecÀÇ Á¤ÀÇ¿¡ µû¶ó Á¦°øÇÑ´Ù. Cookie ¸ÞÄ«´ÏÁòÀº Æ®·¡Å·À̳ª »ç¿ëÀÚ ½Äº° µîÀ» À§ÇØ ¿ø°Ý browser¿¡ ÀúÀåµÈ µ¥ÀÌÅ͸¦ µ¹·Á ¹Þ´Â °úÁ¤À» ¸»ÇÑ´Ù. ¿©·¯ºÐÀº cookie¸¦ ¼³Á¤Çϱâ À§ÇØ SetCookie() ÇÔ¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. Cookie´Â HTTP Çì´õÀÇ ÇÑ ºÎºÐÀ̹ǷÎ, SetCookie() ÇÔ¼ö´Â ºê¶ó¿ìÀú·Î º¸³»´Â ¾î¶² µ¥ÀÌÅͺ¸´Ùµµ ¾Õ¿¡ »ç¿ëÇØ¾ß ÇÑ´Ù. ÀÌ Á¦¾àÀº Header() ÇÔ¼ö¿Í °°Àº Á¦¾àÀ¸·Î º¸¸é µÈ´Ù. ´ç½ÅÀÌ º¸³»ÁØ ¸ðµç cookie´Â ÀÚµ¿ÀûÀ¸·Î GETÀ̳ª POST ¹æ½Ä µ¥ÀÌÅÍ¿Í °°Àº PHP º¯¼ö·Î º¯È¯µÈ´Ù.

¸¸¾à ¿©·¯ºÐÀÌ µ¿ÀÏÇÑ cookie¿¡ ¿©·¯ °ªÀ» ÀúÀåÇÏ°í ½Í´Ù¸é CookieÀ̸§¿¡ []¸¦ ´õÇÏ¸é µÈ´Ù. ¿¹¸¦ µé¾î :

  1 
  2 SetCookie ("MyCookie[]", "Testing", time()+3600);
  3      

ÄíÅ°´Â »õ·Î ¼³Á¤Çϸé path³ª µµ¸ÞÀÎÀÌ ´Ù¸£Áö ¾Ê´Â ÇÑ ÀÌÀüÀÇ ÄíÅ°¸¦ µ¤¾î¾²°Ô µÈ´Ù. ±×·¯¹Ç·Î ¼îÇÎ Ä«Æ® °°Àº ÀÀ¿ë ÇÁ·Î±×·¥¿¡¼­´Â Ä«¿îÅ͸¦ À¯ÁöÇÏ°í, ÀÌ°ÍÀ» ±âÁØÀ¸·Î Cookie¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù. ¿¹ :

Example 7-3. SetCookie Example

  1 
  2 $Count++;
  3 SetCookie ("Count", $Count, time()+3600);
  4 SetCookie ("Cart[$Count]", $item, time()+3600);
  5      

 


ȯ°æ º¯¼ö (Environment variables)

PHP´Â ÀÚµ¿ÀûÀ¸·Î ȯ°æ º¯¼öµéÀ» ÀϹÝÀûÀÎ PHP º¯¼ö·Î ¸¸µç´Ù.

  1 
  2 echo $HOME;  /* Shows the HOME environment variable, if set. */
  3       

GET, POST and Cookie ¸ÞÄ«´ÏÁòÀ» ÅëÇؼ­ Á¤º¸°¡ µé¾î ¿Â Á¤º¸·ÎºÎÅÍ ÀÚµ¿ÀûÀ¸·Î PHP º¯¼ö°¡ »ý±â¹Ç·Î, ÀÌ ¹æ¹ýÀº ¶§¶§·Î ¿Ã¹Ù¸¥ ¹öÀüÀ» È®ÀÎÇϱâ À§ÇØ È¯°æÀ¸·ÎºÎÅÍ º¯¼ö¸¦ ÀÐ¾î µéÀ̱⿡ °¡Àå ÁÁ´Ù. À̸¦ À§ÇØ getenv() ÇÔ¼ö¸¦ »ç¿ëÇÒ ¼öµµ ÀÖ´Ù. ¿©·¯ºÐÀº ȯ°æ º¯¼ö¸¦ ¼³Á¤Çϱâ À§ÇØ putenv() ÇÔ¼ö¸¦ »ç¿ëÇÒ ¼öµµ ÀÖ´Ù.


¿ÜºÎ º¯¼ö¸í¿¡ ÀÖ´Â '.' (Dots in incoming variable names)

ÀϹÝÀûÀ¸·Î PHP´Â º¯¼ö¸¦ ½ºÅ©¸³Æ®·Î °¡Á®¿Ã ¶§ º¯¼ö¸íÀ» ¹Ù²ÙÁö ¾Ê´Â´Ù. ±×·¯³ª, PHPÀÇ º¯¼ö¸í¿¡´Â '.' (Á¡)À» »ç¿ëÇÒ ¼ö ¾ø´Ù. ´ÙÀ½°ú °°Àº °æ¿ì¸¦ º¸ÀÚ. :
  1 
  2 $varname.ext;  /* invalid variable name */
  3      

À§ÀÇ °æ¿ì Æļ­´Â $varnameÀ̶ó´Â º¯¼ö¿Í, ¿¬°á ¿¬»êÀÚ, 'ext'(µû¿ÈÇ¥°¡ ¾ø´Â °æ¿ì ±×°ÍÀÌ ¾î¶² ¾Ë·ÁÁø Å°³ª ¿¹¾à¾î°¡ ¾Æ´Ï¸é ¹®ÀÚ¿­·Î Ãë±ÞµÈ´Ù.)·Î Çؼ®ÇÑ´Ù. µû¶ó¼­ ÀÌ°ÍÀº ¿ì¸®°¡ ¿øÇÏ´Â °á°ú°¡ ¾Æ´Ï´Ù.

À§¿Í °°Àº ÀÌÀ¯·Î PHP´Â ¿ÜºÎ¿¡¼­ ºÒ·¯µéÀÎ º¯¼öÀÇ À̸§¿¡ '.'ÀÌ ÀÖÀ¸¸é '_'(¹ØÁÙ)·Î ¹Ù²Ù¾î ÀоîµéÀδÙ.


º¯¼öÀÇ Type ÆÇ´Ü (Determining variable types)

PHP°¡ º¯¼öÀÇ typeÀ» Á¤ÇÏ°í (ÀϹÝÀûÀ¸·Î) ÇÊ¿äÇÑ °æ¿ì¿¡´Â ±× typeÀ» ¹Ù²Ù¹Ç·Î, ƯÁ¤ ½ÃÁ¡¿¡ ±× º¯¼ö ¾î¶² typeÀÎÁö´Â ½±°Ô ¾Ë ¼ö ¾ø´Ù. PHP´Â º¯¼öÀÇ typeÀ» ¾Ë¾Æº¸±â À§ÇØ ¿©·¯°³ÀÇ ÇÔ¼ö¸¦ °¡Áö°í ÀÖ´Ù. gettype(), is_long(), is_double(), is_string(), is_array(), and is_object()°¡ ±×°ÍµéÀÌ´Ù.


Chapter 8. »ó¼ö(Constants)

PHP´Â ¾à°£ÀÇ ±âº»ÀûÀÎ »ó¼öµéÀ» Á¦°øÇÏ°í, ½ÇÇà½Ã »ó¼ö¸¦ ¼³Á¤ÇÒ ¼ö ÀÖ´Â ¸ÞÄ«´ÏÁòÀ» Áö¿øÇÑ´Ù. »ó¼ö´Â º¯¼ö¿Í ºñ½ÁÇÏ´Ù. ±×·¯³ª define()ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ¼±¾ðÇÑ´Ù´Â °Í°ú ³ªÁß¿¡ ´Ù¸¥ °ªÀ¸·Î ¹Ù²Ü ¼ö ¾ø´Ù´Â Á¡ÀÌ Â÷ÀÌ°¡ ÀÖ´Ù.

¹Ì¸® ÁöÁ¤µÈ »ó¼ö´Â ´ÙÀ½°ú °°´Ù.

__FILE__
ÇöÀç ó¸®ÁßÀÎ ½ºÅ©¸³Æ®ÀÇ ÆÄÀϸí. ÇöÀç ÆÄÀÏÀÌ include³ª require·Î Æ÷ÇÔµÈ ÆÄÀÏÀ̶ó¸é, includeÇÔ¼öµîÀ» È£ÃâÇÑ ºÎ¸ð ÆÄÀÏÀÌ ¾Æ´Ñ, Æ÷ÇÔµÈ ÆÄÀÏÀÇ À̸§À» °¡Áø´Ù.
 
__LINE__
ÇöÀç ó¸®ÁßÀÎ ¸í·ÉÀÇ ½ºÅ©¸³Æ®³»¿¡¼­ÀÇ ¶óÀÎ ¹øÈ£. ÇöÀç ÆÄÀÏÀÌ include³ª require·Î Æ÷ÇÔµÈ ÆÄÀÏÀ̶ó¸é, includeÇÔ¼öµîÀ» È£ÃâÇÑ ºÎ¸ð ÆÄÀÏÀÌ ¾Æ´Ñ, Æ÷ÇÔµÈ ÆÄÀϳ»¿¡¼­ÀÇ ¶óÀÎ ¹øÈ£¸¦ °¡Áø´Ù.
 
PHP_VERSION
ÇöÀç »ç¿ëÁßÀÎ PHP Æļ­ÀÇ ¹öÀü. (¿¹ : '3.0.8-dev')
 
PHP_OS
PHP Æļ­°¡ ½ÇÇàµÇ°í ÀÖÀÀ OSÀÇ À̸§. (¿¹ : 'Linux')
 
TRUE
Âü(TRUE) °ª
 
FALSE
°ÅÁþ(FALSE) °ª
 
E_ERROR
¹®¹ý ¿À·ù°¡ ¾Æ´Ñ º¹±¸°¡ ºÒ°¡´ÉÇÑ ¿¡·¯¸¦ Ç¥½ÃÇÑ´Ù.
 
E_WARNING
PHP°¡ ¾î¶² °è¼Ó ¼öÇà °¡´ÉÇÑ ¿À·ù¸¦ °¨Áö ÇßÀ½À» Ç¥½ÃÇÑ´Ù. ¿¹¸¦µé¾î ereg()¿¡ regexp°¡ À߸øµÈ °æ¿ì µîÀÌ´Ù.
 
E_PARSE
Æļ­°¡ ½ºÅ©¸³Æ® ÆÄÀÏ¿¡¼­ ¹®¹ýÀûÀ¸·Î À߸øµÈ ¸í·ÉÀ» ¸¸³­ °æ¿ìÀÌ´Ù. º¹±¸´Â ºÒ°¡´ÉÇÏ´Ù.
 
E_NOTICE
¿¡·¯´Â ¾Æ´ÏÁö¸¸ ¾î¶² ¾Ë·ÁÁú »çÇ×ÀÌ ÀÖÀ½À» ³ªÅ¸³½´Ù. ½ÇÇàÀº °è¼ÓµÈ´Ù. ¿¹¸¦µé¾î hash À妽º¿¡ µû¿ÈÇ¥°¡ ¾ø´Â ¹®ÀÚ¿­ÀÌ »ç¿ëµÇ¾ú´Ù´øÁö, ÀÌÀü¿¡ ¼±¾ðµÇÁö ¾ÊÀº º¯¼öÀÇ °ªÀ» Àд´ٴøÁö ÇÏ´Â °æ¿ìÀÌ´Ù.

E_* »ó¼ö´Â ´ë°³ error_reporting() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© reporting ·¹º§À» Á¤ÇÒ ¶§ ÈçÈ÷ »ç¿ëµÈ´Ù.

¶ÇÇÑ ¿©·¯ºÐÀº define()ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© Ãß°¡ÀûÀÎ »ó¼ö¸¦ Á¤ÀÇÇÒ ¼ö ÀÖ´Ù.

ÁÖÀÇÇÒ Á¡Àº »ó¼ö´Â C¿¡¼­ÀÇ macro °ªÀº °ÍÀÌ ¾Æ´Ï´Ù. ´ÜÁö scalar °ªÀ» °¡Áú ¼ö ÀÖÀ» »ÓÀÌ´Ù.

Example 8-1. Defining Constants

  1 
  2 <?php
  3 define("CONSTANT", "Hello world.");
  4 echo CONSTANT; // outputs "Hello world."
  5 ?>
  6      

Example 8-2. Using __FILE__ and __LINE__

  1 
  2 <?php
  3 function report_error($file, $line, $message) {
  4     echo "An error occured in $file on line $line: $message.";
  5 }
  6 
  7 report_error(__FILE__,__LINE__, "Something went wrong!");
  8 ?>
  9      

 


Chapter 9. Ç¥Çö½Ä (Expressions)

Ç¥Çö½ÄÀº PHP¿¡¼­ ¸Å¿ì Áß¿äÇÑ ³»¿ëÀÌ´Ù. PHP¿¡¼­ ¿©·¯ºÐÀÌ ÀÛ¼ºÇÏ´Â °ÅÀÇ ¸ðµç °ÍÀº Ç¥Çö½ÄÀÌ´Ù. °£´ÜÈ÷ Ç¥Çö½ÄÀÇ Á¤ÀǸ¦ ¾ö¹ÐÇÏ°Ô ¸»ÇÑ´Ù¸é "°ªÀ» °¡Áö°í ÀÖ´Â ¸ðµç °Í"("anything that has a value")ÀÌ´Ù.

°£´ÜÇÑ ¿¹Á¦·Î "$a = 5"¿Í °°Àº °ÍÀÌ ÀÖ´Ù. ÀÌ°ÍÀº 5¶ó´Â °ªÀ» $a¶ó´Â º¯¼ö¿¡ ´ëÀÔÇÏ´Â ¹®ÀåÀÌ´Ù. ¿©±â¼­ 5¶ó´Â Ç¥Çö½ÄÀº 5ÀÇ °ªÀ̶ó´Â Àǹ̰¡ µÈ´Ù. À§ÀÇ ¹®Àå ´ÙÀ½¿¡ "$b = $a"¶ó´Â ¹®ÀåÀÌ ÀÖ´Ù¸é ¿©±â¼­ $a¶ó´Â Ç¥Çö½ÄÀº ±× º¯¼ö°¡ °¡Áø 5¶ó´Â °ªÀ» Ç¥ÇöÇÑ´Ù.

Á¶±Ý º¹ÀâÇÑ °æ¿ì´Â ÇÔ¼öÀÌ´Ù. ´ÙÀ½ ÇÔ¼ö¸¦ º¸ÀÚ. :

  1 
  2 function foo () {
  3     return 5;
  4 }
  5      

$c = 5¶ó´Â ¹®Àå¿¡¼­ foo()´Â 5¸¦ µ¹·ÁÁÙ °ÍÀ̱⠶§¹®¿¡ 'foo()'¶ó´Â Ç¥Çö½ÄÀº 5¸¦ Ç¥ÇöÇÑ´Ù°í ¸»ÇÒ ¼ö ÀÖ´Ù.

PHP´Â Á¤¼ö°ª(integer values), ½Ç¼ö°ª(floating point values), ¹®ÀÚ¿­(string values)ÀÇ 3°¡Áö ½ºÄ®¶ó typeÀ» °¡Áö°í ÀÖ´Ù. (½ºÄ®¶ó °ªÀ̶õ ´õ ÀÌ»ó ÀÛÀº °ªÀ¸·Î ÂÉ°³Áú ¼ö ¾ø´Â °ªÀ» ¸»ÇÑ´Ù.) ¶ÇÇÑ PHP´Â ¹è¿­(array)°ú °´Ã¼(object)ÀÇ 2°¡Áö È¥ÇÕ(composite, non-scalar) typeÀ» Áö¿øÇÑ´Ù. ÀÌ typeµéÀº º¯¼ö¿¡ °ªÀ» ÇÒ´çÇÒ ¼ö ÀÖ°í, ÇÔ¼ö¿¡ ÀÇÇØ °ªÀ» µ¹·ÁÁÙ ¼ö ÀÖ´Ù.

¿©±â±îÁö´Â PHP/FI 2 »ç¿ëÀÚµéÀº ¾Æ¹«°Íµµ ¹Ù²îÁö ¾Ê¾Ò´Ù°í ´À³¥ °ÍÀÌ´Ù. PHP´Â °ÅÀÇ ¸ðµç °ÍÀÌ Ç¥Çö½ÄÀ¸·Î Ç¥ÇöµÈ´Ù´Â Á¡¿¡¼­, Ç¥Çö Á᫐ ¾ð¾î (expression-oriented language)¶ó°í ºÒ¸± ¼ö ÀÖ´Ù. Ç¥Çö Áß½ÉÀÇ ÁÁÀº ¿¹´Â ´ëÀÔ¹®ÀÌ´Ù. PHP¿¡¼­´Â C¿Í °°ÀÌ ´ëÀÔ¹®µµ ÇϳªÀÇ Ç¥Çö½ÄÀ¸·Î º»´Ù. µû¶ó¼­ '$a=5; $b=5;'´Â '$a = ($b=5);' ȤÀº '$a = $b = 5;'·Î Ç¥Çö °¡´ÉÇÏ´Ù.

Ç¥Çö Áß½ÉÀÇ ´Ù¸¥ ÁÁÀº ¿¹·Î´Â ++¿Í --ÀÌ´Ù. In PHP/FI 2¿¡¼­´Â '$a++'¿Í °°Àº ¹®ÀåÀº ¾Æ¹« °ªµµ °¡ÁöÁö ¾Ê¾Ò´Ù. Áï, Ç¥Çö½ÄÀÌ ¾Æ´Ï¾ú´Ù. µû¶ó¼­ ÀÌ °ªÀ» ´Ù¸¥ °÷¿¡ ´ëÀÔÇÏ´Â °ÍÀº ºÒ°¡´ÉÇß´Ù. ±×·¯³ª PHP 3¿¡¼­´Â ÀÌ°ÍÀÌ °¡´ÉÇØÁ³´Ù. C¿¡¼­¿Í °°ÀÌ ++/--¸¦ »ç¿ëÇÏ´Â ¹æ¹ý¿¡´Â ¾Õ¿¡ ºÙÀÌ´Â °Í°ú µÚ¿¡ ºÙÀÌ´Â °Í µÎ°¡Áö°¡ ÀÖ´Ù. µÑ ¸ðµÎ º¯¼öÀÇ °ªÀÌ Áõ°¡µÈ´Ù´Â Á¡Àº °°À¸³ª, '++$variable'Àº ±× º¯¼öÀÇ Áõ°¡µÈ °ªÀÌ Ç¥Çö½ÄÀÇ °ªÀÌ µÇ°í, '$variable++'´Â º¯¼öÀÇ Áõ°¡µÇ±â ÀüÀÇ °ªÀÌ Ç¥Çö½ÄÀÇ °ªÀÌ µÈ´Ù.

ºñ±³ Ç¥Çö½ÄÀº 0À̳ª 1ÀÇ °ªÀ» °¡Áø´Ù. 0Àº ºÎÁ¤(FALSE)À» 1Àº ±àÁ¤(TRUE)¸¦ ³ªÅ¸³½´Ù. PHP´Â > (bigger than), >= (bigger than or equal to), == (equal),< (smaller than), <= (smaller than or equal to)¸¦ Áö¿øÇÑ´Ù.

¸¶Áö¸· ¿¹´Â °áÇÕµÈ ¿¬»ê-´ëÀÔ Ç¥Çö½Ä(combined operator-assignment expression)ÀÌ´Ù. ¹¹ º¹ÀâÇÑ ¾ê±â´Â ¾Æ´Ï°í '$a = $a + 3'Àº Ç¥Çö½ÄÀ» '$a += 3'À¸·Î Ç¥ÇöÇÒ ¼ö ÀÖ´Â °ÍÀÌ´Ù. -=, *=, /=, .= µîµµ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

´ÙÀ½¿¹¸¦ º¸¸é µµ¿òÀÌ µÉ °ÍÀÌ´Ù. :

 

  1 
  2 function double($i) {
  3     return $i*2;
  4 }
  5 $b = $a = 5;          /* $a¿Í $b ¿¡ 5 ´ëÀÔ */
  6 $c = $a++;            /* post-increment, $c ¿¡´Â $aÀÇ ¿ø·¡ °ªÀÎ 5°¡ ´ëÀԵǰí $a´Â 6ÀÌ µÈ´Ù */
  7 $e = $d = ++$b;       /* pre-increment, $d¿Í $e´Â Áõ°¡µÈ $bÀÇ °ª 6ÀÌ ´ëÀԵȴÙ. */
  8  
  9 /* ¿©±âºÎÅÍ $d¿Í $eÀÇ °ªÀº 6ÀÌ´Ù. */
 10 $f = double($d++);    /* $f´Â $d°¡ Áõ°¡µÇ±â ÀüÀÇ °ªÀÎ 6À» µÎ ¹èÇÑ °ªÀ» °¡Áø´Ù. 2*6 = 12 */
 11 $g = double($++e);    /* $g´Â $e°¡ Áõ°¡µÈ ÈÄÀÇ °ªÀÎ 7À» µÎ¹èÇÑ°ªÀ» °¡Áø´Ù. 2*7 = 14 */
 12 $h = $g += 10;        /* $g´Â 14¿¡ 10À» ´õÇØ 24ÀÇ °ªÀ» °¡Áø ÈÄ ±× °ªÀ» $h¿¡ ´ëÀÔÇÑ´Ù. µÑ´Ù 24 */
 13 

±×·¯³ª, ÇϳªÀÇ Ç¥Çö½ÄÀÌ ÇϳªÀÇ ¹®ÀåÀº ¾Æ´Ï´Ù. Ç¥Çö½ÄÀÌ ¼¼¹ÌÄÝ·Ð ';'À¸·Î ³¡³ª¾ß ÇϳªÀÇ ¹®ÀåÀÌ µÇ´Â °ÍÀÌ´Ù. Áï '$b=$a=5;'¿¡¼­ $a=5´Â Ç¥Çö½ÄÀÌÁö¸¸ ¹®ÀåÀº ¾Æ´Ï´Ù.

PHP¿¡¼­ Âü/°ÅÁþÀÇ ÆÇ´ÜÀº Perl°ú ºñ½ÁÇÏ´Ù. 0ÀÌ ¾Æ´Ñ ¼ýÀÚ´Â ¸ðµÎ TRUEÀÌ°í, 0Àº FALSEÀÌ´Ù. ºó ¹®ÀÚ¿­À̳ª ¹®ÀÚ¿­ "0"Àº FALSEÀÌ´Ù. ´Ù¸¥ ¸ðµç ¹®ÀÚ¿­Àº TRUEÀÌ´Ù. ¹è¿­À̳ª °´Ã¼´Â ¿ø¼Ò°¡ Çϳªµµ ¾ø´Ù¸é FALSE¸¦ ÀǹÌÇÏ°í, ³ª¸ÓÁöÀÇ °æ¿ì´Â TRUEÀÌ´Ù.

¾ÕÀ¸·Î ÀÌ ¸Å´º¾ó¿¡¼­ 'expr'À̶ó°í ¾²¿©Áø ºÎºÐÀº PHPÀÇ ¿Ã¹Ù¸¥ Ç¥Çö½ÄÀ̶ó´Â ÀǹÌÀÌ´Ù.


Chapter 10. ¿¬»êÀÚ (Operators)


»ê¼ú ¿¬»êÀÚ (Arithmetic Operators)

Çб³¿¡¼­ ¹è¿î »ê¼ú ¿¬»ê(°¡°¨½ÂÁ¦)À» ±â¾ïÇϴ°¡? ÀÌ »ê¼ú ¿¬»êÀÚ´Â ±×°Íµéó·³ µ¿ÀÛÇÑ´Ù.

Table 10-1. Arithmetic Operators

¿¹

À̸§

°á°ú

$a + $b

µ¡¼À(Addition)

$a¿Í $bÀÇ ÇÕ.

$a - $b

»¬¼À(Subtraction)

$a¿¡¼­ $b¸¦ »« °ª.

$a * $b

°ö¼À(Multiplication)

$a¿Í $bÀÇ °ö.

$a / $b

³ª´°¼À(Division)

$a¿¡¼­ $b¸¦ ³ª´« °ª(Ȥ Àº ¸ò).

$a % $b

³ª¸ÓÁö(Modulus)

$a¿¡¼­ $b¸¦ ³ª´« ³ª¸ÓÁö.


´ëÀÔ ¿¬»êÀÚ (Assignment Operators)

±âº» ´ëÀÔ ¿¬»êÀÚ´Â "="ÀÌ´Ù. ÀÌ ¿¬»êÀÚ¸¦ óÀ½ º¸¾ÒÀ» ¶§´Â "°°´Ù"¶ó´Â ¿¬»êÀÚ·Î »ý°¢Çϱ⠽±Áö¸¸ ÀüÇô ¾Æ´Ï´Ù. ÀÌ°ÍÀÇ Àǹ̴ ¿À¸¥ÂÊÀÇ Ç¥Çö½ÄÀ» °è»êÇÏ¿© ±× °ªÀ» ¿ÞÂÊ¿¡ ÀÖ´Â ÇÇ¿¬»êÀÚÀÇ °ªÀ¸·Î ¼³Á¤ÇÑ´Ù´Â ÀǹÌÀÌ´Ù. (ÀÌ°ÍÀ» "gets set to"¶ó°í ÇÑ´Ù.)

´ëÀÔ ¿¬»êÀÚÀÇ °ªÀº ¿ÞÂÊÀ¸·Î ´ëÀÔµÈ °ªÀÌ´Ù. Áï, "$a = 3"ÀÇ °ªÀº 3ÀÌ µÈ´Ù. ÀÌ°ÍÀº ¿©·¯ºÐ¿¡°Ô ¾à°£ÀÇ Æ®¸¯ÀÌ °¡´ÉÇϵµ·ÏÇÑ´Ù.

  1 
  2 $a = ($b = 4) + 5; // $a´Â 9, $b´Â 4ÀÇ °ªÀ» °¡Áø´Ù.
  3 

±âº»ÀûÀÎ ´ëÀÔ ¿¬»êÀÚ ¿Ü¿¡ ¸ðµç Bit ´ÜÀ§ ¿¬»êÀÚ, »ê¼ú ¿¬»êÀÚ¿Í °áÇÕÇÑ º¹ÇÕ ´ëÀÔ ¿¬»êÀÚµµ ÀÖ´Ù. °áÇÕµÈ ¿¬»êÀڴ ǥÇö½Ä¿¡¼­ ÇØ´ç ¿¬»êÀ¸·Î »ç¿ëµÇ°í, ±× ¿¬»ê °ªÀ» ¿ÞÂÊ¿¡ ÀÖ´Â ÇÇ¿¬»êÀÚ¿¡ ´ëÀÔÇÑ´Ù. ¿¹¸¦ µé¾î :

  1 
  2 $a = 3;
  3 $a += 5; // $a´Â 8ÀÌ´Ù. $a = $a + 5; ¿Í µ¿ÀÏÇÏ´Ù.
  4 $b = "Hello ";
  5 $b .= "There!"; // $b´Â "Hello There!"°¡ µÈ´Ù. $b = $b . "There!";¿Í °°´Ù.
  6 

 


Bit ´ÜÀ§ ¿¬»êÀÚ (Bitwise Operators)

ºñÆ® ´ÜÀ§ ¿¬»êÀÚ´Â Á¤¼öÀÇ °³º° ºñÆ®ÀÇ °ªÀ» on, off ÇÒ ¼ö ÀÖ´Ù.

Table 10-2. Bitwise Operators

example

name

result

$a & $b

And

$a¿Í $b°¡ ¸ðµÎ 1ÀÎ ºñÆ®¸¸ 1ÀÌ µÈ´Ù.

$a | $b

Or

$a¿Í $bÁß Çϳª¶óµµ 1ÀÎ ºñÆ®´Â 1ÀÌ µÈ´Ù.

$a ^ $b

Xor

$a¿Í $bÁß Çϳª´Â 1ÀÌ°í, ´Ù¸¥ Çϳª´Â 0ÀÎ ºñÆ®¸¸ 1À̵ǰí, ³ª¸ÓÁö´Â 0ÀÌ µÈ´Ù.

~ $a

Not

$a¿¡¼­ 1ÀÎ ºñÆ®´Â 0À¸·Î, 0ÀÎ ºñÆ®´Â 1·Î µÈ´Ù.

$a << $b

Shift left

$aÀÇ ºñÆ®µéÀ» $b step ¸¸Å­ ¿ÞÂÊÀ¸·Î shift ÇÑ´Ù. (ÇÑ stepÀº 2¸¦ ÇÑ ¹ø °öÇÏ´Â ¸¸Å­ÀÇ È¿°ú°¡ ÀÖ´Ù.)

$a >> $b

Shift right

$aÀÇ ºñÆ®µéÀ» $b step ¸¸Å­ ¿À¸¥À¸·Î shift ÇÑ´Ù. (ÇÑ stepÀº 2¸¦ ÇÑ ¹ø ³ª´©´Â ¸¸Å­ÀÇ È¿°ú°¡ ÀÖ´Ù.)


ºñ±³ ¿¬»êÀÚ (Comparison Operators)

ºñ±³ ¿¬»êÀÚ´Â À̸§¿¡¼­ ¾Ë ¼ö ÀÖµíÀÌ µÎ °³ÀÇ °ªÀ» ºñ±³ÇÏ´Â ¿¬»êÀÚÀÌ´Ù.

Table 10-4. Comparson Operators

example

name

result

$a == $b

Equal

$a¿Í $b°¡ °°À¸¸é true.

$a === $b

Identical

$a¿Í $b°¡ °°À¸¸é true. $a¿Í $bÀÇ type±îÁö µ¿ÀÏÇØ¾ß ÇÑ´Ù. (PHP4 only)

$a != $b

Not equal

$a¿Í $b°¡ ´Ù¸£¸é true.

$a < $b

Less than

$a°¡ $bº¸´Ù ÀÛÀ¸¸é true.

$a > $b

Greater than

$a°¡ $bº¸´Ù Å©¸é true.

$a <= $b

Less than or equal to

$a°¡ $bº¸´Ù À۰ųª °°À¸¸é true.

$a >= $b

Greater than or equal to

$a°¡ $bº¸´Ù Å©°Å³ª °°À¸¸é true.

¶Ç´Ù¸¥ Á¶°Ç ¿¬»êÀÚ·Î C³ª ´Ù¸¥ ¾ð¾î¿¡ ÀÖ´Â "?:" ¿¬»êÀÚ°¡ ÀÖ´Ù.

  1 
  2 (expr1) ? (expr2) : (expr3);
  3 

ÀÌ Ç¥Çö½ÄÀº expr1ÀÇ °á°ú°¡  Âü¿©¸é expr2¸¦ ¹ÝȯÇÏ°í, °ÅÁþÀ̸é expr3¸¦ ¹ÝȯÇÑ´Ù.


¿À·ù Á¦¾î ¿¬»êÀÚ (Error control Operators)

PHP´Â @(at Ç¥½Ã)À̶ó´Â ÇÑ °³ÀÇ ¿À·ù Á¦¾î ¿¬»êÀÚ¸¦ Á¦°øÇÑ´Ù. PHPÀÇ Ç¥Çö½Ä ¾Õ¿¡ ÀÌ Ç¥½Ã°¡ ºÙÀ¸¸é, ÇØ´ç Ç¥Çö½Ä¿¡¼­ ¹ß»ýÇÑ ¸ðµç ¿¡·¯ ¸Þ½ÃÁö°¡ ¹«½ÃµÈ´Ù.

¸¸¾à track_errors ±â´ÉÀÌ È°¼ºÈ­ µÇ¾î ÀÖ´Ù¸é, ÇØ´ç Ç¥Çö½Ä¿¡¼­ ¹ß»ýÇÑ ¸ðµç ¿¡·¯ ¸Þ½ÃÁö´Â $php_errormsg ¶ó´Â Àü¿ª º¯¼ö¿¡ ÀúÀåµÉ °ÍÀÌ´Ù. ÀÌ º¯¼öÀÇ °ªÀº ¸Å¹ø ¿¡·¯°¡ ¹ß»ýÇÒ ¶§¸¶´Ù »õ·Î ¼³Á¤µÈ´Ù. µû¶ó¼­ ¸¸¾à ¿©·¯ºÐÀÌ ÀÌ º¯¼ö¸¦ »ç¿ëÇÏ·Á¸é ¿¡·¯°¡ ¹ß»ýÇÑ Á÷ÈÄ¿¡ ÃÖ´ëÇÑ »¡¸® »ç¿ëÇÏ¿©¾ß ÇÑ´Ù.

  1 
  2 <?php
  3 /* Intentional SQL error (extra quote): */
  4 $res = @mysql_query( "select name, code from 'namelist" ) or
  5    die( "Query failed: error was '$php_errormsg'" );
  6 ?>
  7      

See also error_reporting().


½ÇÇà ¿¬»êÀÚ (Execution Operators)

PHP´Â ÇÑ °³ÀÇ ½ÇÇà ¿¬»êÀÚ¸¦ Á¦°øÇÑ´Ù. (``) ÀÏ¹Ý ÀÛÀº µû¿ÈÇ¥°¡ ¾Æ´ÔÀ» ÁÖÀÇÇÏÀÚ! PHP´Â ÀÌ »çÀÌ¿¡ ÀÖ´Â ¸í·ÉÀ» shell ¸í·É¾î·Î ½ÇÇàÇÏ°í ±× °á°ú¸¦ ¹ÝȯÇÑ´Ù. (½ÇÇà °á°ú¸¦ ´Ü¼øÈ÷ Ãâ·ÂÇÏ´Â °ÍÀÌ ¾Æ´Ï°í, º¯È¯ÇÏ¿© º¯¼ö¿¡ ÀúÀåÇÒ ¼öµµ ÀÖ´Ù.)

  1 
  2 $output = `ls -al`;
  3 echo "<pre>$output</pre>";
  4 	 

See also system(), passthru(), exec(), popen(), and escapeshellcmd().


Áõ°¡/°¨¼Ò ¿¬»êÀÚ (Incrementing/Decrementing Operators)

PHP´Â C ÇüÅÂÀÇ ¾Õ, µÚ¿¡ ºÙ´Â Áõ°¡³ª °¨¼Ò ¿¬»êÀÚ¸¦ Á¦°øÇÑ´Ù.

Table 10-4. Increment/decrement Operators

example name effect
++$a Pre-increment $a ¸¦ 1 Áõ°¡½ÃŲ ÈÄ, $a¸¦ ¹ÝȯÇÑ´Ù.
$a++ Post-increment $a¸¦ ¹ÝȯÇÑ ÈÄ,$a ¸¦ 1 Áõ°¡½ÃŲ´Ù.
--$a Pre-decrement $a ¸¦ 1 °¨°¡½ÃŲ ÈÄ, $a¸¦ ¹ÝȯÇÑ´Ù.
$a-- Post-decrement $a¸¦ ¹ÝȯÇÑ ÈÄ,$a ¸¦ 1 °¨¼Ò½ÃŲ´Ù.

¿©±â °£´ÜÇÑ ¿¹Á¦°¡ ÀÖ´Ù. :

  1 
  2 <?php
  3 echo "<h3>Postincrement</h3>";
  4 $a = 5;
  5 echo "Should be 5: " . $a++ . "<br>\n";
  6 echo "Should be 6: " . $a . "<br>\n";
  7 
  8 echo "<h3>Preincrement</h3>";
  9 $a = 5;
 10 echo "Should be 6: " . ++$a . "<br>\n";
 11 echo "Should be 6: " . $a . "<br>\n";
 12 
 13 echo "<h3>Postdecrement</h3>";
 14 $a = 5;
 15 echo "Should be 5: " . $a-- . "<br>\n";
 16 echo "Should be 4: " . $a . "<br>\n";
 17 
 18 echo "<h3>Predecrement</h3>";
 19 $a = 5;
 20 echo "Should be 4: " . --$a . "<br>\n";
 21 echo "Should be 4: " . $a . "<br>\n";
 22 ?>	  
 23 	 

 


Logical Operators

Table 10-3. Logical Operators

example

name

result

$a and $b

And

$a¿Í $b°¡ ¸ðµÎ true À̸é true

$a or $b

Or

$a¿Í $bÁß Çϳª¶óµµ trueÀ̸é true

$a xor $b

Xor

$a¿Í $bÁß Çϳª¸¸ trueÀ̾î¾ß true

! $a

Not

$a°¡ true°¡ ¾Æ´Ï¸é true

$a && $b

And

$a¿Í $b°¡ ¸ðµÎ true À̸é true

$a || $b

Or

$a¿Í $bÁß Çϳª¶óµµ trueÀ̸é true

"and"¿Í "or" ¿¬»êÀÚ°¡ µÎ°¡ÁöÀÇ ´Ù¸¥ ÇüŸ¦ °¡Áö°í ÀÖ´Â ÀÌÀ¯´Â ÀÌ ¿¬»êÀÚµéÀÌ ¼­·Î ´Ù¸¥ ¿ì¼±¼øÀ§¸¦ °¡Áö°í Àֱ⠶§¹®ÀÌ´Ù. (¾Æ·¡¸¦ º¸¶ó.)


¿¬»êÀÚ ¿ì¼± ¼øÀ§ (Precedence)

¿¬»êÀÚµéÀÇ ¿ì¼±¼øÀ§´Â µÎ °³ÀÇ Ç¥Çö½ÄÁß ¾î´À°ÍÀÌ ´õ ´Ü´ÜÈ÷ ¹­¿© Àִ°¡¸¦ ¸í±âÇÑ´Ù. ¿¹¸¦µé¾î 1 + 5 * 3Àº 16À» ¹ÝȯÇÏÁö 18À» ¹ÝȯÇÏÁö ¾Ê´Â´Ù. ¿Ö³ÄÇÏ¸é °öÇϱâ("*")¿¬»êÀÚ°¡ ´õÇϱâ("+")¿¬»êÀÚº¸´Ù ¿ì¼±¼øÀ§°¡ ³ô±â ¶§¹®ÀÌ´Ù.

´ÙÀ½ Ç¥´Â ¿¬»êÀÚÀÇ ¿ì¼±¼øÀ§¸¦ ³ªÅ¸³½´Ù °¡Àå À§¿¡ ÀÖ´Â ¿¬»êÀÚÀÇ ¿ì¼±¼øÀ§°¡ °¡Àå ³·´Ù.

Table 10-6. Operator Precedence

Associativity Operators
left ,
left or
left xor
left and
right print
left = += -= *= /= .= %= &= |= ^= ~= <<= >>=
left ? :
left ||
left &&
left |
left ^
left &
non-associative == != ===
non-associative < <= > >=
left << >>
left + - .
left * / %
right ! ~ ++ -- (int) (double) (string) (array) (object) @
right [
non-associative new

 

¹®ÀÚ¿­ ¿¬»êÀÚ (String Operators)

¹®ÀÚ¿­ ¿¬»êÀÚ¿¡´Â µÎ°³°¡ ÀÖ´Ù. ù ¹ø°´Â ¿À´ÏÂÊ°ú ¿À¸¥ÂÊÀÇ µÎ ¹®ÀÚ¿­À» ¿¬°áÇÏ´Â ¿¬°á(concatenation) ¿¬»êÀÚ (".") °¡ ÀÖ´Ù. µÎ ¹ø¤Š·Î´Â ¿¬°á ´ëÀÔ ¿¬»êÀÚ (".=") °¡ ÀÖ´Ù. ÀÌ¿¡ ´ëÇؼ­´Â ´ëÀÔ¿¬»êÀÚ(Assugnment Operator) ºÎºÐÀ» ÀоÀÚ.

  1 
  2 $a = "Hello ";
  3 $b = $a . "World!"; // now $b contains "Hello World!"
  4 
  5 $a = "Hello ";
  6 $a .= "World!"; // now $a contains "Hello World!"
  7      
$a = "Hello ";
$b = $a . "World!"; // now $b = "Hello World!"


Chapter 11. Á¦¾î ±¸Á¶ (Control Structures)

¸ðµç PHP ½ºÅ©¸³Æ®´Â ÀÏ·ÃÀÇ ±¸¹®À¸·Î ÀÌ·ç¾î Áø´Ù. ÇϳªÀÇ ±¸¹®Àº ´ëÀÔ¹®ÀÌ µÉ ¼öµµ ÀÖ°í, ÇÔ¼ö È£Ãâ, ¹Ýº¹¹®, Á¶°Ç¹®ÀÌ µÉ ¼öµµ ÀÖÀ¸¸ç ½ÉÁö¾î´Â ¾Æ¹« ³»¿ëÀÌ ¾ø´Â ºó ¹®ÀåÀÏ ¼öµµ ÀÖ´Ù. ÇÑ ±¸¹®Àº ÀϹÝÀûÀ¸·Î ¼¼¹ÌÄÝ·Ð(;)À¸·Î ³¡³­´Ù. ¶ÇÇÑ ¿©·¯°³ÀÇ ±¸¹®À» Áß°ýÈ£({,})¸¦ »ç¿ëÇÏ¿© ÇϳªÀÇ ±×·ìÀ¸·Î ¸¸µé¾î »ç¿ëÇÒ ¼öµµ ÀÖ´Ù. ÀÌ ±¸¹®-±×·ìÀº ±× ±×·ìÀÇ ¸ðµç ±¸¹®µéÀÌ ÇϳªÀÇ ±¸¹®ÀÎ °Íó·³ ÀνĵȴÙ. ¿©±â¼­´Â ¿©·¯ °¡Áö ±¸¹®ÇüÅ¿¡ ´ëÇØ ¾Ë¾Æº»´Ù.


if

PHPÀÇ IF¹®Àº C¿Í ºñ½ÁÇÏ´Ù.

  1 
  2 if (expr)
  3     statement
  4      

exprÀ» Æò°¡ÇÏ¿© TRUEÀ̸é statement¸¦ ½ÇÇàÇÑ´Ù. FALSEÀÌ¸é ¹«½ÃÇÑ´Ù.

´ÙÀ½ ¿¹Á¦´Â $a°¡ $bº¸´Ù Å©¸é "a is bigger than b"¸¦ Ãâ·ÂÇÑ´Ù.

  1 
  2 if ($a > $b)
  3     print "a is bigger than b";
  4      

¿©·¯ ¹®ÀåÀ» ½ÇÇà½ÃÅ°·Á¸é Áß°ýÈ£( { } )¸¦ »ç¿ëÇÏ¿© º¹¹®À¸·Î ¸¸µé¸éµÈ´Ù. :

  1 
  2 if ($a > $b) {
  3     print "a is bigger than b";
  4     $b = $a;
  5 }
  6      

 


else

ELSE´Â IF¹®ÀÇ Æò°¡½ÄÀÌ FALSEÀÏ °æ¿ì ½ÇÇàÇÏ´Â ¹®ÀåÀ» ÁöÁ¤ÇÑ´Ù. :

  1 
  2 if ($a > $b) {
  3     print "a is bigger than b";
  4 } else {
  5     print "a is NOT bigger than b";
  6 }
  7      

 


elseif

ELSEIF´Â ELSE¿Í IF¸¦ ÇÕÃijõÀº °Í°ú °°´Ù. :

  1 
  2 if ($a > $b) {
  3     print "a is bigger than b";
  4 } elseif ($a == $b) {
  5     print "a is equal to b";
  6 } else {
  7     print "a is smaller than b";
  8 }
  9      

ÇÑ IF¹®¿¡´Â ¿©·¯°³ÀÇ ELSEIF¹®ÀÌ ÀÖÀ» ¼ö ÀÖ´Ù. ELSEIF¹®Àº ¼ø¼­´ë·Î Æò°¡ÇÏ¿© TRUEÀÎ °÷À» ½ÇÇàÇÑ´Ù. Áï, ¾î¶² ELSEIF¹®ÀÌ ½ÇÇà µÇ·Á¸é IF¹®ÀÇ Æò°¡½Ä°ú ±× ¾ÕÀÇ ¸ðµç ELSEIF¹®ÀÇ Æò°¡½ÄÀÌ FALSEÀ̾î¾ß ÇÑ´Ù. ÀÌ°ÍÀº 'else if'¶ó°í µÎ °³ÀÇ ¹®ÀåÀ¸·Î ½áµµ µÈ´Ù(¹®¹ýÀûÀÎ Àǹ̴ ¾à°£ ´Ù¸£Áö¸¸).


Á¦¾î±¸Á¶ÀÇ ´Ù¸¥ Ç¥Çö (Alternative syntax for control structures)

PHP 3´Â Áß°ýÈ£({ })¸¦ ¾²´Â ´ë½Å IF(expr)µÚ¿¡ ÄÝ·Ð( : )À» Âï°í, Çϳª ÀÌ»óÀÇ ¹®ÀåÀ» ³ª¿­ÇÑ ÈÄ¿¡ ENDIF;·Î ³¡³»´Â ¹æ¹ýÀ» Á¦°øÇÑ´Ù. ÀÌ ¹æ¹ýÀº ƯÈ÷ IF¹® ¾È¿¡ HTML ºí·°À» »ðÀÔÇϴµ¥ À¯¿ëÇÏ°Ô »ç¿ëµÉ ¼ö ÀÖ´Ù. ´ÙÀ½ ¿¹¸¦ º¸ÀÚ. :

  1 
  2  <?php if ($a == 5): ?>
  3  A is equal to 5
  4  <?php endif; ?>
  5      

À§ÀÇ ¿¹¿¡¼­ "A = 5"¶ó´Â HTML ºí·ÏÀÌ IF¹® ¾È¿¡ »ç¿ëµÇ°í ÀÖ´Ù. À§ÀÇ HTML ºí·ÏÀº $a°¡ 5ÀÏ °æ¿ì¿¡¸¸ Ç¥½ÃµÈ´Ù.

´ÙÀ½°ú °°ÀÌ ELSE¿Í ELSEIF (expr)µµ »ç¿ëÇÒ ¼ö ÀÖ´Ù. :

  1 
  2 if ($a == 5):
  3     print "a equals 5";
  4     print "...";
  5 elseif ($a == 6):
  6     print "a equals 6";
  7     print "!!!";
  8 else:
  9     print "a is neither 5 nor 6";
 10 endif;
 11      

 


while

WHILE ·çÇÁ´Â PHP 3ÀÇ °¡Àå °£´ÜÇÑ ÇüÅÂÀÌ´Ù. ÀÌ°ÍÀº C¿Í µ¿ÀÏÇÏ°Ô ÀÛµ¿ÇÑ´Ù. ±âº» ÇüÅ´ ´ÙÀ½°ú °°´Ù. :

  1 
  2 while (expr) statement
  3      

IF¹®°ú ¸¶Âù°¡Áö·Î ´ÙÀ½°ú °°Àº ¹®Àå ÇüÅ·ΠÁß°ýÈ£( { } )¸¦ »ç¿ëÇÏÁö ¾Ê´Â ¹æ¹ýµµ ÀÖ´Ù. :.

  1 
  2 while (expr): statement ... endwhile;
  3      

´ÙÀ½µÎ°³ÀÇ ¿¹Á¦´Â µ¿ÀÏÇÑ ¿¹Á¦ÀÌ´Ù. 1ºÎÅÍ 10±îÁö Ãâ·ÂÇÑ´Ù.:

  1 
  2 /* example 1 */
  3 
  4 $i = 1;
  5 while ($i <= 10) {
  6     print $i++;  /* the printed value would be
  7                     $i before the increment
  8                     (post-increment) */
  9 }
 10  
 11 /* example 2 */
 12  
 13 $i = 1;
 14 while ($i <= 10):
 15     print $i;
 16     $i++;
 17 endwhile;
 18      

 


do..while

DO..WHILE ·çÇÁ´Â ºñ±³½ÄÀÌ ¾ÕÀÌ ¾Æ´Ñ ¸Ç µÚ¿¡ ÀÖ´Ù´Â Á¡À» Á¦¿ÜÇϸé WHILE ·çÇÁ¿Í ºñ½ÁÇÏ´Ù. µû¶ó¼­ WHILE Á¶°ÇÀýÀº DO ¹®ÀåÀÌ ½ÇÇàµÈ ÈÄ¿¡ Æò°¡µÇ¹Ç·Î, DO ÀÌÈÄÀÇ ¹®ÀåÀº ¹«Á¶°Ç ÇѹøÀº ½ÇÇàµÈ´Ù.

´ÙÀ½°ú °°Àº DO..WHILE ·çÇÁ¿¡¼­µµ ÇѹøÀº Ãâ·ÂÀÌ µÈ´Ù. :

  1 
  2 $i = 0;
  3 do {
  4    print $i;
  5 } while ($i>0);
  6      

 


for

FOR´Â PHPÀÇ °¡Àå º¹ÀâÇÑ ·çÇÁÀÌ´Ù. ÀÌ°ÍÀº C¿Í À¯»çÇÏ´Ù. FOR ·çÇÁÀÇ ÇüÅ´ ´ÙÀ½°ú °°´Ù. :

  1 
  2 for (expr1; expr2; expr3) statement
  3      

ù ¹ø° Ç¥Çö½Ä(expr1)Àº ·çÇÁ¸¦ ½ÃÀÛÇÒ ¶§ ¹«Á¶°Ç Çѹø Æò°¡(½ÇÇà)µÈ´Ù.

¸Å ¹Ýº¹ÀÇ ½ÃÀÛ ¶§¸¶´Ù expr2°¡ Æò°¡µÈ´Ù. ¸¸¾à ÀÌ°ÍÀÌ TRUE¸é ·çÇÁ´Â °è¼ÓµÇ°í statement°¡ ½ÇÇàµÈ´Ù. expr2°¡ FALSEÀÌ¸é ·çÇÁ´Â Á¾·áµÈ´Ù.

¸Å ¹Ýº¹ÀÌ ³¡³¯ ¶§ expr3°¡ Æò°¡(½ÇÇà)µÈ´Ù.

°¢ Æò°¡½ÄÀº ºñ¿öµÑ ¼ö ÀÖ´Ù.expr2°¡ ºñ¾îÀÖÀ¸¸é ¹«ÇÑ ·çÇÁ¸¦ ¶æÇÑ´Ù. (PHP´Â C¿Í °°ÀÌ ºñ¾îÀÖÀ¸¸é TRUE·Î ÀνÄÇÑ´Ù.) ÀÌ°Ç º°·Î ÁÁÀº ¹æ¹ýÀÌ ¾Æ´ÏÁö¸¸, Á¾Á¾ BREAK¸¦ »ç¿ëÇÏ¿© Á¾·áÇÏ´Â ¹æ¹ýµµ ÀÖ´Ù.

´ÙÀ½ ¿¹´Â 1¿¡¼­ 10±îÁö Ãâ·ÂÇÏ´Â ¿¹ÀÌ´Ù. :

  1 
  2 /* example 1 */
  3  
  4 for ($i = 1; $i <= 10; $i++) {
  5     print $i;
  6 }
  7  
  8 /* example 2 */
  9  
 10 for ($i = 1;;$i++) {
 11     if ($i > 10) {
 12         break;
 13     }
 14     print $i;
 15 }
 16  
 17 /* example 3 */
 18  
 19 $i = 1;
 20 for (;;) {
 21     if ($i > 10) {
 22         break;
 23     }
 24     print $i;
 25     $i++;
 26 }
 27  
 28 /* example 4 */
 29  
 30 for ($i = 1; $i <= 10; print $i, $i++) ;
 31      

¹°·Ð óÀ½°ÍÀÌ °¡Àå ÁÁ¾Æº¸ÀδÙ. ±×·¯³ª ³ª¸ÓÁöµµ °¡´ÉÇÏ´Ù´Â °ÍÀ» ¾Ë¾Æ¾ß ÇÑ´Ù.

PHP´Â FOR ·çÇÁ¿¡ ´ëÇؼ­µµ ´ÙÀ½°ú °°Àº "colon syntax"¸¦ Áö¿øÇÑ´Ù.

  1 
  2 for (expr1; expr2; expr3): statement; ...; endfor;
  3      

ÀϺΠ´Ù¸¥ ¾ð¾îµéÀº ¹è¿­À» Ž»öÇϱâ À§ÇÏ¿© foreach ¹®ÀåÀ» Á¦°øÇϱ⵵ ÇÑ´Ù. ±×·¯³ª PHP´Â À̸¦ À§ÇØ list()¿Í each() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© while ·çÇÁ·Î ÇØ°áÇÑ´Ù. ÀÌ ÇÔ¼öµé¿¡ ´ëÇؼ­´Â ¿¹Á¦¸¦ ÂüÁ¶ÇÏÀÚ.


foreach

PHP4(PHP3´Â ¾Æ´Ï´Ù)´Â perl µîÀÇ ´Ù¸¥ ¾ð¾î°¡ Á¦°øÇÏ´Â foreach ±¸Á¶¸¦ Á¦°øÇÑ´Ù. ÀÌ ±¸Á¶´Â ¹è¿­¿¡ À־ ¹Ýº¹ÀûÀÎ ÀÛ¾÷À» Çϴµ¥ À¯¿ëÇÏ´Ù. ÀÌ°Í¿¡´Â µÎ°¡Áö ¹®¹ýÀÌ Àִµ¥, µÎ ¹ø° °ÍÀº ù ¹ø° °ÍÀÇ ºÎºÐ È®ÀåÀ̳ª ¸Å¿ì À¯¿ëÇÏ°Ô »ç¿ëµÈ´Ù.

  1 
  2 foreach(array_expression as $value) statement
  3 foreach(array_expression as $key => $value) statement
  4      

ù ¹ø° ¸ð¾çÀº array_expression À¸·Î  ÁÖ¾îÁø ¹è¿­¿¡ ´ëÇØ ¼øȯÀÛ¾÷(loop)À» ¼öÇàÇÑ´Ù. °³°³ÀÇ ¼øȯÀÛ¾÷¿¡¼­, ¹è¿­ÀÇ ¿ø¼Ò´Â $value¿¡ ÀúÀåµÇ°í ³»ºÎ ¹è¿­ Æ÷ÀÎÅÍ(internal array pointer)´Â Çϳª ÀüÁøÇÏ¿© ´ÙÀ½ ÀÛ¾÷½Ã¿¡ »õ·Î¿î ¿ø¼Ò¸¦¤© °¡Á®¿Àµµ·Ï ÇÑ´Ù.

µÎ ¹ø° ¸ð¾çÀº ù ¹ø°¿Í µ¿ÀÏÇÑ ÀÛ¾÷À» ÇÏÁö¸¸, $key¿¡ ÇØ´ç ¿ø¼ÒÀÇ Å°°ªÀ» ÀúÀåÇÏ°Ô µÈ´Ù.

foreach ¹®ÀÌ Ã³À½ ¼öÇàµÉ ¶§, ³»ºÎ ¹è¿­ Æ÷ÀÎÅÍ(internal array pointer)´Â ÀÚµ¿ÀûÀ¸·Î ¹è¿­ÀÇ Ã¹¹ø° ¿ø¼Ò·Î ¼³Á¤µÈ´Ù. À̸»ÀÇ Àǹ̴ ¿©·¯ºÐÀÌ foreach ¹®À» »ç¿ëÇÒ ¶§ reset()À» ¹Ì¸® È£ÃâÇÒ ÇÊ¿ä´Â ¾ø´Ù´Â °ÍÀÌ´Ù.

µû¶ó¼­ ¾Æ·¡ÀÇ µÎ °³ÀÇ ¹®ÀåÀº µ¿ÀÏÇÑ °á°ú¸¦ ¸¸µç´Ù´Â °ÍÀ» ¾Ë ¼ö ÀÖÀ» °ÍÀÌ´Ù. :

  1 
  2 reset ($arr);
  3 while (list(, $value) = each ($arr)) {
  4     echo "Value: $value<br>\n";
  5 }
  6 
  7 foreach ($arr as $value) {
  8     echo "Value: $value<br>\n";
  9 }
 10      

 

´ÙÀ½ µÎ °³ÀÇ ¹®ÀåÀº ±â´ÉÀûÀ¸·Î µ¿ÀÏÇÑ ¹®ÀåÀÌ´Ù. :

  1 
  2 reset ($arr);
  3 while (list($key, $value) = each ($arr)) {
  4     echo "Key: $key; Value: $value<br>\n";
  5 }
  6 
  7 foreach ($arr as $key => $value) {
  8     echo "Key: $key; Value: $value<br>\n";
  9 }
 10      

Ãß°¡ÀûÀ¸·Î ¸î °³ÀÇ ¿¹Á¦¸¦ º¸ÀÚ. :

  1 
  2 /* foreach example 1: value only */
  3 
  4 $a = array (1, 2, 3, 17);
  5 
  6 foreach ($a as $v) {
  7    print "Current value of \$a: $v.\n";
  8 }
  9 
 10 /* foreach example 2: value (with key printed for illustration) */
 11 
 12 $a = array (1, 2, 3, 17);
 13 
 14 $i = 0; /* for illustrative purposes only */
 15 
 16 foreach($a as $v) {
 17     print "\$a[$i] => $k.\n";
 18 }
 19 
 20 /* foreach example 3: key and value */
 21 
 22 $a = array (
 23     "one" => 1,
 24     "two" => 2,
 25     "three" => 3,
 26     "seventeen" => 17
 27 );
 28 
 29 foreach($a as $k => $v) {
 30     print "\$a[$k] => $v.\n";
 31 }
 32      

 


break

break´Â ÇöÀç ·çÇÁ¿¡¼­ ºüÁ® ³ª°¡´Â ¸í·ÉÀÌ´Ù.

break¿¡´Â ¼ýÀÚ ¿É¼ÇÀ» ÁÙ ¼ö Àִµ¥, ÀÌ°ÍÀº Çѹø¿¡ ºüÁ® ³ª°¥ Á¦¾î ±¸Á¶ÀÇ ¼ö¸¦ ÀǹÌÇÑ´Ù.

  1 
  2 $i = 0;
  3 while ($i < 10) {
  4     if ($arr[$i] == "stop") {
  5         break;  /* You could also write 'break 1;' here. */
  6     }
  7     $i++;
  8 }
  9 
 10 /* Using the optional argument. */
 11 
 12 $i = 0;
 13 while ( ++$i ) {
 14     switch ( $i ) {
 15     case 5:
 16         echo "At 5<br>\n";
 17         break 1;  /* Exit only the switch. */
 18     case 10:
 19         echo "At 10; quitting<br>\n";
 20         break 2;  /* Exit the switch and the while. */
 21     default:
 22         break;
 23     }
 24 }
 25      

continue

CONTINUE ´Â ÇöÀç ·çÇÁÀÇ Ã³À½À¸·Î °¡µµ·Ï ÇÏ´Â ¸í·ÉÀÌ´Ù.

continueµµ ¼ýÀÚ ¿É¼ÇÀ» ÁÙ ¼ö Àִµ¥, ÀÌ°ÍÀº Çѹø¿¡ óÀ½À¸·Î °¥ Á¦¾î ±¸Á¶ÀÇ ¼ö¸¦ ÀǹÌÇÑ´Ù.

  1 
  2 while (list ($key, $value) = each ($arr)) {
  3    if (!($key % 2)) { // skip odd members
  4        continue;
  5    }
  6    do_something_odd ($value);
  7 }
  8 
  9 $i = 0;
 10 while ($i++ < 5) {
 11     echo "Outer<br>\n";
 12     while (1) {
 13         echo "  Middle<br>\n";
 14         while (1) {
 15              echo "  Inner<br>\n";
 16              continue 3;
 17         }
 18         echo "This never gets output.<br>\n";
 19     }
 20     echo "Neither does this.<br>\n";
 21 }
 22      

 


switch

SWITCH¹®Àº µ¿ÀÏÇÑ Ç¥Çö½ÄÀÇ IF¹®ÀÇ ³ª¿­°ú ºñ½ÁÇÏ´Ù. ´ÙÀ½ ¿¹´Â µ¿ÀÏÇÑ °ÍÀº IF¹®°ú SWITCH¹®À¸·Î Ç¥ÇöÇÑ °ÍÀÌ´Ù. :

  1 
  2 if ($i == 0) {
  3     print "i equals 0";
  4 }
  5 if ($i == 1) {
  6     print "i equals 1";
  7 }
  8 if ($i == 2) {
  9     print "i equals 2";
 10 }
 11  
 12 switch ($i) {
 13     case 0:
 14         print "i equals 0";
 15         break;
 16     case 1:
 17         print "i equals 1";
 18         break;
 19     case 2:
 20         print "i equals 2";
 21         break;
 22 }
 23      

SWITCH¹®Àº ¹®Àå ´ÜÀ§·Î ½ÇÇàµÈ´Ù. SWITCH¿¡ ÀÖ´Â Æò°¡½Ä°ú ÀÏÄ¡ÇÏ´Â CASE¹®À» ã¾Æ ±× ÀÌÈÄ SWITCHºí·°ÀÌ ³¡³¯ ¶§ ±îÁö ½ÇÇàÇÑ´Ù. µû¶ó¼­ ¿øÇÏ´Â °æ¿ì BREAK·Î ½ÇÇàÀ» ÁßÁö½Ãų ÇÊ¿ä°¡ ÀÖ´Ù. ´ÙÀ½ ¿¹¸¦ º¸ÀÚ. :

  1 
  2 switch ($i) {
  3     case 0:
  4         print "i equals 0";
  5     case 1:
  6         print "i equals 1";
  7     case 2:
  8         print "i equals 2";
  9 }
 10      

¿©±â¼­ $i°¡ 0ÀÌ¸é ¸ðµç print¹®À» ½ÇÇàÇÒ °ÍÀÌ´Ù. ¸¸¾à $i°¡ 1ÀÌ¸é ¸¶Áö¸· µÎ°³ÀÇ print¹®À» ½ÇÇàÇÑ´Ù. µû¶ó¼­ ¿©·¯ºÐÀÌ ¿øÇÏ´Â °á°ú¸¦ ¾òÀ¸·Á¸é BREAK¹®À» ÀØÁö ¾Ê´Â °ÍÀÌ Áß¿äÇÑ´Ù.

Ưº°ÇÑ case·Î default case°¡ ÀÖ´Ù. ÀÌ °ÍÀº ´Ù¸¥ ¾î¶² case¿¡µµ ¸ÂÁö ¾Ê´Â °æ¿ì¸¦ ÀǹÌÇÑ´Ù. ¿¹¸¦ µé¾î :

  1 
  2 switch ($i) {
  3     case 0:
  4         print "i equals 0";
  5         break;
  6     case 1:
  7         print "i equals 1";
  8         break;
  9     case 2:
 10         print "i equals 2";
 11         break;
 12     default:
 13         print "i is not equal to 0, 1 or 2";
 14 }
 15      

´Ù¸¥ Áß¿äÇÑ Á¡Àº CASE Ç¥Çö½Ä¿¡´Â Á¤¼ö, ½Ç¼ö, ¹®ÀÚ¿­ÀÇ ½ºÄ®¸® ŸÀÔÀ¸·Î Æò°¡µÇ´Â ¾î¶² Ç¥Çö½ÄÀ̿͵µ µÈ´Ù´Â °ÍÀÌ´Ù. ¹è¿­À̳ª °´Ã¼µµ ¹®Á¦¸¦ ÀÏÀ¸Å°Áö´Â ¾Ê´Â´Ù. ±×·¯³ª ±×°ÍÀº ¹®Àå¿¡¼­ Àǹ̰¡ ¾ø´Ù.

switch ¹®¿¡ ´ëÇؼ­µµ Alternative syntax°¡ Áö¿øµÈ´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº Alternative syntax for control structures ¸¦ »ìÆ캸ÀÚ

  1 
  2 switch ($i):
  3     case 0:
  4         print "i equals 0";
  5         break;
  6     case 1:
  7         print "i equals 1";
  8         break;
  9     case 2:
 10         print "i equals 2";
 11         break;
 12     default:
 13         print "i is not equal to 0, 1 or 2";
 14 endswitch;
 15      


require

require() ¹®Àº C preprocessorÀÇ #include¿Í ºñ½ÁÇÏ°Ô, ÀÚ½ÅÀ» ÁöÁ¤µÈ ÆÄÀÏ·Î ´ëüÇÑ´Ù.

include() µÇ°Å³ª require() µÇ¾î ÀÐÇôÁö´Â ÆÄÀÏÀº Æ÷ÇÔµÈ ÆÄÀÏÀÇ Ã³À½¿¡ PHP¸ðµå¿¡¼­ ºüÁ®³ª¿Í HTML¸ðµå·Î µé¾î°¡°í, ¸¶Áö¸·¿¡ PHP¸ðµå·Î º¹±ÍÇÑ´Ù. µû¶ó¼­ Æ÷Ç﵃ ÆÄÀÏÀÇ PHP ÄÚµå´Â ÀûÀýÇÑ PHP ½ÃÀÛ, Á¾·á Åÿ¡ µÑ·¯½Î¿© ÀÖ¾î¾ß ÇÑ´Ù.

ÀÌ°ÍÀº require()¹®À» ·çÇÁ ±¸Á¶ ¾È¿¡ µÎ¾î, ¸Å¹ø ´Ù¸¥ ÆÄÀÏÀ» ÀоîµéÀÏ ¼ö ¾ø´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. ÀÌ·± µ¿ÀÛÀ» À§Çؼ­´Â INCLUDE ¹®À» »ç¿ëÇ϶ó.

require('header.inc');

require()´Â »ç½Ç ÇÔ¼ö°¡ ¾Æ´Ï¶ó Á¦¾î±¸Á¶ÀÌ´Ù. µû¶ó¼­ ÀÌ°ÍÀº ÇÔ¼ö¿Í´Â ´Ù¸¥ ±ÔÄ¢À» µû¸¥´Ù. À̸¦Å׸é require()´Â ´Ù¸¥ ¾î¶² Á¦¾î±¸Á¶¿Íµµ »ç¿ëÇÒ ¼ö ¾ø´Ù. ¶ÇÇÑ, ÀÌ°ÍÀº ¹Ýȯ°ªÀÌ ¾ø´Ù. (¹Ýȯ°ªÀ» µ¹·Á¹ÞÀ¸·ÁÇϸé ÆÄ½Ì ¿¡·¯°¡ ³­´Ù.)

include()¿Í ´Ù¸£°Ô, require()´Â ¾ðÁ¦³ª ÇØ´ç ÆÄÀÏÀ» Àоî¿Â´Ù. ½ÉÁö¾î ÇØ´ç ¶óÀÎÀÌ ÀüÇô ½ÇÇàµÇÁö ¾Ê¾Æµµ Àоî¿Â´Ù. ¸¸¾à ¿©·¯ºÐÀÌ Á¶°Ç¿¡ µû¶ó ÆÄÀÏÀ» Æ÷ÇÔ½ÃÅ°°í ½Í´Ù¸é include()¹®À» »ç¿ëÇÏ¿©¾ß ÇÑ´Ù. Á¶°ÇÀýÀº require()¿¡ ¾Æ¹« ¿µÇâÀ» ¹ÌÄ¡Áö ¸øÇÑ´Ù. ±×·¯³ª, require()¹®ÀÌ ÀÖ´Â ÁÙÀÌ ½ÇÇàµÇÁö ¾Ê´Â´Ù¸é ÇØ´ç ÆÄÀÏÀÇ ¾î¶² Äڵ嵵 ½ÇÇàµÇÁö ¾Ê´Â´Ù.

ºñ½ÁÇÏ°Ô, ¼øȯ¹® ¶ÇÇÑ require()¿¡ ¿µÇâÀ» ÁÖÁö ¸øÇÑ´Ù. ÇØ´ç ÆÄÀÏ¿¡ ÀÖ´Â ³»¿ëÀÌ ·çÇÁÀÇ ³»¿ëÀ̶ó ÇÏ´õ·¯µµ require()¹®Àº ´ÜÁö Çѹø¸¸ ³ªÅ¸³ª´Â °ÍÀ¸·Î µÈ´Ù.

ÀÌ°ÍÀº require() ¹®À» ¼øȯ¹® ¾È¿¡ »ç¿ëÇÒ ¼ö ¾ø´Ù´Â °ÍÀ» ÀǹÌÇÏ°í, ¸Å ¼øȯ½Ã¸¶´Ù ´Ù¸¥ ÆÄÀÏÀ» Àоî¿À·Á¸é include()¹®À» »ç¿ëÇÏ¿©¾ß ÇÑ´Ù´Â °ÍÀÌ´Ù.

  1 
  2 require ('header.inc');
  3      

include()¿Í require() ¸ðµÎ È£ÃâÇÑ ½ºÅ©¸³Æ®¾ÈÀ¸·Î ¿øÇÏ´Â ÆÄÀÏÀÇ ³»¿ë ÀÚü¸¦ ²ø¾îµéÀÌ´Â(pull) °ÍÀÌÁö, HTTP³ª ±×¿Í ºñ½ÁÇÑ ¹æ½ÄÀ¸·Î ÇØ´ç Ÿ°ÙÀ» callÇÏ´Â °ÍÀº ¾Æ´Ï´Ù. µû¶ó¼­ ÇöÀç ¹üÀ§¾È¿¡ ¼±¾ðµÈ ¸ðµç º¯¼öµéÀº Æ÷ÇÔÇÒ ÆÄÀÏ ¾È¿¡¼­µµ ±×´ë·Î »ç¿ëµÈ´Ù.

  1 
  2 require ("file.inc?varone=1&vartwo=2"); /* Won't work. */
  3 
  4 $varone = 1;
  5 $vartwo = 2;
  6 require ("file.inc");  /* $varone and $vartwo will be available in file.inc */
  7      

¿©·¯ºÐÀº remote files ±â´ÉÀ» »ç¿ëÇÏ¿© HTTP¸¦ ÅëÇÑ ¿ø°Ý ÆÄÀÏÀ» includeÇϰųª requireÇÒ ¶§ À§ÀÇ ³»¿ëÀ» ¸íÈ®È÷ ¾Ë¾ÆµÑ ÇÊ¿ä°¡ ÀÖ´Ù.

PHP3¿¡¼­´Â require()·Î Æ÷ÇÔµÈ ÆÄÀϾȿ¡¼­ return ¹®À» »ç¿ëÇÒ ¼ö ÀÖ¾ú´Ù. ´Ü, return ¹®ÀÌ Æ÷ÇÔµÈ ÆÄÀÏÀÇ global scope¿¡¼­ ³ªÅ¸³ª´Â °æ¿ì¸¸ °¡´ÉÇÏ°í, ¾î¶°ÇÑ ºí·Ï³»({} ³»ºÎ)¿¡¼­µµ »ç¿ëÇÒ ¼ö ¾ø´Ù. ±×·¯³ª, PHP4¿¡¼­´Â ÀÌ·± ±â´É ÀÚü°¡ ¾ø¾îÁ® ¹ö·È´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ÀÌ·± ±â´ÉÀ» »ç¿ëÇÏ°í ½Í´Ù¸é include() ¹®À» »ç¿ëÇϱ⠹ٶõ´Ù.


include

INCLUDE¹®Àº ÁöÁ¤ÇÑ ÆÄÀÏÀ» ÀÐ°í ½ÇÇàÇÑ´Ù.

include() µÇ°Å³ª require() µÇ¾î ÀÐÇôÁö´Â ÆÄÀÏÀº Æ÷ÇÔµÈ ÆÄÀÏÀÇ Ã³À½¿¡ PHP¸ðµå¿¡¼­ ºüÁ®³ª¿Í HTML¸ðµå·Î µé¾î°¡°í, ¸¶Áö¸·¿¡ PHP¸ðµå·Î º¹±ÍÇÑ´Ù. µû¶ó¼­ Æ÷Ç﵃ ÆÄÀÏÀÇ PHP ÄÚµå´Â ÀûÀýÇÑ PHP ½ÃÀÛ, Á¾·á Åÿ¡ µÑ·¯½Î¿© ÀÖ¾î¾ß ÇÑ´Ù.

ÀÌ µ¿ÀÛÀº ½ÇÇàÁß include() ¹®À» ¸¸³¯ ¶§ ¸¸´Ù ÀϾ´Ù. µû¶ó¼­ ¿©·¯ºÐÀº include() ¹®À» ·çÇÁ ±¸Á¶ ¾È¿¡ µÎ¾î ¸Å¹ø ´Ù¸¥ ÆÄÀÏÀ» ÀÐ¾î µéÀ̵µ·Ï ÇÒ ¼ö ÀÖ´Ù.

  1 
  2 $files = array ('first.inc', 'second.inc', 'third.inc');
  3 for ($i = 0; $i < count($files); $i++) {
  4     include $files[$i];
  5 }
  6      

include()´Â ÀÌ ¹®ÀåÀ» ¸¸³¯ ¶§ ¸¶´Ù ¸Å¹ø ÀçÆò°¡µÇ¾î Àç½ÇÇàµÈ´Ù´Â Á¡¿¡¼­ require()¿Í ´Ù¸£´Ù. ¹Ý¸é¿¡ require()¹®Àº ÁöÁ¤µÈ ÆÄÀÏÀÇ ³»¿ëÀÌ ½ÇÇàµÇ´Â°¡¿¡ °ü°è¾øÀÌ(¿¹¸¦µé¾î if ¹® ¾È¿¡ µé¾îÀÖ°í »óÅ°¡ °ÅÁþÀÎ °æ¿ì¿¡µµ), ÀÌ ¹®ÀåÀ» óÀ½ ¸¸³¯À» ¶§ ÁöÁ¤µÈ ÆÄÀÏ·Î ´ëüµÈ´Ù.

include()´Â Ưº°ÇÑ ±¸Á¶À̹ǷÎ, ¸¸¾à ÀÌ°ÍÀÌ Á¶ÀüÀý ¾È¿¡ ³õ¿©ÀÖ´Ù¸é ¹Ýµå½Ã {}(statement block)À¸·Î µÑ·¯½Î¾ß ÇÑ´Ù.

  1 
  2 /* This is WRONG and will not work as desired. */
  3  
  4 if ($condition)
  5     include($file);
  6 else
  7     include($other);
  8  
  9 /* This is CORRECT. */
 10  
 11 if ($condition) {
 12     include($file);
 13 } else {
 14     include($other);
 15 }
 16      

PHP3, PHP4 ¸ðµÎ include() µÈ ÆÄÀÏ ³»¿¡¼­, ÀÌ ÆÄÀÏÀÇ ¼öÇàÀ» Á¾·áÇÏ°í, ÀÌ ÆÄÀÏÀ» ºÎ¸¥ ½ºÅ©¸³Æ®·Î º¹±ÍÇϱâ À§ÇØ return ¹®À» »ç¿ëÇÒ ¼ö ÀÖ´Ù. ¾à°£ ´Ù¸¥Á¡ÀÌ ÀÖ±â´ÂÇÏ´Ù. ¿ì¼±, PHP3¿¡¼­´Â ÇØ´ç ºí·ÏÀÌ ÇÔ¼öÀÇ ºí·ÏÀÌ ¾Æ´ÑÇÑ return ¹®ÀÌ ºí·Ï¾È¿¡ ¿Ã ¼ö ¾ø´Ù. (ÇÔ¼öÀÇ ºí·Ï ¾È¿¡ ÀÖ´Â °æ¿ì´Â ÇØ´ç ÇÔ¼ö¿¡¼­ return ÇÏ´Â °ÍÀÌÁö ÇöÀç ÆÄÀÏ¿¡¼­ return ÇÏ´Â °ÍÀº ¾Æ´Ï´Ù.) ±×·¯³ª, PHP4¿¡¼­´Â ÀÌ Á¦ÇÑÀÌ ¾ø´Ù. ¤¨¶ÇÇÑ PHP4¿¡¼­´Â include() ÆÄÀÏÀÇ return½Ã¿¡ ¸®ÅÏ°ªÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù. ¿©·¯ºÐÀº include() ¹®À» ÀÏ¹Ý ÇÔ¼öó·³ ¹Ýȯ°ªÀ» ¹ÞÀ» ¼ö ÀÖ´Ù. (ÀÌ°ÍÀº PHP3¿¡¼­´Â ±¸¹®¿¡·¯¸¦ ¹ß»ý½ÃŲ´Ù.)

Example 11-1. include() in PHP3 and PHP4

´ÙÀ½ÀÇ test.inc ¶ó´Â ÆÄÀÏÀÌ ¸ÞÀÎ ÆÄÀÏ°ú µ¿ÀÏÇÑ µð·ºÅ丮¿¡ ÀÖ´Ù°í °¡Á¤ÇÑ´Ù. :
  1 
  2 <?php
  3 echo "Before the return <br>\n";
  4 if (1) {
  5     return 27;
  6 }
  7 echo "After the return <br>\n";
  8 ?>
  9      

main.html À̶ó´Â ¸ÞÀÎÆÄÀÏÀÇ ³»¿ëÀº ´ÙÀ½°ú °°´Ù. :
  1 
  2 <?php
  3 $retval = include ('test.inc');
  4 echo "File returned: '$retval'<br>\n";
  5 ?>
  6      

main.html ÀÌ PHP3¿¡¼­ ºÒ·ÁÁö¸é, ÀÌ ÆÄÀÏÀº µÎ ¹ø° ÁÙ¿¡¼­ "you can't take the value of an include()" ¶ó´Â ±¸¹® ¿¡·¯¸¦ ¹ß»ý½ÃŲ´Ù. ±×·¯³ª, PHP4¿¡¼­´Â ´ÙÀ½µÂ °°Àº °á°ú¸¦ Ãâ·ÂÇÑ´Ù. :

Before the return
File returned: '27'
     

ÀÌÁ¦ main.html À» ´ÙÀ½°ú °°Àº ³»¿ëÀ¸·Î °íÃļ­ ½ÇÇàÇØ º¸ÀÚ. :
  1 
  2 <?php
  3 include ('test.inc');
  4 echo "Back in main.html<br>\n";
  5 ?>
  6      

PHP4¿¡¼­´Â ´ÙÀ½°ú °°Àº °á°ú°¡ Ãâ·ÂµÈ´Ù. :
Before the return
Back in main.html
     

±×·¯³ª PHP3¿¡¼­´Â ´ÙÀ½°ú °°Àº °á°ú°¡ ³ª¿Â´Ù. :

Before the return 
27Back in main.html

Parse error: parse error in /home/torben/public_html/phptest/main.html on line 5
     

À§ÀÇ ±¸¹® ¿¡·¯´Â test.inc¿¡¼­ return ¹®ÀÌ ÇÔ¼öºí·ÏÀÌ¿ÜÀÇ ºí·Ï¾È¿¡ »ç¿ëµÇ¾ú±â ¶§¹®¿¡ »ý±ä´Ù. return À» ºí·Ï ¹ÛÀ¸·Î ²¨³»¸é ´ÙÀ½°ú °°Àº °æ°ú°¡ Ãâ·ÂµÈ´Ù. :
Before the return
27Back in main.html
     

À§ÀÇ '27'ÀÌ Ãâ·ÂµÈ °ÍÀº PHP3°¡ includeÆÄÀÏ·Î ºÎÅÍÀÇ °ªÀÇ ¹ÝȯÀ» Áö¿øÇÏÁö ¾Ê±â ¶§¹®ÀÌ´Ù.

include()¿Í require() ¸ðµÎ È£ÃâÇÑ ½ºÅ©¸³Æ®¾ÈÀ¸·Î ¿øÇÏ´Â ÆÄÀÏÀÇ ³»¿ë ÀÚü¸¦ ²ø¾îµéÀÌ´Â(pull) °ÍÀÌÁö, HTTP³ª ±×¿Í ºñ½ÁÇÑ ¹æ½ÄÀ¸·Î ÇØ´ç Ÿ°ÙÀ» callÇÏ´Â °ÍÀº ¾Æ´Ï´Ù. µû¶ó¼­ ÇöÀç ¹üÀ§¾È¿¡ ¼±¾ðµÈ ¸ðµç º¯¼öµéÀº Æ÷ÇÔÇÒ ÆÄÀÏ ¾È¿¡¼­µµ ±×´ë·Î »ç¿ëµÈ´Ù.

  1 
  2 include ("file.inc?varone=1&vartwo=2"); /* Won't work. */
  3 
  4 $varone = 1;
  5 $vartwo = 2;
  6 include ("file.inc");  /* $varone and $vartwo will be available in file.inc */
  7      

¿©·¯ºÐÀº remote files ±â´ÉÀ» »ç¿ëÇÏ¿© HTTP¸¦ ÅëÇÑ ¿ø°Ý ÆÄÀÏÀ» includeÇϰųª requireÇÒ ¶§ À§ÀÇ ³»¿ëÀ» ¸íÈ®È÷ ¾Ë¾ÆµÑ ÇÊ¿ä°¡ ÀÖ´Ù.

See also readfile(), require(), virtual().


Chapter 12. Functions

User-defined functions

ÇÔ¼ö´Â ´ÙÀ½°ú °°ÀÌ Á¤ÀÇÇÑ´Ù. :

  1 
  2 function foo ($arg_1, $arg_2, ..., $arg_n) {
  3     echo "Example function.\n";
  4     return $retval;
  5 }
  6      

ÇÔ¼ö ¾È¿¡´Â ´Ù¸¥ ÇÔ¼ö³ª classÀÇ ¼±¾ð µîÀ» Æ÷ÇÔÇÑ ¸ðµç °¡´ÉÇÑ PHP Äڵ尡 »ç¿ëµÉ ¼ö ÀÖ´Ù.

PHP3¿¡¼­´Â ÇÔ¼ö´Â ±× ÇÔ¼ö°¡ »ç¿ëµÇ±â ÀÌÀü¿¡ ¼±¾ðµÇ¾î ÀÖ¾î¾ß ÇÏ¿´À¸³ª PHP4¿¡¼­´Â ÀÌ·± Á¦¾àÀÌ ¾ø¾îÁ³´Ù.

PHP´Â function overloadingÀ» Áö¿øÇÏÁö ¾Ê°í, ÀÌ¹Ì Á¤ÀÇµÈ ÇÔ¼ö¸¦ ÀçÁ¤ÀÇÇϰųª ¾ø¾ÖÁö ¸øÇÑ´Ù.

PHP3¿¡¼­´Â ÇÔ¼ö ÆĶó¸ÞÅÍÀÇ ±âº»°ªÀ» ¼³Á¤ÇØÁÖ´Â °Í(default argument values¸¦ º¸ÀÚ.)Àº °¡´ÉÇصµ, ÆĶó¸ÞÅÍÀÇ °³¼ö¸¦ °¡º¯À¸·Î ¼³Á¤ÇÏ´Â °ÍÀº ºÒ°¡´ÉÇßÁö¸¸, PHP4´Â µÎ°¡Áö ¸ðµÎ °¡´ÉÇÏ´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº Variable-length argument lists ¿Í func_num_args(), func_get_arg(), func_get_args() ÀÇ ÇÔ¼ö ¼³¸íÀ» º¸±â ¹Ù¶õ´Ù.

 


Function arguments

argument list¸¦ ÅëÇØ ÇÔ¼ö¿¡ ¾î¶² Á¤º¸¸¦ ³Ñ°ÜÁÙ ¼ö ÀÖ´Ù. ÀÌ argument list´Â ½°Ç¥(,)·Î ³ªÀ§¾îÁø º¯¼ö³ª »ó¼öÀÇ listÀÌ´Ù.

PHP´Â passing by value(±âº»ÀûÀ¸·Î ÀÌ°ÍÀ» »ç¿ë)¿Í passing by reference, default argument valuesÀÇ 3°¡Áö ¹æ¹ýÀ» Á¦°øÇÑ´Ù. °¡º¯ ±æÀÌ(Variable-length) argument list´Â PHP4ÀÌÈÄ¿¡¼­¸¸ Á¦°øµÈ´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº Variable-length argument lists ¿Í func_num_args(), func_get_arg(), func_get_args() ÀÇ ÇÔ¼ö ¼³¸íÀ» º¸±â ¹Ù¶õ´Ù. ±×·¯³ª PHP3¿¡¼­µµ ¹è¿­À» ÅëÇÑ Àü´ÞÀ» »ç¿ëÇÑ´Ù¸é ºñ½ÁÇÑ È¿°ú¸¦ ³¾ ¼ö ÀÖ´Ù.

  1 
  2 function takes_array($input) {
  3     echo "$input[0] + $input[1] = ", $input[0]+$input[1];
  4 }
  5      

Making arguments be passed by reference

±âº»ÀûÀ¸·Î ÇÔ¼öÀÇ Àμö(argument)µéÀº °ªÀ¸·Î Àü´ÞµÈ´Ù(passed by value). ÇÔ¼ö³»¿¡¼­ º¯È­½ÃŲ °ªÀ» ±×´ë·Î À¯ÁöÇÏ·Á¸é pass by reference·Î Àμö¸¦ ³Ñ°Ü¾ß ÇÑ´Ù.

¿©·¯ºÐÀÌ ¾î¶² ÇÔ¼öÀÇ Àμö¸¦ Ç×»ó pass by reference·Î ³Ñ±â·Á ÇÑ´Ù¸é, ¿©·¯ºÐÀº ÇÔ¼ö¸¦ ¼±¾ðÇÒ ¶§ ampersand(&)¸¦ ÀμöÀÇ ¾Õ¿¡ ºÙ¿©ÁÖ¸é µÈ´Ù. :

  1 
  2 function add_some_extra(&$string) {
  3     $string .= 'and something extra.';
  4 }
  5 $str = 'This is a string, ';
  6 add_some_extra($str);
  7 echo $str;    // outputs 'This is a string, and something extra.'
  8       

¸¸¾à ±âº»Àº by value ·Î ÇÏÁö¸¸ ÇÊ¿ä¿¡ µû¶ó by reference·Î È£ÃâÇÏ°í ½Í´Ù¸é ÇÔ¼ö È£Ã⠽ÿ¡ ÀμöÀÇ ¾Õ¿¡ &¸¦ ºÙÀÌ¸é µÈ´Ù. :

  1 
  2 function foo ($bar) {
  3     $bar .= ' and something extra.';
  4 }
  5 $str = 'This is a string, ';
  6 foo ($str);
  7 echo $str;    // outputs 'This is a string, '
  8 foo (&$str);
  9 echo $str;    // outputs 'This is a string, and something extra.'
 10       

Default argument values

½ºÄ®¶ó Àμö´Â ´ÙÀ½°ú °°ÀÌ C++ °ú ºñ½ÁÇÏ°Ô ±âº»°ªÀ» Á¤ÇØÁÙ ¼ö ÀÖ´Ù. :

  1 
  2 function makecoffee ($type = "cappucino") {
  3     return "Making a cup of $type.\n";
  4 }
  5 echo makecoffee ();
  6 echo makecoffee ("espresso");
  7       

À§ÀÇ ÄÚµåÀÇ ½ÇÇà °á°ú´Â ´ÙÀ½°ú °°´Ù :

Making a cup of cappucino.
Making a cup of espresso.
     

default °ªÀº ¹Ýµå½Ã »ó¼öÀ̾î¾ß ÇÑ´Ù. (¿¹¸¦µé¾î) º¯¼ö³ª classÀÇ ¸â¹ö¸¦ »ç¿ëÇؼ­´Â ¾ÈµÈ´Ù.

PHP 4.0¿¡¼­´Â default argument·Î unsetÀ» ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº ÇØ´ç argument¿¡ °ªÀÌ Á¦°øµÇÁö ¾ÊÀ¸¸é, Àý´ë·Î °ªÀ» ¼³Á¤ÇÏÁö ¾Ê´Â °ÍÀ» ÀǹÌÇÑ´Ù.

default argument¸¦ »ç¿ëÇÒ ¶§, default°¡ µÇ´Â ÀμöµéÀº non-defaultÀÎ Àμöµéº¸´Ù ¿À¸¥ÂÊ¿¡ À§Ä¡ÇØ¾ß ÇÑ´Ù. ±×·¸Áö ¾ÊÀ¸¸é ¿øÇÏ´Â °á°ú°¡ ³ª¿ÀÁö ¾Ê´Â´Ù. ´ÙÀ½À» º¸ÀÚ. :

  1 
  2 function makeyogurt ($type = "acidophilus", $flavour) {
  3     return "Making a bowl of $type $flavour.\n";
  4 }
  5  
  6 echo makeyogurt ("raspberry");   // won't work as expected
  7       

À§ ÄÚµåÀÇ ½ÇÇà °á°ú´Â ´ÙÀ½°ú °°´Ù :

Warning: Missing argument 2 in call to makeyogurt() in 
/usr/local/etc/httpd/htdocs/php3test/functest.html on line 41
Making a bowl of raspberry .
     

±×·¯¸é ÀÌÁ¦ À§ÀÇ °Í°ú ¾Æ·¡°ÍÀ» ºñ±³ÇØ º¸ÀÚ. :

  1 
  2 function makeyogurt ($flavour, $type = "acidophilus") {
  3     return "Making a bowl of $type $flavour.\n";
  4 }
  5  
  6 echo makeyogurt ("raspberry");   // works as expected
  7       

ÀÌ ¿¹Á¦ÀÇ ½ÇÇà °á°ú´Â ´ÙÀ½°ú °°´Ù. :

Making a bowl of acidophilus raspberry.
     

 


Variable-length argument lists

PHP4¿¡¼­´Â »ç¿ëÀÚ Á¤ÀÇ ÇÔ¼ö¿¡ °¡º¯ ±æÀÌ(Variable-length) argument list¸¦ Á¦°øÇÑ´Ù. func_num_args(), func_get_arg(), func_get_args() ÀÇ ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ½±°Ô »ç¿ëÇÒ ¼ö ÀÖ´Ù.

Ưº°ÇÑ ¹®¹ýÀÌ »ç¿ëµÇÁöµµ ¾Ê°í, ÇÔ¼öÀÇ Á¤Àǽóª »ç¿ë½Ã argument list´Â º¸ÅëÀÇ °æ¿ì¿Í µ¿ÀÏÇÏ°Ô »ç¿ëÇÏ¸é µÈ´Ù.


Returning values

ÇÔ¼ö´Â return ¹®À» ÅëÇØ ÇÔ¼ö°ªÀ» µ¹·ÁÁÙ ¼ö ÀÖ´Ù. list¿Í object¸¦ Æ÷ÇÔÇÑ ¾î¶² typeµµ µ¹·ÁÁú ¼ö ÀÖ´Ù.

  1 
  2 function square ($num) {
  3     return $num * $num;
  4 }
  5 echo square (4);   // outputs '16'.
  6      

¿©·¯°ªÀ» µ¹·ÁÁÖ´Â ÀÏÀº ÇÒ ¼ö ¾ø´Ù. ±×·¯³ª list¸¦ µ¹·ÁÁÜÀ¸·Î½á ºñ½ÁÇÑ ÀÏÀ» ÇÒ ¼ö ÀÖ´Ù. :

  1 
  2 function small_numbers() {
  3     return array (0, 1, 2);
  4 }
  5 list ($zero, $one, $two) = small_numbers();
  6      

 


old_function

OLD_FUNCTION ¹®ÀåÀº PHP/FI2¿¡¼­ µ¿ÀÏÇÑ ÇÔ¼ö »ç¿ë¹ýÀ» Á¦°øÇÑ´Ù. (function´ë½Å old_functionÀ» »ç¿ëÇÑ´Ù´Â Á¡Àº Á¦¿ÜÇÏ°í)

ÀÌ°ÍÀ» »ç¿ëÇÏ´Â °ÍÀº ÁÁÁö ¾ÊÀº ¹æ¹ýÀÌ´Ù. ÀÌ°ÍÀÌ »ç¿ëµÉ ¶§´Â PHP/FI2->PHP3 º¯È¯±â¿¡¼­ »ÓÀÌ´Ù.

ÁÖÀÇ

OLD_FUNCTIONÀ¸·Î Á¤ÀÇµÈ ÇÔ¼öµéÀº PHPÀÇ ³»ºÎ Äڵ忡¼­ È£ÃâµÉ ¼ö ¾ø´Ù. ÀÌ ¸»Àº usort()³ª array_walk(), register_shutdown_function()°°Àº ÇÔ¼ö¿¡ »ç¿ëÇÒ ¼ö ¾ø´Ù´Â ÀǹÌÀÌ´Ù. À̸¦ ÇØ°áÇϱâ À§Çؼ­´Â ÀÌ OLD_FUNCTIONÀ¸·Î ¼±¾ðµÈ ÇÔ¼ö¸¦ È£ÃâÇÏ´Â PHP3 ÇüÅÂÀÇ ÇÔ¼ö¸¦ ¸¸µé¾î »ç¿ëÇÏ´Â °ÍÀÌ´Ù.

 


Variable functions

PHP´Â °¡º¯ ÇÔ¼ö(variable functions) °³³äÀ» Áö¿øÇÑ´Ù. ÀÌ°ÍÀº º¯¼ö¸í µÚ¿¡ °ýÈ£°¡ ¿ÔÀ» ¶§, PHP´Â ±× À̸§À» °¡Áø ÇÔ¼ö¸¦ ã¾Æ ½ÇÇàÇÑ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. ÀÌ ±â´ÉÀº  callbacks, function table µîÀÇ ±â´É¿¡ »ç¿ëÇÏ¸é ¸Å¿ì À¯¿ëÇÏ°Ô »ç¿ëÇÒ ¼ö ÀÖ´Ù.

Example 12-1. Variable function example

  1 
  2 <?php
  3 function foo() {
  4     echo "In foo()<br>\n";
  5 }
  6 
  7 function bar( $arg = '' ) {
  8     echo "In bar(); argument was '$arg'.<br>\n";
  9 }
 10 
 11 $func = 'foo';
 12 $func();
 13 $func = 'bar';
 14 $func( 'test' );
 15 ?>
 16      

 


Chapter 13. Classes and Objects

( ¿ªÀÚÁÖ : Class ¹®ÀåÀº JavaÀÇ subsetÀ̶ó ÇÒ¸¸Å­ µ¿ÀÏÇÏ´Ù. )

class

Ŭ·¡½º´Â ÀÏ·ÃÀÇ º¯¼ö¿Í ÀÌ º¯¼öµéÀ» »ç¿ëÇÏ´Â ÇÔ¼öµéÀÇ ¸ðÀ½ÀÌ´Ù. Ŭ·¡½º´Â ´ÙÀ½°ú °°Àº ÇüÅ·Π¼±¾ðµÈ´Ù.

  1 
  2 <?php
  3 class Cart {
  4     var $items;  // Items in our shopping cart
  5    
  6     // Add $num articles of $artnr to the cart
  7  
  8     function add_item ($artnr, $num) {
  9         $this->items[$artnr] += $num;
 10     }
 11    
 12     // Take $num articles of $artnr out of the cart
 13  
 14     function remove_item ($artnr, $num) {
 15         if ($this->items[$artnr] > $num) {
 16             $this->items[$artnr] -= $num;
 17             return true;
 18         } else {
 19             return false;
 20         }   
 21     }
 22 }
 23 ?>
 24      

ÀÌ ¼±¾ðÀº Cart¶ó´Â À̸§ÀÇ Å¬·¡½º·Î, Ä«Æ®¾È¿¡ µé¾îÀÖ´Â ¹°Ç°À» À§ÇÑ ÇÑ °³ÀÇ ¹è¿­ º¯¼ö¿Í cart¿¡ ¹°°ÇÀ» ³Ö°Å³ª »©´Â µÎ °³ÀÇ ÇÔ¼ö·Î ±¸¼ºµÇ¾î ÀÖ´Ù.

Classe´Â TypeÀ¸·Î, ½ÇÁ¦ º¯¼öµéÀÇ Ã»»çÁøÀ̶ó ÇÒ ¼ö ÀÖ´Ù. ¿©·¯ºÐÀº new ¿¬»êÀÚ¸¦ »ç¿ëÇÏ¿© ¿øÇÏ´Â typeÀÇ º¯¼ö¸¦ »ý¼ºÇÏ¿©¾ß ÇÑ´Ù.

  1 
  2  $cart = new Cart;
  3  $cart->add_item("10", 1);
  4     

À§¿¡ ÀÖ´Â ¿¹´Â Cart Ŭ·¡½ºÀÇ $cart¶ó´Â object¸¦ ¸¸µå´Â °ÍÀÌ´Ù. ÀÌ objectÀÇ add_item() ÇÔ¼ö¸¦ È£ÃâÇÏ¿© ¹°Ç° ¹øÈ£ "10"¹øÀÇ ¹°Ç° 1°³¸¦ Ä«Æ®¿¡ ³Ö´Â´Ù.

Ŭ·¡½º´Â ´Ù¸¥ Ŭ·¡½º·Î È®Àå µÉ ¼ö ÀÖ´Ù. È®Àå ȤÀº ÆÄ»ýµÈ(extended or derived) Ŭ·¡½º´Â base °¡ µÇ´Â Ŭ·¡½ºÀÇ ¸ðµç º¯¼öµé°ú ÇÔ¼öµéÀ» ±×´ë·Î °¡Á¦°Ô µÇ°í, ¿©·¯ºÐÀº ¿©±â¿¡ Ãß°¡·Î È®ÀåµÈ ¼±¾ðÀ» ÇÒ ¼ö ÀÖ´Ù. À̸¦ À§ÇØ "extends"¶ó´Â Å°¿öµå°¡ »ç¿ëµÈ´Ù.

  1 
  2 class Named_Cart extends Cart {
  3     var $owner;
  4   
  5     function set_owner ($name) {
  6         $this->owner = $name;
  7     }
  8 }
  9     

À§ÀÇ ¿¹´Â Cart Ŭ·¡½ºÀÇ º¯¼ö¿Í ÇÔ¼ö¿¡ $owner º¯¼ö¿Í set_owner() ÇÔ¼ö¸¦ Ãß°¡ÇÑ Named_Cart¶ó´Â Ŭ·¡½ºÀÇ ¼±¾ðÀÌ´Ù. ¿©·¯ºÐÀº À̸§ºÙÀº Ä«Æ®(named cart)¸¦ »ç¿ëÇÏ¿© Ä«Æ®ÀÇ ÁÖÀÎÀ» ¼³Á¤ÇÏ°í ã¾Æº¼ ¼ö ÀÖ´Ù. ¶ÇÇÑ ±âÁ¸ÀÇ ÀÏ¹Ý Ä«Æ®(normal cart)¿¡ ÀÖ´ø ÇÔ¼öµµ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

  1 
  2 $ncart = new Named_Cart;    // Create a named cart
  3 $ncart->set_owner ("kris"); // Name that cart
  4 print $ncart->owner;        // print the cart owners name
  5 $ncart->add_item ("10", 1); // (inherited functionality from cart)
  6     

Ŭ·¡½º ³»ºÎ¿¡ ÀÖ´Â ÇÔ¼ö¿¡¼­ $this ¶ó´Â º¯¼ö´Â ÀÚ±â ÀڽŠobject¸¦ ÀǹÌÇÑ´Ù. ¿©·¯ºÐÀº $this->something ÀÇ ÇüÅ·ΠÇöÀç objectÀÇ º¯¼ö³ª ÇÔ¼ö¸¦ »ç¿ëÇÏ¿©¾ß ÇÑ´Ù.

»ý¼ºÀÚ(Constructor)´Â ÇØ´ç Ŭ·¡½ºÀÇ »õ ÀνºÅϽº(»õ·Î ¸¸µç º¯¼ö¶ó°í »ý°¢ÇØ µÎÀÚ)¸¦ ¸¸µé ¶§ ÀÚµ¿ÀûÀ¸·Î ½ÇÇàµÇ´Â ÇÔ¼ö¸¦ ÀǹÌÇÑ´Ù. Ŭ·¡½ºÀÇ À̸§°ú °°Àº À̸§ÀÇ ÇÔ¼ö°¡ »ý¼ºÀÚ°¡ µÈ´Ù.

  1 
  2 class Auto_Cart extends Cart {
  3     function Auto_Cart () {
  4         $this->add_item ("10", 1);
  5     }
  6 }
  7     

À§ÀÇ ¿¹´Â Cart Ŭ·¡½º¿¡ ¹°Ç°¹øÈ£ 10¹øÀÇ ¹°Ç°À» ÇÑ °³ ÀÚµ¿À¸·Î Ãß°¡ÇÏ´Â »ý¼ºÀÚ¸¦ Ãß°¡ÇÑ Auto_Cart¶ó´Â Ŭ·¡½ºÀÇ ¼±¾ðÀÌ´Ù. Auto_Cart´Â "new"·Î »ý¼ºµÈ´Ù. »ý¼ºÀÚ´Â ¶ÇÇÑ Àμö(argument)¸¦ °¡Áú ¼ö ÀÖ°í, ÀÌ ÀμöµéÀº default°ªÀ» °¡Áø ¿É¼ÇÀ¸·Î ¼±¾ð ÇÒ ¼ö ÀÖ´Ù. ÀÌ ±â´ÉÀº ¸Å¿ì À¯¿ëÇÏ°Ô »ç¿ëµÈ´Ù.

  1 
  2 class Constructor_Cart extends Cart {
  3     function Constructor_Cart ($item = "10", $num = 1) {
  4         $this->add_item ($item, $num);
  5     }
  6 }
  7  
  8 // Shop the same old boring stuff.
  9  
 10 $default_cart   = new Constructor_Cart;
 11  
 12 // Shop for real...
 13  
 14 $different_cart = new Constructor_Cart ("20", 17);
 15     

 

Caution

ÆÄ»ýµÈ(derived) Ŭ·¡½ºÀÇ °æ¿ì, ÀÌ Å¬·¡½ºÀÇ »ý¼ºÀÚ°¡ È£ÃâµÉ ¶§ ºÎ¸ð Ŭ·¡½ºÀÇ »ý¼ºÀÚ´Â ÀÚµ¿À¸·Î È£ÃâµÇÁö ¾Ê´Â´Ù.

 


III. ±â´É (Features)

Table of Contents
14. Error handling
15. Creating GIF images
16. HTTP authentication with PHP
17. Cookies
18. Handling file uploads
19. Using remote files
20. Connection handling
21. Persistent database connections


Chapter 14. Error handling

PHP¿¡´Â ´ÙÀ½°ú °°Àº 4°¡ÁöÀÇ ¿¡·¯¿Í °æ°í ÇüÅ°¡ ÀÖ´Ù.

error reporting levelÀº À§ÀÇ 4°³ÀÇ ¼ýÀÚ°¡ ´õÇØÁ®¼­ °áÁ¤µÈ´Ù. ±âº» error reporting level Àº 7·Î 1+2+4°¡ µÇ°í, ÀÌ´Â Notice¸¦ Á¦¿ÜÇÑ ¸ðµç °ÍÀ» ·¹Æ÷Æ®Ç϶ó´Â ÀǹÌÀÌ´Ù. ÀÌ ·¹º§Àº php3.ini ÆÄÀÏ¿¡¼­ error_reporting Áö½ÃÀÚ·Î °áÁ¤ÇÒ ¼ö ÀÖ´Ù. ȤÀº, ¾ÆÆÄÄ¡ÀÇ httpd.conf ÆÄÀÏ¿¡¼­ php3_error_reporting Áö½ÃÀÚ·Î °áÁ¤Çϰųª, ½ºÅ©¸³Æ® ½ÇÇà Áß¿¡ error_reporting() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ¹Ù²ãÁÙ ¼öµµ ÀÖ´Ù.

¸ðµç PHP Ç¥Çö½Ä(expression)Àº "@"¸¦ ¾Õ¿¡ ºÙÀÌ°í È£ÃâµÇ¸é error reportingÀ» ÇÏÁö ¾Ê´Â´Ù. ¸¸¾à track_errors ±â´ÉÀÌ Enabled·Î µÇ¾î Àִµ¥ ÇØ´ç ¹®Àå¿¡¼­ ¿¡·¯°¡ ¹ß»ýÇß´Ù¸é, $php_errormsg¶ó´Â Àü¿ªº¯¼ö¿¡¼­ ¿¡·¯ ¸Þ½ÃÁö¸¦ ãÀ» ¼ö ÀÖÀ» °ÍÀÌ´Ù.


Chapter 15. PHP¿¡¼­ GIFÀÇ »ý¼º (Creating GIF images)

PHP´Â ´ÜÁö HTMLÃâ·ÂÀ» ¸¸µå´Â °Í¸¸ ÇÒ ¼ö ÀÖ´Â °ÍÀÌ ¾Æ´Ï´Ù. PHP´Â GIF image fileµµ ¸¸µé ¼ö ÀÖÀ» ÀÖÀ» »Ó¾Æ´Ï¶ó, »ç¿ëÇϱ⿡ Æí¸®ÇÑ GIF image stream±îÁö ¸¸µé ¼ö ÀÖ´Ù. À̸¦ À§Çؼ­ ¿©·¯ºÐÀº PHP¸¦ ÄÄÆÄÀÏ ÇÒ ¶§, image ÇÔ¼ö¸¦ °¡Áö°í ÀÖ´Â GD ¶óÀ̺귯¸®¸¦ Æ÷ÇÔÇÏ¿©¾ß ÇÑ´Ù.

Example 15-1. GIF creation with PHP

  1 
  2 <?php
  3     Header("Content-type: image/gif");
  4     $string=implode($argv," ");
  5     $im = imagecreatefromgif("images/button1.gif");
  6     $orange = ImageColorAllocate($im, 220, 210, 60);
  7     $px = (imagesx($im)-7.5*strlen($string))/2;
  8     ImageString($im,3,$px,9,$string,$orange);
  9     ImageGif($im);
 10     ImageDestroy($im);
 11 ?>
 12     

À§ÀÇ ¿¹Á¦´Â <img src="button.php3?text">¿Í °°Àº tagÀÌ ÀÖ´Â ÆäÀÌÁö·ÎºÎÅÍ ºÒ·ÁÁö°Ô µÉ °ÍÀÌ´Ù. ±×·¯¸é À§¿¡ÀÖ´Â button.php ½ºÅ©¸³Æ®´Â "text"¶ó´Â ¹®ÀÚ¿­À» "images/button1.gif"¿¡ ¿À¹ö·¹ÀÌ ½ÃÄÑ °á°ú image¿¡ Ãâ·ÂÇÑ´Ù. ÀÌ·¸°Ô ÇÏ¸é ¹öÆ°¿¡ µé¾î°¡´Â ±Û¾¾¸¦ ¸Å¹ø ¼Õ½±°Ô ¹Ù²ã ¾µ ¼ö ÀÖ°í, ¶ÇÇÑ ¸Å¹ø À̹ÌÁö ÆÄÀÏÀ» ¸¸µé ÇÊ¿ä°¡ ¾ø¾î È¿À²ÀûÀÌ°í °£´ÜÇÏ´Ù.


Chapter 16. HTTP ÀÎÁõ (HTTP authentication with PHP)

(¿ªÀÚÁÖ. HTTP authenticationÀ̶õ Web Client¿¡°Ô ID¿Í Password¸¦ ÀԷ¹޾Æ, ±× ID¿Í Password·Î Web¹®¼­¿¡ Á¢±ÙÀ» Çã°¡, ºÒÇãÇÏ´Â ±â´ÉÀ» ¸»ÇÑ´Ù. ÀÚ¼¼È÷ ¾Ë°í ½Í´Ù¸é RFC1945ÀÇ Authentication ºÎºÐÀ» Âü°íÇϱ⠹ٶõ´Ù. http://pec.etri.re.kr/!qkim/HTTP/¿¡ ÇÑ±Û ¹ø¿ª ¹®¼­µµ ÀÖÀ¸´Ï ÂüÁ¶ÇÏÀÚ.)

PHP¸¦ »ç¿ëÇÑ HTTP ÀÎÁõÀº Apache ¸ðµâ·Î »ç¿ëµÉ ¶§¸¸ µ¿ÀÛÇÑ´Ù. Apache ¸ðµâÀÇ PHP ½ºÅ©¸³Æ®¿¡¼­ Header()¶ó´Â ÇÔ¼ö¸¦ »ç¿ëÇϸé Client ºê¶ó¿ìÀú¿¡°Ô Username°ú Password¸¦ ÀԷ¹޴ À©µµ¿ì¸¦ ¶ç¿ìµµ·Ï ÇÏ´Â "ÀÎÁõ ¿ä±¸"("Authentication Required") ¸Þ½ÃÁö¸¦ º¸³»°Ô µÈ´Ù. ÀÏ´Ü »ç¿ëÀÚ°¡ Username°ú Password¸¦ ÀÔ·ÂÇϸé, user name, password, authentication typeÀÇ °ªÀ» °¡Áö´Â $PHP_AUTH_USER, $PHP_AUTH_PW, $PHP_AUTH_TYPEÀÇ 3°³ÀÇ º¯¼ö¸¦ °¡Áö°í ÇØ´ç URL(PHP ½ºÅ©¸³Æ®¸¦ Æ÷ÇÔÇÑ)ÀÌ ´Ù½Ã ºÒ¸®¿öÁø´Ù. ÇöÀç authentication typeÀº "Basic"¸¸ÀÌ Áö¿øµÈ´Ù.

client authenticationÀ» »ç¿ëÇÏ¿© ±× ÀÔ·ÂµÈ °ªÀ» Ãâ·ÂÇÏ´Â ¿¹Á¦°¡ ¾Æ·¡¿¡ ÀÖ´Ù. :

Example 16-1. HTTP Authentication example

  1 
  2 <?php
  3   if(!isset($PHP_AUTH_USER)) {
  4     Header("WWW-Authenticate: Basic realm=\"My Realm\"");
  5     Header("HTTP/1.0 401 Unauthorized");
  6     echo "Text to send if user hits Cancel button\n";
  7     exit;
  8   } else {
  9     echo "Hello $PHP_AUTH_USER.<P>";
 10     echo "You entered $PHP_AUTH_PW as your password.<P>";
 11   }
 12 ?>
 13     

¿©·¯ºÐÀº $PHP_AUTH_USER ¿Í $PHP_AUTH_PW¸¦ ´Ü¼øÈ÷ Ãâ·ÂÇÏ´Â ´ë½Å, »ç¿ëÀÚÀÇ ½Äº°À» À§ÇØ username°ú password¸¦ »ç¿ëÇϱ⸦ ¿øÇÒ °ÍÀÌ´Ù. À̶§´Â Database¿¡ QueryÇϰųª Á÷Á¢ dbm ÆÄÀÏ¿¡¼­ ã¾Æº¸¸é °¡´ÉÇÒ °ÍÀÌ´Ù.

Internet Explorer browser¿¡¼­´Â ¹ö±×·Î ÀÎÇØ HeaderÀÇ ¼ø¼­°¡ ¸Å¿ì ±î´Ù·Ó´Ù. WWW-authenticate header¸¦ HTTP/1.0 401 headerº¸´Ù ¸ÕÀú º¸³»´Â °ÍÀÌ ÇöÀç °¡´ÉÇÑ ¿ä·ÉÀ¸·Î º¸ÀδÙ.

ºñ¹Ð¹øÈ£ÀÇ À¯ÃâÀ» ¿ì·ÁÇÏ¿© HTTP¿¡¼­ Á¦°øÇÏ´Â ÀÎÁõÀ» »ç¿ëÇÏ´Â ´ë½Å ±âÁ¸ÀÇ ¿ÜºÎ ¸ÞÄ«´ÏÁòÀ» »ç¿ëÇÒ °æ¿ì¿¡´Â ¹°·Ð PHP_AUTH º¯¼ö´Â ¼³Á¤µÇÁö ¾Ê´Â´Ù.

À¯ÀÇÇÒ Á¡Àº ÀÎÁõÀÌ ÇÊ¿äÇÑ ÆäÀÌÁö¿Í ÀÎÁõÀÌ ÇÊ¿ä¾ø´Â ÆäÀÌÁö°¡ °°Àº ¼­¹ö»ó¿¡ Á¸ÀçÇÒ ¶§, ÀÎÁõÀÌ ÇÊ¿ä¾ø´Â URLÀ» controlÇÒ ¼ö ÀÖ´Â ´©±º°¡°¡, ÀÎÁõÀÌ ÇÊ¿äÇÑ URLÀÇ ¾ÏÈ£¸¦ ÈÉÃ帴 °ÍÀº ¸·À» ¼ö ¾ø´Ù´Â Á¡ÀÌ´Ù.

Netscape¿Í Internet Explorer ¸ðµÎ 401ÀÀ´ä Äڵ带 ¼­¹ö¿¡¼­ ¹Þ°ÔµÇ¸é local browser windowÀÇ authentication cache¸¦ clearÇÑ´Ù. Áï, ÀÌ°ÍÀº "log out"°³³äÀÌ µÇ´Â °ÍÀ¸·Î, »ç¿ëÀÚµé·Î ÇÏ¿©±Ý username°ú ¾ÏÈ£¸¦ ´Ù½Ã ÀÔ·ÂÇÏ°Ô ÇÑ´Ù. ÀϺδ ÀÌ°ÍÀ» loginÀÇ "time out"À̳ª "log-out"¹öÆ°À» ¸¸µå´Âµ¥ »ç¿ëÇÑ´Ù

Example 16-2. HTTP Authentication example forcing a new name/password

  1 
  2 <?php
  3   function  authenticate()  {
  4     Header( "WWW-authenticate:  basic  realm='Test  Authentication  System'");
  5     Header( "HTTP/1.0  401  Unauthorized");
  6     echo  "You  must  enter  a  valid  login  ID  and  password  to  access  this  resource\n";
  7     exit;
  8   }
  9 
 10   if(!isset($PHP_AUTH_USER)  ||  ($SeenBefore ==  1  &&  !strcmp($OldAuth,  $PHP_AUTH_USER))  )  {
 11     authenticate();
 12   }  
 13   else  {
 14     echo  "Welcome:  $PHP_AUTH_USER<BR>";
 15     echo  "Old:  $OldAuth";
 16     echo  "<FORM  ACTION=\"$PHP_SELF\"  METHOD=POST>\n";
 17     echo  "<INPUT  TYPE=HIDDEN  NAME=\"SeenBefore\"  VALUE=\"1\">\n";
 18     echo  "<INPUT  TYPE=HIDDEN  NAME=\"OldAuth\"  VALUE=\"$PHP_AUTH_USER\">\n";
 19     echo  "<INPUT  TYPE=Submit  VALUE=\"Re  Authenticate\">\n";
 20     echo  "</FORM>\n";
 21 
 22 }
 23 ?>
 24   

ÀÌ µ¿ÀÛÀº HTTP Basic authentication ±âÁØ¿¡ ¿ä±¸µÇ´Â °ÍÀº ¾Æ´Ï¹Ç·Î ¿©·¯ºÐÀº ÀÌ°Í¿¡ ÀÇÁ¸ÇÏ¿©¼­´Â ¾ÈµÈ´Ù. Lynx¿¡¼­´Â 401 ¼­¹ö ÀÀ´äÀ» ¹Þ¾Æµµ authentication Á¤º¸¸¦ clearÇÏÁö ¾Ê´Â´Ù. µû¶ó¼­ BackÀ» ´©¸£°í ´Ù½Ã Forward ¹öÆ°À» ´­·¯¼­ ´Ù½Ã Á¢±ÙÇÒ ¼ö ÀÖ´Ù.

¶ÇÇÑ ÀÌ Authentication ±â´ÉÀº Microsoft's IIS server¿¡¼­ CGI versionÀÇ PHP¸¦ »ç¿ëÇÒ °æ¿ì¿¡´Â IISÀÇ Á¦¾àÀ¸·ÎÀÎÇØ µ¿ÀÛÇÏÁö ¾Ê´Â´Ù.


Chapter 17. Cookies

PHP´Â HTTP Cookie¸¦ Åõ¸íÇÏ°Ô(transparently) Áö¿øÇÑ´Ù. Cookie ¸ÞÄ«´ÏÁòÀº Æ®·¡Å·À̳ª »ç¿ëÀÚ ½Äº° µîÀ» À§ÇØ ¿ø°Ý browser¿¡ ÀúÀåµÈ µ¥ÀÌÅ͸¦ µ¹·Á ¹Þ´Â °úÁ¤À» ¸»ÇÑ´Ù. ¿©·¯ºÐÀº cookie¸¦ ¼³Á¤Çϱâ À§ÇØ setcookie() ÇÔ¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. Cookie´Â HTTP Çì´õÀÇ ÇÑ ºÎºÐÀ̹ǷÎ, SetCookie() ÇÔ¼ö´Â ºê¶ó¿ìÀú·Î º¸³»´Â ¾î¶² µ¥ÀÌÅͺ¸´Ùµµ ¾Õ¿¡ »ç¿ëÇØ¾ß ÇÑ´Ù. ÀÌ Á¦¾àÀº Header() ÇÔ¼ö¿Í °°Àº Á¦¾àÀ¸·Î º¸¸é µÈ´Ù.

´ç½ÅÀÌ º¸³»ÁØ ¸ðµç cookie´Â ÀÚµ¿ÀûÀ¸·Î GETÀ̳ª POST ¹æ½Ä µ¥ÀÌÅÍ¿Í °°Àº PHP º¯¼ö·Î º¯È¯µÈ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ µ¿ÀÏÇÑ cookie¿¡ ¿©·¯ °ªÀ» ÀúÀåÇÏ°í ½Í´Ù¸é CookieÀ̸§¿¡ []¸¦ ´õÇÏ¸é µÈ´Ù. ÀÚ¼¼ÇÑ °ÍÀº setcookie() ÇÔ¼ö ¼³¸íÀ» ÂüÁ¶ÇÏÀÚ.


Chapter 18. Handling file uploads


POST method uploads

PHP´Â RFC-1867À» Áö¿øÇÏ´Â ºê¶ó¿ìÀú·ÎºÎÅÍ ÆÄÀÏÀ» ¾÷·Îµå ¹ÞÀ» ¼ö ÀÖ´Â ±â´ÉÀÌ ÀÖ´Ù. ÀÌ ±â´ÉÀ» »ç¿ëÇϸé TextºÐ¾Æ´Ï¶ó BinaryÆÄÀϵµ ¾÷·Îµå°¡ °¡´ÉÇÏ´Ù. ¿©·¯ºÐÀº PHP's authetication°ú ³í¸®ÀûÀÎ ÇÔ¼öµéÀ» »ç¿ëÇÏ¿©, Upload°¡ °¡´ÉÇÑ »ç¿ëÀÚ¿Í, ÆÄÀÏÀÌ UploadµÈ ÈÄ¿¡ ÇØ¾ß ÇÒ ÀÏÀ» ¹Ýµå½Ã Á¤ÇØ µÎ¾î¾ß ÇÑ´Ù. (¿ªÀÚÁÖ. RFC-1867Àº Netscape 3.0ÀÌ»ó, Explorer 4.0À̻󿡼­ Áö¿øÇÑ´Ù. Netscape 2.x´ëÀÇ ÀϺΠ»óÀ§¹öÁ¯µµ Áö¿øÇÏ°í, Explorer 3.02´Â Patch°¡ ³ª¿Í ÀÖÀ¸¹Ç·Î patch½ÃÅ°¸é °¡´ÉÇÏ´Ù.)

PHP´Â ¶ÇÇÑ Netscape Composer ¿Í W3C's Amaya clients¸¦ »ç¿ëÇÒ °æ¿ì PUT-method ÀÇ ÆÄÀÏ ¾÷·Îµåµµ Áö¿øÇÑ´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº PUT Method Support ¸¦ Àо±â¹Ù¶õ´Ù.

ÆÄÀÏ ¾÷·Îµå È­¸éÀº ´ÙÀ½°ú °°Àº Á» Ưº°ÇÑ ÆûÀ» ¸¸µé¾î ¶ç¿ï ¼ö ÀÖ´Ù. :

Example 18-1. File Upload Form

  1 
  2 <FORM ENCTYPE="multipart/form-data" ACTION="_URL_" METHOD=POST>
  3 <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000">
  4 Send this file: <INPUT NAME="userfile" TYPE="file">
  5 <INPUT TYPE="submit" VALUE="Send File">
  6 </FORM>
  7     

¿©±â¼­_URL_Àº PHP htmlÆÄÀÏÀ̾î¾ß ÇÕ´Ï´Ù. hidden ÇʵåÀÎ MAX_FILE_SIZE´Â File input Çʵåµéº¸´Ù ¼±ÇàµÇ¾î¾ß ÇÕ´Ï´Ù. ÀÌ °ªÀº PHP htmlÀÌ ¹Þ¾ÆµéÀÌ´Â ÃÖ´ë ÆÄÀÏ Å©±â¸¦ Byte´ÜÀ§·Î ³ªÅ¸³À´Ï´Ù. ¾÷·Îµå°¡ ¼º°øÀûÀ¸·Î µÇ¸é ÁöÁ¤µÈ ÆÄÀÏ¿¡´Â ´ÙÀ½°ú °°Àº º¯¼öµéÀÌ Á¤ÀǵǾî Áø´Ù. :

À§ º¯¼öÀÇ "$userfile"ºÎºÐÀº upload form¿¡¼­ TYPE=filedÀ» °¡Áø INPUT ÇʵåÀÇ À̸§ÀÌ µÈ´Ù. À§ÀÇ ¿¹Á¦¿¡¼­ ¿ì¸®´Â ±× À̸§Àº "userfile"À̶ó°í Á¤Çß´Ù.

FileÀº ±âº»ÀûÀ¸·Î ¿ì¼± ¼­¹öÀÇ default temporary directory¿¡ ÀúÀåµÈ´Ù. ÀÌ µðÆúÆ® µð·ºÅ丮´Â PHP°¡ µ¹¾Æ°¡´Â ÄÄÇ»ÅÍÀÇ È¯°æº¯¼ö "TMPDIR"À» ¼³Á¤ÇÏ¿© º¯°æÇÒ ¼ö ÀÖ´Ù. À̸¦ PHP ½ºÅ©¸³Æ® ¾È¿¡¼­ putenv() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© º¯°æÇÏ´Â °ÍÀº µ¿ÀÛÇÏÁö ¾Ê´Â´Ù.

¾÷·ÎµåµÈ ÆÄÀÏÀ» ´Ù·ç´Â PHP ½ºÅ©¸³Æ®´Â ÇØ´ç ÆÄÀÏÀ» °¡Áö°í ÇÏ´Â ÀÛ¾÷À» ¼³Á¤ÇØ ÁÙ ÇÊ¿ä°¡ ÀÖ´Ù. ¿¹¸¦µé¾î, ¿©·¯ºÐÀº $file_sizeº¯¼ö¸¦ »ç¿ëÇÏ¿© ³Ê¹« À۰ųª Å« ÆÄÀÏÀ» ¹ö¸± ¼öµµ ÀÖ´Ù. ¶ÇÇÑ ¿©·¯ºÐÀº $file_typeº¯¼ö¸¦ °¡Áö°í ƯÁ¤ÇÑ Å¸ÀÔ¿¡ ¸ÂÁö ¾Ê´Â ÆÄÀÏÀ» ¹ö¸± ¼ö ÀÖ´Ù. ¾î¶² ·ÎÁ÷ÀÌ´ø, ¿©·¯ºÐÀº Àӽà µð·ºÅ丮¿¡ ÀÖ´Â ÆÄÀÏÀ» Áö¿ì°Å³ª ³ªÁß¿¡ ÇÊ¿äÇÒ °æ¿ì¿¡´Â ´Ù¸¥ °÷¿¡ À̵¿½ÃÄÑ¾ß ÇÑ´Ù.

¸¸¾à Àӽà µð·ºÅ丮¿¡ ÀÖ´Â ÆÄÀÏÀ» ÇØ´ç request°¡ ³¡³¯ ¶§ ±îÁöµµ Áö¿ì°Å³ª À̵¿½ÃÅ°Áö ¾Ê¾Ò´Ù¸é, ÀÌ ÆÄÀÏÀº ÇØ´ç request°¡ Á¾·áµÇ´Â ½ÃÁ¡¿¡¼­ ÀÚµ¿À¸·Î Áö¿öÁø´Ù.


ÀϹÝÀûÀÎ ÁÖÀÇ»çÇ× (Common Pitfalls)

MAX_FILE_SIZE ¾ÆÀÌÅÛÀÇ °ªÀº PHP3.ini¿¡ ¼³Á¤µÈ upload_max_filesizeÀÇ °ªÀ̳ª Apache .conf¿¡ ¼³Á¤ÇÑ php3_upload_max_filesizeÀÇ °ªº¸´Ù Å©°Ô ¼³Á¤ÇÒ ¼ö ¾ø´Ù. ±âº»°ªÀº 2¸Þ°¡ ¹ÙÀÌÆ®ÀÌ´Ù.

CERN httpd ¼­¹ö´Â client·ÎºÎÅÍ ÀԷ¹ÞÀº mime headerÀÇ ¾ÕÂÊ ¿©¹éÀ» ¸ðµÎ strip off ½ÃÄѹö¸®¹Ç·Î, CERN httpd ¼­¹ö¿¡¼­´Â File Upload ±â´ÉÀÌ µ¿ÀÛÇÏÁö ¾Ê´Â´Ù.


¿©·¯ ÆÄÀÏÀ» UploadÇϱâ (Uploading multiple files)

Çѹø¿¡ ¿©·¯°³ÀÇ ÆÄÀÏÀ» µ¿½Ã¿¡ Àü¼ÛÇÏ´Â °Íµµ °¡´ÉÇÏ´Ù. À̶§ PHP´Â ÀÌ ÆÄÀϵ鿡 ´ëÇÑ Á¤º¸¸¦ ¹è¿­·Î Àü´ÞÇÑ´Ù. µû¶ó¼­ ÀÌ·± °æ¿ì¿¡´Â ¿©·¯°³¸¦ ¼±ÅÃÇÏ´Â select³ª checkbox ¶§Ã³·³ HTMLÀÇ formÀÇ ¾ÆÀÌÅÛ¿¡ µ¿ÀÏÇÑ array¸íÀ» Àû¾îÁÖ¾î¾ß ÇÑ´Ù.

Note: ¿©·¯ ÆÄÀÏ Àü¼Û ±â´ÉÀº 3.0.10ºÎÅÍ Ãß°¡µÈ ±â´ÉÀÌ´Ù. (¿ªÀÚÁÖ: php 4.0.0Àº ¹ö±×·Î ÀÎÇØ ÀÌ ±â´ÉÀÌ µ¿ÀÛÇÏÁö ¾Ê´Â´Ù)

Example 18-2. Uploading multiple forms

  1 
  2 <form action="file-upload.html" method="post" enctype="multipart/form-data">
  3   Send these files:<br>
  4   <input name="userfile[]" type="file"><br>
  5   <input name="userfile[]" type="file"><br>
  6   <input type="submit" value="Send files">
  7 </form>
  8      

À§ÀÇ ÆûÀÌ Àü¼ÛµÉ ¶§ $userfile, $userfile_name, $userfile_sizeÀÇ ¹è¿­ÀÌ Àü¿ª º¯¼ö·Î ¸¸µé¾îÁø´Ù. ($HTTP_POST_VARS¿¡µµ ¸¸µé¾îÁø´Ù.) ÀÌ ¹è¿­µéÀº Àü¼ÛµÈ ÆÄÀÏÀÇ Á¤º¸¸¦ °¡Áö°í ÀÖ°í, °¢ ¹è¿­µéÀº ¹øÈ£·Î À妽ºµÇ¾î ÀÖ´Ù.

¿¹¸¦ µé¾î, À§ÀÇ ¿¹¿¡¼­ /home/test/review.html °ú /home/test/xwp.out ÀÇ µÎ °³ÀÇ ÆÄÀÏÀ» Àü¼ÛÇß´Ù¸é $userfile_name[0]¿¡´Â review.htmlÀ̶ó´Â °ªÀÌ, $userfile_name[1]¿¡´Â xwp.outÀ̶ó´Â °ªÀÌ ÀúÀåµÇ°Ô µÈ´Ù. µ¿½Ã¿¡, $userfile_size[0] ¿¡´Â review.htmlÀÇ ÆÄÀÏ Å©±â°¡ ÀúÀåµÇ´Â ½ÄÀÌ µÈ´Ù.


PUT Method Support

PHP´Â Netscape Composer³ª W3C Amaya°°Àº Ŭ¸®À̾ðÆ®¿¡ ´ëÇØ HTTP PUT ¹æ½Ä(method)À» Áö¿øÇÑ´Ù. PUT ¿ä±¸(request)´Â file uploadº¸´Ù ÈξÀ ½±´Ù. ´ÜÁö ´ÙÀ½°ú °°ÀÌ ÇÏ¸é µÈ´Ù. :

  1 
  2 PUT /path/filename.html HTTP/1.1
  3     

ÀÌ°ÍÀº º¸Åë ¿ø°Ý Ŭ¶óÀ̾ðÆ®°¡ º¸³½ ³»¿ëÀ» À¥ Æ®¸® ¹ØÀÇ /path/filename.html·Î ÀúÀåÇ϶ó´Â ÀǹÌÀÌ´Ù. ±×·±µ¥ ¿©·¯ºÐÀÇ À¥ Æ®¸®¹Ø¿¡ ÀÖ´Â ÆÄÀϵéÀ» ¾Æ¹«³ª µ¤¾î ¾µ ¼ö ÀÖ´Ù´Â °ÍÀº Apache³ª PHP¿¡ À־ È®½ÇÈ÷ ÁÁÁö ¾ÊÀº »ý°¢ÀÌ´Ù. µû¶ó¼­ ÀÌ¿Í °°Àº ¿ä±¸¸¦ ´Ù·ç±â Àü¿¡, ¿ì¼± À¥ ¼­¹ö¿¡°Ô ÀÌ·± ¿ä±¸¸¦ ´Ù·ç´Â PHP ½ºÅ©¸³Æ®¸¦ ¹Ì¸® ÁöÁ¤ÇØ ÁÖ¾î¾ß ÇÑ´Ù. ¾ÆÆÄÄ¡¿¡¼­´Â Script Áö½ÃÀÚ·Î ±× ³»¿ëÀ» ÁöÁ¤ÇÑ´Ù. ÀÌ Áö½ÃÀÚ´Â Apache ¼³Á¤ ÆÄÀÏÁßÀÇ ¾î´À À§Ä¡¿¡ À־ ±¦ÂúÀ¸³ª, º¸Åë <Directory> ºí·Ï ¾ÈÀ̳ª <Virtualhost> ºí·Ï ¾È¿¡ À§Ä¡ÇÏ´Â °ÍÀÌ ÀϹÝÀûÀÌ´Ù. º¸Åë ´ÙÀ½°ú °°ÀÌ ¾²¿©Áø´Ù. :

  1 
  2 Script PUT /put.php3
  3     

ÀÌ°ÍÀº ÀÌ ¶óÀÎÀ» À§Ä¡½ÃŲ ºí·ÏÀÇ URI¿¡ ÇØ´çµÇ´Â ¸ðµç PUT ¿ä±¸¸¦ put.php3 ½ºÅ©¸³Æ®¿¡°Ô Àü´ÞÇ϶ó°í Apache¿¡°Ô ¾Ë·Á ÁØ´Ù. ¹°·Ð ÀÌ °æ¿ì .php3 È®ÀåÀÚ¿¡ ´ëÇÏ¿© PHP¼³Á¤ÀÌ ¿Ï·áµÇ¾î ÀÖ°í, PHP°¡ ÀÛµ¿ÁßÀ̾î¾ß ÇÑ´Ù.

put.php3 ÆÄÀϳ»¿¡¼­´Â º¸Åë ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÒ ¼ö ÀÖ´Ù. :

  1 
  2 <? copy($PHP_UPLOADED_FILE_NAME,$DOCUMENT_ROOT.$REQUEST_URI); ?>
  3     

À§ÀÇ ¸í·ÉÀº ÇØ´ç ÆÄÀÏÀ» ¿ø°Ý Ŭ¶óÀ̾ðÆ®°¡ ¿äûÇÑ À§Ä¡¿¡ º¹»çÇÏ´Â °ÍÀÌ´Ù. ¾Æ¸¶ ¿©·¯ºÐÀº º¹»çÇϱâ Àü¿¡ »ç¿ëÀÚ¸¦ È®ÀÎÇϰųª ÆÄÀÏÀ» °Ë»çÇÏ´Â µîÀÇ ±â´ÉÀ» ¿øÇÒ °ÍÀÌ´Ù. ¿©±â¼­ ¾Ë ¼ö ÀÖ´Â °ÍÀº PHP°¡ PUT-methodÀÇ ¿ä±¸¸¦ ¹Þ¾ÒÀ» ¶§ POST-method±â´É°ú ¸¶Âù°¡Áö·Î Àӽà ÆÄÀÏ¿¡ ÇØ´ç ³»¿ëÀ» ÀúÀåÇÑ´Ù´Â °ÍÀÌ´Ù. Áï, ¿ä±¸°¡ ³¡³ª°Ô µÇ¸é ÀÓ½ÃÆÄÀÏÀº Áö¿öÁø´Ù. µû¶ó¼­ PUTÀ» ´Ù·ç´Â PHP ½ºÅ©¸³Æ®´Â ÇØ´ç ÆÄÀÏÀ» ¾îµð ´Ù¸¥ °÷¿¡ º¹»çÇØ µÎ¾î¾ß ÇÑ´Ù. ÀÓ½ÃÆÄÀÏÀÇ À̸§Àº $PHP_PUT_FILENAME À̶ó´Â º¯¼ö¿¡ ÀúÀåµÇ°í, $REQUEST_URI º¯¼ö¿¡ Ŭ¶óÀ̾ðÆ®¿¡¼­ º¸³»¿Â ÀúÀåÇÒ ÆÄÀÏÀÇ °æ·Î¿Í À̸§ÀÌ ÀúÀåµÈ´Ù.(Apache°¡ ¾Æ´Ñ À¥¼­¹ö¿¡¼­´Â ¸ð¾çÀÌ Á¶±Ý ´Þ¶óÁø´Ù.) ¹°·Ð ¿©·¯ºÐÀº ÀÌ °æ·Î¸í°ú ÆÄÀϸíÀÌ ¾Æ´Ñ ÀüÇô ´Ù¸¥ À§Ä¡¿¡ ´Ù¸¥ ÆÄÀϸíÀ» »ç¿ëÇÒ ¼öµµ ÀÖ´Ù.


Chapter 19. Using remote files

¿©·¯ºÐÀÌ PHP¸¦ ¼³Á¤ÇÒ ¶§ "URL fopen wrapper"¸¦ enable·Î ¼³Á¤ÇÏ¿´´Ù¸é(ÀÌ ¼³Á¤Àº --disable-url-fopen-wrapper·Î ¸í½ÃÇÏÁö ¾ÊÀ¸¸é ¼³Á¤µÈ´Ù.), ¿©·¯ºÐÀº ´ëºÎºÐ ÇÔ¼öÀÇ ÆĶó¸ÞŸ·Î ÀÖ´Â ÆÄÀÏÀ̸§(filename)¿¡ HTTP³ª FTP URLÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù. ½ÉÁö¾î require()³ª include() ÇÔ¼ö¿¡µµ »ç¿ëÀÌ °¡´ÉÇÏ´Ù.

Note: ´Ü, Windowsȯ°æÀÇ include()¿Í require() ÇÔ¼ö¿¡¼­´Â »ç¿ëÇÒ ¼ö ¾ø´Ù.

¿¹¸¦ µé¾î, ¿©·¯ºÐÀº ÀÌ ±â´ÉÀ» »ç¿ëÇÏ¿© ¿ø°Ý À¥ ¼­¹ö°¡ Ãâ·ÂÇÏ´Â ³»¿ëÀ» ÆÄÀÏ·Î ¿­°í, ±× Ãâ·Â ³»¿ë¿¡¼­ ¿©·¯ºÐÀÌ ¿øÇÏ´Â µ¥ÀÌŸ¸¦ ºÐ¼®ÇÏ¿©, ÀÌ ¿øÇÏ´Â µ¥ÀÌŸ·Î µ¥ÀÌŸº£À̽º ÁúÀÇ¿¡ »ç¿ëÇϰųª, ¿©·¯ºÐÀÇ À¥ »çÀÌÆ®¿¡ ¸Â´Â ¸ð¾çÀ¸·Î º¯Çü ½ÃÄÑ Ãâ·ÂÇÒ ¼ö ÀÖ´Ù.

Example 19-1. Getting the title of a remote page

  1 
  2 <?php
  3   $file = fopen("http://www.php.net/", "r");
  4   if (!$file) {
  5     echo "<p>Unable to open remote file.\n";
  6     exit;
  7   }
  8   while (!feof($file)) {
  9     $line = fgets($file, 1024);
 10     /* This only works if the title and its tags are on one line. */
 11     if (eregi("<title>(.*)</title>", $line, $out)) {
 12       $title = $out[1];
 13       break;
 14     }
 15   }
 16   fclose($file);
 17 ?>
 18     

¿©·¯ºÐÀº ÇØ´ç ¼­¹ö¿¡ ±ÇÇÑÀÌ ÀÖ´Â »ç¿ëÀÚ·Î Á¢¼ÓÇÏ°í, ÇØ´ç ÆÄÀÏÀÌ Á¸ÀçÇÏÁö ¾Ê´Â´Ù¸é, FTP¸¦ ÀÌ¿ëÇÑ ÆÄÀÏ·Î ¾µ ¼öµµ ÀÖ´Ù. 'anonymous'°¡ ¾Æ´Ñ »ç¿ëÀÚ·Î Á¢¼ÓÇÏ·Á¸é, URL³»¿¡ usernameÀ» (ÇÊ¿äÇÏ´Ù¸é passwordµµ) ´ÙÀ½°ú °°ÀÌ ¸í½ÃÇØ¾ß ÇÑ´Ù : 'ftp://user:password@ftp.example.com/path/to/file'. (¶ÇÇÑ HTTP¿¡¼­ Basic authenticationÀ» »ç¿ëÇÑ ÀÎÁõÀ» ¿ä±¸ÇÏ´Â °æ¿ì¿¡µµ ÀÌ¿Í °°Àº ¹®¹ýÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù.)

Example 19-2. Storing data on a remote server

  1 
  2 <?php
  3   $file = fopen("ftp://ftp.php.net/incoming/outputfile", "w");
  4   if (!$file) {
  5     echo "<p>Unable to open remote file for writing.\n";
  6     exit;
  7   }
  8   /* Write the data here. */
  9   fputs($file, "$HTTP_USER_AGENT\n");
 10   fclose($file);
 11 ?>
 12     

Note: ¿©·¯ºÐÀº À§ÀÇ ¿¹Á¦¸¦ º¸°í, ÀÌ Å×Å©´ÐÀ» »ç¿ëÇÏ¿© remote log¸¦ ÀÛ¼ºÇÒ ¼ö ÀÖ°Ú´Ù°í »ý°¢ÇÒ ¼öµµ ÀÖ´Ù. ±×·¯³ª À§¿¡ ¾ð±ÞÇÑ´ë·Î URL fopen() wrapper´Â »õ ÆÄÀÏ¿¡¸¸ ¾µ ¼ö ÀÖ´Ù. ¿©·¯ºÐÀÌ ¿øÇÏ´Â ´ë·Î ºÐ»êµÈ log¸¦ ÇÏ°í ½Í´Ù¸é syslog()ÀÇ ³»¿ëÀ» »ìÆ캸¶ó.


Chapter 20. Connection handling

Note: ÀÌ ±â´ÉÀº PHP version 3.0.7 ÀÌÈĺÎÅÍ Àû¿ëµÈ °ÍµéÀÌ´Ù.

³»ºÎÀûÀ¸·Î PHP´Â ¿¬°áÀÇ »óŸ¦ ´ÙÀ½ 3°¡ÁöÁß Çϳª·Î ¼³Á¤ÇÑ´Ù. :

PHP ½ºÅ©¸³Æ®°¡ ÀϹÝÀûÀ¸·Î ½ÇÇàµÇ°í ÀÖÀ» ¶§´Â NORMAL »óÅ°¡ activeµÈ´Ù. ¸¸¾à ¿ø°Ý Ŭ¶óÀ̾ðÆ®°¡ ¿¬°áÀ» ²÷°ÔµÇ¸é ABORTED »óÅ flag°¡ ÄÑÁö°Ô µÈ´Ù. º¸Åë Ŭ¶óÀ̾ðÆ®°¡ ¿¬°áÀ» ²÷´Â °ÍÀº »ç¿ëÀÚ°¡ STOP ¹öÆ°À» ´­·¶À» ¶§ ÀϾ´Ù. ¸¸¾à PHP°¡ ¼³Á¤ÇÑ ½Ã°£ Á¦ÇÑ¿¡ (set_time_limit()À» º¸¶ó) °É¸®°Ô µÇ¸é TIMEOUT »óÅ flag°¡ ÄÑÁö°Ô µÈ´Ù.

¿©·¯ºÐÀº Ŭ¶óÀ̾ðÆ®°¡ ¿¬°áÀ» ²÷¾úÀ» ¶§ ½ºÅ©¸³Æ®°¡ ¼öÇàÀ» Áß´ÜÇÒ °ÍÀΰ¡ ¾Æ´Ñ°¡¸¦ °áÁ¤ÇÏ¿©¾ß ÇÑ´Ù. ¶§¶§·Î ¿ø°Ý ºê¶ó¿ìÀú°¡ ¾î¶² °á°úµµ ¹Þ¾ÆµéÀÌÁö ¾Ê´õ¶óµµ ½ºÅ©¸³Æ®¸¦ ³¡±îÁö ½ÇÇàÇÏ´Â °ÍÀÌ Æí¸®ÇÒ ¶§°¡ ¸¹´Ù. ±âº» µ¿ÀÛÀº Ŭ¶óÀ̾ðÆ®°¡ ¿¬°áÀ» ²÷À¸¸é ½ºÅ©¸³Æ®µµ ÁߴܵǴ °ÍÀÌ´Ù. ÀÌ µ¿ÀÛÀº ignore_user_abort¶ó´Â php3.ini Áö½ÃÀÚ(directive)³ª, php3_ignore_user_abort¶ó´Â Apache .confÀÇ Áö½ÃÀÚ·Î ¼³Á¤ÀÌ °¡´ÉÇÏ°í, ignore_user_abort() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ¼³Á¤ÇÒ ¼öµµ ÀÖ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ PHP¿¡°Ô »ç¿ëÀÚ°¡ ³»¸° ÁßÁö ¸í·ÉÀ» ¹«½ÃÇ϶ó°í ¸»ÇØÁÖÁö ¾Ê¾Ò´Ù¸é, »ç¿ëÀÚÀÇ ÁßÁö ½ÅÈ£´Â ¿©·¯ºÐÀÇ ½ºÅ©¸³Æ®¸¦ Á¾·á½ÃŲ´Ù. ´Ü, register_shutdown_function()À» »ç¿ëÇÏ¿© shutdown ÇÔ¼ö¸¦ µî·ÏÇسõÀº °æ¿ì´Â ¿¹¿Ü°¡ µÈ´Ù. shutdown ÇÔ¼ö¸¦ »ç¿ëÇϸé, »ç¿ëÀÚ°¡ STOP¹öÆ°À» ´­·¶À» ¶§, ¿©·¯ºÐÀÇ ½ºÅ©¸³Æ®´Â ³²Àº Ãâ·ÂÀ» ÇÏ·Á°í ÇÏ°í, PHP´Â ¿¬°áÀÌ ÁߴܵǾúÀ½À» ÀÎÁöÇÏ¿© shutdown ÇÔ¼ö¸¦ È£ÃâÇÏ°Ô µÈ´Ù. shutdown ÇÔ¼ö´Â ¿©·¯ºÐÀÇ ½ºÅ©¸³Æ®°¡ Á¤»óÀûÀ¸·Î Á¾·áµÇ¾úÀ» ¶§µµ È£Ã⠵ȴÙ. µû¶ó¼­ Ŭ¶óÀ̾ðÆ®ÀÇ ¿¬°á Áß´Ü ¶§¿Í ÀϹÝÀûÀÎ Á¾·á½Ã¿¡ ´Ù¸¥ µ¿ÀÛÀ» ¿øÇÑ´Ù¸é connection_aborted() ÇÔ¼ö¸¦ »ç¿ëÇÏ¸é µÈ´Ù. ÀÌ ÇÔ¼ö´Â ¿¬°áÀÌ ÁߴܵǾú´Ù¸é true¸¦ ¹ÝȯÇÑ´Ù.

¿©·¯ºÐÀÇ ½ºÅ©¸³Æ®´Â ³»ÀåµÈ ŸÀ̸ӿ¡ ÀÇÇØ Á¾·áµÉ ¼ö ÀÖ´Ù. ±âº» timeout ½Ã°£Àº 30ÃÊ·Î µÇ¾î ÀÖ´Ù. ÀÌ°ÍÀº max_execution_timeÀ̶ó´Â php3.ini Áö½ÃÀÚ(directive)³ª µ¿ÀÏÇÑ ³»¿ëÀÇ php3_max_execution_timeÀ̶ó´Â Apache .conf Áö½ÃÀÚ¿¡ ÀÇÇØ ´Ù¸£°Ô ¼³Á¤ÀÌ °¡´ÉÇÏ°í set_time_limit() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ¼³Á¤ÇÒ ¼öµµ ÀÖ´Ù. ½Ã°£ÀÌ ´Ù µÇ¸é ½ºÅ©¸³Æ®´Â Áߴܵǰí, ÀÌ ½ºÅ©´Â À§¿¡¼­ ¼³¸íÇÑ Å¬¶óÀ̾ðÆ®¿ÍÀÇ ¿¬°áÀÌ Á¾·áµÈ °Íó·³ µ¿ÀÛÇÑ´Ù. µû¶ó¼­ shutdown ÇÔ¼ö°¡ µî·ÏµÇ¾î ÀÖ´Ù¸é ÀÌ ÇÔ¼ö°¡ ½ÇÇàµÈ´Ù. shutdown ÇÔ¼ö³»¿¡¼­ ÀÌ ÇÔ¼ö°¡ timeout¿¡ ÀÇÇØ È£ÃâµÈ °ÍÀΰ¡¸¦ ÆÇ´ÜÇÏ·Á¸é connection_timeout() ÇÔ¼ö¸¦ »ç¿ëÇÏ¸é µÈ´Ù. ÀÌ ÇÔ¼ö´Â timeout¿¡ ÀÇÇØ shutdown ÇÔ¼ö°¡ È£ÃâµÇ¾ú´Ù¸é true¸¦ ¹ÝȯÇÑ´Ù.

ÇÑ°¡Áö À¯ÀÇÇÒ »çÇ×Àº ABORTED¿Í TIMEOUT »óÅ´ µÎ °³°¡ µ¿½Ã¿¡ activeµÉ ¼ö ÀÖ´Ù´Â °ÍÀÌ´Ù. ÀÌ°ÍÀº PHP°¡ »ç¿ëÀÚ Áß´ÜÀ» ¹«½ÃÇϵµ·Ï ¼³Á¤ÇØ ³õ¾ÒÀ» ¶§ °¡´ÉÇÏ´Ù. ¶Ç ´Ù¸¥ °æ¿ì´Â »ç¿ëÀÚ°¡ ¿¬°áÀ» ²÷Áö´Â ¾Ê¾ÒÁö¸¸ ¿¬°á¿¡ ¾î¶² ¹®Á¦°¡ »ý°Ü ¿¬°áÀÌ ¸Á°¡Áø °æ¿ì·Î, ÀÌ ¶§µµ ½ºÅ©¸³Æ®´Â °è¼Ó ½ÇÇàµÈ´Ù. ÀÌ·± °æ¿ì¿¡ ½ºÅ©¸³Æ®´Â °è¼Ó½ÇÇàµÇ°í, ½Ã°£ Á¦ÇÑ¿¡ °É·Á ½ºÅ©¸³Æ®ÀÇ ¼öÇàÀÌ Áߴܵǰí shutdown ÇÔ¼ö°¡ È£ÃâµÇ¸é, connection_timeout()°ú connection_aborted() ÇÔ¼ö ¸ðµÎ true¸¦ ¹ÝȯÇÏ°Ô µÈ´Ù. ¿©·¯ºÐÀº connection_status() ¶ó´Â ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© µÎ°¡Áö »óÅ ¸ðµÎ¸¦ °Ë»çÇÒ ¼ö ÀÖ´Ù. ÀÌ ÇÔ¼ö´Â °¢ »óÅ¿¡ ´ëÇÑ Á¤º¸¸¦ bit´ÜÀ§·Î °¡Áö°í ÀÖ´Ù. ¿¹¸¦µé¾î À§¿Í°°ÀÌ ABORT¿Í TIMEOUT µÎ °³ÀÇ »óÅ°¡ ¸ðµÎ activeµÇ¾î ÀÖ´Ù¸é ÀÌ ÇÔ¼ö´Â 3À» ¹ÝȯÇÑ´Ù.


Chapter 21. ¿µ±¸ÀûÀÎ µ¥ÀÌÅͺ£À̽º Á¢¼Ó (Persistent database connections)

¿µ±¸ÀûÀÎ Á¢¼Ó(Persistent connection)Àº ¿©·¯ºÐÀÇ ½ºÅ©¸³Æ®°¡ Á¾·áµÇ¾îµµ SQL link¸¦ ´ÝÁö ¾Ê´Â Á¢¼ÓÀ» ¸»ÇÑ´Ù. ¿µ±¸ÀûÀÎ Á¢¼ÓÀÌ ¿äûµÇ¸é, PHP´Â ±âÁ¸ÀÇ (ÀÌÀü¿¡ ¿­¾î µÎ¾ú´ø) µ¿ÀÏÇÑ(identical) ¿µ±¸ÀûÀÎ Á¢¼ÓÀÌ Àִ°¡¸¦ °Ë»çÇÑ´Ù. ¸¸¾à ÀÖ´Ù¸é ±âÁ¸ÀÇ °ÍÀ» »ç¿ëÇÏ°í, ¾ø´Ù¸é »õ·Î¿î link¸¦ ¸¸µç´Ù. 'µ¿ÀÏÇÑ(identical)' Á¢¼ÓÀ̶õ °°Àº È£½ºÆ®¿¡ °°Àº »ç¿ëÀÚ¸í(username)°ú °°Àº ¾ÏÈ£(password)¸¦ »ç¿ëÇÑ Á¢¼ÓÀ» ¸»ÇÑ´Ù.

°¡²û À¥¼­¹öÀÇ ÀÛµ¿°ú ÀÛ¾÷ÀÇ ÇÒ´ç¿¡ ´ëÇØ Àß ¾Ë°í ÀÖÁö ¸øÇÑ »ç¶÷µéÀº ¿µ±¸ÀûÀÎ Á¢¼ÓÀÌ »ç½ÇÀº º° °Í ¾Æ´Ï¶ó°í ¿ÀÇØÇϱ⵵ ÇÑ´Ù. ƯÈ÷, ¿µ±¸ÀûÀÎ Á¢¼ÓÀÌ µ¿ÀÏÇÑ SQL link¿¡¼­ 'user sessions'¸¦ ¿©´Âµ¥ º° ³ªÀ» °Íµµ ¾ø´Ù´ø°¡, transactionÀ» È¿À²ÀûÀ¸·Î ó¸®ÇÏ´Â °Íµµ ¾Æ´Ï¶ó´Ù´ø°¡, ȤÀº ´Ù¸¥ ¾î¶² ÀÛ¾÷À» ÇÏÁö ¸øÇÑ´Ù°íµµ ÇÑ´Ù. »ç½Ç, ÀÌ·± ¸»µé¿¡ ´ëÇØ ¸í¹éÈ÷ ¸»ÇÏÀÚ¸é, ¿µ±¸ÀûÀÎ Á¢¼ÓÀº ºñ¿µ±¸ÀûÀÎ Á¢¼Ó¿¡ ºñÇØ ¾î¶°ÇÑ ±â´ÉÀûÀÎ Çâ»óµµ ÁÖÁö ¸øÇÑ´Ù.

¿Ö?

ÀÌ°ÍÀº À¥¼­¹öÀÇ µ¿ÀÛ ¹æ¹ý´ë·Î µ¿ÀÛÇÑ´Ù. ¿©·¯ºÐÀÇ À¥¼­¹ö°¡ À¥ ÆäÀÌÁö¸¦ ¸¸µé±âÀ§ÇØ PHP¸¦ ÀÌ¿ëÇϴµ¥´Â 3°¡Áö ¹æ¹ýÀÌ ÀÖ´Ù.

ù ¹ø° ¹æ¹ýÀº PHP¸¦ CGI "wrapper"ÀÌ ÇüÅ·Π»ç¿ëÇÏ´Â °ÍÀÌ´Ù. ÀÌ ¹æ¹ýÀÇ °æ¿ì, À¥¼­¹ö¿¡ ¸Å PHP ÆäÀÌÁö°¡ ¿ä±¸µÉ ¶§ ¸¶´Ù, PHP ÀÎÅÍÇÁ¸®ÅÍÀÇ ½ÇÇàÀÌ ¸¸µé¾îÁö°í Á¾·áµÈ´Ù. µû¶ó¼­ ¸Å ¿ä±¸°¡ Á¾·áµÉ ¶§¸¶´Ù ÀÎÅÍÇÁ¸®ÅÍÀÇ ½ÇÇàÀÌ Á¾·áµÇ¹Ç·Î, ½ÇÇà Áß ¸¸µé¾ú´ø (SQL link¸¦ Æ÷ÇÔÇÑ) ¸ðµç ÀÚ¿øÀº ½ÇÇà Á¾·á¿Í ´õºÒ¾î ÇØÁ¦µÈ´Ù. ÀÌ °æ¿ì ¿©·¯ºÐÀº ¿µ±¸ÀûÀÔ Á¢¼ÓÀ» »ç¿ëÇÏ¿© ¾î¶² À̵浵 ¾òÀ» ¼ö ¾ø´Ù. ´Ù¸£°Ô ¸»Çϸé ÀÌ °æ¿ì´Â ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» Çصµ ¿µ±¸ÀûÀÌ ¾Æ´Ï´Ù.

µÎ ¹ø° ¹æ¹ýÀº °¡Àå ´ëÁßÀûÀÎ ¹æ¹ýÀε¥, PHP¸¦ ´ÙÁßÇÁ·Î¼¼½º(multiprocess) À¥¼­¹öÀÇ ¸ðµâ·Î »ç¿ëÇÏ´Â °ÍÀÌ´Ù. (ÇöÀç´Â Apache°¡ À¯ÀÏÇÏ´Ù.) ´ÙÁßÇÁ·Î¼¼½º ¼­¹ö´Â º¸Åë ÇÑ °³ÀÇ ºÎ¸ð(parent) ÇÁ·Î¼¼½º¿Í, ÀÌ¿Í À¯±âÀûÀ¸·Î ¿¬°áµÇ¾î À¥ ÆäÀÌÁö¸¦ ½ÇÁ¦·Î ¸¸µå´Â ÀÛ¾÷À» ÇÏ´Â ¿©·¯°³ÀÇ ÀÚ½Ä(child) ÇÁ·Î¼¼½ºµéÀ» °¡Áö°í ÀÖ´Ù. Ŭ¶óÀ̾ðÆ®·ÎºÎÅÍ µé¾î¿À´Â °³º° ¿ä±¸´Â ´Ù¸¥ Ŭ¶óÀ̾ðÆ®ÀÇ ·á±¸¸¦ ó¸®ÇÏ°í ÀÖÁö ¾ÊÀº ³²´Â ÀÚ½Ä ÇÁ·Î¼¼½º·Î ³Ñ°ÜÁø´Ù. ÀÌ°ÍÀº µ¿ÀÏÇÑ Å¬¶óÀ̾ðÆ®°¡ ¼­¹ö¿¡ µÎ ¹ø° ¿ä±¸¸¦ º¸³¾ ¶§, º¸Åë óÀ½°ú ´Ù¸¥ ÀÚ½Ä ÇÁ·Î¼¼½º¿¡¼­ 󸮵ȴٴ °ÍÀ» ÀǹÌÇÑ´Ù. ÀÌ °æ¿ì ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» »ç¿ëÇÏ¸é °¢°¢ÀÇ ÀÚ½Ä ÇÁ·Î¼¼½ºµéÀº óÀ½ ¿ä±¸¿¡¼­¸¸ SQL ¼­¹ö¿¡ Á¢¼ÓÇÏ°Ô µÈ´Ù. ´Ù¸¥ ÆäÀÌÁö¿¡¼­ SQL ¼­¹ö¿¡ÀÇ Á¢¼Ó ¿ä±¸½Ã´Â ±âÁ¸¿¡ ¸¸µé¾îÁø Á¢¼ÓÀ» ´Ù½Ã »ç¿ëÇÏ°Ô µÈ´Ù.

¸¶Áö¸· ¹æ¹ýÀº PHP¸¦ ¸ÖƼ¾²·¹µå(multithreaded) À¥¼­¹öÀÇ Ç÷¯±×-ÀÎÀÇ ÇüÅ·ΠÀÛµ¿½ÃÅ°´Â °ÍÀε¥, ÇöÀç À̹æ¹ýÀº ÀÌ·ÐÀûÀ¸·Î¸¸ Á¸ÀçÇÏ°í, ½ÇÁ¦·Î ¸¸µé¾î Áø °ÍÀº ¾ø´Ù. ISAPI, WSAPI, NSAPI (Windows¿¡¼­) µîÀÇ ¹æ¹ýÀ» »ç¿ëÇÏ¿© Netscape FastTrack, Microsoft's Internet Information Server (IIS), O'Reilly's WebSite Pro µîÀÇ ¸ÖƼ¾²·¹µå À¥¼­¹ö¿¡¼­ PHP¸¦ Ç÷¯±×-ÀÎÀ¸·Î µ¿ÀÛ½ÃÅ°·Á´Â ÀÛ¾÷ÀÌ ÇöÀç ÁøÇàÁßÀÌ´Ù. ÀÌ °æ¿ì ±âº» µ¿ÀÛÀº À§¿¡¼­ ¾ð±ÞÇÑ ´ÙÁßÇÁ·Î¼¼½º ¸ðµ¨°ú µ¿ÀÏÇÏ°Ô µ¿ÀÛÇÑ´Ù.

¿µ±¸ÀûÀÎ Á¢¼ÓÀÌ ½ÇÁ¦·Î ¾Æ¹«·± ±â´ÉÀÇ Çâ»óµµ ÁÖÁö ¸øÇÑ´Ù¸é, ÀÌ°ÍÀ» »ç¿ëÇØ ¾î¶² ÀÌÁ¡ÀÌ ÀÖ³ª¿ä?

ÀÌ°Í¿¡ ´ëÇÑ °£´ÜÇÑ ´äÀº È¿À²¼ºÀÌ´Ù. ¿µ±¸ÀûÀÎ Á¢¼ÓÀº SQL ¼­¹ö¿ÍÀÇ link¸¦ ¸¸µå´Â °Í¿¡ µû¸¥ overhead°¡ Ŭ °æ¿ì¿¡ À¯¿ëÇÏ´Ù. ÀÌ  overhead´Â ¸¹Àº ¿äÀο¡ µû¶ó Ä¿Áö±âµµ ÇÏ°í ÀÛ¾ÆÁö±âµµ ÇÑ´Ù. ¾î¶² Á¾·ùÀÇ µ¥ÀÌÅͺ£À̽ºÀΰ¡? À¥¼­¹ö¿Í °°Àº ÄÄÇ»ÅÍ¿¡ µ¥ÀÌÅͺ£À̽º ¼­¹ö°¡ Àִ°¡? SQL ¼­¹ö°¡ ¾î¶»°Ô »ç¿ëµÇ°í Àִ°¡? µî¿¡ µû¶ó Å©°Ô ´Þ¶óÁø´Ù. Á¢¼Ó¿¡ µû¸¥ overhead°¡ Ŭ °æ¿ì¿¡ ¿µ±¸ÀûÀÎ Á¢¼ÓÀº ¿©·¯ºÐ¿¡°Ô ÀûÁö ¾ÊÀº µµ¿òÀ» ÁÙ °ÍÀÌ´Ù. ÀÌ°ÍÀº ÀÚ½Ä process¿¡¼­ SQL ¼­¹ö¿¡ Á¢¼ÓÀ» ¿äûÇÒ ¶§ ¸¶´Ù Á¢¼ÓÀ» ¸¸µå´Â ´ë½Å, ÀÌ ÇÁ·Î¼¼½º°¡ Á¾·áµÉ ¶§ ±îÁö »ì¾ÆÀÖ´Â ÇÑ °³ÀÇ Á¢¼Ó ¸¸À» »ç¿ëÇÑ´Ù. ÀÌ°ÍÀº ¸ðµç ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» »ç¿ëÇÑ ÇÁ·Î¼¼½º´Â, ±×¿¡ ÇØ´çÇÏ´Â ÇÑ ´ëÀÇ ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» °¡Áö°í ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. ¿¹¸¦ µé¾î SQL ¼­¹ö¿¡ ´ëÇÏ¿© ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» »ç¿ëÇÏ´Â ½ºÅ©¸³Æ®¸¦ ½ÇÇàÇÏ¿´´ø 20°³ÀÇ ´Ù¸¥ ÀÚ½Ä ÇÁ·Î¼¼½º°¡ ÀÖ´Ù¸é, ¾Æ¸¶µµ °¢°¢ÀÇ ÀÚ½Ä ÇÁ·Î¼¼½º¿¡´ëÇØ 1°³¾¿, 20°³ÀÇ SQL Á¢¼ÓÀÌ ÀÖÀ» °ÍÀÌ´Ù.

Áß¿äÇÑ ¿ä¾à ÇÑ°¡Áö. ¿µ±¸ÀûÀÎ Á¢¼ÓÀº ÀϹÝÀûÀÎ Á¢¼Ó¿¡ 1´ë1·Î ´ëÀÀµÇµµ·Ï ¼³°èµÇ¾ú´Ù. ÀÌ°ÍÀº ½ºÅ©¸³Æ®ÀÇ ±â´ÉÀº ±×´ë·Î µÎ°í, ¾ðÁ¦¶óµµ ºñ¿µ±¸ÀûÀÎ ¿¬°áÀ» ¿µ±¸ÀûÀÎ ¿¬°á·Î ´ëÄ¡ÇÒ ¼ö ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. ÀÌ°ÍÀ¸·Î ¿©·¯ºÐÀº ¾Æ¸¶µµ ½ºÅ©¸³Æ®ÀÇ È¿À²À» Çâ»ó½Ãų ¼ö ÀÖÀ» °ÍÀÌ´Ù.


IV. Function Reference

(¿ªÀÚÁÖ: ÀÌ Reference ºÎºÐÀº ºñ±³Àû °£´ÜÇÑ ³»¿ëµéÀÌ°í, ³»¿ëÀÇ Á¤È®¼ºÀ» ±âÇϱâ À§ÇØ Æ¯º°ÇÑ °æ¿ì¸¦ Á¦¿ÜÇÏ°í´Â Á¦¸ñ ºÎºÐ¸¸ ¹ø¿ªÇÏ¿´´Ù.)

Table of Contents
I. Apache-specific functions
II. Arbitrary precision mathematics functions
III. Array functions
IV. Aspell functions
V. Calendar functions
VI. COM support functions for Windows
VII. Class/Object Functions
VIII. ClibPDF functions
IX. Cybercash payment functions
X. DOM XML functions
XI. Compression functions
XII. Database (dbm-style) abstraction layer functions
XIII. Date and Time functions
XIV. dBase functions
XV. dbm functions
XVI. Directory functions
XVII. Dynamic Loading functions
XVIII. Encryption functions
XIX. filePro functions
XX. Filesystem functions
XXI. Forms Data Format functions
XXII. FTP functions
XXIII. GNU Gettext
XXIV. Hash functions
XXV. HTTP functions
XXVI. Hyperwave functions
XXVII. Image functions
XXVIII. IMAP, POP3, and NNTP functions
XXIX. Informix functions
XXX. InterBase functions
XXXI. LDAP functions
XXXII. Mail functions
XXXIII. Mathematical functions
XXXIV. MCAL functions
XXXV. Microsoft SQL Server functions
XXXVI. Miscellaneous functions
XXXVII. mSQL functions
XXXVIII. MySQL functions
XXXIX. Network functions
XL. NIS functions
XLI. ODBC functions
XLII. Oracle functions
XLIII. Oracle 8 functions
XLIV. PDF functions
XLV. Perl-compatible Regular Expression functions
XLVI. PHP options & information
XLVII. POSIX functions
XLVIII. PostgreSQL functions
XLIX. Program Execution functions
L. GNU Recode functions
LI. Regular expression functions
LII. Semaphore and shared memory functions
LIII. Session handling functions
LIV. SNMP functions
LV. String functions
LVI. Shockwave Flash functions
LVII. Sybase functions
LVIII. URL functions
LIX. Variable functions
LX. Vmailmgr functions
LXI. WDDX functions
LXII. XML parser functions


I. Apache Specific functions

Table of Contents
apache_lookup_uri ¡¦ Perform a partial request for the specified URI and return all info about it
apache_note ¡¦ Get and set apache request notes
getallheaders ¡¦ Fetch all HTTP request headers
virtual ¡¦ Perform an Apache sub-request

apache_lookup_uri

apache_lookup_uri -- ƯÁ¤ URI¿¡ ´ëÇÑ ºÎºÐÀûÀÎ ¿äû(partial request)À» ¼öÇàÇÏ°í ±×°Í¿¡ ´ëÇÑ ¸ðµç Á¤º¸¸¦ µ¹·ÁÁØ´Ù.

Description

class apache_lookup_uri(string filename);

This performs a partial request for a URI. It goes just far enough to obtain all the important information about the given resource and returns this information in a class. The properties of the returned class are:

status

the_request

status_line

method

content_type

handler

uri

filename

path_info

args

boundary

no_cache

no_local_copy

allowed

send_bodyct

bytes_sent

byterange

clength

unparsed_uri

mtime

request_time

apache_note

apache_note -- apache request note¸¦ ¼³Á¤Çϰųª Àоî¿Â´Ù.

Description

string apache_note(string note_name, string [note_value]);

apache_note() is an Apache-specific function which gets and sets values in a request's notes table. If called with one argument, it returns the current value of note note_name. If called with two arguments, it sets the value of note note_name to note_value and returns the previous value of note note_name.

getallheaders

getallheaders -- ¸ðµç HTTP request header¸¦ ºÐ¼®ÇÏ¿© Àоî¿Â´Ù.

Description

array getallheaders(void);

This function returns an associative array of all the HTTP headers in the current request.

Example 1. getallheaders() Example

  1 
  2 $headers = getallheaders();
  3 while (list($header, $value) = each($headers)) {
  4     echo "$header: $value<br>\n";
  5 }
  6       

This example will display all the request headers for the current request.

Note: GetAllHeaders() ´Â PHP°¡ ¸ðµâ·Î ¼³Ä¡µÇ¾úÀ» °æ¿ì¸¸ µ¿ÀÛÇÑ´Ù.

virtual

virtual -- Apache sub-request¸¦ ¼öÇàÇÑ´Ù.

Description

int virtual(string filename);

virtual() is an Apache-specific function which is equivalent to <!--#include virtual...--> in mod_include. It performs an Apache sub-request. It is useful for including CGI scripts or .shtml files, or anything else that you would parse through Apache. Note that for a CGI script, the script must generate valid CGI headers. At the minimum that means it must generate a Content-type header. For PHP files, you need to use include() or require(); virtual() cannot be used to include a document which is itself a PHP file.

II. Arbitrary precision mathematics functions

ÀÌ BC ÇÔ¼öµéÀº PHP°¡ --enable-bcmath ¼³Á¤ ¿É¼ÇÀ¸·Î ÄÄÆÄÀÏ µÈ °æ¿ì¿¡¸¸ »ç¿ëÀÌ °¡´ÉÇÏ´Ù.

Table of Contents
bcadd ¡¦ Add two arbitrary precision numbers.
bccomp ¡¦ Compare two arbitrary precision numbers.
bcdiv ¡¦ Divide two arbitrary precision numbers.
bcmod ¡¦ Get modulus of an arbitrary precision number.
bcmul ¡¦ Multiply two arbitrary precision number.
bcpow ¡¦ Raise an arbitrary precision number to another.
bcscale ¡¦ Set default scale parameter for all bc math functions.
bcsqrt ¡¦ Get the square root of an arbitray precision number.
bcsub ¡¦ Subtract one arbitrary precision number from another.

bcadd

bcadd -- µÎ °³ÀÇ arbitrary precision number¸¦ ´õÇÑ´Ù.

Description

string bcadd(string left operand, string right operand, int [scale]);

Adds the left operand to the right operand and returns the sum in a string. The optional scale parameter is used to set the number of digits after the decimal place in the result.

See also bcsub().

bccomp

bccomp -- µÎ arbitrary precision numbers¸¦ ºñ±³ÇÑ´Ù.

Description

int bccomp(string left operand, string right operand, int [scale]);

Compares the left operand to the right operand and returns the result as an integer. The optional scale parameter is used to set the number of digits after the decimal place which will be used in the comparion. The return value is 0 if the two operands are equal. If the left operand is larger than the right operand the return value is +1 and if the left operand is less than the right operand the return value is -1.

bcdiv

bcdiv -- µÎ arbitrary precision number¸¦ ³ª´«´Ù.

Description

string bcdiv(string left operand, string right operand, int [scale]);

Divides the left operand by the right operand and returns the result. The optional scale sets the number of digits after the decimal place in the result.

See also bcmul().

bcmod

bcmod -- arbitrary precision numberÀÇ ³ª¸ÓÁö¸¦ ±¸ÇÑ´Ù.

Description

string bcmod(string left operand, string modulus);

Get the modulus of the left operand using modulus.

See also bcdiv().

bcmul

bcmul -- µÎ arbitrary precision number¸¦ °öÇÑ´Ù.

Description

string bcmul(string left operand, string right operand, int [scale]);

Multiply the left operand by the right operand and returns the result. The optional scale sets the number of digits after the decimal place in the result.

See also bcdiv().

bcpow

bcpow -- arbitrary precision numberÀÇ n Á¦°öÇÑ´Ù.

Description

string bcpow(string x, string y, int [scale]);

Raise x to the power y. The scale can be used to set the number of digits after the decimal place in the result.

See also bcsqrt().

bcscale

bcscale -- ¸ðµç bc ¼öÇÐ ÇÔ¼öÀÇ ±âº» scale parameter¸¦ Á¤ÇÑ´Ù.

Description

string bcscale(int scale);

This function sets the default scale parameter for all subsequent bc math functions that do not explicitly specify a scale parameter.

bcsqrt

bcsqrt -- arbitray precision numberÀÇ Á¦°ö±ÙÀ» ±¸ÇÑ´Ù.

Description

string bcsqrt(string operand, int scale);

Return the square root of the operand. The optional scale parameter sets the number of digits after the decimal place in the result.

See also bcpow().

bcsub

bcsub -- arbitrary precision number ¸¦ »«´Ù.

Description

string bcsub(string left operand, string right operand, int [scale]);

Subtracts the right operand from the left operand and returns the result in a string. The optional scale parameter is used to set the number of digits after the decimal place in the result.

See also bcadd().


III. Array functions

Table of Contents
array ¡¦ Create an array
array_count_values ¡¦ Counts all the values of an array
array_flip ¡¦ Flip all the values of an array
array_keys ¡¦ Return all the keys of an array
array_merge ¡¦ Merge two or more arrays
array_pad ¡¦ Pad array to the specified length with a value
array_pop ¡¦ Pop the element off the end of array
array_push ¡¦ Push one or more elements onto the end of array
array_reverse ¡¦ Return an array with elements in reverse order
array_shift ¡¦ Pop an element of the beginning of array
array_slice ¡¦ Extract a slice of the array
array_splice ¡¦ Remove a portion of the array and replace it with something else
array_unshift ¡¦ Push one or more elements onto the beginning of array
array_values ¡¦ Return all the values of an array
array_walk ¡¦ Apply a user function to every member of an array.
arsort ¡¦ Sort an array in reverse order and maintain index association
asort ¡¦ Sort an array and maintain index association
compact ¡¦ Create array containing variables and their values
count ¡¦ count elements in a variable
current ¡¦ return the current element in an array
each ¡¦ return next key/value pair from an array
end ¡¦ set internal pointer of array to last element
extract ¡¦ Import variables into the symbol table from an array
in_array ¡¦ Return true if a value exists in an array
key ¡¦ fetch a key from an associative array
krsort ¡¦ Sort an array by key in reverse order
ksort ¡¦ Sort an array by key.
list ¡¦ assign variables as if they were an array
next ¡¦ advance the internal array pointer
pos ¡¦ return the current element in an array
prev ¡¦ rewind internal array pointer
range ¡¦ Create an array containing a range of integers
reset ¡¦ set internal pointer of array to first element
rsort ¡¦ Sort an array in reverse order
shuffle ¡¦ Shuffle an array
sizeof ¡¦ get size of array
sort ¡¦ Sort an array
uasort ¡¦ Sort an array with a user-defined comparison function and maintain index association
uksort ¡¦ Sort an array by keys using a user-defined comparison function
usort ¡¦ Sort an array by values using a user-defined comparison function

array

array -- ¹è¿­À» ¸¸µç´Ù.

Description

array array(...);

Returns an array of the parameters. The parameters can be given an index with the => operator.

Note: array() is a language construct used to represent literal arrays, and not a regular function.

The following example demonstrates how to create a two-dimensional array, how to specify keys for associative arrays, and how to skip-and-continue numeric indices in normal arrays.

Example 1. array() example

  1 
  2 $fruits = array (
  3     "fruits"  => array("a"=>"orange", "b"=>"banana", "c"=>"apple"),
  4     "numbers" => array(1, 2, 3, 4, 5, 6),
  5     "holes"   => array("first", 5 => "second", "third")
  6 );
  7       

See also: list().

array_count_values

array_count_values -- ¹è¿­ÀÇ ¸ðµç °³°³ÀÇ °ªÀÇ °¹¼ö¸¦ ¼¾´Ù.

Description

array array_count_values(array input);

array_count_values() returns an array using the values of the input array as keys and their frequency in input as values.

Example 1. array_count_values() example

  1 
  2 $array = array(1, "hello", 1, "world", "hello");
  3 array_count_values($array); // returns array(1=>2, "hello"=>2, "world"=>1)
  4       

Note: This function was added in PHP 4.0.

array_flip

array_flip -- ¹è¿­ °ªµéÀÇ ¼ø¼­¸¦ ¹Ý´ë·Î ÇÑ´Ù.

Description

array array_flip(array trans);

array_flip() returns an array in flip order.

Example 1. array_flip() example

  1 
  2 $trans = array_flip ($trans);
  3 $original = strtr ($str, $trans);
  4       

Note: This function was added in PHP 4.0.

array_keys

array_keys -- ¹è¿­ÀÇ ¸ðµç Å°µéÀ» ¹ÝȯÇÑ´Ù,

Description

array array_keys(array input, mixed [search_value] );

array_keys() returns the keys, numeric and string, from the input array.

If the optional search_value is specified, then only the keys for that value are returned. Otherwise, all the keys from the input are returned.

Example 1. array_keys() example

  1 
  2 $array = array(0 => 100, "color" => "red");
  3 array_keys ($array);       // returns array (0, "color")
  4 
  5 $array = array(1, 100, 2, 100);
  6 array_keys ($array, 100);  //  returns array (0, 2) 
  7       

See also array_values().

Note: This function was added in PHP 4.0.

array_merge

array_merge -- µÎ °³ ÀÌ»óÀÇ ¹è¿­À» Çϳª·Î ÇÕÄ£´Ù.

Description

array array_merge(array array1, array array2, [ ...] );

array_merge() merges the elements of two or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.

If the input arrays had the same string keys, then the later value for that key will overwrite previous one. If, however, the arrays have the same numeric key, this does not happen since the values are appended.

Example 1. array_merge() example

  1 
  2 $array1 = array ("color" => "red", 2, 4);
  3 $array2 = array ("a", "b", "color" => "green", "shape" => "trapezoid");
  4 array_merge ($array1, $array2);
  5       

Resulting array will be array("color" => "green", 2, 4, "a", "b", "shape" => "trapezoid").

Note: This function was added in PHP 4.0.

array_pad

array_pad -- ¹è¿­À» ÁÖ¾îÁø ±æÀ̸¸Å­ ÁÖ¾îÁø °ªÀ¸·Î ä¿î´Ù.

Description

array array_pad(array input, int pad_size, mixed pad_value);

array_pad() returns a copy of the input padded to size specified by pad_size with value pad_value. If pad_size is positive then the array is padded on the right, if it's negative then on the left. If the absolute value of pad_size is less than or equal to the length of the input then no padding takes place.

Example 1. array_pad() example

  1 
  2 $input = array (12, 10, 9);
  3 
  4 $result = array_pad ($input, 5, 0);
  5 // result is array (12, 10, 9, 0, 0)
  6 
  7 $result = array_pad ($input, -7, -1);
  8 // result is array (-1, -1, -1, -1, 12, 10, 9)
  9 
 10 $result = array_pad ($input, 2, "noop");
 11 // not padded
 12       

array_pop

array_pop -- ¹è¿­ÀÇ ¸Ç µÚ¿¡ ÀÖ´Â ¿ø¼Ò¸¦ ²¨³»°í ±× ¿ø¼Ò¸¦ »èÁ¦ÇÑ´Ù.

Description

mixed array_pop(array array);

array_pop() pops and returns the last value of the array, shortening the array by one element.

Example 1. array_pop() example

  1 
  2 $stack = array ("orange", "apple", "raspberry");
  3 $fruit = array_pop ($stack);
  4       

After this, $stack has only 2 elements: "orange" and "apple", and $fruit has "raspberry".

See also array_push(), array_shift(), and array_unshift().

Note: This function was added in PHP 4.0.

array_push

array_push -- ¹è¿­ÀÇ ¸Ç µÚ¿¡ ÇÑ °³³ª ±× ÀÌ»óÀÇ ¿ø¼Ò¸¦ ÷°¡ÇÑ´Ù.

Description

int array_push(array array, mixed var, [...] );

array_push() treats array as a stack, and pushes the passed variables onto the end of array. The length of array increases by the number of variables pushed. Has the same effect as:
  1 
  2 $array[] = $var;
  3      
repeated for each var.

Returns the new number of elements in the array.

Example 1. array_push() example

  1 
  2 $stack = array (1, 2);
  3 array_push($stack, "+", 3);
  4       
This example would result in $stack having 4 elements: 1, 2, "+", and 3.

See also array_pop(), array_shift(), and array_unshift().

Note: This function was added in PHP 4.0.

array_reverse

array_reverse -- ÁÖ¾îÁø ¹è¿­ÀÇ ¿ø¼ÒÀÇ ¼ø¼­¸¦ ¹Ý´ë·Î ÇÑ ¹è¿­À» µ¹·ÁÁØ´Ù.

Description

array array_reverse(array array);

array_reverse() takes input array and returns a new array with the order of the elements reversed.

Example 1. array_reverse() example

  1 
  2 $input = array ("php", 4.0, array ("green", "red"));
  3 $result = array_reverse ($input);
  4       
This makes $result have array (array ("green", "red"), 4.0, "php").

Note: This function was added in PHP 4.0 Beta 3.

array_shift

array_shift -- ¹è¿­ÀÇ ¸Ç ¾Õ¿¡ ÀÖ´Â ¿ø¼Ò¸¦ ²¨³»°í ±× ¿ø¼Ò¸¦ »èÁ¦ÇÑ´Ù.

Description

mixed array_shift(array array);

array_shift() shifts the first value of the array off and returns it, shortening the array by one element and moving everything down.

Example 1. array_shift() example

  1 
  2 $args = array ("-v", "-f");
  3 $opt = array_shift ($args);
  4       
This would result in $args having one element "-f" left, and $opt being "-v".

See also array_unshift(), array_push(), and array_pop().

Note: This function was added in PHP 4.0.

array_slice

array_slice -- ¹è¿­ÀÇ ÀϺθ¦ ÃßÃâÇÑ´Ù.

Description

array array_slice(array array, int offset, int [length] );

array_slice() returns a sequence of elements from the array specified by the offset and length parameters.

If offset is positive, the sequence will start at that offset in the array. If offset is negative, the sequence will start that far from the end of the array.

If length is given and is positive, then the sequence will have that many elements in it. If length is given and is negative then the sequence will stop that many elements from the end of the array. If it is omitted, then the sequence will have everything from offset up until the end of the array.

Example 1. array_slice() examples

  1 
  2 $input = array ("a", "b", "c", "d", "e");
  3 
  4 $output = array_slice ($input, 2);      // returns "c", "d", and "e"
  5 $output = array_slice ($input, 2, -1);  // returns "c", "d"
  6 $output = array_slice ($input, -2, 1);  // returns "d"
  7 $output = array_slice ($input, 0, 3);   // returns "a", "b", and "c"
  8       

See also array_splice().

Note: This function was added in PHP 4.0.

array_splice

array_splice -- ¹è¿­ÀÇ ÀϺθ¦ »èÁ¦ÇÏ°í, ±× À§Ä¡¿¡ ´Ù¸¥ ³»¿ëÀ» ³¢¿ö ³Ö´Â´Ù.

Description

array array_splice(array input, int offset, int [length] , array [replacement] );

array_splice() removed the elements designated by offset and length from the input array, and replaces them with the elements of the replacement array, if supplied.

If offset is positive then the start of removed portion is at that offset from the beginning of the input array. If offset is negative then it starts that far from the end of the input array.

If length is omitted, removes everything from offset to the end of the array. If length is specified and is positive, then that many elements will be removed. If length is specified and is negative then the end of the removed portion will be that many elements from the end of the array. Tip: to remove everything from offset to the end of the array when replacement is also specified, use count($input) for length.

If replacement array is specified, then the removed elements are replaced with elements from this array. If offset and length are such that nothing is removed, then the elements from the replacement array are inserted in the place specified by the offset. Tip: if the replacement is just one element it is not necessary to put array() around it, unless the element is an array itself.

The following equivalences hold:
  1 
  2 array_push($input, $x, $y)     array_splice($input, count($input), 0, array($x, $y))
  3 array_pop($input)              array_splice($input, -1)
  4 array_shift($input)            array_splice($input, 0, 1)
  5 array_unshift($input, $x, $y)  array_splice($input, 0, 0, array($x, $y))
  6 $a[$x] = $y                    array_splice($input, $x, 1, $y)
  7      

Returns the array consisting of removed elements.

Example 1. array_splice() examples

  1 
  2 $input = array("red", "green", "blue", "yellow");
  3 
  4 array_splice($input, 2);      // $input is now array("red", "green")
  5 array_splice($input, 1, -1);  // $input is now array("red", "yellow")
  6 array_splice($input, 1, count($input), "orange");  
  7                               // $input is now array("red", "orange")
  8 array_splice($input, -1, 1, array("black", "maroon")); 
  9                               // $input is now array("red", "green", 
 10                               //          "blue", "black", "maroon")
 11       

See also array_slice().

Note: This function was added in PHP 4.0.

array_unshift

array_unshift -- ¹è¿­ÀÇ ¸Ç ¾Õ¿¡ ÇÑ °³³ª ±× ÀÌ»óÀÇ ¿ø¼Ò¸¦ ÷°¡ÇÑ´Ù.

Description

int array_unshift(array array, mixed var, [...] );

array_unshift() prepends passed elements to the front of the array. Note that the list of elements is prepended as a whole, so that the prepended elements stay in the same order.

Returns the new number of elements in the array.

Example 1. array_unshift() example

  1 
  2 $queue = array("p1", "p3");
  3 array_unshift($queue, "p4", "p5", "p6");
  4       
This would result in $queue having 5 elements: "p4", "p5", "p6", "p1", and "p3".

See also array_shift(), array_push(), and array_pop().

Note: This function was added in PHP 4.0.

array_values

array_values -- ¹è¿­ÀÇ ¸ðµç °ªµéÀ» ¹ÝȯÇÑ´Ù.

Description

array array_values(array input);

array_values() returns all the values from the input array.

Example 1. array_values() example

  1 
  2 $array = array("size" => "XL", "color" => "gold");
  3 array_values($array);    // returns array("XL", "gold")
  4       

Note: This function was added in PHP 4.0.

array_walk

array_walk -- ¹è¿­ÀÇ °³°³ÀÇ ¿ø¼Ò¿¡ ƯÁ¤ ÇÔ¼ö¸¦ Àû¿ëÇÏ¿© ¼öÇàÇÑ´Ù.

Description

int array_walk(array arr, string func, mixed userdata);

Applies the function named by func to each element of arr. func will be passed array value as the first parameter and array key as the second parameter. If userdata is supplied, it will be passed as the third parameter to the user function.

If func requires more than two or three arguments, depending on userdata, a warning will be generated each time array_walk() calls func. These warnings may be suppressed by prepending the '@' sign to the array_walk() call, or by using error_reporting().

Note: If func needs to be working with the actual values of the array, specify that the first parameter of func should be passed by reference. Then any changes made to those elements will be made in the array itself.

Note: Passing the key and userdata to func was added in 4.0.

In PHP 4 reset() needs to be called as necessary since array_walk() does not reset the array by default.

Example 1. array_walk() example

  1 
  2 $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
  3 
  4 function test_alter (&$item1, $key, $prefix) {
  5    $item1 = "$prefix: $item1";
  6 }
  7 
  8 function test_print ($item2, $key) {
  9    echo "$key. $item2<br>\n";
 10 }
 11 
 12 array_walk ($fruits, 'test_print');
 13 reset ($fruits);
 14 array_walk ($fruits, 'test_alter', 'fruit');
 15 reset ($fruits);
 16 array_walk ($fruits, 'test_print');
 17       

See also each() and list().

arsort

arsort -- ¹è¿­À» ¿ª¼øÀ¸·Î Á¤·ÄÇÏ°í index associationÀ» À¯ÁöÇÑ´Ù.

Description

void arsort(array array);

This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant.

Example 1. arsort() example

  1 
  2 $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
  3 arsort ($fruits);
  4 for (reset ($fruits); $key = key ($fruits); next ($fruits)) {
  5     echo "fruits[$key] = ".$fruits[$key]."\n";
  6 }
  7       
This example would display: fruits[a] = orange fruits[d] = lemon fruits[b] = banana fruits[c] = apple The fruits have been sorted in reverse alphabetical order, and the index associated with each element has been maintained.

See also: asort(), rsort(), ksort(), and sort().

asort

asort -- ¹è¿­À» Á¤·ÄÇÏ°í index associationÀ» À¯ÁöÇÑ´Ù.

Description

 

void asort(array array);

This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant.

Example 1. asort() example

  1 
  2 $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
  3 asort ($fruits);
  4 for (reset ($fruits); $key = key ($fruits); next ($fruits)) {
  5     echo "fruits[$key] = ".$fruits[$key]."\n";
  6 }
  7       
This example would display: fruits[c] = apple fruits[b] = banana fruits[d] = lemon fruits[a] = orange The fruits have been sorted in alphabetical order, and the index associated with each element has been maintained.

See also arsort(), rsort(), ksort(), and sort().

compact

compact -- ÁÖ¾îÁø ¿©·¯ º¯¼öÀÇ À̸§°ú °ªÀ» °¡Áö´Â ¹è¿­À» ¸¸µç´Ù.

Description

array compact(string varname | array varnames, [...] );

compact() takes a variable number of parameters. Each parameter can be either a string containing the name of the variable, or an array of variable names. The array can contain other arrays of variable names inside it; compact() handles it recursively.

For each of these, compact() looks for a variable with that name in the current symbol table and adds it to the output array such that the variable name becomes the key and the contents of the variable become the value for that key. In short, it does the opposite of extract(). It returns the output array with all the variables added to it.

Example 1. compact() example

  1 
  2 $city = "San Francisco";
  3 $state = "CA";
  4 $event = "SIGGRAPH";
  5 
  6 $location_vars = array ("city", "state");
  7 
  8 $result = compact ("event", $location_vars);
  9       

After this, $result will be array ("event" => "SIGGRAPH", "city" => "San Francisco", "state" => "CA").

See also extract().

Note: This function was added in PHP 4.0.

count

count -- ¹è¿­ º¯¼öÀÇ ¿ø¼Ò °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

int count(mixed var);

Returns the number of elements in var, which is typically an array (since anything else will have one element).

Returns 1 if the variable is not an array.

Returns 0 if the variable is not set.

Warning

count() may return 0 for a variable that isn't set, but it may also return 0 for a variable that has been initialized with an empty array. Use isset() to test if a variable is set.

See also: sizeof(), isset(), and is_array().

current

current -- ¹è¿­ÀÇ ÇöÀç ¿ø¼Ò¸¦ µ¹·ÁÁØ´Ù.

Description

mixed current(array array);

°¢°¢ÀÇ ¹è¿­ º¯¼ö´Â ±×°ÍÀÇ ¿ø¼Ò¸¦ °¡¸£Å°´Â ³»ºÎÀûÀÎ pointer¸¦ °¡Áö°í ÀÖ´Ù. °Ô´Ù°¡, ¹è¿­ÀÇ ¸ðµç ¿ø¼ÒµéÀº °Ë»öÀÌ ¿ëÀÌÇϵµ·Ï ¾ç¹æÇâ linked list·Î ¿¬°áµÇ¾î ÀÖ´Ù. ÀÌ ³»ºÎÀûÀÎ pointer´Â ´Ù¸¥ ¾î¶² Á¶ÀÛÀ» Çϱâ Àü¿¡´Â Ç×»ó ù ¹ø° ¿ä¼Ò¸¦ °¡¸£Å°°í ÀÖ´Ù.

current() ÇÔ¼ö´Â ´Ü¼øÈ÷ ³»ºÎÀûÀÎ Pointer°¡ °¡¸£Å°°í ÀÖ´Â ¿ø¼Ò¸¦ ¹ÝȯÇÒ »ÓÀÌ´Ù. ¸¸¾à ÀÌ pointer°¡ ¿ø¼Ò listÀÇ ¹üÀ§¸¦ ³Ñ¾î¼­ Áö½ÃÇÏ°í ÀÖ´Ù¸é current()´Â false¸¦ ¹ÝȯÇÑ´Ù.

Warning

current()´Â ÇöÀç ¿ø¼Ò°¡ 0À̳ª ""(ºó ¹®ÀÚ¿­)ÀÇ °ªÀ» °¡Áö°í ÀÖÀ¸¸é falseÀ» ¹ÝȯÇÑ´Ù. µû¶ó¼­ ÀÌ current() ÇÔ¼ö´Â ¿ø¼ÒÀÇ °ªÀÌ 0Àΰ¡ ¾Æ´Ï¸é ¹è¿­ÀÇ ¹üÀ§¸¦ ³Ñ¾ú´Â°¡¸¦ ÆÇ´ÜÇÒ ¼ö ¾ø´Ù. current()¸¦ »ç¿ëÇÑ loop ÄÚµùº¸´Ù´Â  each() ÇÔ¼ö¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù.

See also: end(), next(), prev() and reset().

each

each -- ¹è¿­¿¡¼­ ´ÙÀ½ key/value ½ÖÀ» µ¹·ÁÁØ´Ù.

Description

array each(array array);

array ¹è¿­¿¡¼­ ´ÙÀ½ key/value ½ÖÀ» ¹ÝȯÇÑ´Ù. ÀÌ ½ÖÀº ³× °³ÀÇ ¿ø¼Ò¸¦ °¡Áø ¹è¿­·Î ¹ÝȯµÇ´Âµ¥ ÀÌ ³× °³ÀÇ ¿ø¼ÒÀÇ key´Â 0, 1, key, valueÀÌ´Ù. 0°ú key ¿ø¼Ò´Â °¢°¢ º¯¼öÀÇ key À̸§À» °¡Áö°í, 1°ú value´Â ±× °ªÀ» °¡Áö°í ÀÖ´Ù.

Example 1. each() examples

  1 
  2 $foo = array ("bob", "fred", "jussi", "jouni", "egon", "marliese");
  3 $bar = each ($foo);
  4       

$bar now contains the following key/value pairs:

  • 0 => 0
  • 1 => 'bob'
  • key => 0
  • value => 'bob'
  1 
  2 $foo = array ("Robert" => "Bob", "Seppo" => "Sepi");
  3 $bar = each ($foo);
  4        

$bar now contains the following key/value pairs:

  • 0 => 'Robert'
  • 1 => 'Bob'
  • key => 'Robert'
  • value => 'Bob'

º¸Åë each()´Â list() ÇÔ¼ö¿Í ÇÔ²² ¹è¿­À» Ž»öÇϴµ¥ »ç¿ëµÈ´Ù. ¿¹¸¦ µé¾î ´ÙÀ½°ú °°ÀÌ $HTTP_POST_VARS¿Í °°Àº ¹è¿­À» Ž»öÇϴµ¥ ¸¹ÀÌ »ç¿ëµÈ´Ù

Example 2. Traversing $HTTP_POST_VARS with each()

  1 
  2 echo "Values submitted via POST method:<br>";
  3 reset ($HTTP_POST_VARS);
  4 while (list ($key, $val) = each ($HTTP_POST_VARS)) {
  5     echo "$key => $val<br>";
  6 }
  7       

After each() has executed, the array cursor will be left on the next element of the array, or on the last element if it hits the end of the array.

See also key(), current(), reset(), next(), and prev().

end

end -- ¹è¿­ÀÇ ³»ºÎÀûÀÎ(internal) pointer¸¦ ¸Ç ¸¶Áö¸· ¿ø¼Ò·Î ¿Å±ä´Ù.

Description

end(array array);

end() advances array's internal pointer to the last element.

See also: current(), end() next() and reset()

extract

extract -- ¹è¿­ÀÇ ³»¿ëÀ» ½Éº¼ Å×À̺í·Î Àоîµé¿© ÀϹÝÀûÀÎ º¯¼ö·Î ¸¸µç´Ù.

Description

void extract(array var_array, int [extract_type] , string [prefix] );

This function is used to import variables from an array into the current symbol table. It takes associative array var_array and treats keys as variable names and values as variable values. For each key/value pair it will create a variable in the current symbol table, subject to extract_type and prefix parameters.

extract() checks for colissions with existing variables. The way collisions are treated is determined by extract_type. It can be one of the following values:

EXTR_OVERWRITE

If there is a collision, overwrite the existing variable.

EXTR_SKIP

If there is a collision, don't overwrite the existing variable.

EXTR_PREFIX_SAME

If there is a collision, prefix the new variable with prefix.

EXTR_PREFIX_ALL

Prefix all variables with prefix.

If extract_type is not specified, it is assumed to be EXTR_OVERWRITE.

Note that prefix is only required if extract_type is EXTR_PREFIX_SAME or EXTR_PREFIX_ALL.

extract() checks each key to see if it constitues a valid variable name, and if it does only then does it proceed to import it.

A possible use for extract is to import into symbol table variables contained in an associative array returned by wddx_deserialize().

Example 1. Extract() example

  1 
  2 <php?
  3 
  4 /* Suppose that $var_array is an array returned from
  5    wddx_deserialize */
  6 
  7 $size = "large";
  8 $var_array = array ("color" => "blue",
  9                     "size"  => "medium",
 10                     "shape" => "sphere");
 11 extract ($var_array, EXTR_PREFIX_SAME, "wddx");
 12 
 13 print "$color, $size, $shape, $wddx_size\n";
 14 
 15 ?>
 16       

The above example will produce:
  1 
  2 blue, large, sphere, medium
  3      

The $size wasn't overwritten, becaus we specified EXTR_PREFIX_SAME, which resulted in $wddx_size being created. If EXTR_SKIP was specified, then $wddx_size wouldn't even have been created. EXTR_OVERWRITE would have cause $size to have value "medium", and EXTR_PREFIX_ALL would result in new variables being named $wddx_color, $wddx_size, and $wddx_shape.

in_array

in_array -- ¹è¿­¿¡ ã´Â °ªÀÌ ÀÖÀ¸¸é true¸¦ ¹ÝȯÇÑ´Ù.

Description

bool in_array(mixed needle, array haystack);

Searches haystack for needle and returns true if it is found in the array, false otherwise.

Example 1. in_array() example

  1 
  2 $os = array ("Mac", "NT", "Irix", "Linux");
  3 if (in_array ("Irix", $os))
  4     print "Got Irix";
  5       

Note: This function was added in PHP 4.0.

key

key --¹è¿­(associative array)¿¡¼­ ³»ºÎÀûÀÎ(internal) pointer°¡ °¡¸®Å°°í ÀÖ´Â ¿ø¼ÒÀÇ key °ªÀ» °¡Á®¿Â´Ù.

Description

mixed prev(array array);

key() returns the index element of the current array position.

See also: current() next()

krsort

krsort -- key ¼øÀ¸·Î ¹è¿­À» Å«°Í¼­ ÀÛÀº¼ø¼­·Î Á¤·ÄÇÑ´Ù.

Description

int krsort(array array);

Sorts an array by key in reverse order, maintaining key to data correlations. This is useful mainly for associative arrays.

Example 1. krsort() example

  1 
  2 $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
  3 krsort ($fruits);
  4 for (reset ($fruits); $key = key ($fruits); next ($fruits)) {
  5     echo "fruits[$key] = ".$fruits[$key]."\n";
  6 }
  7       
This example would display: fruits[d] = lemon fruits[c] = apple fruits[b] = banana fruits[a] = orange

See also asort(), arsort(), ksort(), sort(), and rsort().

ksort

ksort -- key ¼øÀ¸·Î ¹è¿­À» Á¤·ÄÇÑ´Ù.

Description

int ksort(array array);

Sorts an array by key, maintaining key to data correlations. This is useful mainly for associative arrays.

Example 1. ksort() example

  1 
  2 $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
  3 ksort ($fruits);
  4 for (reset ($fruits); $key = key ($fruits); next ($fruits)) {
  5     echo "fruits[$key] = ".$fruits[$key]."\n";
  6 }
  7       
This example would display: fruits[a] = orange fruits[b] = banana fruits[c] = apple fruits[d] = lemon

See also asort(), arsort(), sort(), and rsort().

list

list -- º¯¼ö¸¦ ¹è¿­ÀÎ °Íó·³ ¸¸µç´Ù.

Description

void list(...);

Like array(), this is not really a function, but a language construct. list() is used to assign a list of variables in one operation.

Example 1. list() example

  1 
  2 <table>
  3  <tr>
  4   <th>Employee name</th>
  5   <th>Salary</th>
  6  </tr>
  7 
  8 <?php
  9 
 10 $result = mysql($conn, "SELECT id, name, salary FROM employees");
 11 while (list($id, $name, $salary) = mysql_fetch_row($result)) {
 12     print(" <tr>\n".
 13           "  <td><a href=\"info.php3?id=$id\">$name</a></td>\n".
 14           "  <td>$salary</td>\n".
 15           " </tr>\n");
 16 }
 17 
 18 ?>
 19 
 20 </table>
 21       

See also: array().

next

next -- ¹è¿­ÀÇ internal pointer¸¦ Çϳª ÀüÁø½ÃŲ´Ù.

Description

mixed next(array array);

Returns the array element in the next place that's pointed by the internal array pointer, or false if there are no more elements.

next() behaves like current(), with one difference. It advances the internal array pointer one place forward before returning the element. That means it returns the next array element and advances the internal array pointer by one. If advancing the internal array pointer results in going beyond the end of the element list, next() returns false.

Warning

If the array contains empty elements then this function will return false for these elements as well. To properly traverse an array which may contain empty elements see the each() function.

See also: current(), end() prev() and reset()

pos

pos -- ¹è¿­ÀÇ ÇöÀç ¿ø¼Ò¸¦ returnÇÑ´Ù.

Description

mixed pos(array array);

This is an alias for current().

See also: end(), next(), prev() and reset().

prev

prev -- ¹è¿­ÀÇ internal pointer¸¦ Çϳª µÚ·Î ÈÄÁø½ÃŲ´Ù.

Description

mixed prev(array array);

Returns the array element in the previous place that's pointed by the internal array pointer, or false if there are no more elements.

Warning

If the array contains empty elements then this function will return false for these elements as well. To properly traverse an array which may contain empty elements see the each() function.

prev() behaves just like next(), except it rewinds the internal array pointer one place instead of advancing it.

See also: current(), end() next() and reset()

range

range -- ÀÏÁ¤ ¹üÀ§¿¡ ÀÖ´Â Á¤¼ö°ªÀ» ÀÏ·Ä·Î °¡Áø ¹è¿­À» ¸¸µç´Ù.

Description

array range(int low, int high);

range() returns an array of integers from low to high, inclusive.

ÀÌ ÇÔ¼öÀÇ »ç¿ë ¿¹´Â shuffle()¿¡ ³ª¿ÍÀÖ´Ù.

reset

reset -- ¹è¿­ÀÇ internal pointer¸¦ ¸Ç óÀ½ ¿ø¼Ò·Î ¼³Á¤ÇÑ´Ù.

Description

mixed reset(array array);

reset() rewinds array's internal pointer to the first element.

reset() returns the value of the first array element.

See also: current(), next() prev() and reset()

rsort

rsort -- ¹è¿­À» ¿ª¼øÀ¸·Î Á¤·ÄÇÑ´Ù.

Description

void rsort(array array);

This function sorts an array in reverse order (highest to lowest).

Example 1. rsort() example

  1 
  2 $fruits = array ("lemon", "orange", "banana", "apple");
  3 rsort ($fruits);
  4 for (reset ($fruits); list ($key, $value) = each ($fruits); ) {
  5     echo "fruits[$key] = ", $value, "\n";
  6 }
  7       
This example would display: fruits[0] = orange fruits[1] = lemon fruits[2] = banana fruits[3] = apple The fruits have been sorted in reverse alphabetical order.

See also arsort(), asort(), ksort(), and sort().

shuffle

shuffle -- ¹è¿­ÀÇ ³»¿ëÀ» µÚ¼¯´Â´Ù.

Description

void shuffle(array array);

This function shuffles (randomizes the order of the elements in) an array.

Example 1. shuffle() example

  1 
  2 $numbers = range (1,20);
  3 srand (time());
  4 shuffle ($numbers);
  5 while (list(, $number) = each ($numbers)) {
  6     echo "$number ";
  7 }
  8       

See also arsort(), asort(), ksort(), rsort(), sort() and usort().

sizeof

sizeof -- ¹è¿­ÀÇ Å©±â¸¦ ±¸ÇÑ´Ù. ¿ø¼ÒÀÇ °³¼ö°¡ ±¸ÇØÁø´Ù.

Description

int sizeof(array array);

Returns the number of elements in the array.

See also: count()

sort

sort -- ¹è¿­À» Á¤·ÄÇÑ´Ù.

Description

void sort(array array);

This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.

Example 1. sort() example

  1 
  2 $fruits = array ("lemon", "orange", "banana", "apple");
  3 sort ($fruits);
  4 for (reset ($fruits); $key = key ($fruits); next ($fruits)) {
  5     echo "fruits[$key] = ".$fruits[$key]."\n";
  6 }
  7       
This example would display: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange The fruits have been sorted in alphabetical order.

 See also arsort(), asort(), ksort(), rsort(), and usort().

uasort

uasort -- »ç¿ëÀÚ°¡ ÁöÁ¤ÇÑ ºñ±³ ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© Á¤·ÄÇÏ°í index associationÀ» À¯ÁöÇÑ´Ù.

Description

void uasort(array array, function cmp_function);

This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. The comparison function is user-defined.

uksort

uksort -- »ç¿ëÀÚ°¡ ÁöÁ¤ÇÑ ºñ±³ ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© key ¼øÀ¸·Î Á¤·ÄÇÑ´Ù.

Sort an array by keys using a user-defined comparison function

Description

void uksort(array array, function cmp_function);

This function will sort the keys of an array using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function.

Example 1. uksort() example

  1 
  2 function mycompare ($a, $b) {   
  3     if ($a == $b) return 0;
  4     return ($a > $b) ? -1 : 1;
  5 }
  6 $a = array (4 => "four", 3 => "three", 20 => "twenty", 10 => "ten");
  7 uksort ($a, mycompare);
  8 while (list ($key, $value) = each ($a)) {
  9     echo "$key: $value\n";
 10 }
 11       
This example would display: 20: twenty 10: ten 4: four 3: three

See also arsort(), asort(), uasort(), ksort(), rsort() and sort().

usort

usort -- »ç¿ëÀÚ°¡ ÁöÁ¤ÇÑ ºñ±³ ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© value ¼øÀ¸·Î Á¤·ÄÇÑ´Ù.

Description

 void usort(array array, function cmp_function);

This function will sort an array by its values using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function.

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. If two members compare as equal, their order in the sorted array is undefined.

Example 1. usort() example

  1 
  2 function cmp ($a, $b) {   
  3     if ($a == $b) return 0;
  4     return ($a > $b) ? -1 : 1;
  5 }
  6 $a = array (3, 2, 5, 6, 1);
  7 usort ($a, cmp);
  8 while (list ($key, $value) = each ($a)) {
  9     echo "$key: $value\n";
 10 }
 11       
This example would display: 0: 6 1: 5 2: 3 3: 2 4: 1

Note: Obviously in this trivial case the rsort() function would be more appropriate.

Warning

The underlying quicksort function in some C libraries (such as on Solaris systems) may cause PHP to crash if the comparison function does not return consistent values.

See also arsort(), asort(), ksort(), rsort() and sort().


IV. Aspell functions

aspell() ÇÔ¼öµéÀº ¿©·¯ºÐ¿¡°Ô ´Ü¾îÀÇ Ã¶ÀÚ¸¦ °Ë»çÇÏ°í ¼öÁ¤»çÇ×À» Á¶¾ðÇØ ÁØ´Ù.

ÀÌ ÇÔ¼öµéÀ» »ç¿ëÇÏ·Á¸é aspell ¶óÀ̺귯¸®°¡ ÇÊ¿äÇÏ´Ù. ´ÙÀ½ »çÀÌÆ®¿¡¼­ ãÀ» ¼ö ÀÖÀ» °ÍÀÌ´Ù. : http://metalab.unc.edu/kevina/aspell/

Table of Contents
aspell_new ¡¦ load a new dictionary
aspell_check ¡¦ check a word
aspell_check-raw ¡¦ check a word without changing its case or trying to trim it
aspell_suggest ¡¦ suggest spellings of a word

aspell_new

aspell_new -- »õ »çÀüÀ» ÀÐ¾î ¿Â´Ù.

Description

int aspell_new(string master, string personal);

aspell_new() opens up a new dictionary and returns the dictionary link identifier for use in other aspell functions.

Example 1. aspell_new

  1 
  2 $aspell_link=aspell_new("english");
  3       

aspell_check

aspell_check -- ´Ü¾î¸¦ °Ë»çÇÑ´Ù.

Description

boolean aspell_check(int dictionary_link, string word);

aspell_check() checks the spelling of a word and returns true if the spelling is correct, false if not.

Example 1. aspell_check

  1 
  2 $aspell_link=aspell_new("english");
  3 if (aspell_check($aspell_link,"testt")) {
  4     echo "This is a valid spelling";
  5 } else {
  6     echo "Sorry, wrong spelling";
  7 }
  8       

aspell_check-raw

aspell_check-raw -- ´Ü¾îÀÇ ´ë/¼Ò¹®ÀÚ¸¦ º¯È¯ÇÏÁö ¾Ê°í, ¾ÕµÚÀÇ °ø¹éµµ Á¦°ÅÇÏÁö ¾ÊÀº ä·Î °Ë»çÇÑ´Ù.

Description

boolean aspell_check_raw(int dictionary_link, string word);

aspell_check_raw() checks the spelling of a word, without changing its case or trying to trim it in any way and returns true if the spelling is correct, false if not.

Example 1. aspell_check_raw

  1 
  2 $aspell_link=aspell_new("english");
  3 if (aspell_check_raw($aspell_link,"testt")) {
  4     echo "This is a valid spelling";
  5 } else {
  6     echo "Sorry, wrong spelling";
  7 }
  8       

aspell_suggest

aspell_suggest -- ´Ü¾îÀÇ Ã¶ÀÚ¸¦ Á¶¾ðÇØ ÁØ´Ù.

Description

array aspell_suggest(int dictionary_link, string word);

aspell_suggest() returns an array of possible spellings for the given word.

Example 1. aspell_suggest

  1 
  2 $aspell_link=aspell_new("english");
  3 
  4 if (!aspell_check($aspell_link,"testt")) {
  5     $suggestions=aspell_suggest($aspell_link,"testt");
  6 
  7     for($i=0; $i < count($suggestions); $i++) {
  8        echo "Possible spelling: " . $suggestions[$i] . "<br>"; 
  9     }
 10 }
 11       


V. Calendar functions

PHP¿¡´Â ¼­·Î ´Ù¸¥ ³¯Â¥(´Þ·Â) ÇüŸ¦ º¯È¯½ÃÄÑ ÁÖ´Â ÇÔ¼öµéÀ» Á¦°øÇÑ´Ù. Julian Day Count°¡ ±âº»ÀÌ µÈ´Ù. ÀÌ°ÍÀº BC4000³âÀÇ ¾î´À ½ÃÁ¡À» ±âÁØÀ¸·Î Àâ¾Æ ±×°÷¿¡¼­ºÎÅÍ ¾ó¸¶ÀÇ ³¯Â¥°¡ Áö³µ´ÂÁö¸¦ ±âÁØÀ¸·Î »ï´Â °ÍÀÌ´Ù. ÀÌ Julian Day Count´Â ÀϹÝÀûÀ¸·Î »ç¿ëÇÏ´Â Julian ´Þ·Â°ú´Â ´Ù¸£´Ù´Â °ÍÀ» ¾Ë¾ÆµÎÀÚ. Calendar ½Ã½ºÅÛ¿¡ ´ëÇØ ÀÚ¼¼È÷ ¾Ë°í ½Í´Ù¸é http://genealogy.org/~scottlee/cal-overview.html¸¦ ¹æ¹®ÇÏ¿© º¸¶ó. ÀÌ ¼³¸í¼­Áß¿¡¼­´Â À§ÀÇ ÆäÀÌÁö¿¡¼­ ¹ßÃéµÈ ³»¿ëÀ» ""·Î µÑ·¯ ½Î°í ÀÖ´Ù.

( ¿ªÀÚÁÖ : ÀÌ ÇÔ¼öµéÀº dl/calender extensionÀ» LoadÇÑ ÈÄ¿¡ »ç¿ë°¡´ÉÇÏ´Ù. dl/README ÆÄÀÏÀ» Àо¶ó. )

Table of Contents
JDToGregorian ¡¦ Converts Julian Day Count to Gregorian date
GregorianToJD ¡¦ Converts a Gregorian date to Julian Day Count
JDToJulian ¡¦ Converts a Julian Calendar date to Julian Day Count
JulianToJD ¡¦ Converts a Julian Calendar date to Julian Day Count
JDToJewish ¡¦ Converts a Julian Day Count to the Jewish Calendar
JewishToJD ¡¦ Converts a date in the Jewish Calendar to Julian Day Count
JDToFrench ¡¦ Converts a Julian Day Count to the French Republican Calendar
FrenchToJD ¡¦ Converts a date from the French Republican Calendar to a Julian Day Count
JDMonthName ¡¦ Returns a month name
JDDayOfWeek ¡¦ Returns the day of the week
easter_date ¡¦ get UNIX timestamp for midnight on Easter of a given year
easter_days ¡¦ get number of days after March 21 on which Easter falls for a given year

JDToGregorian

JDToGregorian -- Julian Day Count¸¦ Gregorian date·Î º¯È¯

Description

string jdtogregorian(int julianday);

Converts Julian Day Count to a string containing the Gregorian date in the format of "month/day/year"

GregorianToJD

GregorianToJD -- Gregorian date¸¦ Julian Day Count·Î º¯È¯

Description

int gregoriantojd(int month, int day, int year);

Valid Range for Gregorian Calendar 4714 B.C. to 9999 A.D.

Although this software can handle dates all the way back to 4714 B.C., such use may not be meaningful. The Gregorian calendar was not instituted until October 15, 1582 (or October 5, 1582 in the Julian calendar). Some countries did not accept it until much later. For example, Britain converted in 1752, The USSR in 1918 and Greece in 1923. Most European countries used the Julian calendar prior to the Gregorian.

Example 1. Calendar functions

  1 
  2 <?php
  3 $jd = GregorianToJD(10,11,1970);
  4 echo("$jd\n");
  5 $gregorian = JDToGregorian($jd);
  6 echo("$gregorian\n");
  7 ?>
  8 

JDToJulian

JDToJulian -- Julian Day Count¸¦ Julian Calendar date·Î º¯È¯

Description

string jdtojulian(int julianday);

Converts Julian Day Count to a string containing the Julian Calendar Date in the format of "month/day/year".

JulianToJD

JulianToJD -- Julian Calendar date¸¦ Julian Day Count·Î º¯È¯

Description

int juliantojd(int month, int day, int year);

Valid Range for Julian Calendar 4713 B.C. to 9999 A.D.

Although this software can handle dates all the way back to 4713 B.C., such use may not be meaningful. The calendar was created in 46 B.C., but the details did not stabilize until at least 8 A.D., and perhaps as late at the 4th century. Also, the beginning of a year varied from one culture to another - not all accepted January as the first month.

JDToJewish

JDToJewish -- Julian Day Count¸¦ the À¯´ë Calendar·Î º¯È¯.

Description

string jdtojewish(int julianday);

Converts a Julian Day Count the the Jewish Calendar.

JewishToJD

JewishToJD -- À¯´ë Calendar¸¦ Julian Day Count·Î º¯È¯.

Description

int jewishtojd(int month, int day, int year);

Valid Range Although this software can handle dates all the way back to the year 1 (3761 B.C.), such use may not be meaningful.

The Jewish calendar has been in use for several thousand years, but in the early days there was no formula to determine the start of a month. A new month was started when the new moon was first observed.

JDToFrench

JDToFrench -- Julian Day Count¸¦ French Republican Calendar·Î º¯È¯.

Description

string jdtofrench(int month, int day, int year);

Converts a Julian Day Count to the French Republican Calendar.

FrenchToJD

FrenchToJD -- French Republican Calendar¸¦ Julian Day Count·Î º¯È¯.

Description

int frenchtojd(int month, int day, int year);

Converts a date from the French Republican Calendar to a Julian Day Count

These routines only convert dates in years 1 through 14 (Gregorian dates 22 September 1792 through 22 September 1806). This more than covers the period when the calendar was in use.

JDMonthName

JDMonthName -- ¿ùÀÇ À̸§À» ¹Ýȯ

Description

string jdmonthname(int julianday, int mode);

Returns a string containing a month name. mode tells this function which calendar to convert the Julian Day Count to, and what type of month names are to be returned.

Table 1. Calendar modes

Mode

Meaning

0

Gregorian - apreviated

1

Gregorian

2

Julian - apreviated

3

Julian

4

Jewish

5

French Republican

JDDayOfWeek

JDDayOfWeek -- ÇØ´ç ³¯Â¥ÀÇ ¿äÀÏÀ» ¹ÝȯÇÑ´Ù.

Description

mixed jddayofweek(int julianday, int mode);

Returns the day of the week. Can return a string or an int depending on the mode.

Table 1. Calendar week modes

Mode

Meaning

0

returns the day number as an int (0=sunday, 1=monday, etc)

1

returns string containing the day of week (english-gregorian)

2

returns a string containing the abreviated day of week (english-gregorian)

easter_date

easter_date -- ÁÖ¾îÁø ¿¬µµÀÇ ºÎÈ°ÀýÀÇ ÀÚÁ¤¿¡ ´ëÇÑ UNIX timestamp¸¦ ¾ò´Â´Ù.

Description

int easter_date(int year);

Returns the UNIX timestamp corresponding to midnight on Easter of the given year. If no year is specified, the current year is assumed.

Warning: This function will generate a warning if the year is outside of the range for UNIX timestamps (i.e. before 1970 or after 2037).

Example 1. easter_date() example

  1 
  2 echo date( "M-d-Y", easter_date(1999) );        /* "Apr-04-1999" */
  3 echo date( "M-d-Y", easter_date(2000) );        /* "Apr-23-2000" */
  4 echo date( "M-d-Y", easter_date(2001) );        /* "Apr-15-2001" */
  5 

The date of Easter Day was defined by the Council of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox. The Equinox is assumed to always fall on 21st March, so the calculation reduces to determining the date of the full moon and the date of the following Sunday. The algorithm used here was introduced around the year 532 by Dionysius Exiguus. Under the Julian Calendar (for years before 1753) a simple 19-year cycle is used to track the phases of the Moon. Under the Gregorian Calendar (for years after 1753 - devised by Clavius and Lilius, and introduced by Pope Gregory XIII in October 1582, and into Britain and its then colonies in September 1752) two correction factors are added to make the cycle more accurate.

(The code is based on a C program by Simon Kershaw, <webmaster@ely.anglican.org>)

See easter_days() for calculating Easter before 1970 or after 2037.

easter_days

easter_days -- ÁÖ¾îÁø ¿¬µµÀÇ ºÎÈ°ÀýÀÌ 3¿ù 21ÀϷκÎÅÍ ¸çÄ¥ÀÌ Áö³­ °ÍÀÎÁö¸¦ ¾ò´Â´Ù.

Description

int easter_days(int year);

Returns the number of days after March 21 on which Easter falls for a given year. If no year is specified, the current year is assumed.

This function can be used instead of easter_date() to calculate Easter for years which fall outside the range of UNIX timestamps (i.e. before 1970 or after 2037).

Example 1. easter_date() example

  1 
  2 echo easter_days(1999);        /* 14, i.e. April 4   */
  3 echo easter_days(1492);        /* 32, i.e. April 22  */
  4 echo easter_days(1913);        /*  2, i.e. March 23  */
  5 

The date of Easter Day was defined by the Council of Nicaea in AD325 as the Sunday after the first full moon which falls on or after the Spring Equinox. The Equinox is assumed to always fall on 21st March, so the calculation reduces to determining the date of the full moon and the date of the following Sunday. The algorithm used here was introduced around the year 532 by Dionysius Exiguus. Under the Julian Calendar (for years before 1753) a simple 19-year cycle is used to track the phases of the Moon. Under the Gregorian Calendar (for years after 1753 - devised by Clavius and Lilius, and introduced by Pope Gregory XIII in October 1582, and into Britain and its then colonies in September 1752) two correction factors are added to make the cycle more accurate.

(The code is based on a C program by Simon Kershaw, <webmaster@ely.anglican.org>)

See also easter_date().


VI. COM support functions for Windows

ÀÌ ÇÔ¼öµéÀº À©µµ¿ì ¹öÀüÀÇ PHP¿¡¼­¸¸ ÀÛµ¿ÇÑ´Ù. ÀÌ ÇÔ¼öµéÀº PHP4¿¡¼­ Ãß°¡µÇ¾ú´Ù.

Table of Contents
com_load ¡¦ ???
com_invoke ¡¦ ???
com_propget ¡¦ ???
com_get ¡¦ ???
com_propput ¡¦ ???
com_propset ¡¦ ???
com_set ¡¦ ???

com_load

(PHP3 >= 3.0.3, PHP4 )

com_load -- ???

Description

string com_load (string module name [, string server name])

com_invoke

(PHP3 >= 3.0.3, PHP4 )

com_invoke -- ???

Description

mixed com_invoke (resource object, string function_name [, mixed function parameters, ...])

com_propget

(PHP3 >= 3.0.3, PHP4 )

com_propget -- ???

Description

mixed com_propget (resource object, string property)

com_get

(PHP3 >= 3.0.3, PHP4 )

com_get -- ???

Description

mixed com_get (resource object, string property)

com_propput

(PHP3 >= 3.0.3, PHP4 )

com_propput -- ???

Description

void com_propput (resource object, string property, mixed value)

com_propset

(PHP3 >= 3.0.3, PHP4 )

com_propset -- ???

Description

void com_propset (resource object, string property, mixed value)

This function is an alias for com_propput().

com_set

(PHP3 >= 3.0.3, PHP4 )

com_set -- ???

Description

void com_set (resource object, string property, mixed value)

This function is an alias for com_set().


VII. Class/Object Functions

Table of Contents
get_class_methods ¡¦ Returns an array of class methods' names
get_class_vars ¡¦ Returns an array of default properties of the class
get_object_vars ¡¦ Returns an array of object properties
method_exists ¡¦ Checks if the class method exists

get_class_methods

(PHP4 >= 4.0RC1)

get_class_methods -- Å¬·¡½ºÀÇ methods À̸§À» ¹è¿­·Î ¹ÝȯÇÑ´Ù.

Description

array get_class_methods (string class_name)

This function returns an array of method names defined for the class specified by class_name.

get_class_vars

(PHP4 >= 4.0RC1)

get_class_vars -- Å¬·¡½ºÀÇ default properties À̸§À» ¹è¿­·Î ¹ÝȯÇÑ´Ù.

Returns an array of default properties of the class

Description

array get_class_vars (string class_name)

This function will return an array of default properties of the class.

get_object_vars

(PHP4 >= 4.0RC1)

get_object_vars -- °´Ã¼(object)ÀÇ properties¸¦ ¹è¿­·Î ¹ÝȯÇÑ´Ù.

Description

array get_class_vars (object obj)

This function returns an array of object properties for the specified object obj.

method_exists

(PHP4 >= 4.0b2)

method_exists -- ÇØ´ç Ŭ·¡½ºÀÇ method °¡ Á¸ÀçÇϴ°¡¸¦ °Ë»çÇÑ´Ù.

Checks if the class method exists

Description

bool method_exists (object object, string method_name)

This function returns true if the method given by method_name has been defined for the given object, false otherwise.


VIII. ClibPDF functions

ClibPDF´Â PHP¿¡¼­ pdf ¹®¼­¸¦ ¸¸µé ¼ö ÀÖ°Ô ÇØ ÁØ´Ù. ÀÌ°ÍÀº FastIO¿¡¼­ ±¸ÇÒ ¼ö ÀÖÀ¸³ª ¹«·á(free software)´Â ¾Æ´Ï´Ù. ¿©·¯ºÐÀº ClibPDF¸¦ »ç¿ëÇϱâ Àü¿¡ ¶óÀ̼¾½º¸¦ ÀÚ¼¼È÷ ÀоîºÁ¾ß ÇÒ °ÍÀÌ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ÀÌ ¶óÀ̼¾½º¿¡ µ¿ÀÇÇϱ⸦ ¿øÇÏÁö ¾ÊÀ¸¸é Thomas MerzÀÇ pdflibÀÇ »ç¿ëÀ» °í·Á ÇÒ ¼öµµ ÀÖ´Ù. pdflibµµ ¿ª½Ã °­·ÂÇÑ ±â´ÉÀ» °¡Áö°í ÀÖ´Ù. ClibPDF´Â Thomas MerzÀÇ pdflib¿Í ±â´ÉÀ̳ª API°¡ ¸Å¿ì À¯»çÇÏÁö¸¸, FastIO¿¡ µû¸£¸é ClibPDF´Â ¹®¼­¸¦ ´õ ÀÛÀº Å©±â·Î ´õ ºü¸£°Ô ¸¸µé ¼ö ÀÖ´Ù°í ÇÑ´Ù. ClibPDF´Â pdflib »õ·Î¿î 2.0 ¹öÀü¿¡¼­ º¯È­µÈ °Í °°´Ù. °£´ÜÇÑ ¿¹Á¦(pdflib 2.0ÀÇ pdfclock.c¸¦ php ½ºÅ©¸³Æ®·Î °íÄ£ °Í)¿¡¼­´Â ½ÇÁúÀûÀÎ ¼ÓµµÀÇ Â÷ÀÌ´Â ¾ø¾ú´Ù. ¶ÇÇÑ ¾ÐÃà±â´ÉÀ» ²¨ ³õÀ¸¸é µÎ °³ÀÇ ÆÄÀÏ Å©±âµµ ºñ½ÁÇÏ´Ù.

¿©±âÀÇ ¼³¸éÀº ClibPDFÀÇ ¸Å´º¾ó°ú °°ÀÌ Àд °ÍÀÌ ÁÁÀ» °ÍÀÌ´Ù. ÀÌ ¸Å´º¾óÀº ¶óÀ̺귯¸®¿¡ ´ëÇÑ ´õ ÀÚ¼¼ÇÑ ¼³¸íÀ» ÇÏ°í ÀÖ´Ù. ClibPDFÀÇ ¸Å´º¾óÀÇ ³»¿ëÀ» ÀÌÇØ¿©¾ß ¿©·¯ºÐÀº PHP¿¡¼­ ÀÌ ¶óÀ̺귯¸®¸¦ »ç¿ëÇÒ ¼ö ÀÖÀ» °ÍÀÌ´Ù.

´ëºÎºÐÀÇ PHP ¸ðµâÀÇ ÇÔ¼öÀ̸§Àº ClibPDF °íÀ¯ÀÇ ÇÔ¼ö(pdflibµµ ¸¶Âù°¡Áö°í) À̸§°ú µ¿ÀÏÇÏ´Ù. cpdf_open() À» Á¦¿ÜÇÑ ¸ðµç ÇÔ¼öµéÀº ù ¹ø° Àμö·Î ÀÛ¾÷ÇÒ ¹®¼­ÀÇ ÇÚµéÀ» °¡Áö°Ô µÈ´Ù. ÇöÀç ClibPDF°¡ µ¿½Ã¿¡ ¿©·¯°³ÀÇ PDF ¹®¼­¸¦ ¸¸µéÁö ¸øÇϱ⠶§¹®¿¡ ÀÌ ÇÚµéÀº ³»ºÎÀûÀ¸·Î ¾Æ¹« Àǹ̰¡ ¾ø´Ù. ±×·¯³ª À̸¦ ½ÃÇèÇÏÁö´Â ¸»¶ó. ¾î¶² °á°ú°¡ ³ª¿ÃÁö ¾Ë ¼ö ¾ø´Ù. ´õ±¸³ª ¸ÖƼ ¾²·¹µå ȯ°æ¿¡¼­´Â Áß´ëÇÑ ¿À·ù°¡ »ý±æ ¼öµµ ÀÖ´Ù. ClibPDFÀÇ Á¦ÀÛÀÚ¿¡ µû¸£¸é ÀÌ ³»¿ëÀº ´ÙÀ½ ¹öÀü¿¡¼­ ¼öÁ¤µÉ °ÍÀ̶ó°í ÇÑ´Ù.(ÇöÀç ¹öÀüÀº 1.10ÀÌ´Ù.) ¿©·¯¹®¼­¸¦ µ¿½Ã¿¡ ¸¸µå´Â ±â´ÉÀÌ ÇÊ¿äÇÏ´Ù¸é pdflib moduleÀ» »ç¿ëÇϵµ·Ï Ç϶ó.

pdflib¿¡ ºñÇؼ­ ClibPDFÀÇ °¡Àå Å« ÀåÁ¡Àº pdf ¹®¼­¸¦ Àӽà ÆÄÀÏÀ» »ç¿ëÇÏÁö ¾Ê°í ¸Þ¸ð¸® »ó¿¡¼­ ¸¸µé ¼ö ÀÖ´Ù´Â Á¡ÀÌ´Ù. ¶ÇÇÑ ClibPDF´Â ¹Ì¸® Á¤ÀÇµÈ À¯´Ö ±æÀÌÀÇ ÁÂÇ¥¸¦ ³Ñ°ÜÁÙ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº ¸ÅÀ¯ Æí¸®ÇÑ ±â´ÉÀÌÁö¸¸ pdflib¿¡¼­µµ pdf_translate()¸¦ »ç¿ëÇÏ¸é ºñ½ÁÇÑ ±â´ÉÀ» ÇÒ ¼ö ÀÖ´Ù.

´ëºÎºÐÀÇ ÇÔ¼öµéÀº »ç¿ëÇϱ⠽±´Ù. °£´ÜÇÑ pdf ¹®¼­¸¦ Çϳª ¸¸µé¾îº¸¸é º°·Î ¾î·ÆÁö ¾Ê´Ù´Â °ÍÀ» ¾Ë ¼ö ÀÖÀ» °ÍÀÌ´Ù. ´ÙÀ½ ¿¹¸¦ º¸¸é ½±°Ô ½ÃÀÛÇÒ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº ÇÑ ÀåÂ¥¸® test.pdf¶ó´Â ÆÄÀÏÀ» ¸¸µå´Â °ÍÀÌ´Ù. ÀÌ ÆäÀÌÁö¿¡´Â ¿Ü°û¼± 30ptÀÇ "Times-Roman" ÆùÆ®ÀÇ text°¡ ¾²¿©Áø´Ù. ÀÌ text´Â ¹ØÁÙÀÌ ±×¾îÁø´Ù.

Example 1. Simple ClibPDF Example

  1 
  2 <?php
  3 $cpdf = cpdf_open(0);
  4 cpdf_page_init($cpdf, 1, 0, 595, 842);
  5 cpdf_add_outline($cpdf, 0, 0, 0, 1, "Page 1");
  6 cpdf_set_font($cpdf, "Times-Roman", 30, "WinAnsiEncoding");
  7 cpdf_set_text_rendering($cpdf, 1);
  8 cpdf_text($cpdf, "Times Roman outlined", 50, 750);
  9 cpdf_moveto($cpdf, 50, 740);
 10 cpdf_lineto($cpdf, 330, 740);
 11 cpdf_stroke($cpdf);
 12 cpdf_finalize($cpdf);
 13 Header("Content-type: application/pdf");
 14 cpdf_output_buffer($cpdf);
 15 cpdf_close($cpdf);
 16 ?>
 17     

pdflib ¹èÆ÷º»¿¡ º¸¸é ¾Æ³ª·Î±× ½Ã°è°¡ Æ÷ÇÔµÈ ¿©·¯ ÆäÀÌÁöÀÇ ¹®¼­¸¦ ¸¸µå´Â Á¶±ÝÀº º¹ÀâÇÑ ¿¹Á¦°¡ ÀÖ´Ù. ¿©±â ±× ¿¹Á¦¸¦ ClibPDF È®ÀåÀ» »ç¿ëÇÑ PHP·Î º¯È¯ÇÑ ¿¹°¡ ÀÖ´Ù.

Example 2. pdfclock example from pdflib 2.0 distribution

  1 
  2 <?php
  3 $radius = 200;
  4 $margin = 20;
  5 $pagecount = 40;
  6 
  7 $pdf = cpdf_open(0);
  8 cpdf_set_creator($pdf, "pdf_clock.php3");
  9 cpdf_set_title($pdf, "Analog Clock");
 10   
 11 while($pagecount-- > 0) {
 12   cpdf_page_init($pdf, $pagecount+1, 0, 2 * ($radius + $margin), 2 * ($radius + $margin), 1.0);
 13   
 14   cpdf_set_page_animation($pdf, 4, 0.5, 0, 0, 0);  /* wipe */
 15   
 16   cpdf_translate($pdf, $radius + $margin, $radius + $margin);
 17   cpdf_save($pdf);
 18   cpdf_setrgbcolor($pdf, 0.0, 0.0, 1.0);
 19   
 20   /* minute strokes */
 21   cpdf_setlinewidth($pdf, 2.0);
 22   for ($alpha = 0; $alpha < 360; $alpha += 6)
 23     {
 24     cpdf_rotate($pdf, 6.0);
 25     cpdf_moveto($pdf, $radius, 0.0);
 26     cpdf_lineto($pdf, $radius-$margin/3, 0.0);
 27     cpdf_stroke($pdf);
 28     }
 29   
 30   cpdf_restore($pdf);
 31   cpdf_save($pdf);
 32  
 33   /* 5 minute strokes */
 34   cpdf_setlinewidth($pdf, 3.0);
 35   for ($alpha = 0; $alpha < 360; $alpha += 30)
 36   {
 37     cpdf_rotate($pdf, 30.0);
 38     cpdf_moveto($pdf, $radius, 0.0);
 39     cpdf_lineto($pdf, $radius-$margin, 0.0);
 40     cpdf_stroke($pdf);
 41   }
 42 
 43   $ltime = getdate();
 44 
 45   /* draw hour hand */
 46   cpdf_save($pdf);
 47   cpdf_rotate($pdf, -(($ltime['minutes']/60.0) + $ltime['hours'] - 3.0) * 30.0);
 48   cpdf_moveto($pdf, -$radius/10, -$radius/20);
 49   cpdf_lineto($pdf, $radius/2, 0.0);
 50   cpdf_lineto($pdf, -$radius/10, $radius/20);
 51   cpdf_closepath($pdf);
 52   cpdf_fill($pdf);
 53   cpdf_restore($pdf);
 54 
 55   /* draw minute hand */
 56   cpdf_save($pdf);
 57   cpdf_rotate($pdf, -(($ltime['seconds']/60.0) + $ltime['minutes'] - 15.0) * 6.0);
 58   cpdf_moveto($pdf, -$radius/10, -$radius/20);
 59   cpdf_lineto($pdf, $radius * 0.8, 0.0);
 60   cpdf_lineto($pdf, -$radius/10, $radius/20);
 61   cpdf_closepath($pdf);
 62   cpdf_fill($pdf);
 63   cpdf_restore($pdf);
 64 
 65   /* draw second hand */
 66   cpdf_setrgbcolor($pdf, 1.0, 0.0, 0.0);
 67   cpdf_setlinewidth($pdf, 2);
 68   cpdf_save($pdf);
 69   cpdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0));
 70   cpdf_moveto($pdf, -$radius/5, 0.0);
 71   cpdf_lineto($pdf, $radius, 0.0);
 72   cpdf_stroke($pdf);
 73   cpdf_restore($pdf);
 74 
 75   /* draw little circle at center */
 76   cpdf_circle($pdf, 0, 0, $radius/30);
 77   cpdf_fill($pdf);
 78 
 79   cpdf_restore($pdf);
 80 
 81   cpdf_finalize_page($pdf, $pagecount+1);
 82 }
 83 
 84 cpdf_finalize($pdf);
 85 Header("Content-type: application/pdf");
 86 cpdf_output_buffer($pdf);
 87 cpdf_close($pdf);
 88 ?>
 89     

Table of Contents
cpdf_global_set_document_limits ¡¦ Sets document limits for any pdf document
cpdf_set_creator ¡¦ Sets the creator field in the pdf document
cpdf_set_title ¡¦ Sets the title field of the pdf document
cpdf_set_subject ¡¦ Sets the subject field of the pdf document
cpdf_set_keywords ¡¦ Sets the keywords field of the pdf document
cpdf_open ¡¦ Opens a new pdf document
cpdf_close ¡¦ Closes the pdf document
cpdf_page_init ¡¦ Starts new page
cpdf_finalize_page ¡¦ Ends page
cpdf_finalize ¡¦ Ends document
cpdf_output_buffer ¡¦ Outputs the pdf document in memory buffer
cpdf_save_to_file ¡¦ Writes the pdf document into a file
cpdf_set_current_page ¡¦ Sets current page
cpdf_begin_text ¡¦ Starts text section
cpdf_end_text ¡¦ ends text section
cpdf_show ¡¦ Output text at current position
cpdf_show_xy ¡¦ Output text at position
cpdf_text ¡¦ Output text with parameters
cpdf_set_font ¡¦ Select the current font face and size
cpdf_set_leading ¡¦ Sets distance between text lines
cpdf_set_text_rendering ¡¦ Determines how text is rendered
cpdf_set_horiz_scaling ¡¦ Sets horizontal scaling of text
cpdf_set_text_rise ¡¦ Sets the text rise
cpdf_set_text_matrix ¡¦ Sets the text matrix
cpdf_set_text_pos ¡¦ Sets text position
cpdf_set_char_spacing ¡¦ Sets character spacing
cpdf_set_word_spacing ¡¦ Sets spacing between words
cpdf_continue_text ¡¦ Output text in next line
cpdf_stringwidth ¡¦ Returns width of text in current font
cpdf_save ¡¦ Saves current enviroment
cpdf_restore ¡¦ Restores formerly saved enviroment
cpdf_translate ¡¦ Sets origin of coordinate system
cpdf_scale ¡¦ Sets scaling
cpdf_rotate ¡¦ Sets rotation
cpdf_setflat ¡¦ Sets flatness
cpdf_setlinejoin ¡¦ Sets linejoin parameter
cpdf_setlinecap ¡¦ Sets linecap aparameter
cpdf_setmiterlimit ¡¦ Sets miter limit
cpdf_setlinewidth ¡¦ Sets line width
cpdf_setdash ¡¦ Sets dash pattern
cpdf_moveto ¡¦ Sets current point
cpdf_rmoveto ¡¦ Sets current point
cpdf_curveto ¡¦ Draws a curve
cpdf_lineto ¡¦ Draws a line
cpdf_rlineto ¡¦ Draws a line
cpdf_circle ¡¦ Draw a circle
cpdf_arc ¡¦ Draws an arc
cpdf_rect ¡¦ Draw a rectangle
cpdf_closepath ¡¦ Close path
cpdf_stroke ¡¦ Draw line along path
cpdf_closepath_stroke ¡¦ Close path and draw line along path
cpdf_fill ¡¦ Fill current path
cpdf_fill_stroke ¡¦ Fill and stroke current path
cpdf_closepath_fill_stroke ¡¦ Close, fill and stroke current path
cpdf_clip ¡¦ Clips to current path
cpdf_setgray_fill ¡¦ Sets filling color to gray value
cpdf_setgray_stroke ¡¦ Sets drawing color to gray value
cpdf_setgray ¡¦ Sets drawing and filling color to gray value
cpdf_setrgbcolor_fill ¡¦ Sets filling color to rgb color value
cpdf_setrgbcolor_stroke ¡¦ Sets drawing color to rgb color value
cpdf_setrgbcolor ¡¦ Sets drawing and filling color to rgb color value
cpdf_add_outline ¡¦ Adds bookmark for current page
cpdf_set_page_animation ¡¦ Sets duration between pages
cpdf_import_jpeg ¡¦ Opens a JPEG image
cpdf_place_inline_image ¡¦ Places an image on the page
cpdf_add_annotation ¡¦ Adds annotation

cpdf_global_set_document_limits

(PHP4 >= 4.0b4)

cpdf_global_set_document_limits -- ¸ðµç pdf ¹®¼­¿¡ ´ëÇÑ Á¦ÇÑÀ» ¼³Á¤ÇÑ´Ù.

Description

void cpdf_global_set_document_limits (int maxpages, int maxfonts, int maximages, int maxannotations, int maxobjects)

The cpdf_global_set_document_limits() function sets several document limits. This function has to be called before cpdf_open() to take effect. It sets the limits for any document open afterwards.

See also cpdf_open().

cpdf_set_creator

cpdf_set_creator -- pdf ¹®¼­¿¡¼­ creator Çʵ带 ¼³Á¤ÇÑ´Ù.

Description

void cpdf_set_creator(string creator);

The cpdf_set_creator() function sets the creator of a pdf document.

See also cpdf_set_subject(), cpdf_set_title(), cpdf_set_keywords().

cpdf_set_title

cpdf_set_title -- pdf ¹®¼­¿¡¼­ title Çʵ带 ¼³Á¤ÇÑ´Ù.

Description

void cpdf_set_title(string title);

The cpdf_set_title() function sets the title of a pdf document.

See also cpdf_set_subject(), cpdf_set_creator(), cpdf_set_keywords().

cpdf_set_subject

cpdf_set_subject -- pdf ¹®¼­¿¡¼­ subject Çʵ带 ¼³Á¤ÇÑ´Ù.

Description

void cpdf_set_subject(string subject);

The cpdf_set_subject() function sets the subject of a pdf document.

See also cpdf_set_title(), cpdf_set_creator(), cpdf_set_keywords().

cpdf_set_keywords

cpdf_set_keywords -- pdf ¹®¼­¿¡¼­ keywords Çʵ带 ¼³Á¤ÇÑ´Ù.

Description

void cpdf_set_keywords(string keywords);

The cpdf_set_keywords() function sets the keywords of a pdf document.

See also cpdf_set_title(), cpdf_set_creator(), cpdf_set_subject().

cpdf_open

cpdf_open -- »õ pdf ¹®¼­¸¦ ¿¬´Ù.

Description

int cpdf_open(int compression, string filename);

The cpdf_open() function opens a new pdf document. The first parameter turns document compression on if it is unequal to 0. The second optional parameter sets the file in which the document is written. If it is omitted the document is created in memory and can either be written into a file with the cpdf_save_to_file() or written to standard output with cpdf_output_buffer().

Note: The return value will be needed in futher versions of ClibPDF as the first parameter in all other functions which are writing to the pdf document.

The ClibPDF library takes the filename "-" as a synonym for stdout. If PHP is compiled as an apache module this will not work because the way ClibPDF outputs to stdout does not work with apache. You can solve this problem by skipping the filename and using cpdf_output_buffer() to output the pdf document.

See also cpdf_close(), cpdf_output_buffer().

cpdf_close

cpdf_close -- pdf ¹®¼­¸¦ ´Ý´Â´Ù.

Description

void cpdf_close(int pdf document);

The cpdf_close() function closes the pdf document. This should be the last function even after cpdf_finalize(), cpdf_output_buffer() and cpdf_save_to_file().

See also cpdf_open().

cpdf_page_init

cpdf_page_init -- »õ page¸¦ ½ÃÀÛÇÑ´Ù.

Description

void cpdf_page_init(int pdf document, int page number, int orientation, double height, double width, double unit);

The cpdf_page_init() function starts a new page with height height and width width. The page has number page number and orientation orientation. orientation can be 0 for portrait and 1 for landscape. The last optional parameter unit sets the unit for the koordinate system. The value should be the number of postscript points per unit. Since one inch is equal to 72 points, a value of 72 would set the unit to one inch. The default is also 72.

See also cpdf_set_current_page().

cpdf_finalize_page

cpdf_finalize_page -- page¸¦ ³¡³½´Ù.

Description

void cpdf_finalize_page(int pdf document, int page number);

The cpdf_finalize_page() function ends the page with page number page number. This function is only for saving memory. A finalized page takes less memory but cannot be modified anymore.

See also cpdf_page_init().

cpdf_finalize

cpdf_finalize -- ¹®¼­¸¦ ³¡³½´Ù.

Description

void cpdf_finalize(int pdf document);

The cpdf_finalize() function ends the document. You still have to call cpdf_close().

See also cpdf_close().

cpdf_output_buffer

cpdf_output_buffer -- ¸Þ¸ð¸® ¹öÆÛÀÇ PDF ¹®¼­¸¦ Ãâ·ÂÇÑ´Ù.

Description

void cpdf_output_buffer(int pdf document);

The cpdf_output_buffer() function outputs the pdf document to stdout. The document has to be created in memory which is the case if cpdf_open() has been called with no filename parameter.

See also cpdf_open().

cpdf_save_to_file

cpdf_save_to_file -- PDF¹®¼­¸¦ ÆÄÀÏ·Î Ãâ·ÂÇÑ´Ù.

Description

void cpdf_save_to_file(int pdf document, string filename);

The cpdf_save_to_file() function outputs the pdf document into a file if it has been created in memory. This function is not needed if the pdf document has been open by specifying a filename as a parameter of cpdf_open().

See also cpdf_output_buffer(), cpdf_open().

cpdf_set_current_page

cpdf_set_current_page -- ÇöÀç page¸¦ ¼³Á¤ÇÑ´Ù.

Description

void cpdf_set_current_page(int pdf document, int page number);

The cpdf_set_current_page() function set the page on which all operations are performed. One can switch between pages until a page is finished with cpdf_finalize_page().

See also cpdf_finalize_page().

cpdf_begin_text

cpdf_begin_text -- text sectionÀ» ½ÃÀÛÇÑ´Ù.

Description

void cpdf_begin_text(int pdf document);

The cpdf_begin_text() function starts a text section. It must be ended with cpdf_end_text().

Example 1. Text output

<?php cpdf_begin_text($pdf);
cpdf_set_font($pdf, 16, "Helvetica", 4);
cpdf_text($pdf, 100, 100, "Some text");
cpdf_end_text($pdf) ?>

See also cpdf_end_text().

cpdf_end_text

cpdf_end_text -- text sectionÀ» ³¡³½´Ù.

Description

void cpdf_end_text(int pdf document);

The cpdf_end_text() function ends a text section which was started with cpdf_begin_text().

Example 1. Text output

<?php cpdf_begin_text($pdf);
cpdf_set_font($pdf, 16, "Helvetica", 4);
cpdf_text($pdf, 100, 100, "Some text");
cpdf_end_text($pdf) ?>

See also cpdf_begin_text().

cpdf_show

cpdf_show -- ÇöÀç À§Ä¡¿¡ text¸¦ Ãâ·ÂÇÑ´Ù.

Description

void cpdf_show(int pdf document, string text);

The cpdf_show() function outputs the string in text at the current position.

See also cpdf_text(), cpdf_begin_text(), cpdf_end_text().

cpdf_show_xy

cpdf_show_xy -- ÁöÁ¤ÇÑ À§Ä¡¿¡ text¸¦ Ãâ·ÂÇÑ´Ù.

Description

void cpdf_show_xy(int pdf document, string text, double x-koor, double y-koor, int mode);

The cpdf_show_xy() function outputs the string text at position with coordinates (x-koor, y-koor). The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

Note: The function cpdf_show_xy() is identical to cpdf_text().

See also cpdf_text().

cpdf_text

cpdf_text -- ÁöÁ¤µÈ ÆĶó¸ÞÅÍ´ë·Î text¸¦ Ãâ·ÂÇÑ´Ù.

Description

void cpdf_text(int pdf document, string text, double x-koor, double y-koor, int mode, double orientation, int alignmode);

The cpdf_text() function outputs the string text at position with coordinates (x-koor, y-koor). The optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit. The optional parameter orientation is the rotation of the text in degree. The optional parameter alignmode determines how the text is align. See the ClibPDF documentation for possible values.

See also cpdf_show_xy().

cpdf_set_font

cpdf_set_font -- ÇöÀç »ç¿ëÇÒ ÆùÆ® ¸ð¾ç°ú Å©±â¸¦ ¼±ÅÃÇÑ´Ù.

Description

void cpdf_set_font (int pdf document, string font name, double size, string encoding)

The cpdf_set_font() function sets the the current font face, font size and encoding. Currently only the standard postscript fonts are supported. The last parameter encoding can take the following values: "MacRomanEncoding", "MacExpertEncoding", "WinAnsiEncoding", and "NULL". "NULL" stands for the font's built-in encoding. See the ClibPDF Manual for more information, especially how to support asian fonts.

cpdf_set_leading

cpdf_set_leading -- text ÁÙ°£°ÝÀ» ÁöÁ¤ÇÑ´Ù.

Description

void cpdf_set leading(int pdf document, double distance);

The cpdf_set_leading() function sets the distance between text lines. This will be used if text is output by cpdf_continue_text().

See also cpdf_continue_text().

cpdf_set_text_rendering

cpdf_set_text_rendering -- textÀÇ rendering ¹æ¹ýÀ» °áÁ¤ÇÑ´Ù.

Description

void cpdf_set_text_rendering(int pdf document, int mode);

The cpdf_set_text_rendering() function determines how text is rendered. The possible values for mode are 0=fill text, 1=stroke text, 2=fill and stroke text, 3=invisible, 4=fill text and add it to cliping path, 5=stroke text and add it to clipping path, 6=fill and stroke text and add it to cliping path, 7=add it to clipping path.

cpdf_set_horiz_scaling

cpdf_set_horiz_scaling -- textÀÇ ¼öÆò È®´ë°ªÀ» Á¤ÇÑ´Ù.

Description

void cpdf_set_horiz_scaling(int pdf document, double scale);

The cpdf_set_horiz_scaling() function sets the horizontal scaling to scale percent.

cpdf_set_text_rise

cpdf_set_text_rise -- text¸¦ ¼Ú¾Æ ¿À¸¥ ¸ð¾ç(rise)À¸·Î ¸¸µç´Ù.

Description

void cpdf_set_text_rise(int pdf document, double value);

The cpdf_set_text_rise() function sets the text rising to value units.

cpdf_set_text_matrix

cpdf_set_text_matrix -- text¸¦ Çà¿­ÀÇ ÇüÅ·Π¼³Á¤ÇÑ´Ù.

Description

void cpdf_set_text_matrix(int pdf document, array matrix);

The cpdf_set_text_matrix() function sets a matrix which describes a transformation applied on the current text font.

cpdf_set_text_pos

cpdf_set_text_pos -- text À§Ä¡¸¦ Á¤ÇÑ´Ù.

Description

void cpdf_set_text_pos(int pdf document, double x-koor, double y-koor, int mode);

The cpdf_set_text_pos() function sets the position of text for the next cpdf_show() function call. The optional parameter mode

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

See also cpdf_show(), cpdf_text().

cpdf_set_char_spacing

cpdf_set_char_spacing -- ±ÛÀÚ°£ÀÇ °£°ÝÀ» Á¤ÇÑ´Ù.

Description

void cpdf_set_char_spacing(int pdf document, double space);

The cpdf_set_char_spacing() function sets the spacing between characters.

See also cpdf_set_word_spacing(), cpdf_set_leading().

cpdf_set_word_spacing

cpdf_set_word_spacing -- ´Ü¾î°£ÀÇ °£°ÝÀ» Á¤ÇÑ´Ù.

Description

void cpdf_set_word_spacing(int pdf document, double space);

The cpdf_set_word_spacing() function sets the spacing between words.

See also cpdf_set_char_spacing(), cpdf_set_leading().

cpdf_continue_text

cpdf_continue_text -- ´ÙÀ½ÁÙ¿¡ text¸¦ Ãâ·ÂÇÑ´Ù.

Description

void cpdf_continue_text(int pdf document, string text);

The cpdf_continue_text() function outputs the string in text in the next line.

See also cpdf_show_xy(), cpdf_text(), cpdf_set_leading(), cpdf_set_text_pos().

cpdf_stringwidth

cpdf_stringwidth -- ÇöÀç ÆùÆ®¸¦ »ç¿ëÇÑ ÇØ´ç textÀÇ ³ÐÀ̸¦ ¹ÝȯÇÑ´Ù.

Description

double cpdf_stringwidth(int pdf document, string text);

The cpdf_stringwidth() function returns the width of the string in text. It requires a font to be set before.

See also cpdf_set_font().

cpdf_save

cpdf_save -- ÇöÀçÀÇ È¯°æÀ» ÀúÀåÇÑ´Ù.

Description

void cpdf_save(int pdf document);

The cpdf_save() function saves the current enviroment. It works like the postscript command gsave. Very useful if you want to translate or rotate an object without effecting other objects.

See also cpdf_restore().

cpdf_restore

cpdf_restore -- ÀÌÀü¿¡ ÀúÀåÇß´ø ȯ°æÀ¸·Î Àç¼³Á¤ÇÑ´Ù.

Description

void cpdf_restore(int pdf document);

The cpdf_restore() function restores the enviroment saved with cpdf_save(). It works like the postscript command grestore. Very useful if you want to translate or rotate an object without effecting other objects.

Example 1. Save/Restore

<?php cpdf_save($pdf);
// do all kinds of rotations, transformations, ...
cpdf_restore($pdf) ?>

See also cpdf_save().

cpdf_translate

cpdf_translate -- ÁÂÇ¥ ½Ã½ºÅÛÀÇ ¿øÁ¡À» ÁöÁ¤ÇÑ´Ù.

Description

void cpdf_translate(int pdf document, double x-koor, double y-koor, int mode);

The cpdf_translate() function set the origin of coordinate system to the point (x-koor, y-koor).

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

cpdf_scale

cpdf_scale -- È­´ë/Ãà¼Ò°ªÀ» Á¤ÇÑ´Ù.

Description

void cpdf_scale(int pdf document, double x-scale, double y-scale);

The cpdf_scale() function set the scaling factor in both directions.

cpdf_rotate

cpdf_rotate -- ȸÀü Á¤µµ(rotation )¸¦ Á¤ÇÑ´Ù.

Description

void cpdf_rotate(int pdf document, double angle);

The cpdf_rotate() function set the rotation in degress to angle.

cpdf_setflat

cpdf_setflat -- flatness¸¦ Á¤ÇÑ´Ù.

Description

void cpdf_setflat(int pdf document, double value);

The cpdf_setflat() function set the flatness to a value between 0 and 100.

cpdf_setlinejoin

cpdf_setlinejoin -- linejoin ÆĶó¸ÞÅ͸¦ ¼³Á¤ÇÑ´Ù.

Description

void cpdf_setlinejoin(int pdf document, long value);

The cpdf_setlinejoin() function set the linejoin parameter between a value of 0 and 2. 0 = miter, 1 = round, 2 = bevel.

cpdf_setlinecap

cpdf_setlinecap -- linecap ÆĶó¸ÞÅ͸¦ ¼³Á¤ÇÑ´Ù.

Description

void cpdf_setlinecap(int pdf document, int value);

The cpdf_setlinecap() function set the linecap parameter between a value of 0 and 2. 0 = butt end, 1 = round, 2 = projecting square.

cpdf_setmiterlimit

cpdf_setmiterlimit -- miter ÇѰ踦 ¼³Á¤ÇÑ´Ù.

Description

void cpdf_setmiterlimit(int pdf document, double value);

The cpdf_setmiterlimit() function set the miter limit to a value greater or equal than 1.

cpdf_setlinewidth

cpdf_setlinewidth -- ÁÙÀÇ µÎ²²¸¦ Á¤ÇÑ´Ù.

Description

void cpdf_setlinewidth(int pdf document, double width);

The cpdf_setlinewidth() function set the line width to width.

cpdf_setdash

cpdf_setdash -- ¼±À̳ª Á¡¼±ÀÇ ÇüŸ¦ Á¤ÇÑ´Ù.

Description

void cpdf_setdash(int pdf document, double white, double black);

The cpdf_setdash() function set the dash pattern white white units and black black units. If both are 0 a solid line is set.

cpdf_moveto

cpdf_moveto -- ÇöÀç À§Ä¡¸¦ Á¤ÇÑ´Ù.

Description

void cpdf_moveto(int pdf document, double x-koor, double y-koor, int mode);

The cpdf_moveto() function set the current point to the coordinates x-koor and y-koor.

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

cpdf_rmoveto

cpdf_rmoveto -- ÇöÀç À§Ä¡¸¦ Á¤ÇÑ´Ù. (ÇöÀç À§Ä¡¿¡¼­ »ó´ëÀûÀÎ °ªÀ» ÁØ´Ù.)

Description

void cpdf_rmoveto(int pdf document, double x-koor, double y-koor, int mode);

The cpdf_rmoveto() function set the current point relative to the coordinates x-koor and y-koor.

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

See also cpdf_moveto().

cpdf_curveto

cpdf_curveto -- °î¼±À» ±×¸°´Ù.

Description

void cpdf_curveto(int pdf document, double x1, double y1, double x2, double y2, double x3, double y3, int mode);

The cpdf_curveto() function draws a Bezier curve from the current point to the point (x3, y3) using (x1, y1) and (x2, y2) as control points.

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

See also cpdf_moveto(), cpdf_rmoveto(), cpdf_rlineto(), cpdf_lineto().

cpdf_lineto

cpdf_lineto -- Á÷¼±À» ±×¸°´Ù.

Description

void cpdf_lineto(int pdf document, double x-koor, double y-koor, int mode);

The cpdf_lineto() function draws a line from the current point to the point with coordinates (x-koor, y-koor).

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

See also cpdf_moveto(), cpdf_rmoveto(), cpdf_curveto().

cpdf_rlineto

cpdf_rlineto -- Á÷¼±À» ±×¸°´Ù. (ÇöÀç À§Ä¡¿¡¼­ »ó´ëÀûÀÎ À§Ä¡°ªÀ¸·Î ±×¸°´Ù.)

Description

void cpdf_rlineto(int pdf document, double x-koor, double y-koor, int mode);

The cpdf_rlineto() function draws a line from the current point to the relative point with coordinates (x-koor, y-koor).

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

See also cpdf_moveto(), cpdf_rmoveto(), cpdf_curveto().

cpdf_circle

cpdf_circle -- À©À» ±×¸°´Ù.

Description

void cpdf_circle(int pdf document, double x-koor, double y-koor, double radius, int mode);

The cpdf_circle() function draws a circle with center at point (x-koor, y-koor) and radius radius.

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

See also cpdf_arc().

cpdf_arc

cpdf_arc -- ¿øÈ£¸¦ ±×¸°´Ù.

Description

void cpdf_arc(int pdf document, double x-koor, double y-koor, double radius, double start, double end, int mode);

The cpdf_arc() function draws an arc with center at point (x-koor, y-koor) and radius radius, starting at angle start and ending at angle end.

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

See also cpdf_circle().

cpdf_rect

cpdf_rect -- Á÷»ç°¢ÇüÀ» ±×¸°´Ù.

Description

void cpdf_rect(int pdf document, double x-koor, double y-koor, double width, double height, int mode);

The cpdf_rect() function draws a rectangle with its lower left corner at point (x-koor, y-koor). This width is set to widgth. This height is set to height.

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

cpdf_closepath

cpdf_closepath -- path¸¦ ´Ý´Â´Ù.

Description

void cpdf_closepath(int pdf document);

The cpdf_closepath() function closes the current path.

cpdf_stroke

cpdf_stroke -- path¸¦ µû¶ó ¼±À» ±×¸°´Ù.

Description

void cpdf_stroke(int pdf document);

The cpdf_stroke() function draws a line along current path.

See also cpdf_closepath(), cpdf_closepath_stroke().

cpdf_closepath_stroke

cpdf_closepath_stroke -- path¸¦ ´Ý°í ÇØ´ç path¿¡ µû¶ó ¼±À» ±×¸°´Ù.

Description

void cpdf_closepath_stroke(int pdf document);

The cpdf_closepath_stroke() function is a combination of cpdf_closepath() and cpdf_stroke(). Than clears the path.

See also cpdf_closepath(), cpdf_stroke().

cpdf_fill

cpdf_fill -- ÇöÀç pathÀÇ ³»ºÎ¸¦ ä¿î´Ù.

Description

void cpdf_fill(int pdf document);

The cpdf_fill() function fills the interior of the current path with the current fill color.

See also cpdf_closepath(), cpdf_stroke(), cpdf_setgray_fill(), cpdf_setgray(), cpdf_setrgbcolor_fill(), cpdf_setrgbcolor().

cpdf_fill_stroke

cpdf_fill_stroke -- ÇöÀç path¸¦ ä¿ì°í ¼±À» ±×¸°´Ù.

Description

void cpdf_fill_stroke(int pdf document);

The cpdf_fill_stroke() function fills the interior of the current path with the current fill color and draws current path.

See also cpdf_closepath(), cpdf_stroke(), cpdf_fill(), cpdf_setgray_fill(), cpdf_setgray(), cpdf_setrgbcolor_fill(), cpdf_setrgbcolor().

cpdf_closepath_fill_stroke

cpdf_closepath_fill_stroke -- ÇöÀç path¸¦ ´ÝÀº ÈÄ, ä¿ì°í ¼±À» ±×¸°´Ù.

Description

void cpdf_closepath_fill_stroke(int pdf document);

The cpdf_closepath_fill_stroke() function closes, fills the interior of the current path with the current fill color and draws current path.

See also cpdf_closepath(), cpdf_stroke(), cpdf_fill(), cpdf_setgray_fill(), cpdf_setgray(), cpdf_setrgbcolor_fill(), cpdf_setrgbcolor().

cpdf_clip

cpdf_clip -- ÇöÀç path¸¦ µû³½´Ù.(clip)

Description

void cpdf_clip(int pdf document);

The cpdf_clip() function clips all drawing to the current path.

cpdf_setgray_fill

cpdf_setgray_fill -- ä¿ì´Â »öÀ» Èæ¹é°ªÀ¸·Î Á¤ÇÑ´Ù.

Description

void cpdf_setgray_fill(int pdf document, double value);

The cpdf_setgray_fill() function sets the current gray value to fill a path.

See also cpdf_setrgbcolor_fill().

cpdf_setgray_stroke

cpdf_setgray_stroke -- (¼±À̳ª ±ÛÀÚ¸¦) ±×¸®´Â »öÀ» Èæ¹é°ªÀ¸·Î Á¤ÇÑ´Ù.

Description

void cpdf_setgray_stroke(int pdf document, double gray value);

The cpdf_setgray_stroke() function sets the current drawing color to the given gray value.

See also cpdf_setrgbcolor_stroke().

cpdf_setgray

cpdf_setgray -- ä¿ì´Â »ö°ú ±×¸®´Â »öÀÇ Èæ¹é°ª Á¤µµ¸¦ Á¤ÇÑ´Ù.

Description

void cpdf_setgray(int pdf document, double gray value);

The cpdf_setgray_stroke() function sets the current drawing and filling color to the given gray value.

See also cpdf_setrgbcolor_stroke(), cpdf_setrgbcolor_fill().

cpdf_setrgbcolor_fill

cpdf_setrgbcolor_fill -- ä¿ì´Â »öÀ» rgb color °ªÀ¸·Î Á¤ÇÑ´Ù.

Description

void cpdf_setrgbcolor_fill(int pdf document, double red value, double green value, double blue value);

The cpdf_setrgbcolor_fill() function sets the current rgb color value to fill a path.

See also cpdf_setrgbcolor_fill().

cpdf_setrgbcolor_stroke

cpdf_setrgbcolor_stroke -- ±×¸®´Â »öÀ» rgb color °ªÀ¸·Î Á¤ÇÑ´Ù.

Description

void cpdf_setrgbcolor_stroke(int pdf document, double red value, double green value, double blue value);

The cpdf_setrgbcolor_stroke() function sets the current drawing color to the given rgb color value.

See also cpdf_setrgbcolor_stroke().

cpdf_setrgbcolor

cpdf_setrgbcolor -- ä¿ì´Â »ö°ú ±×¸®´Â »öÀÇ rgb color °ªÀ» Á¤ÇÑ´Ù.

Description

void cpdf_setrgbcolor(int pdf document, double red value, double green value, double blue value);

The cpdf_setrgbcolor_stroke() function sets the current drawing and filling color to the given rgb color value.

See also cpdf_setrgbcolor_stroke(), cpdf_setrgbcolor_fill().

cpdf_add_outline

cpdf_add_outline -- ÇöÀç page¿¡ bookmark¸¦ Ãß°¡ÇÑ´Ù.

Description

void cpdf_add_outline(int pdf document, string text);

The cpdf_add_outline() function adds a bookmark with text text that points to the current page.

Example 1. Adding a page outline

<?php
$cpdf = cpdf_open(0);
cpdf_page_init($cpdf, 1, 0, 595, 842);
cpdf_add_outline($cpdf, 0, 0, 0, 1, "Page 1");
// ...
// some drawing
// ...
cpdf_finalize($cpdf);
Header("Content-type: application/pdf");
cpdf_output_buffer($cpdf);
cpdf_close($cpdf);
?>
    

cpdf_set_page_animation

cpdf_set_page_animation -- page°£¿¡ ³Ñ¾î°¡´Â ¹æ¹ýÀ» Á¤ÇÑ´Ù.

Description

void cpdf_set_page_animation(int pdf document, int transition, double duration);

The cpdf_set_page_animation() function set the transition between following pages.

The value of transition can be

0 for none,

1 for two lines sweeping across the screen reveal the page,

2 for multiple lines sweeping across the screen reveal the page,

3 for a box reveals the page,

4 for a single line sweeping across the screen reveals the page,

5 for the old page dissolves to reveal the page,

6 for the dissolve effect moves from one screen edge to another,

7 for the old page is simply replaced by the new page (default)

The value of duration is the number of seconds between page flipping.

cpdf_import_jpeg

cpdf_import_jpeg -- JPEG À̹ÌÁö¸¦ ¿¬´Ù.

Description

int cpdf_open_jpeg(int pdf document, string file name, double x-koor, double y-koor, double angle, double width, double height, double x-scale, double y-scale, int mode);

The cpdf_import_jpeg() function opens an image stored in the file with the name file name. The format of the image has to be jpeg. The image is placed on the current page at position (x-koor, y-koor). The image is rotated by angle degres.

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

See also cpdf_place_inline_image(),

cpdf_place_inline_image

cpdf_place_inline_image -- À̹ÌÁö¸¦ ÇØ´ç ÆäÀÌÁö¿¡ À§Ä¡½ÃŲ´Ù.

Description

void cpdf_place_inline_image(int pdf document, int image, double x-koor, double y-koor, double angle, double width, double height, int mode);

The cpdf_place_inline_image() function places an image created with the php image functions on the page at postion (x-koor, y-koor). The image can be scaled at the same time.

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.

See also cpdf_import_jpeg()

cpdf_add_annotation

cpdf_add_annotation -- ÁÖ¼®(annotation)À» ´Ü´Ù.

Description

void cpdf_add_annotation(int pdf document, double llx, double lly, double urx, double ury, string title, string content, int mode);

The cpdf_add_annotation() adds a note with the lower left corner at (llx, lly) and the upper right corner at (urx, ury).

The last optional parameter determines the unit length. If is 0 or omitted the default unit as specified for the page is used. Otherwise the koodinates are measured in postscript points disregarding the current unit.


IX. Cybercash payment functions

ÀÌ ÇÔ¼öµéÀº PHP¸¦ ÄÄÆÄÀÏÇÒ ¶§ --with-cybercash=[DIR] ¿É¼ÇÀ» ÁÖ°í ÄÄÆÄÀÏÇÑ °æ¿ì¿¡¸¸ »ç¿ë°¡´ÉÇÏ´Ù. ÀÌ ÇÔ¼öµéÀº PHP4¿¡ Ãß°¡µÇ¾ú´Ù.

Table of Contents
cybercash_encr ¡¦ ???
cybercash_decr ¡¦ ???
cybercash_base64_encode ¡¦ ???
cybercash_base64_decode ¡¦

cybercash_encr

(PHP4 >= 4.0b4)

cybercash_encr -- ???

Description

array cybercash_encr (string wmk, string sk, string inbuff)

The function returns an associative array with the elements "errcode" and, if "errcode" is false, "outbuff" (string), "outLth" (long) and "macbuff" (string).

cybercash_decr

(PHP4 >= 4.0b4)

cybercash_decr -- ???

Description

array cybercash_decr (string wmk, string sk, string inbuff)

The function returns an associative array with the elements "errcode" and, if "errcode" is false, "outbuff" (string), "outLth" (long) and "macbuff" (string).

cybercash_base64_encode

(PHP4 >= 4.0b4)

cybercash_base64_encode -- ???

Description

string cybercash_base64_encode (string inbuff)

cybercash_base64_decode

(PHP4 >= 4.0b4)

cybercash_base64_decode -- 

Description

string cybercash_base64_decode (string inbuff)

X. DOM XML functions

ÀÌ ÇÔ¼öµéÀº GNOME xml ¶óÀ̺귯¸®¸¦ »ç¿ëÇÏ°í, PHP¸¦ ¼³Á¤ÇÒ ¶§ --with-dom=[DIR] ¿É¼ÇÀ» ÁÖ¾úÀ» °æ¿ì¿¡¸¸ »ç¿ë°¡´ÉÇÏ´Ù. ÀÌ ÇÔ¼öµéÀº PHP4¿¡ Ãß°¡µÇ¾ú´Ù.

ÀÌ ¸ðµâÀº ´ÙÀ½°ú °°Àº »ó¼öµéÀ» ¹Ì¸® Á¤ÀÇÇØ ³õ°í ÀÖ´Ù.

Table 1. XML constants

Constant Value Description
XML_ELEMENT_NODE 1  
XML_ATTRIBUTE_NODE 2  
XML_TEXT_NODE 3  
XML_CDATA_SECTION_NODE 4  
XML_ENTITY_REF_NODE 5  
XML_ENTITY_NODE 6  
XML_PI_NODE 7  
XML_COMMENT_NODE 8  
XML_DOCUMENT_NODE 9  
XML_DOCUMENT_TYPE_NODE 10  
XML_DOCUMENT_FRAG_NODE 11  
XML_NOTATION_NODE 12  
XML_GLOBAL_NAMESPACE 1  
XML_LOCAL_NAMESPACE 2  

This module defines a number of classes. The DOM XML functions return a parsed tree of the XML document with each node being an object belonging to one of these classes.

Table of Contents
xmldoc ¡¦ Creates a DOM object of an XML document
xmldocfile ¡¦ Creates a DOM object from XML file
xmltree ¡¦ Creates a tree of php objects from XML document

xmldoc

(PHP4 >= 4.0b4)

xmldoc -- XML ¹®¼­·ÎºÎÅÍ DOM °´Ã¼¸¦ ¸¸µé¾î³½´Ù.

Description

object xmldoc (string str)

The function parses the XML document in str and returns an object of class "Dom document", having the properties "doc" (resource), "version" (string) and "type" (long).

xmldocfile

(PHP4 >= 4.0b4)

xmldocfile -- XML ÆÄÀϷκÎÅÍ DOM °´Ã¼¸¦ ¸¸µé¾î³½´Ù.

Description

object xmldocfile (string filename)

The function parses the XML document in the file named filename and returns an object of class "Dom document", having the properties "doc" (resource), "version" (string).

xmltree

(PHP4 >= 4.0b4)

xmltree --  XML ¹®¼­·ÎºÎÅÍ PHP °´Ã¼µéÀÇ tree¸¦ ¸¸µé¾î³½´Ù.

Description

object xmltree (string str)

The function parses the XML document in str and returns a tree PHP objects as the parsed document.


XI. Compression functions

ÀÌ ¸ðµâÀº gzip(.gz)À¸·Î ¾ÐÃàµÈ ÆÄÀÏÀ» Åõ¸íÇÏ°Ô(¾ÐÃàµÇÁö ¾ÊÀº °Íó·³) ÀÐ°í ¾²±â À§ÇØ Jean-loup Gailly¿Í Mark Adler¿¡ ÀÇÇÑ zlib >= 1.0.9 (http://www.cdrom.com/pub/infozip/zlib/) ÇÔ¼öµéÀ» »ç¿ëÇÑ´Ù.

ÀÌ ¸ðµâÀº (socketÀ» Á¦¿ÜÇÑ) ´ëºÎºÐÀÇ ÆÄÀÏ°ü¸®(filesystem)ÇÔ¼ö¿¡ gzip-¾ÐÃà°ú ¾ÐÃàÇØÁ¦ ±â´ÉÀ» ´õÇÑ ³»¿ëÀÇ ÇÔ¼öµéÀ» Á¦°øÇÑ´Ù.

¿¹Á¦

ÀÓ½ÃÆÄÀÏÀ» ¿­¾î ¹®ÀÚ¿­À» ¾´ ÈÄ¿¡, ±× ÆÄÀÏ¿¡ ÀÖ´Â ³»¿ëÀ» ´Ù¸¥ ¹æ¹ýÀ¸·Î µÎ ¹ø Ãâ·ÂÇÏ´Â ¿¹Á¦ÀÌ´Ù.

Example 1. Small Zlib example

  1 
  2 <?php
  3   $filename = tempnam('/tmp', 'zlibtest').'.gz';
  4   print "<html>\n<head></head>\n<body>\n<pre>\n";
  5   $s = "Only a test, test, test, test, test, test, test, test!\n";
  6   // open file for writing with maximum compression
  7   $zp = gzopen($filename, "w9");
  8   // write string to file
  9   gzwrite($zp, $s);
 10   // close file
 11   gzclose($zp);
 12   // open file for reading
 13   $zp = gzopen($filename, "r");
 14   // read 3 char
 15   print gzread($zp, 3);
 16   // output until end of the file and close it.
 17   gzpassthru($zp);
 18   print "\n";
 19   // open file and print content (the 2nd time).
 20   if (readgzfile($filename) != strlen($s)) {
 21           echo "Error with zlib functions!";
 22   }
 23   unlink($filename);
 24   print "</pre>\n</h1></body>\n</html>\n";
 25 ?>
 26 
Table of Contents
gzclose ¡¦ close an open gz-file pointer
gzeof ¡¦ test for end-of-file on a gz-file pointer
gzfile ¡¦ read entire gz-file into an array
gzgetc ¡¦ get character from gz-file pointer
gzgets ¡¦ get line from file pointer
gzgetss ¡¦ get line from gz-file pointer and strip HTML tags
gzopen ¡¦ open gz-file
gzpassthru ¡¦ output all remaining data on a gz-file pointer
gzputs ¡¦ write to a gz-file pointer
gzread ¡¦ Binary-safe gz-file read
gzrewind ¡¦ rewind the position of a gz-file pointer
gzseek ¡¦ seek on a gz-file pointer
gztell ¡¦ tell gz-file pointer read/write position
gzwrite ¡¦ Binary-safe gz-file write
readgzfile ¡¦ output a gz-file
gzcompress ¡¦ gz-compress a string
gzuncompress ¡¦ uncompress a gz-compressed string
 

gzclose

gzclose -- gz-file pointer¸¦ ´Ý´Â´Ù.

Description

int gzclose(int zp);

The gz-file pointed to by zp is closed.

Returns true on success and false on failure.

The gz-file pointer must be valid, and must point to a file successfully opened by gzopen().

gzeof

gzeof -- gz-file pointer°¡ end-of-file¿¡ Àִ°¡ °Ë»çÇÑ´Ù.

Description

int gzeof(int zp);

Returns true if the gz-file pointer is at EOF or an error occurs; otherwise returns false.

The gz-file pointer must be valid, and must point to a file successfully opened by gzopen().

gzfile

gzfile -- gz-fileÀÇ ³»¿ëÀ» ¹è¿­·Î Àд´Ù.

Description

array gzfile(string filename);

Identical to readgzfile(), except that gzfile() returns the file in an array.

See also readgzfile(), and gzopen().

gzgetc

gzgetc -- gz-file pointer¿¡¼­ ÇÑ ¹®ÀÚ¸¦ Àд´Ù.

Description

string gzgetc(int zp);

Returns a string containing a single (uncompressed) character read from the file pointed to by zp. Returns FALSE on EOF (as does gzeof()).

The gz-file pointer must be valid, and must point to a file successfully opened by gzopen().

See also gzopen(), and gzgets().

gzgets

gzgets -- gz-file pointer¿¡¼­ ÇÑ ÁÙÀ» Àд´Ù.

Description

string gzgets(int zp, int length);

Returns a (uncompressed) string of up to length - 1 bytes read from the file pointed to by fp. Reading ends when length - 1 bytes have been read, on a newline, or on EOF (whichever comes first).

If an error occurs, returns false.

The file pointer must be valid, and must point to a file successfully opened by gzopen().

See also gzopen(), and gzgetc().

gzgetss

gzgetss -- gz-file pointer¿¡¼­ ÇÑ ÁÙÀ» Àоî HTML tagµéÀ» stripÇÑ´Ù.

Description

string gzgetss(int zp, int length);

Identical to gzgets(), except that gzgetss attempts to strip any HTML and PHP tags from the text it reads.

See also gzgets(), and gzopen().

gzopen

gzopen -- gz-fileÀ» ¿¬´Ù.

Description

int gzopen(string filename, string mode);

Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen() ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman only compression as in "wb1h". (See the description of deflateInit2 in zlib.h for more information about the strategy parameter.)

Gzopen can be used to read a file which is not in gzip format; in this case gzread will directly read from the file without decompression.

Gzopen returns a file pointer to the file opened, after that, everything you read from this file descriptor will be transparently decompressed and what you write gets compressed.

If the open fails, the function returns false.

Example 1. gzopen() example

$fp = gzopen("/tmp/file.gz", "r");

See also gzclose().

gzpassthru

gzpassthru -- gz-file pointer¿¡¼­ºÎÅÍ µÚ¿¡ ³²¾ÆÀÖ´Â ¸ðµç µ¥ÀÌŸ¸¦ Ãâ·Â(output)ÇÑ´Ù.

Description

int gzpassthru(int zp);

Reads to EOF on the given gz-file pointer and writes the (uncompressed) results to standard output.

If an error occurs, returns false.

The file pointer must be valid, and must point to a file successfully opened by gzopen().

The gz-file is closed when gzpassthru() is done reading it (leaving zp useless).

gzputs

gzputs -- gz-file pointer¿¡ ¾´´Ù.

Description

int gzputs(int zp, string str, int [length]);

gzputs() is an alias to gzwrite(), and is identical in every way.

gzread

gzread -- gz-file¿¡¼­ ÀÌÁø µ¥ÀÌŸ·Î Àд´Ù.

Description

string gzread(int zp, int length);

gzread() reads up to length bytes from the gz-file pointer referenced by zp. Reading stops when length (uncompressed) bytes have been read or EOF is reached, whichever comes first.

// get contents of a gz-file into a string
$filename = "/usr/local/something.txt.gz";
$zd = gzopen( $filename, "r" );
$contents = gzread( $zd, 10000 );
gzclose( $zd );

See also gzwrite(), gzopen(), gzgets(), gzgetss(), gzfile(), and gzpassthru().

gzrewind

gzrewind -- gz-file pointerÀÇ À§Ä¡¸¦ ¸Ç ¾ÕÀ¸·Î °¡Á®°£´Ù.

Description

int gzrewind(int zp);

Sets the file position indicator for zp to the beginning of the file stream.

If an error occurs, returns 0.

The file pointer must be valid, and must point to a file successfully opened by gzopen().

See also gzseek() and gztell().

gzseek

gzseek -- gz-file pointer¸¦ ¿Å±ä´Ù.

Description

int gzseek(int zp, int offset);

Sets the file position indicator for the file referenced by zp to offset bytes into the file stream. Equivalent to calling (in C) gzseek( zp, offset, SEEK_SET ).

If the file is opened for reading, this function is emulated but can be extremely slow. If the file is opened for writing, only forward seeks are supported; gzseek then compresses a sequence of zeroes up to the new starting position.

Upon success, returns 0; otherwise, returns -1. Note that seeking past EOF is not considered an error.

See also gztell() and gzrewind().

gztell

gztell -- gz-file pointerÀÇ Àаí, ¾µ À§Ä¡¸¦ ¹ÝȯÇÑ´Ù.

Description

int gztell(int zp);

Returns the position of the file pointer referenced by zp; i.e., its offset into the file stream.

If an error occurs, returns false.

The file pointer must be valid, and must point to a file successfully opened by gzopen().

See also gzopen(), gzseek() and gzrewind().

gzwrite

gzwrite -- gz-file¿¡ ÀÌÁø µ¥ÀÌŸ¸¦ ¾´´Ù.

Description

int gzwrite(int zp, string string, int [length]);

gzwrite() writes the contents of string to the gz-file stream pointed to by zp. If the length argument is given, writing will stop after length (uncompressed) bytes have been written or the end of string is reached, whichever comes first.

Note that if the length argument is given, then the magic_quotes_runtime configuration option will be ignored and no slashes will be stripped from string.

See also gzread(), gzopen(), and gzputs().

readgzfile

readgzfile -- gz-fileÀ» Ãâ·Â(output)ÇÑ´Ù.

Description

int readgzfile(string filename);

Reads a file, decompresses it and writes it to standard output.

Readgzfile() can be used to read a file which is not in gzip format; in this case readgzfile() will directly read from the file without decompression.

Returns the number of (uncompressed) bytes read from the file. If an error occurs, false is returned and unless the function was called as @readgzfile, an error message is printed.

The file filename will be opened from the filesystem and its contents written to standard output.

See also gzpassthru(), gzfile(), and gzopen().

gzcompress

gzcompress -- ¹®ÀÚ¿­À» gz-¾ÐÃà(compress) ÇÑ´Ù.

Description

string gzcompress (string data [, int level])

This function returns a gzip-compressed version of the input data or false on errors. The optional parameter level can be given as 0 for no compression up to 9 for maximum compression.

See also gzuncompress().

gzuncompress

gzuncompress -- gz-¾ÐÃà(compress)µÈ ¹®ÀÚ¿­À» ÇØÁ¦(uncompress)ÇÑ´Ù.

Description

string gzcompress (string data [, int length])

This function takes data compressed by gzcompress() and returns the orignial uncompressed data or false on error. The function will return an error if the uncompressed data is more than 256 times the lenght of the compressed input data or more than the optional parameter length.

See also gzcompress().


XII. Database (dbm-style) abstraction layer functions

ÀÌ ÇÔ¼öµéÀº Berkeley DB ÇüÅÂÀÇ µ¥ÀÌÅͺ£À̽º¸¦ Á¢±ÙÇϱâ À§ÇÑ °ÍÀÌ´Ù.

ÀÌ°ÍÀº ¿©·¯ file-based µ¥ÀÌÅͺ£À̽ºÀÇ ÀϹÝÀûÀÎ abstraction layerÀÌ´Ù. ±â´ÉÀûÀ¸·Î ÀÌ°ÍÀº Sleepycat Software's DB2 °°Àº Çö´ëÀûÀÎ µ¥ÀÌÅͺ£À̽º ±â´ÉÀÇ ºÎºÐ ÁýÇÕ(subset)ÀÌ µÈ´Ù. (IBMÀÇ DB2¿Í È¥µ·ÇÏÁö ¸»±â ¹Ù¶õ´Ù. IBMÀÇ DB2´Â ODBC¸¦ ÅëÇØ Áö¿øµÈ´Ù.)

±âÃÊ°¡ µÇ´Â µ¥ÀÌÅͺ£À̽ºÀÇ ±¸Çö¿¡ µû¶ó ¾ó¸¶³ª ´Ù¾çÇÏ°Ô »ç¿ëµÉ ¼ö Àִ°¡°¡ °áÁ¤µÈ´Ù. dba_optimize()³ª dba_sync() °°Àº ÇÔ¼ö´Â ´ÜÁö ÇÑ µ¥ÀÌÅͺ£À̽º¿¡ ´ëÇØ ÀÛµ¿µÇ°í ´Ù¸¥ µ¥ÀÌÅͺ£À̽º¿¡ ´ëÇؼ­´Â ¾Æ¹« ¿µÇâÀ» ¹ÌÄ¡Áö ¸øÇÑ´Ù.

´ÙÀ½°ú °°Àº handler¸¦ Áö¿øÇÑ´Ù. :

Example 1. DBA example

  1 
  2 <?php
  3 
  4 $id = dba_open("/tmp/test.db", "n", "db2");
  5 
  6 if(!$id) {
  7     echo "dba_open failed\n";
  8     exit;
  9 }
 10 
 11 dba_replace("key", "This is an example!", $id);
 12 
 13 if(dba_exists("key", $id)) {
 14     echo dba_fetch("key", $id);
 15     dba_delete("key", $id);
 16 }
 17 
 18 dba_close($id);
 19 ?>
 20 

DBA´Â binary safeÇÏ°í ¾î¶² ¾î¶² arbitrary limitµµ °¡Áö°í ÀÖÁö ¾Ê´Ù. ÀÌ°ÍÀÇ Á¦ÇÑÀº ±âÃÊ°¡ µÇ´Â µ¥ÀÌÅͺ£À̽º ±¸Çö¿¡ µû¸¥ ÇÑ°è¿¡¼­ ¿Â °ÍÀÌ´Ù.

¸ðµç ÆÄÀÏ ±â¹Ý(file-based) µ¥ÀÌÅͺ£À̽º´Â »õ·Î ¸¸µé¾îÁø µ¥ÀÌÅͺ£À̽º¿¡ ´ëÇÏ¿© ÆÄÀÏ ¸ðµå¸¦ ÁöÁ¤ÇÏ´Â ¹æ¹ýÀ» Á¦°øÇØ¾ß ÇÑ´Ù. ÀϹÝÀûÀ¸·Î ÆÄÀÏ ¸ðµå´Â dba_open()À̳ª dba_popen()ÀÇ ³× ¹ø° Àμö·Î Àü´ÞÇÏ°Ô µÈ´Ù.

¿©·¯ºÐÀº dba_firstkey()°ú dba_nextkey()ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© Àüü µ¥ÀÌÅ͸¦ ¼øÂ÷ÀûÀ¸·Î Á¢±ÙÇÒ ¼ö ÀÖ´Ù. ±×¸®°í, µ¥ÀÌÅͺ£À̽º¸¦ Ž»öÇÏ´Â µ¿¾ÈÀº µ¥ÀÌÅͺ£À̽ºÀÇ ³»¿ëÀ» ¹Ù²Ü ¼ö ¾ø´Ù.

Example 2. Traversing a database

  1 
  2 <?php
  3 
  4 # ...open database...
  5 
  6 $key = dba_firstkey($id);
  7 
  8 while($key != false) {
  9     if(...) { # remember the key to perform some action later
 10         $handle_later[] = $key;
 11     }
 12     $key = dba_nextkey($id);
 13 }
 14 
 15 for($i = 0; $i < count($handle_later); $i++)
 16     dba_delete($handle_later[$i], $id);
 17 
 18 ?>
 19 	 

Table of Contents
dba_close ¡¦ Close database
dba_delete ¡¦ Delete entry specified by key
dba_exists ¡¦ Check whether key exists
dba_fetch ¡¦ Fetch data specified by key
dba_firstkey ¡¦ Fetch first key
dba_insert ¡¦ Insert entry
dba_nextkey ¡¦ Fetch next key
dba_popen ¡¦ Open database persistently
dba_open ¡¦ Open database
dba_optimize ¡¦ Optimize database
dba_replace ¡¦ Replace or insert entry
dba_sync ¡¦ Synchronize database

dba_close

dba_close -- µ¥ÀÌÅͺ£À̽º¸¦ ´Ý´Â´Ù.

Description

void dba_close(int handle);

dba_close() closes the established database and frees all resources specified by handle.

handle is a database handle returned by dba_open().

dba_close() does not return any value.

See also: dba_open() dba_popen()

dba_delete

dba_delete -- ÁöÁ¤µÈ key°ªÀ» °¡Áö´Â entry¸¦ Áö¿î´Ù.

Description

string dba_delete(string key, int handle);

dba_delete() deletes the entry specified by key from the database specified with handle.

key is the key of the entry which is deleted.

handle is a database handle returned by dba_open().

dba_delete() returns true or false, if the entry is deleted or not deleted, respectively.

See also: dba_exists() dba_fetch() dba_insert() dba_replace()

dba_exists

dba_exists -- ÁöÁ¤µÈ key°¡ Àִ°¡ °Ë»çÇÑ´Ù.

Description

bool dba_exists(string key, int handle);

dba_exists() checks whether the specified key exists in the database specified by handle.

key is the key the check is performed for.

handle is a database handle returned by dba_open().

dba_exists() returns true or false, if the key is found or not found, respectively.

See also: dba_fetch() dba_delete() dba_insert() dba_replace()

dba_fetch

dba_fetch -- ÁöÁ¤µÈ key°ªÀÇ data¸¦ °¡Á®¿Â´Ù.

Description

string dba_fetch(string key, int handle);

dba_fetch() fetches the data specified by key from the database specified with handle.

key is the key the data is specified by.

handle is a database handle returned by dba_open().

dba_fetch() returns the associated string or false, if the key/data pair is found or not found, respectively.

See also: dba_exists() dba_delete() dba_insert() dba_replace()

dba_firstkey

dba_firstkey -- ù ¹ø° keyÀÇ °ªÀ» °¡Á®¿Â´Ù.

Description

string dba_firstkey(int handle);

dba_firstkey() returns the first key of the database specified by handle and resets the internal key pointer. This permits a linear search through the whole database.

handle is a database handle returned by dba_open().

dba_firstkey() returns the key or false depending on whether it succeeds or fails, respectively.

See also: dba_nextkey()

dba_insert

dba_insert -- entry¸¦ »ðÀÔÇÑ´Ù.

Description

bool dba_insert(string key, string value, int handle);

dba_insert() inserts the entry described with key and value into the database specified by handle. It fails, if an entry with the same key already exists.

key is the key of the entry to be inserted.

value is the value to be inserted.

handle is a database handle returned by dba_open().

dba_insert() returns true or false, depending on whether it succeeds of fails, respectively.

See also: dba_exists() dba_delete() dba_fetch() dba_replace()

dba_nextkey

dba_nextkey -- ´ÙÀ½ key°ªÀ» °¡Á®¿Â´Ù.

Description

string dba_nextkey(int handle);

dba_nextkey() returns the next key of the database specified by handle and increments the internal key pointer.

handle is a database handle returned by dba_open().

dba_nextkey() returns the key or false depending on whether it succeeds or fails, respectively.

See also: dba_firstkey()

dba_popen

dba_popen -- µ¥ÀÌÅͺ£À̽º¸¦ ¿µ±¸ÀûÀ¸·Î ¿¬´Ù.

Description

int dba_popen(string path, string mode, string handler, [...]);

dba_popen() establishes a persistent database instance for path with mode using handler.

path is commonly a regular path in your filesystem.

mode is "r" for read access, "w" for read/write access to an already existing database, "c" for read/write access and database creation if it doesn't currently exist, and "n" for create, truncate and read/write access.

handler is the name of the handler which shall be used for accessing path. It is passed all optional parameters given to dba_popen() and can act on behalf of them.

dba_popen() returns a positive handler id or false, in the case the open is successful or fails, respectively.

See also: dba_open() dba_close()

dba_open

dba_open -- µ¥ÀÌÅͺ£À̽º¸¦ ¿¬´Ù.

Description

int dba_open(string path, string mode, string handler, [...]);

dba_open() establishes a database instance for path with mode using handler.

path is commonly a regular path in your filesystem.

mode is "r" for read access, "w" for read/write access to an already existing database, "c" for read/write access and database creation if it doesn't currently exist, and "n" for create, truncate and read/write access.

handler is the name of the handler which shall be used for accessing path. It is passed all optional parameters given to dba_open() and can act on behalf of them.

dba_open() returns a positive handler id or false, in the case the open is successful or fails, respectively.

See also: dba_popen() dba_close()

dba_optimize

dba_optimize -- µ¥ÀÌÅͺ£À̽º¸¦ ÃÖÀûÈ­(Optimize)ÇÑ´Ù.

Description

bool dba_optimize(int handle);

dba_optimize() optimizes the underlying database specified by handle.

handle is a database handle returned by dba_open().

dba_optimize() returns true or false, if the optimization succeeds or fails, respectively.

See also: dba_sync()

dba_replace

dba_replace -- entry¸¦ ´ëÄ¡(replace)Çϰųª »ðÀÔÇÑ´Ù.

Description

bool dba_replace(string key, string value, int handle);

dba_replace() replaces or inserts the entry described with key and value into the database specified by handle.

key is the key of the entry to be inserted.

value is the value to be inserted.

handle is a database handle returned by dba_open().

dba_replace() returns true or false, depending on whether it succeeds of fails, respectively.

See also: dba_exists() dba_delete() dba_fetch() dba_insert()

dba_sync

dba_sync -- µ¥ÀÌÅͺ£À̽º¸¦ µ¿±âÈ­(Synchronize)ÇÑ´Ù.

Description

bool dba_sync(int handle);

dba_sync() synchronizes the database specified by handle. This will probably trigger a physical write to disk, if supported.

handle is a database handle returned by dba_open().

dba_sync() returns true or false, if the synchronization succeeds or fails, respectively.

See also: dba_optimize()


XIII. Date and Time functions

Table of Contents
checkdate ¡¦ validate a date/time
date ¡¦ format a local time/date
getdate ¡¦ get date/time information
gettimeofday ¡¦ get current time
gmdate ¡¦ format a GMT/CUT date/time
gmmktime ¡¦ get UNIX timestamp for a GMT date
gmstrftime ¡¦ format a GMT/CUT time/date according to locale settings
localtime ¡¦ Get the local time
microtime ¡¦ return current UNIX timestamp with microseconds
mktime ¡¦ get UNIX timestamp for a date
strftime ¡¦ format a local time/date according to locale settings
time ¡¦ return current UNIX timestamp
strtotime ¡¦ Parse about any english textual datetime description into a UNIX timestamp

checkdate

checkdate -- date/time°ªÀÌ ¿Ã¹Ù¸¥°¡ °Ë»çÇÑ´Ù.

Description

int checkdate(int month, int day, int year);

Returns true if the date given is valid; otherwise returns false. Checks the validity of the date formed by the arguments. A date is considered valid if:

date

date -- local timeÀ» ÁöÁ¤µÈ ÇüÅ·Π¸¸µé¾î ¹ÝȯÇÑ´Ù.

Description

string date(string format, int timestamp);

Returns a string formatted according to the given format string using the given timestamp or the current local time if no timestamp is given.

The following characters are recognized in the format string:

Unrecognized characters in the format string will be printed as-is. The "Z" format will always return "0" when using gmdate().

Example 1. Date() example

  1 
  2 print (date ("l dS of F Y h:i:s A"));
  3 print ("July 1, 2000 is on a " . date ("l", mktime(0,0,0,7,1,2000)));
  4       

It is possible to use date() and mktime() together to find dates in the future or the past.

Example 2. Date() and mktime() example

  1 
  2 $tomorrow  = mktime (0,0,0,date("m")  ,date("d")+1,date("Y"));
  3 $lastmonth = mktime (0,0,0,date("m")-1,date("d"),  date("Y"));
  4 $nextyear  = mktime (0,0,0,date("m"),  date("d"),  date("Y")+1);
  5       

To format dates in other languages, you should use the setlocale() and strftime() functions.

See also gmdate() and mktime().

getdate

getdate -- date/time Á¤º¸¸¦ ¾ò´Â´Ù.

Description

array getdate(int timestamp);

Returns an associative array containing the date information of the timestamp as the following array elements:

gettimeofday

gettimeofday -- ÇöÀç ½Ã°¢À» ¾ò´Â´Ù.

Description

array gettimeofday(void);

This is an interface to gettimeofday(2). It returns an associative array containing the data returned from the system call.

gmdate

gmdate -- GMT/CUT date/timeÀ» ÁöÁ¤µÈ ÇüÅ·Π¸¸µé¾î ¹ÝȯÇÑ´Ù.

Description

string gmdate(string format, int timestamp);

Identical to the date() function except that the time returned is Greenwich Mean Time (GMT). For example, when run in Finland (GMT +0200), the first line below prints "Jan 01 1998 00:00:00", while the second prints "Dec 31 1997 22:00:00".

Example 1. Gmdate() example

  1 
  2 echo date ("M d Y H:i:s", mktime (0,0,0,1,1,1998));
  3 echo gmdate ("M d Y H:i:s", mktime (0,0,0,1,1,1998));
  4       

See also date(), mktime() and gmmktime().

gmmktime

gmmktime -- GMT ³¯Â¥¸¦ °¡Áö°í timestamp¸¦ ¸¸µç´Ù.

Description

int gmmktime(int hour, int minute, int second, int month, int day, int year);

Identical to mktime() except the passed parameters represents a GMT date.

gmstrftime

gmstrftime -- GMT/CUT time/date¸¦ locale ¼³Á¤¿¡ µû¸¥ ÇüÅ·Π¸¸µé¾î ¹ÝȯÇÑ´Ù.

Description

string gmstrftime(string format, int timestamp);

Behaves the same as strftime() except that the time returned is Greenwich Mean Time (GMT). For example, when run in Eastern Standard Time (GMT -0500), the first line below prints "Dec 31 1998 20:00:00", while the second prints "Jan 01 1999 01:00:00".

Example 1. Gmstrftime() example

  1 
  2 setlocale ('LC_TIME', 'en_US');
  3 echo strftime ("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n";
  4 echo gmstrftime ("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n";
  5       

See also strftime().

localtime

(PHP4 >= 4.0RC2)

localtime -- ÇöÀç Áö¿ªÀÇ ½Ã°£À» ¾ò´Â´Ù.

Description

array localtime ([int timestamp [, bool is_associative]])

The localtime() function returns an array identical to that of the structure returned by the C function call. The first argument to localtime() is the timestamp, if this is not given the current time is used. The second argument to the localtime() is the is_associative, if this is set to 0 or not supplied than the array is returned as a regular, numerically indexed array. If the argument is set to 1 then localtime() is an associative array containing all the different elements of the structure returned by the C function call to localtime. The names of the different keys of the associative array are as follows:

microtime

microtime -- ÇöÀç ½Ã°¢ÀÇ timestamp¸¦ 1000ºÐÀÇ 1ÃÊ ´ÜÀ§±îÁö ¹ÝȯÇÑ´Ù.

Description

string microtime(void);

Returns the string "msec sec" where sec is the current time measured in the number of seconds since the Unix Epoch (0:00:00 January 1, 1970 GMT), and msec is the microseconds part. This function is only available on operating systems that support the gettimeofday() system call.

See also time().

mktime

mktime -- ÁöÁ¤µÈ ³¯Â¥¸¦ date()ÇÔ¼ö µîÀÌ »ç¿ëÇÏ´Â timestamp·Î ¸¸µç´Ù.

Description

int mktime (int hour, int minute, int second, int month, int day, int year [, int is_dst])

Warning: Note the strange order of arguments, which differs from the order of arguments in a regular UNIX mktime() call and which does not lend itself well to leaving out parameters from right to left (see below). It is a common error to mix these values up in a script.

Returns the Unix timestamp corresponding to the arguments given. This timestamp is a long integer containing the number of seconds between the Unix Epoch (January 1 1970) and the time specified.

Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time.

Is_dst can be set to 1 if the time is during daylight savings time, 0 if it is not, or -1 (the default) if it is unknown whether the time is within daylight savings time or not.

Note: Is_dst was added in 3.0.10.

Mktime() is useful for doing date arithmetic and validation, as it will automatically calculate the correct value for out-of-range input. For example, each of the following lines produces the string "Jan-01-1998".

Example 1. Mktime() example

  1 
  2 echo date ("M-d-Y", mktime (0,0,0,12,32,1997));
  3 echo date ("M-d-Y", mktime (0,0,0,13,1,1997));
  4 echo date ("M-d-Y", mktime (0,0,0,1,1,1998));
  5 echo date ("M-d-Y", mktime (0,0,0,1,1,98));
  6       
Year may be a two or four digit value, with values between 0-69 mapping to 2000-2069 and 70-99 to 1970-1999 (on systems where time_t is a 32bit signed integer, as most common today, the valid range for year is somewhere between 1902 and 2037).

The last day of any given month can be expressed as the "0" day of the next month, not the -1 day. Both of the following examples will produce the string "The last day in Feb 2000 is: 29".

Example 2. Last day of next month

  1 
  2 $lastday = mktime (0,0,0,3,0,2000);
  3 echo strftime ("Last day in Feb 2000 is: %d", $lastday);
  4      
  5 $lastday = mktime (0,0,0,4,-31,2000);
  6 echo strftime ("Last day in Feb 2000 is: %d", $lastday);
  7       

( ¿ªÀÚÁÖ : ´ÙÀ½°ú °°ÀÌ date() ÇÔ¼ö¸¦ °°ÀÌ »ç¿ëÇÏ¸é °ú°Å³ª ¹Ì·¡ÀÇ Æ¯Á¤ÀÏÀ» ¾Ë ¼ö ÀÖ´Ù.
$tomorrow = mktime(0,0,0,date("d")+1,date("m"), date("Y"));
$lastmonth = mktime(0,0,0,date("d"),date("m")-1,date("Y"));
$nextyear = mktime(0,0,0,date("d"),date("m"),date("Y")+1); )

See also date() and time().

strftime

strftime -- ÇöÀç ½Ã°£/³¯Â¥¸¦ ÁöÁ¤ÇÑ ÇüÅ·Πº¯È¯ÇÑ´Ù.

Description

string strftime(string format, int timestamp);

Returns a string formatted according to the given format string using the given timestamp or the current local time if no timestamp is given. Month and weekday names and other language dependent strings respect the current locale set with setlocale().

The following conversion specifiers are recognized in the format string:

Example 1. Strftime() example

  1 
  2 setlocale ("LC_TIME", "C");
  3 print (strftime ("%A in Finnish is "));
  4 setlocale ("LC_TIME", "fi_FI");
  5 print (strftime ("%A, in French "));
  6 setlocale ("LC_TIME", "fr_CA");
  7 print (strftime ("%A and in German "));
  8 setlocale ("LC_TIME", "de_DE");
  9 print (strftime ("%A.\n"));
 10       

This example works if you have the respective locales installed in your system.

See also setlocale() and mktime() and the Open Group specification of strftime() .

time

time -- ÇöÀç ½Ã°¢ÀÇ timestamp¸¦ ¹ÝȯÇÑ´Ù.

Description

int time(void);

Returns the current time measured in the number of seconds since the Unix Epoch (January 1, 1970).

See also date().

strtotime

(PHP3 >= 3.0.12, PHP4 >= 4.0b2)

strtotime --  °¡´ÉÇÑ ¿©·¯ ÇüÅÂÀÇ ¿µ¹® ³¯Â¥/½Ã°£À» Ç¥½ÃÇÏ´Â ¹®ÀÚ¿­À» ºÐ¼®ÇÏ¿© UNIX timestamp·Î ¸¸µç´Ù.

Description

int strtotime (string time [, int now])

The function expects to be given a string containing an english date format and will try to parse that format into a UNIX timestamp.

Example 1. Strtotime() example

  1 
  2 echo strtotime ("10 march 2000") . "\n";
  3       


XIV. dBase functions

ÀÌ ÇÔ¼öµéÀº dBase ÇüÅÂÀÇ databse(dbf)¿¡ ÀúÀåµÈ ·¹ÄÚµåµéÀ» Á¢±ÙÇÒ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù.

index¿Í memo Çʵå´Â Áö¿øÇÏÁö ¾Ê´Â´Ù. ¶ÇÇÑ lockingµµ Áö¿øÇÏÁö ¾Ê´Â´Ù. µÎ °³ÀÇ À¥¼­¹ö ÇÁ·Î¼¼½º°¡ µ¿½Ã¿¡ °°Àº dBase ÆÄÀÏÀ» ¼öÁ¤ÇÏ·Á ÇÑ´Ù¸é, database ÀÚü°¡ ¸Á°¡Áú ¼öµµ ÀÖ´Ù.

SQL µ¥ÀÌÅͺ£À̽º¿Í ´Ù¸£°Ô dBase µ¥ÀÌÅͺ£À̽º´Â »ý¼ºÈÄ¿¡ ±× ±¸Á¶¸¦ ¹Ù²Ü ¼ö ¾ø´Ù. ÇÑ ÆÄÀÏÀÌ »ý¼ºµÇ¸é ÇØ´ç µ¥ÀÌÅͺ£À̽ºÀÇ ¼±¾ðÀº °íÁ¤µÈ´Ù. ¼Óµµ Çâ»ó µîÀ» À§ÇØ »ç¿ëÇÏ´Â indexµµ Áö¿øÇÏÁö ¾Ê´Â´Ù. dBase´Â °íÁ¤µÈ ±æÀÌÀÇ ·¹Äڵ带 °¡Áø ´Ü¼øÇÑ ¼øÂ÷ ÆÄÀÏÀÌ´Ù. »õ·¹ÄÚµå´Â ÆÄÀÏÀÇ ¸Ç µÚ¿¡ ºÙ°í, »èÁ¦µÈ ·¹ÄÚµå´Â dbase_pack()ÀÌ ¼öÇàµÇ±â Àü¿¡´Â µ¥ÀÌÅÍ ÀÚü´Â À¯ÁöµÈ´Ù.

¿ì¸®´Â dBase ÆÄÀÏÀº »ç¿ëÇÏÁö ¸»±â¸¦ ±ÇÇÑ´Ù. ´ë½Å ÁøÂ¥ SQL ¼­¹ö¸¦ »ç¿ëÇϱ⸦ ±ÇÇÑ´Ù. MySQLÀ̳ª PostgreSQLÀÌ PHP¿Í °°ÀÌ ¸¹¤· »ç¿ëµÈ´Ù. dBase Áö¿øÀº ´ÜÁö ¿©·¯ºÐÀÌ »ç¿ëÇÏ´Â µ¥ÀÌÅͺ£À̽º¿¡ µ¥ÀÌÅ͸¦ ÀоîµéÀ̰ųª ³»º¸³¾ ¶§¸¸ »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù. dBase Æ÷¸ËÀº ´ëºÎºÐÀÇ Windows¿ë ÇÁ·Î±×·¥ÀÌ »ç¿ë°¡´ÉÇÑ µ¥ÀÌÅÍ Æ÷¸ËÀ̱⠶§¹®ÀÌ´Ù.

Table of Contents
dbase_create ¡¦ creates a dBase database
dbase_open ¡¦ opens a dBase database
dbase_close ¡¦ close a dBase database
dbase_pack ¡¦ packs a dBase database
dbase_add_record ¡¦ add a record to a dBase database
dbase_replace_record ¡¦ replace a record in a dBase database
dbase_delete_record ¡¦ deletes a record from a dBase database
dbase_get_record ¡¦ gets a record from a dBase database
dbase_get_record_with_names ¡¦ Gets a record from a dBase databaseas an associative array
dbase_numfields ¡¦ find out how many fields are in a dBase database
dbase_numrecords ¡¦ find out how many records are in a dBase database

dbase_create

dbase_create -- dBase database¸¦ »ý¼ºÇÑ´Ù.

Description

int dbase_create(string filename, array fields);

The fields parameter is an array of arrays, each array describing the format of one field in the database. Each field consists of a name, a character indicating the field type, a length, and a precision.

The types of fields available are:

If the database is successfully created, a dbase_identifier is returned, otherwise false is returned.

Example 1. Creating a dBase database file

// "database" name
$dbname = "/tmp/test.dbf";
// database "definition"
$def =
    array(
        array("date",     "D"),
        array("name",     "C",  50),
        array("age",      "N",   3, 0),
        array("email",    "C", 128),
        array("ismember", "L")
    );
// creation
if (!dbase_create($dbname, $def))
    print "<strong>Error!</strong>";

dbase_open

dbase_open -- dBase database¸¦ ¿¬´Ù.

Description

int dbase_open(string filename, int flags);

The flags correspond to those for the open() system call. (Typically 0 means read-only, 1 means write-only, and 2 means read and write.)

Returns a dbase_identifier for the opened database, or false if the database couldn't be opened.

dbase_close

dbase_close -- dBase database¸¦ ´Ý´Â´Ù.

Description

bool dbase_close(int dbase_identifier);

Closes the database associated with dbase_identifier.

dbase_pack

dbase_pack -- dBase database¸¦ packÇÑ´Ù.

Description

bool dbase_pack(int dbase_identifier);

Packs the specified database (permanently deleting all records marked for deletion using dbase_delete_record().

dbase_add_record

dbase_add_record -- dBase database¿¡ ÇÑ record¸¦ ´õÇÑ´Ù.

Description

bool dbase_add_record(int dbase_identifier, array record);

Adds the data in the record to the database. If the number of items in the supplied record isn't equal to the number of fields in the database, the operation will fail and false will be returned.

dbase_replace_record

dbase_replace_record -- dBase databaseÀÇ ÇÑ ·¹ÄÚµåÀÇ ³»¿ëÀ» ¹Ù²Û´Ù.

Description

bool dbase_replace_record(int dbase_identifier, array record, int dbase_record_number);

Replaces the data associated with the record record_number with the data in the record in the database. If the number of items in the supplied record is not equal to the number of fields in the database, the operation will fail and false will be returned.

dbase_record_number is an integer which spans from 1 to the number of records in the database (as returned by dbase_numrecords()).

dbase_delete_record

dbase_delete_record -- dBase database¿¡¼­ ÇÑ record¸¦ »èÁ¦ÇÑ´Ù

Description

bool dbase_delete_record(int dbase_identifier, int record);

Marks record to be deleted from the database. To actually remove the record from the database, you must also call dbase_pack().

dbase_get_record

dbase_get_record -- dBase database¿¡¼­ ÇÑ record¸¦ Àоî¿Â´Ù.

Description

array dbase_get_record(int dbase_identifier, int record);

Returns the data from record in an array. The array is indexed starting at 0, and includes an associative member named 'deleted' which is set to 1 if the record has been marked for deletion (see dbase_delete_record().

Each field is converted to the appropriate PHP type. (Dates are left as strings.)

dbase_get_record_with_names

(PHP3 >= 3.0.4, PHP4 )

dbase_get_record_with_names --  dBase database¿¡¼­ ÇÑ record¸¦ associative ¹è¿­·Î Àоî¿Â´Ù.

Description

array dbase_get_record_with_names (int dbase_identifier, int record)

Returns the data from record in an associative array. The array also includes an associative member named 'deleted' which is set to 1 if the record has been marked for deletion (see dbase_delete_record()).

Each field is converted to the appropriate PHP type. (Dates are left as strings.)

dbase_numfields

dbase_numfields -- dBase databaseÀÇ fieldÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

int dbase_numfields(int dbase_identifier);

Returns the number of fields (columns) in the specified database. Field numbers are between 0 and dbase_numfields($db)-1, while record numbers are between 1 and dbase_numrecords($db).

Example 1. Using dbase_numfields()

  1 
  2 $rec = dbase_get_record($db, $recno);
  3 $nf  = dbase_numfields($db);
  4 for ($i=0; $i < $nf; $i++) {
  5     print $rec[$i]."<br>\n";
  6 }
  7       

dbase_numrecords

dbase_numrecords -- fdBase databaseÀÇ recordÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

int dbase_numrecords(int dbase_identifier);

Returns the number of records (rows) in the specified database. Record numbers are between 1 and dbase_numrecords($db), while field numbers are between 0 and dbase_numfields($db)-1.


XV. dbm functions

ÀÌ ÇÔ¼öµéÀº dbm ÇüÅÂÀÇ databse(dbf)¿¡ ÀúÀåµÈ ·¹ÄÚµåµéÀ» Á¢±ÙÇÒ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù. ÀÌ ÇüÅÂÀÇ database´Â Berkeley db, gdbm µî°ú ³»ÀåµÈ flatfile ¶óÀ̺귯¸® °°Àº ÀϺΠsystem ¶óÀ̺귯¸® µîÀÌ Áö¿øÇϴµ¥, ÀϹÝÀûÀÎ relational databases¿Í ´Þ¸® key/valueÀÇ ½ÖÀ¸·Î data¸¦ ÀúÀåÇÑ´Ù.

Example 1. dbm example

  1 
  2 $dbm = dbmopen("lastseen", "w");
  3 if (dbmexists($dbm, $userid)) {
  4   $last_seen = dbmfetch($dbm, $userid);
  5 } else {
  6   dbminsert($dbm, $userid, time());
  7 }
  8 do_stuff();
  9 dbmreplace($dbm, $userid, time());
 10 dbmclose($dbm);
 11 

Table of Contents
dbmopen ¡¦ opens a dbm database
dbmclose ¡¦ closes a dbm database
dbmexists ¡¦ tells if a value exists for a key in a dbm database
dbmfetch ¡¦ fetches a value for a key from a dbm database
dbminsert ¡¦ inserts a value for a key in a dbm database
dbmreplace ¡¦ replaces the value for a key in a dbm database
dbmdelete ¡¦ deletes the value for a key from a dbm database
dbmfirstkey ¡¦ retrieves the first key from a dbm database
dbmnextkey ¡¦ retrieves the next key from a dbm database
dblist ¡¦ describes the dbm-compatible library being used

dbmopen

dbmopen -- dbm database¸¦ ¿¬´Ù.

Description

int dbmopen(string filename, int flags);

The first argument is the full-path filename of the dbm file to be opened and the second is the file open mode which is one of "r", "n", "c" or "w" for read-only, new (implies read-write, and most likely will truncate an already-existing database of the same name), create (implies read-write, and will not truncate an already-existing database of the same name) and read-write respectively.

Returns an identifer to be passed to the other dbm functions on success, or false on failure.

If ndbm support is used, ndbm will actually create filename.dir and filename.pag files. gdbm only uses one file, as does the internal flat-file support, and Berkeley db creates a filename.db file. Note that PHP does its own file locking in addition to any file locking that may be done by the dbm library itself. PHP does not delete the .lck files it creates. It uses these files simply as fixed inodes on which to do the file locking. For more information on dbm files, see your Unix man pages, or obtain GNU's gdbm.

dbmclose

dbmclose -- dbm database¸¦ ´Ý´Â´Ù.

Description

bool dbmclose(int dbm_identifier);

Unlocks and closes the specified database.

dbmexists

dbmexists -- dbm database¿¡ ÁÖ¾îÁø key¿¡ ÇØ´çÇÏ´Â °ªÀÌ ÀÖ´ÂÁö ¾Ë¾Æº»´Ù.

Description

bool dbmexists(int dbm_identifier, string key);

Returns true if there is a value associated with the key.

dbmfetch

dbmfetch -- dbm database¿¡¼­ ÁÖ¾îÁø keyÀÇ value¸¦ Àоî¿Â´Ù.

Description

string dbmfetch(int dbm_identifier, string key);

Returns the value associated with key.

dbminsert

dbminsert -- dbm database¿¡ keyÀÇ value¸¦ »ðÀÔÇÑ´Ù.

Description

int dbminsert(int dbm_identifier, string key, string value);

Adds the value to the database with the specified key.

Returns -1 if the database was opened read-only, 0 if the insert was successful, and 1 if the specified key already exists. (To replace the value, use dbmreplace().)

dbmreplace

dbmreplace -- dbm database¿¡¼­ keyÀÇ value¸¦ ¹Ù²Û´Ù.

Description

bool dbmreplace(int dbm_identifier, string key, string value);

Replaces the value for the specified key in the database.

This will also add the key to the database if it didn't already exist.

dbmdelete

dbmdelete -- dbm database¿¡¼­ keyÀÇ value¸¦ »èÁ¦ÇÑ´Ù.

Description

bool dbmdelete(int dbm_identifier, string key);

Deletes the value for key in the database.

Returns false if the key didn't exist in the database.

dbmfirstkey

dbmfirstkey -- dbm databaseÀÇ Ã¹ ¹ø° key¸¦ °Ë»öÇÑ´Ù.

Description

string dbmfirstkey(int dbm_identifier);

Returns the first key in the database. Note that no particular order is guaranteed since the database may be built using a hash-table, which doesn't guarantee any ordering.

dbmnextkey

dbmnextkey -- dbm databaseÀÇ ´ÙÀ½ key¸¦ °Ë»öÇÑ´Ù.

Description

string dbmnextkey(int dbm_identifier, string key);

Returns the next key after key. By calling dbmfirstkey() followed by successive calls to dbmnextkey() it is possible to visit every key/value pair in the dbm database. For example:

Example 1. Visiting every key/value pair in a dbm database.

  1 
  2 $key = dbmfirstkey($dbm_id);
  3 while ($key) {
  4     echo "$key = " . dbmfetch($dbm_id, $key) . "\n";
  5     $key = dbmnextkey($dbm_id, $key);
  6 }
  7      

dblist

dblist -- »ç¿ëÁßÀÎ dbm-compatible library¿¡ ´ëÇÑ Á¤º¸¸¦ Ç¥½ÃÇÑ´Ù.

Description

string dblist(void);


XVI. Directory functions

Table of Contents
chdir ¡¦ change directory
dir ¡¦ directory class
closedir ¡¦ close directory handle
opendir ¡¦ open directory handle
readdir ¡¦ read entry from directory handle
rewinddir ¡¦ rewind directory handle

chdir

chdir -- ÇöÀç directory¸¦ ¹Ù²Û´Ù.

Description

int chdir(string directory);

Changes PHP's current directory to directory. Returns FALSE if unable to change directory, TRUE otherwise.

dir

dir -- directory class

Description

new dir(string directory);

A pseudo-object oriented mechanism for reading a directory. The given directory is opened. Two properties are available once directory has been opened. The handle property can be used with other directory functions such as readdir(), rewinddir() and closedir(). The path property is set to path the directory that was opened. Three methods are available: read, rewind and close.

Example 1. Dir() Example

  1 
  2 $d = dir("/etc");
  3 echo "Handle: ".$d->handle."<br>\n";
  4 echo "Path: ".$d->path."<br>\n";
  5 while($entry=$d->read()) {
  6     echo $entry."<br>\n";
  7 }
  8 $d->close();
  9       

closedir

closedir -- directory handleÀ» ´Ý´Â´Ù.

Description

void closedir(int dir_handle);

Closes the directory stream indicated by dir_handle. The stream must have previously been opened by opendir().

opendir

opendir -- directory handleÀ» ¿¬´Ù.

Description

int opendir(string path);

Returns a directory handle to be used in subsequent closedir(), readdir(), and rewinddir() calls.

readdir

readdir -- directory handle·Î ºÎÅÍ Ç׸ñÀ» Àоî¿Â´Ù.

Description

string readdir(int dir_handle);

Returns the filename of the next file from the directory. The filenames are not returned in any particular order.

Example 1. List all files in the current directory

  1 
  2 <?php
  3 $handle=opendir('.');
  4 echo "Directory handle: $handle\n";
  5 echo "Files:\n";
  6 while ($file = readdir($handle)) {
  7     echo "$file\n";
  8 }
  9 closedir($handle); 
 10 ?>
 11       

rewinddir

rewinddir -- directory handleÀ» directoryÀÇ ½ÃÀÛ À§Ä¡·Î µÇµ¹¸°´Ù.

Description

void rewinddir(int dir_handle);

Resets the directory stream indicated by dir_handle to the beginning of the directory.


XVII. Dynamic Loading functions

Table of Contents
dl ¡¦ load a PHP extension at runtime

dl

dl -- PHP extensionÀ» ½ÇÇàÁß¿¡ loadÇÑ´Ù.

Description

int dl(string library);

Loads the PHP extension defined in library. See also the extension_dir configuration directive.


XXVIII. Encryption functions

ÀÌ ÇÔ¼öµéÀº mcrypt¿Í °°ÀÌ µ¿ÀÛÇϱâÀ§ÇØ ¸¸µé¾ú´Ù.

ÀÌ°ÍÀº mcrypt ¶óÀ̺귯¸®¿¡ ´ëÇÑ ÀÎÅÍÆäÀ̽ºÀÌ´Ù. mcrypt´Â ´ÙÀ½°ú °°Àº ±¤¹üÀ§ÇÑ block ¾Ë°í¸®ÁòÀ» Áö¿øÇÑ´Ù. : DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and GOST in CBC, OFB, CFB and ECB cipher modes Ãß°¡·Î Áö¿øÇÏ´Â RC6¿Í IDEA´Â ¹«·á°¡ ¾Æ´Ï´Ù.

ÀÌ°ÍÀ» »ç¿ëÇϱâ À§Çؼ­´Â ¿ì¼± ftp://argeas.cs-net.gr/pub/unix/mcrypt/¿¡¼­ libmcrypt-x.x.tar.gzÀ» ´Ù¿î¹ÞÀº ÈÄ¿¡ Æ÷ÇÔµÈ ¼³Ä¡ ¼³¸í¼­ ´ë·Î ¼³Ä¡ÇÑ ÈÄ¿¡, PHP¸¦ --with-mcrypt ¼³Á¤À» ÁÖ¾î ÀÌ È®ÀåÀ» È°¼ºÈ­ÇÏ¿© ÄÄÆÄÀÏ ÇÏ¿©¾ß ÇÑ´Ù.

mcrypt´Â À§¿¡¼­ ¾ð±ÞµÈ ¾ÏÈ£¹æ½Ä(cipher)À¸·Î ¾ÏȣȭÇϰųª Çص¶ÇÒ ¼ö ÀÖ´Ù. mcrypt_cbc(), mcrypt_cfb(), mcrypt_ecb() mcrypt_ofb()ÀÇ ³×°¡Áö Áß¿äÇÑ mcrypt ¸í·ÉÀº °¢°¢ MCRYPT_ENCRYPT¿Í MCRYPT_DECRYPT·Î ¸í¸íµÈ µÎ°¡Áö ¸ðµå·Î µ¿ÀÛÇÑ´Ù.

Example 1. Encrypt an input value with TripleDES in ECB mode

  1 
  2 <?php
  3 $key = "this is a very secret key";
  4 $input = "Let us meet at 9 o'clock at the secret place.";
  5 
  6 $encrypted_data = mcrypt_ecb(MCRYPT_TripleDES, $key, $input, MCRYPT_ENCRYPT);
  7 ?>
  8      

À§ÀÇ ¿¹Á¦¿¡¼­ ¿©·¯ºÐÀº $encrypted_data¿¡ ¾ÏȣȭµÈ ¹®ÀÚ¿­ µ¥ÀÌÅ͸¦ ¾ò°Ô µÈ´Ù.

mcrypt´Â CBC, OFB, CFB, ECBÀÇ 4°¡Áö ¾ÏÈ£ ¸ðµå·Î µ¿ÀÛÇÑ´Ù. ¿©±â¼­´Â °³°³ÀÇ ¸ðµå¿¡ ´ëÇÑ °£·«ÇÑ ¼³¸í¸¸À» ÇÏ°Ú´Ù. º¸´Ù ÀÚ¼¼ÇÑ ³»¿ëÀº SchneierÀÇ Applied Cryptography (ISBN 0-471-11709-9)¸¦ º¸±â ¹Ù¶õ´Ù.

PHP´Â ÇöÀç bit stream¿¡ ´ëÇؼ­´Â ¾ÏȣȭÇϰųª Çص¶ÇÒ ¼ö ¾ø´Ù. ÇöÀçÀÇ PHP´Â ´ÜÁö ¹®ÀÚ¿­À» Áö¿øÇÒ »ÓÀÌ´Ù.

Áö¿øµÇ´Â ¾ÏÈ£¹æ½ÄÀÇ Àüü ¸®½ºÆ®´Â mcrypt.h ÆÄÀÏÀÇ ¸¶Áö¸·¿¡ ÀÖ´Ù. PHP¿¡¼­ ¾ÏÈ£¹æ½Ä(cipher)À» »ç¿ëÇÏ´Â ÀϹÝÀûÀÎ ¹ýÄ¢Àº "MCRYPT_¾ÏÈ£¹æ½ÄÀ̸§"ÀÇ ÇüÅÂÀÌ´Ù.

¾Æ·¡´Â ÇöÀç PHP/mcrypt¿¡¼­ Áö¿øÇÏ´Â ¾ÏÈ£¹æ½ÄÀÇ °£´ÜÇÑ ListÀÌ´Ù. mcrypt¿¡¼­ Áö¿øÇÑ´Ù°í Ç¥½ÃµÇ¾î ÀÖÀ¸³ª, ¿©±â¿¡ ³ª¿ÍÀÖÁö ¾ÊÀº °ÍÀº ÀÌ ¸Å´º¾ó ÀÌÈÄ¿¡ Ãß°¡·Î Áö¿øµÈ °ÍÀ̹ǷΠ¾È½ÉÇÏ°í »ç¿ëÇÏ¿©µµ µÈ´Ù.

CFB¿Í OFB ¸ðµå¿¡¼­´Â ¹Ýµå½Ã °¢°¢ÀÇ ¾Ïȣȭ ÇÔ¼ö¿¡ ´ëÇØ initialization vector (IV)¸¦ ÁÖ¾î¾ß ÇÑ´Ù. CBC ¸ðµå¿¡¼­´Â ¿É¼ÇÀ¸·Î ÁÙ ¼ö ÀÖ´Ù. IV´Â À¯ÀÏÇÏ¿©¾ß ÇÏ°í, ¾ÏÈ£/ÇØÁ¦½Ã¿¡ µ¿ÀÏÇÏ¿©¾ß ÇÑ´Ù. ¾ÏȣȭµÇ¾î ÀúÀåµÈ µ¥ÀÌÅ͸¦ °¡Áö°í, µ¥ÀÌÅÍ°¡ ÀúÀåµÈ°÷ÀÇ index¸¦ ¾î¶² ÇÔ¼ö¸¦ Àû¿ëÇÏ¿© ¿© ¾òÀº °ªÀ» »ç¿ëÇÒ ¼ö µµ ÀÖ´Ù. (¿¹, ÆÄÀÏÀ̸§ÀÇ MD5 Å°) ´Ù¸¥ ´ë¾ÈÀ¸·Î IV¸¦ ¾ÏȣȭµÈ µ¥ÀÌÅÍ¿Í ÇÔ²² º¸³»´Â ¹æ¹ýÀÌ ÀÖ´Ù. (¿©±â¿¡ ´ëÇؼ­´Â SchneierÀÇ Applied CryptographyÀÇ chapter 9.3À» º¸¶ó.)

Table of Contents
mcrypt_get_cipher_name Get the name of the specified cipher
mcrypt_get_block_size Get the block size of the specified cipher
mcrypt_get_key_size Get the key size of the specified cipher
mcrypt_create_iv Create an initialization vector (IV) from a random source
mcrypt_cbc Encrypt/decrypt data in CBC mode
mcrypt_cfb Encrypt/decrypt data in CFB mode
mcrypt_ecb Encrypt/decrypt data in ECB mode
mcrypt_ofb Encrypt/decrypt data in OFB mode

mcrypt_get_cipher_name

mcrypt_get_cipher_name -- ƯÁ¤ ¾ÏÈ£¹æ½Ä(cipher)ÀÇ À̸§À» ±¸ÇÑ´Ù.

Description

string mcrypt_get_cipher_name (int cipher)

Mcrypt_get_cipher_name() is used to get the name of the specified cipher.

Mcrypt_get_cipher_name() takes the cipher number as an argument and returns the name of the cipher or false, if the cipher does not exist.

Example 1. Mcrypt_get_cipher_name() example

  1 
  2 <?php
  3 $cipher = MCRYPT_TripleDES;
  4 
  5 print mcrypt_get_cipher_name ($cipher);
  6 ?>
  7       

The above example will produce:
  1 
  2 TripleDES
  3      

mcrypt_get_block_size

mcrypt_get_block_size -- ƯÁ¤ ¾ÏÈ£¹æ½Ä(cipher)ÀÇ ºí·Ï Å©±â¸¦ ±¸ÇÑ´Ù.

Description

int mcrypt_get_block_size(int cipher);

mcrypt_get_block_size() is used to get the size of a block of the specified cipher.

mcrypt_get_block_size() takes one argument, the cipher and returns the size in bytes.

See also: mcrypt_get_key_size()

mcrypt_get_key_size

mcrypt_get_key_size -- ƯÁ¤ ¾ÏÈ£¹æ½Ä(cipher)ÀÇ keyÀÇ ±æÀ̸¦ ±¸ÇÑ´Ù.

Description

int mcrypt_get_key_size(int cipher);

mcrypt_get_key_size() is used to get the size of a key of the specified cipher.

mcrypt_get_key_size() takes one argument, the cipher and returns the size in bytes.

See also: mcrypt_get_block_size()

mcrypt_create_iv

mcrypt_create_iv -- ·£´ý ¼Ò½º¿¡¼­ initialization vector(IV)¸¦ ¸¸µç´Ù.

Description

string mcrypt_create_iv (int size, int source)

Mcrypt_create_iv() is used to create an IV.

mcrypt_create_iv() takes two arguments, size determines the size of the IV, source specifies the source of the IV.

The source can be MCRYPT_RAND (system random number generator), MCRYPT_DEV_RANDOM (read data from /dev/random) and MCRYPT_DEV_URANDOM (read data from /dev/urandom). If you use MCRYPT_RAND, make sure to call srand() before to initialize the random number generator.

Example 1. Mcrypt_create_iv() example

  1 
  2 <?php
  3 $cipher = MCRYPT_TripleDES;
  4 $block_size = mcrypt_get_block_size ($cipher);
  5 $iv = mcrypt_create_iv ($block_size, MCRYPT_DEV_RANDOM);
  6 ?>
  7       

mcrypt_cbc

mcrypt_cbc -- CBC ¸ðµå·Î µ¥ÀÌÅ͸¦ ¾ÏȣȭÇϰųª ÇØÁ¦ ÇÑ´Ù.

Description

int mcrypt_cbc(int cipher, string key, string data, int mode, string [iv]);

mcrypt_cbc() encrypts or decrypts (depending on mode) the data with cipher and key in CBC cipher mode and returns the resulting string.

cipher is one of the MCRYPT_ciphername constants.

key is the key supplied to the algorithm. It must be kept secret.

data is the data which shall be encrypted/decrypted.

mode is MCRYPT_ENCRYPT or MCRYPT_DECRYPT.

iv is the optional initialization vector.

See also: mcrypt_cfb(), mcrypt_ecb(), mcrypt_ofb()

mcrypt_cfb

mcrypt_cfb -- CFB ¸ðµå·Î µ¥ÀÌÅ͸¦ ¾ÏȣȭÇϰųª ÇØÁ¦ ÇÑ´Ù.

Description

int mcrypt_cfb(int cipher, string key, string data, int mode, string iv);

mcrypt_cfb() encrypts or decrypts (depending on mode) the data with cipher and key in CFB cipher mode and returns the resulting string.

cipher is one of the MCRYPT_ciphername constants.

key is the key supplied to the algorithm. It must be kept secret.

data is the data which shall be encrypted/decrypted.

mode is MCRYPT_ENCRYPT or MCRYPT_DECRYPT.

iv is the initialization vector.

See also: mcrypt_cbc(), mcrypt_ecb(), mcrypt_ofb()

mcrypt_ecb

mcrypt_ecb -- ECB ¸ðµå·Î µ¥ÀÌÅ͸¦ ¾ÏȣȭÇϰųª ÇØÁ¦ ÇÑ´Ù.

Description

int mcrypt_ecb(int cipher, string key, string data, int mode);

mcrypt_ecb() encrypts or decrypts (depending on mode) the data with cipher and key in ECB cipher mode and returns the resulting string.

cipher is one of the MCRYPT_ciphername constants.

key is the key supplied to the algorithm. It must be kept secret.

data is the data which shall be encrypted/decrypted.

mode is MCRYPT_ENCRYPT or MCRYPT_DECRYPT.

See also: mcrypt_cbc(), mcrypt_cfb(), mcrypt_ofb()

mcrypt_ofb

mcrypt_ofb -- OFB ¸ðµå·Î µ¥ÀÌÅ͸¦ ¾ÏȣȭÇϰųª ÇØÁ¦ ÇÑ´Ù.

Description

int mcrypt_ofb(int cipher, string key, string data, int mode, string iv);

mcrypt_ofb() encrypts or decrypts (depending on mode) the data with cipher and key in OFB cipher mode and returns the resulting string.

cipher is one of the MCRYPT_ciphername constants.

key is the key supplied to the algorithm. It must be kept secret.

data is the data which shall be encrypted/decrypted.

mode is MCRYPT_ENCRYPT or MCRYPT_DECRYPT.

iv is the initialization vector.

See also: mcrypt_cbc(), mcrypt_cfb(), mcrypt_ecb()


XIX. filePro functions

ÀÌ ÇÔ¼öµéÀº filePro ÇüÅÂÀÇ databse(dbf)¿¡ ÀúÀåµÈ ·¹ÄÚµåµéÀ» read-only·Î Á¢±ÙÇÒ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù.

filePro´Â Fiserv, Inc.ÀÇ trademark·Î µî·ÏµÇ¾î ÀÖ´Ù. ¿©·¯ºÐÀº http://www.fileproplus.com/¿¡¼­ filePro¿¡ °üÇÑ ´õ ¸¹Àº Á¤º¸¸¦ ¾òÀ» ¼ö ÀÖ´Ù.

Table of Contents
filepro ¡¦ read and verify the map file
filepro_fieldname ¡¦ gets the name of a field
filepro_fieldtype ¡¦ gets the type of a field
filepro_fieldwidth ¡¦ gets the width of a field
filepro_retrieve ¡¦ retrieves data from a filePro database
filepro_fieldcount ¡¦ find out how many fields are in a filePro database
filepro_rowcount ¡¦ find out how many rows are in a filePro database

filepro

filepro -- map fileÆÄÀÏÀ» ÀÐ°í °ËÁõÇÑ´Ù.

Description

bool filepro(string directory);

This reads and verifies the map file, storing the field count and info.

No locking is done, so you should avoid modifying your filePro database while it may be opened in PHP.

filepro_fieldname

filepro_fieldname -- fieldÀÇ À̸§À» ±¸ÇÑ´Ù.

Description

string filepro_fieldname(int field_number);

Returns the name of the field corresponding to field_number.

filepro_fieldtype

filepro_fieldtype -- fieldÀÇ typeÀ» ±¸ÇÑ´Ù.

Description

string filepro_fieldtype(int field_number);

Returns the edit type of the field corresponding to field_number.

filepro_fieldwidth

filepro_fieldwidth -- fieldÀÇ Å©±â(width)¸¦ ±¸ÇÑ´Ù.

Description

int filepro_fieldwidth(int field_number);

Returns the width of the field corresponding to field_number.

filepro_retrieve

filepro_retrieve -- filePro database¿¡¼­ µ¥ÀÌŸ¸¦ °Ë»öÇÑ´Ù.

Description

string filepro_retrieve(int row_number, int field_number);

Returns the data from the specified location in the database.

filepro_fieldcount

filepro_fieldcount -- filePro databaseÀÇ fieldÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

int filepro_fieldcount(void);

Returns the number of fields (columns) in the opened filePro database.

See also filepro().

filepro_rowcount

filepro_rowcount -- filePro databaseÀÇ rowÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

int filepro_rowcount(void);

Returns the number of rows in the opened filePro database.

See also filepro().


XX. Filesystem functions

Table of Contents
basename ¡¦ return filename component of path
chgrp ¡¦ change file group
chmod ¡¦ change file mode
chown ¡¦ change file owner
clearstatcache ¡¦ clear file stat cache
copy ¡¦ copy file
delete ¡¦ a dummy manual entry
dirname ¡¦ return directory name component of path
diskfreespace ¡¦ return available space in directory
fclose ¡¦ close an open file pointer
feof ¡¦ test for end-of-file on a file pointer
fgetc ¡¦ get character from file pointer
fgetcsv ¡¦ get line from file pointer and parse for CSV fields
fgets ¡¦ get line from file pointer
fgetss ¡¦ get line from file pointer and strip HTML tags
file ¡¦ read entire file into an array
file_exists ¡¦ Check whether a file exists.
fileatime ¡¦ get last access time of file
filectime ¡¦ get inode change time of file
filegroup ¡¦ get file group
fileinode ¡¦ get file inode
filemtime ¡¦ get file modification time
fileowner ¡¦ get file owner
fileperms ¡¦ get file permissions
filesize ¡¦ get file size
filetype ¡¦ get file type
flock ¡¦ portable advisory file locking
fopen ¡¦ open file or URL
fpassthru ¡¦ output all remaining data on a file pointer
fputs ¡¦ write to a file pointer
fread ¡¦ Binary-safe file read
fseek ¡¦ seek on a file pointer
ftell ¡¦ tell file pointer read/write position
ftruncate ¡¦ Truncate a file to a given length.
fwrite ¡¦ Binary-safe file write
set_file_buffer ¡¦ Sets file buffering on the given file pointer
is_dir ¡¦ tells whether the filename is a directory
is_executable ¡¦ tells whether the filename is executable
is_file ¡¦ tells whether the filename is a regular file
is_link ¡¦ tells whether the filename is a symbolic link
is_readable ¡¦ tells whether the filename is readable
is_writeable ¡¦ tells whether the filename is writeable
link ¡¦ Create a hard link
linkinfo ¡¦ Get information about a link
mkdir ¡¦ make directory
pclose ¡¦ close process file pointer
popen ¡¦ open process file pointer
readfile ¡¦ output a file
readlink ¡¦ Return the target of a symbolic link
rename ¡¦ rename a file
rewind ¡¦ rewind the position of a file pointer
rmdir ¡¦ remove directory
stat ¡¦ give information about a file
lstat ¡¦ give information about a file or symbolic link
symlink ¡¦ Create a symbolic link
tempnam ¡¦ create unique file name
touch ¡¦ set modification time of file
umask ¡¦ changes the current umask
unlink ¡¦ Delete a file

basename

basename -- pathÁß name ºÎºÐÀ» ±¸ÇÑ´Ù.

Description

string basename(string path);

Given a string containing a path to a file, this function will return the base name of the file.

On Windows, both slash (/) and backslash (\) are used as path separator character. In other environments, it is the forward slash (/).

Example 1. basename() example

$path = "/home/httpd/html/index.php3";
$file = basename($path); // $file is set to "index.php3"

See also: dirname()

chgrp

chgrp -- ÆÄÀÏÀÇ groupÀ» ¹Ù²Û´Ù.

Description

int chgrp(string filename, mixed group);

Attempts to change the group of the file filename to group. Only the superuser may change the group of a file arbitrarily; other users may change the group of a file to any group of which that user is a member.

Returns true on success; otherwise returns false.

On Windows, does nothing and returns true.

See also chown() and chmod().

chmod

chmod -- ÆÄÀÏÀÇ mode¸¦ ¹Ù²Û´Ù.

Description

int chmod(string filename, int mode);

Attempts to change the mode of the file specified by filename to that given in mode.

Note that mode is not automatically assumed to be an octal value. To ensure the expected operation, you need to prefix mode with a zero (0):

chmod( "/somedir/somefile", 755 );   // decimal; probably incorrect
chmod( "/somedir/somefile", 0755 );  // octal; correct value of mode

Returns true on success and false otherwise.

See also chown() and chgrp().

chown

chown -- ÆÄÀÏÀÇ owner¸¦ ¹Ù²Û´Ù.

Description

int chown(string filename, mixed user);

Attempts to change the owner of the file filename to user user. Only the superuser may change the owner of a file.

Returns true on success; otherwise returns false.

NOTE: On Windows, does nothing and returns true.

See also chown() and chmod().

clearstatcache

clearstatcache -- ÆÄÀÏÀÇ stat cache¸¦ ¹Ù²Û´Ù.

Description

void clearstatcache(void);

Invoking the stat() or lstat() system call on most systems is quite expensive. Therefore, the result of the last call to any of the status functions (listed below) is stored for use on the next such call using the same filename. If you wish to force a new status check, for instance if the file is being checked many times and may change or disappear, use this function to clear the results of the last call from memory.

This value is only cached for the lifetime of a single request.

Affected functions include stat(), lstat(), file_exists(), is_writeable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), filectime(), fileatime(), filemtime(), fileinode(), filegroup(), fileowner(), filesize(), filetype(), and fileperms().

copy

copy -- ÆÄÀÏÀ» º¹»çÇÑ´Ù.

Description

int copy(string source, string dest);

Makes a copy of a file. Returns true if the copy succeeded, false otherwise.

Example 1. copy() example

if (!copy($file, $file.'.bak')) {
    print("failed to copy $file...<br>\n");
}

See also: rename()

delete

delete -- ½ÇÁ¦·Î´Â ¾ø´Â ¸í·É

Description

void delete(string file);

ÀÌ ¸í·ÉÀ» ã´Â »ç¶÷µéÀº ¾Æ¸¶ unlink()³ª unset() ¸í·ÉÀ» »ç¿ëÇÏ´Â ±â´ÉÀ» ¿øÇÒ °ÍÀÌ´Ù.

See also: ÆÄÀÏÀ» Áö¿ì±â À§Çؼ­´Â unlink(), º¯¼ö¸¦ Áö¿ì±â À§Çؼ­´Â unset()

dirname

dirname -- pathÀÇ DirectoryºÎºÐÀ» µ¹·ÁÁØ´Ù.

Description

string dirname(string path);

Given a string containing a path to a file, this function will return the name of the directory.

On Windows, both slash (/) and backslash (\) are used as path separator character. In other environments, it is the forward slash (/).

Example 1. dirname() example

$path = "/etc/passwd";
$file = dirname($path); // $file is set to "/etc"

See also: basename()

diskfreespace

diskfreespace -- ÇØ´ç µð·ºÅ丮¿¡ ÀúÀå °¡´ÉÇÑ ³²Àº ¿ë·®À» ¹ÝȯÇÑ´Ù.

Description

float diskfreespace(string directory);

Given a string containing a directory, this function will return the number of bytes available on the corresponding disk.

Example 1. diskfreespace() example

$df = diskfreespace("/"); // $df contains the number of bytes available on "/"

fclose

fclose -- ÁöÁ¤µÈ file pointer¸¦ ´Ý´Â´Ù.

Description

int fclose(int fp);

The file pointed to by fp is closed.

Returns true on success and false on failure.

The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen().

feof

feof -- file pointer°¡ end-of-file¿¡ Àִ°¡ °Ë»çÇÑ´Ù.

Description

int feof(int fp);

Returns true if the file pointer is at EOF or an error occurs; otherwise returns false.

The file pointer must be valid, and must point to a file successfully opened by fopen(), popen(), or fsockopen().

fgetc

fgetc -- file pointer¿¡¼­ ¹®ÀÚ¸¦ Àд´Ù.

Description

string fgetc(int fp);

Returns a string containing a single character read from the file pointed to by fp. Returns FALSE on EOF (as does feof()).

The file pointer must be valid, and must point to a file successfully opened by fopen(), popen(), or fsockopen().

See also fread(), fopen(), popen(), fsockopen(), and fgets().

fgetcsv

fgetcsv -- ÆÄÀÏÀÇ ÇöÀç À§Ä¡¿¡¼­ CSV Çʵå·Î µÈ ÁÙÀ» Àоî¿Í¼­ parseÇÑ´Ù.

Description

array fgetcsv(int fp, int length, string [delimiter]);

Similar to fgets() except that fgetcsv() parses the line it reads for fields in CSV format and returns an array containing the fields read. The field delimiter is a comma, unless you specifiy another delimiter with the optional third parameter.

fp must be a valid file pointer to a file successfully opened by fopen(), popen(), or fsockopen()

length must be greater than the longest line to be found in the CSV file (allowing for trailing line-end characters).

fgetcsv() returns false on error, including end of file.

NB A blank line in a CSV file will be returned as an array comprising just one single null field, and will not be treated as an error.

Example 1. fgetcsv() example - Read and print entire contents of a CSV file

$row=1;
$fp = fopen("test.csv","r");
while ($data = fgetcsv($fp,1000)) {
        $num = count($data);
        print "<p> $num fields in line $row: <br>";
        $row++;
        for ( $c=0; $c<$num; $c++ ) print $data[$c] . "<br>";
}
fclose($fp);

fgets

fgets -- file pointer¿¡¼­ ÇÑ ÁÙÀ» ÀÐ¾î ¿Â´Ù.

Description

string fgets(int fp, int length);

Returns a string of up to length - 1 bytes read from the file pointed to by fp. Reading ends when length - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first).

If an error occurs, returns false.

Common Pitfalls:

People used to the 'C' semantics of fgets should note the difference in how EOF is returned.

The file pointer must be valid, and must point to a file successfully opened by fopen(), popen(), or fsockopen().

A simple example follows:

Example 1. Reading a file line by line

$fd = fopen("/tmp/inputfile.txt", "r");
while ($buffer = fgets($fd, 4096)) {
  echo $buffer;
}
fclose($fd);

See also fread(), fopen(), popen(), fgetc(), and fsockopen().

fgetss

fgetss -- file pointer¿¡¼­ ÇÑ ÁÙÀ» Àоî¿Í HTML tagµéÀ» stripÇÑ´Ù.

Description

string fgetss(int fp, int length);

Identical to fgets(), except that fgetss attempts to strip any HTML and PHP tags from the text it reads.

See also fgets(), fopen(), fsockopen(), popen(), and strip_tags().

file

file -- ÆÄÀÏ Àüü¸¦ Àо ¹è¿­¿¡ ÀúÀåÇÑ´Ù.

Description

array file(string filename);

Identical to readfile(), except that file() returns the file in an array. Each element of the array corresponds to a line in the file, with the newline still attached.

See also readfile(), fopen(), and popen().

file_exists

file_exists -- ÆÄÀÏÀÌ Á¸ÀçÇÏ´ÂÁö °Ë»çÇÑ´Ù.

Description

int file_exists(string filename);

Returns true if the file specified by filename exists; false otherwise.

The results of this function are cached. See clearstatcache() for more details.

fileatime

fileatime -- ÆÄÀÏ¿¡ ¸¶Áö¸·À¸·Î Á¢±ÙÇÑ ½Ã°£À» ±¸ÇÑ´Ù.

Description

int fileatime(string filename);

Returns the time the file was last accessed, or false in case of an error.

The results of this function are cached. See clearstatcache() for more details.

filectime

filectime -- ÆÄÀÏÀÇ inode°¡ º¯°æµÈ ½Ã°£À» ±¸ÇÑ´Ù.

Description

int filectime(string filename);

Returns the time the file was last changed, or false in case of an error.

The results of this function are cached. See clearstatcache() for more details.

filegroup

filegroup -- ÆÄÀÏÀÇ groupÀ» ±¸ÇÑ´Ù.

Description

int filegroup(string filename);

Returns the group ID of the owner of the file, or false in case of an error.

The results of this function are cached. See clearstatcache() for more details.

fileinode

fileinode -- ÆÄÀÏÀÇ inode¸¦ ±¸ÇÑ´Ù.

Description

int fileinode(string filename);

Returns the inode number of the file, or false in case of an error.

The results of this function are cached. See clearstatcache() for more details.

filemtime

filemtime -- ÆÄÀÏÀÌ ¼öÁ¤µÈ ½Ã°£À» ±¸ÇÑ´Ù.

Description

int filemtime(string filename);

Returns the time the file was last modified, or false in case of an error.

The results of this function are cached. See clearstatcache() for more details. error.

fileowner

fileowner -- ÆÄÀÏÀÇ owner¸¦ ±¸ÇÑ´Ù.

Description

int fileowner(string filename);

Returns the user ID of the owner of the file, or false in case of an error.

The results of this function are cached. See clearstatcache() for more details. error.

fileperms

fileperms -- ÆÄÀÏÀÇ permissionÀ» ±¸ÇÑ´Ù.

Description

int fileperms(string filename);

Returns the permissions on the file, or false in case of an error.

The results of this function are cached. See clearstatcache() for more details.

filesize

filesize -- ÆÄÀÏÀÇ Å©±â¸¦ ±¸ÇÑ´Ù.

Description

int filesize(string filename);

Returns the size of the file, or false in case of an error.

The results of this function are cached. See clearstatcache() for more details.

filetype

filetype -- ÆÄÀÏÀÇ typeÀ» ±¸ÇÑ´Ù.

Description

string filetype(string filename);

Returns the type of the file. Possible values are fifo, char, dir, block, link, file, and unknown.

Returns false if an error occurs.

The results of this function are cached. See clearstatcache() for more details.

flock

flock -- portable ÆÄÀÏ locking

Description

bool flock(int fp, int operation);

PHP supports a portable way of locking complete files in an advisory way (which means all accessing programs have to use the same way of locking or it will not work).

flock() operates on fp which must be an open file pointer. operation is one of the following values:

flock() allows you to perform a simple reader/writer model which can be used on virtually every platform (including most Unices and even Windows).

flock() returns true on success and false on error (e.g. when a lock could not be acquired).

fopen

fopen -- ÆÄÀÏÀ̳ª URLÀ» ¿¬´Ù.

Description

int fopen(string filename, string mode);

If filename begins with "http://" (not case sensitive), an HTTP 1.0 connection is opened to the specified server and a file pointer is returned to the beginning of the text of the response.

Does not handle HTTP redirects, so you must include trailing slashes on directories.

If filename begins with "ftp://" (not case sensitive), an ftp connection to the specified server is opened and a pointer to the requested file is returned. If the server does not support passive mode ftp, this will fail. You can open files for either reading and writing via ftp (but not both simultaneously).

If filename begins with anything else, the file will be opened from the filesystem, and a file pointer to the file opened is returned.

If the open fails, the function returns false.

mode may be any of the following:

As well, mode may contain the letter 'b'. This is useful only on systems which differentiate between binary and text files (i.e., it's useless on Unix). If not needed, this will be ignored.

Example 1. fopen() example

$fp = fopen("/home/rasmus/file.txt", "r");
$fp = fopen("http://www.php.net/", "r");
$fp = fopen("ftp://user:password@example.com/", "w");

If you are experiencing problems with reading and writing to files and you're using the server module version of PHP, remember to make sure that the files and directories you're using are accessible to the server process.

On the Windows platform, be careful to escape any backslashes used in the path to the file, or use forward slashes.

$fp = fopen("c:\\data\\info.txt", "r");

See also fclose(), fsockopen(), and popen().

fpassthru

fpassthru -- file pointer¿¡¼­ºÎÅÍ ³²¾Æ ÀÖ´Â ¸ðµç µ¥ÀÌŸ¸¦ Ãâ·ÂÇÑ´Ù.

Description

int fpassthru(int fp);

Reads to EOF on the given file pointer and writes the results to standard output.

If an error occurs, fpassthru() returns false.

The file pointer must be valid, and must point to a file successfully opened by fopen(), popen(), or fsockopen(). The file is closed when fpassthru() is done reading it (leaving fp useless).

If you just want to dump the contents of a file to stdout you may want to use the readfile(), which saves you the fopen() call.

See also readfile(), fopen(), popen(), and fsockopen()

fputs

fputs -- file pointer¿¡ ¾´´Ù.

Description

int fputs(int fp, string str, int [length]);

fputs() is an alias to fwrite(), and is identical in every way. Note that the length parameter is optional and if not specified the entire string will be written.

fread

fread -- ÆÄÀÏÀ» binary·Î Àоî¿Â´Ù.

Description

string fread(int fp, int length);

fread() reads up to length bytes from the file pointer referenced by fp. Reading stops when length bytes have been read or EOF is reached, whichever comes first.

// get contents of a file into a string
$filename = "/usr/local/something.txt";
$fd = fopen( $filename, "r" );
$contents = fread( $fd, filesize( $filename ) );
fclose( $fd );

See also fwrite(), fopen(), fsockopen(), popen(), fgets(), fgetss(), file(), and fpassthru().

fseek

fseek -- file pointer¸¦ ¿Å±ä´Ù.

Description

int fseek(int fp, int offset);

Sets the file position indicator for the file referenced by fp to offset bytes into the file stream. Equivalent to calling (in C) fseek( fp, offset, SEEK_SET ).

Upon success, returns 0; otherwise, returns -1. Note that seeking past EOF is not considered an error.

May not be used on file pointers returned by fopen() if they use the "http://" or "ftp://" formats.

See also ftell() and rewind().

ftell

ftell -- file pointerÀÇ read/write À§Ä¡¸¦ ±¸ÇÑ´Ù.

Description

int ftell(int fp);

Returns the position of the file pointer referenced by fp; i.e., its offset into the file stream.

If an error occurs, returns false.

The file pointer must be valid, and must point to a file successfully opened by fopen() or popen().

See also fopen(), popen(), fseek() and rewind().

ftruncate

(PHP4 >= 4.0RC1)

ftruncate --  ÆÄÀÏÀ» ÁÖ¾îÁø Å©±â·Î ¸¸µç´Ù.

Description

int ftruncate (int fp, int size)

Takes the filepointer, fp, and truncates the file to length, size. This function returns true on success and false on failure.

fwrite

fwrite -- ÆÄÀÏÀ» Binary·Î ¾´´Ù.

Description

int fwrite(int fp, string string, int [length]);

fwrite() writes the contents of string to the file stream pointed to by fp. If the length argument is given, writing will stop after length bytes have been written or the end of string is reached, whichever comes first.

Note that if the length argument is given, then the magic_quotes_runtime configuration option will be ignored and no slashes will be stripped from string.

See also fread(), fopen(), fsockopen(), popen(), and fputs().

set_file_buffer

set_file_buffer -- ÇØ´ç ÆÄÀÏ Æ÷ÀÎÅÍ¿¡¼­ ÆÄÀÏ ¹öÆÛ¸µ(buffering)À» ÁöÁ¤ÇÑ´Ù.

Description

int fwrite(int fp, int buffer);

set_file_buffer() sets the buffering for write operations on the given filepointer fp to buffer bytes. If buffer is 0 then write operations are unbuffered.

The function returns 0 on success, or EOF if the request cannot be honored.

Note that the default for any fopen with calling set_file_buffer is 8K.

See also fopen().

is_dir

is_dir -- ÁöÁ¤µÈ ÆÄÀϸíÀÌ directoryÀΰ¡ ¾Ë·ÁÁØ´Ù.

Description

bool is_dir(string filename);

Returns true if the filename exists and is a directory.

The results of this function are cached. See clearstatcache() for more details.

See also is_file() and is_link().

is_executable

is_executable -- ÁöÁ¤µÈ ÆÄÀϸíÀÌ ½ÇÇà°¡´É ÆÄÀÏÀΰ¡ ¾Ë·ÁÁØ´Ù.

Description

bool is_executable(string filename);

Returns true if the filename exists and is executable.

The results of this function are cached. See clearstatcache() for more details.

See also is_file() and is_link().

is_file

is_file -- ÁöÁ¤µÈ ÆÄÀϸíÀÌ º¸ÅëÆÄÀÏÀΰ¡ ¾Ë·ÁÁØ´Ù.

Description

bool is_file(string filename);

Returns true if the filename exists and is a regular file.

The results of this function are cached. See clearstatcache() for more details.

See also is_dir() and is_link().

is_link

is_link -- ÁöÁ¤µÈ ÆÄÀϸíÀÌ symbolic linkÀΰ¡ ¾Ë·ÁÁØ´Ù.

Description

bool is_link(string filename);

Returns true if the filename exists and is a symbolic link.

The results of this function are cached. See clearstatcache() for more details.

See also is_dir() and is_file().

is_readable

is_readable -- ÁöÁ¤µÈ ÆÄÀϸíÀÌ Àб⠰¡´ÉÀΰ¡ ¾Ë·ÁÁØ´Ù.

Description

bool is_readable(string filename);

Returns true if the filename exists and is readable.

Keep in mind that PHP may be accessing the file as the user id that the web server runs as (often 'nobody'). Safe mode limitations are not taken into account.

The results of this function are cached. See clearstatcache() for more details.

See also is_writeable().

is_writeable

is_writeable -- ÁöÁ¤µÈ ÆÄÀϸíÀÌ ¾²±â °¡´ÉÀΰ¡ ¾Ë·ÁÁØ´Ù.

Description

bool is_readable(string filename);

Returns true if the filename exists and is writeable. The filename argument may be a directory name allowing you to check if a directory is writeable.

Keep in mind that PHP may be accessing the file as the user id that the web server runs as (often 'nobody'). Safe mode limitations are not taken into account.

The results of this function are cached. See clearstatcache() for more details.

See also is_readable().

link

link -- hard link¸¦ ¸¸µç´Ù.

Description

int link(string target, string link);

Link() creates a hard link.

See also the symlink() to create soft links, and readlink() along with linkinfo().

linkinfo

linkinfo -- link¿¡ ´ëÇÑ Á¤º¸¸¦ ±¸ÇÑ´Ù.

Description

int linkinfo(string path);

Linkinfo() returns the st_dev field of the UNIX C stat structure returned by the lstat system call. This function is used to verify if a link (pointed to by path) really exists (using the same method as the S_ISLNK macro defined in stat.h). Returns 0 or FALSE in case of error.

See also symlink(), link(), and readlink().

mkdir

mkdir -- directory¸¦ ¸¸µç´Ù.

Description

int mkdir(string pathname, int mode);

Attempts to create the directory specified by pathname.

Note that you probably want to specify the mode as an octal number, which means it should have a leading zero.

mkdir("/path/to/my/dir", 0700);

Returns true on success and false on failure.

See also rmdir().

pclose

pclose -- process file pointer¸¦ ´Ý´Â´Ù.

Description

int pclose(int fp);

Closes a file pointer to a pipe opened by popen().

The file pointer must be valid, and must have been returned by a successful call to popen().

Returns the termination status of the process that was run.

See also popen().

popen

popen -- process file pointer¸¦ ¿¬´Ù.

Description

int popen(string command, string mode);

Opens a pipe to a process executed by forking the command given by command.

Returns a file pointer identical to that returned by fopen(), except that it is unidirectional (may only be used for reading or writing) and must be closed with pclose(). This pointer may be used with fgets(), fgetss(), and fputs().

If an error occurs, returns false.

       $fp = popen( "/bin/ls", "r" );
      

See also pclose().

readfile

readfile -- fileÀ» Àоî Ãâ·ÂÇÑ´Ù.

Description

int readfile(string filename);

Reads a file and writes it to standard output.

Returns the number of bytes read from the file. If an error occurs, false is returned and unless the function was called as @readfile, an error message is printed.

If filename begins with "http://" (not case sensitive), an HTTP 1.0 connection is opened to the specified server and the text of the response is written to standard output.

Does not handle HTTP redirects, so you must include trailing slashes on directories.

If filename begins with "ftp://" (not case sensitive), an ftp connection to the specified server is opened and the requested file is written to standard output. If the server does not support passive mode ftp, this will fail.

If filename begins with neither of these strings, the file will be opened from the filesystem and its contents written to standard output.

See also fpassthru(), file(), fopen(), include(), require(), and virtual().

readlink

readlink -- symbolic linkÀÇ ´ë»óÀ» ¹ÝȯÇÑ´Ù.

Description

int readlink(string path);

Readlink() does the same as the readlink C function and returns the contents of the symbolic link path or 0 in case of error.

See also symlink(), readlink() and linkinfo().

rename

rename -- ÆÄÀϸíÀ» ¹Ù²Û´Ù.

Description

int rename(string oldname, string newname);

Attempts to rename oldname to newname.

Returns true on success and false on failure.

rewind

rewind -- file pointer¸¦ ÆÄÀÏÀÇ Ã³À½ À§Ä¡·Î ¼³Á¤ÇÑ´Ù.

Description

int rewind(int fp);

Sets the file position indicator for fp to the beginning of the file stream.

If an error occurs, returns 0.

The file pointer must be valid, and must point to a file successfully opened by fopen().

See also fseek() and ftell().

rmdir

rmdir -- directory¸¦ Áö¿î´Ù.

Description

int rmdir(string dirname);

Attempts to remove the directory named by pathname. The directory must be empty, and the relevant permissions must permit this.

If an error occurs, returns 0.

See also mkdir().

stat

stat -- ÆÄÀÏÀÇ stat Á¤º¸¸¦ ±¸ÇÑ´Ù.

Description

array stat(string filename);

Gathers the statistics of the file named by filename.

Returns an array with the statistics of the file with the following elements:

* - only valid on systems supporting the st_blksize type--other systems (i.e. Windows) return -1

The results of this function are cached. See clearstatcache() for more details.

lstat

lstat -- ÆÄÀÏÀ̳ª symbolic linkÀÇ stat Á¤º¸¸¦ ±¸ÇÑ´Ù.

Description

array lstat(string filename);

Gathers the statistics of the file or symbolic link named by filename. This function is identical to the stat() function except that if the filename parameter is a symbolic link, the status of the symbolic link is returned, not the status of the file pointed to by the symbolic link.

Returns an array with the statistics of the file with the following elements:

* - only valid on systems supporting the st_blksize type--other systems (i.e. Windows) return -1

The results of this function are cached. See clearstatcache() for more details.

symlink

symlink -- symbolic link¸¦ ¸¸µç´Ù.

Description

int symlink(string target, string link);

symlink() creates a symbolic link from the existing target with the specified name link.

See also link() to create hard links, and readlink() along with linkinfo().

tempnam

tempnam -- À¯ÀÏÇÑ ÆÄÀϸíÀ» ¸¸µç´Ù.

Description

string tempnam(string dir, string prefix);

Creates a unique temporary filename in the specified directory. If the directory does not exist, tempnam() may generate a filename in the system's temporary directory.

The behaviour of the tempnam() function is system dependent. On Windows the TMP environment variable will override the dir parameter, on Linux the TMPDIR environment variable has precedence, while SVR4 will always use your dir parameter if the directory it points to exists. Consult your system documentation on the tempnam(3) function if in doubt.

Returns the new temporary filename, or the null string on failure.

Example 1. tempnam() example

$tmpfname = tempnam( "/tmp", "FOO" );

touch

touch -- ÆÄÀÏÀÇ ¼öÁ¤ ½Ã°¢À» ¼³Á¤ÇÑ´Ù.

Description

int touch(string filename, int time);

Attempts to set the modification time of the file named by filename to the value given by time. If the option time is not given, uses the present time.

If the file does not exist, it is created.

Returns true on success and false otherwise.

umask

umask -- ÇöÀçÀÇ umask¸¦ º¯°æÇÑ´Ù.

Description

int umask(int mask);

Umask() sets PHP's umask to mask & 0777 and returns the old umask. When PHP is being used as a server module, the umask is restored when each request is finished.

Umask() without arguments simply returns the current umask.

unlink

unlink -- ÆÄÀÏÀ» Áö¿î´Ù.

Description

int unlink(string filename);

Deletes filename. Similar to the Unix C unlink() function.

Returns 0 or FALSE on an error.

See also rmdir() for removing directories.


XXI. Forms Data Format functions

ÀÌ°ÍÀº PHP¿¡¼­ Forms Data Format (FDF)À» Áö¿øÇϱâÀ§ÇÑ Ã¹ ¹ø° ½ÃµµÀÌ´Ù. FDF¿Í ÀÌ°ÍÀÇ »ç¿ë¹ý¿¡ ´ëÇØ ¾Ë°í ½Í´Ù¸é http://partners.adobe.com/asn/developer/acrosdk/forms.htmlÀ» Àо¾Æ¾ß ÇÒ °ÍÀÌ´Ù.

Note: ÇöÀç Adobe´Â Linux¿ëÀ¸·Î libc5¿¡ ȣȯµÇ´Â ¹öÀü¸¸À» Á¦°øÇÑ´Ù. glibc2¿¡¼­ Å×½ºÆ® ÇØ º¸¾ÒÀ¸³ª segmentation fault°¡ ¹ß»ýÇÏ¿´´Ù. ¸¸¾à ´©±º°¡ ÀÌ°ÍÀ» °¡´ÉÇÏ°Ô ÇÑ »ç¶÷ÀÌ ÀÖ´Ù¸é ¾ð±ÞÇØ Áֱ⸦ ¹Ù¶õ´Ù.

Note: ¸¸¾à php¸¦ fdftk Áö¿øÀ¸·Î ¼³Á¤ÇÏ´Â °ÍÀÌ Àß ¾ÈµÇ´Â °æ¿ì, Çì´õ ÆÄÀÏÀÎ FdfTk.h¿Í libFdfTk.so ¶óÀ̺귯¸® ÆÄÀÏÀÌ Á¦ÀÚ¸®¿¡ Àִ°¡ºÎÅÍ È®ÀÎÇØ º¸ÀÚ. µÎ ÆÄÀÏÀº °¢°¢ fdftk-dir/include¿Í fdftk-dir/lib µð·ºÅ丮¿¡ ÀÖ¾î¾ß ÇÑ´Ù. ¿©·¯ºÐÀÌ FdfTk ¹èÆ÷º»À» Ç®¾î³õ±â¸¸ ÇÑ °æ¿ì ¾Æ¸¶µµ ÀÌ µÎ ÆÄÀÏÀº Á¦ À§Ä¡¿¡ ÀÖÁö ¾ÊÀ» °ÍÀÌ´Ù.

FDFÀÇ ¾ÆÀ̵ð¾î´Â HTML Æû°ú ºñ½ÁÇÏ´Ù. ±âº»ÀûÀ¸·Î ´Ù¸¥ °ÍÀº submit ¹öÆ°ÀÌ ´­·ÁÁ³À» ¶§ ¼­¹ö¿¡ Àü¼ÛµÇ´Â Æ÷¸Ë(½ÇÁ¦·Î ÀÌ°ÍÀÌ Form Data FormatÀÌ´Ù)°ú, Æû ÀÚüÀÇ ÇüÅÂ(ÀÌ°ÍÀº Portable Document Format, PDFÀÌ´Ù)ÀÌ´Ù. FDF µ¥ÀÌÅ͸¦ ó¸®ÇÏ´Â °ÍÀÌ fdf ÇÔ¼öµéÀÌ Á¦°øÇÏ´Â ±â´ÉÁß ÇϳªÀÌ´Ù. ÇÏÁö¸¸ ±×°ÍÀÌ ÀüºÎ´Â ¾Æ´Ï´Ù. ÀÌ°ÍÀº ±âÁ¸ÀÇ PDF Æû¿¡ ÀÌ Æû ÀÚü¸¦ ¼öÁ¤ÇÏÁö ¾Ê°íµµ input Çʵå¿Í µ¥ÀÌÅ͸¦ Ãß°¡ÇÒ ¼ö ÀÖ´Ù. ÀÌ·± °æ¿ì FDF ¹®¼­¸¦ »ý¼ºÇÏ¿© (fdf_create()) °¢°¢ÀÇ input Çʵ忡 °ªÀ» ¼³Á¤ÇÏ°í (fdf_set_value()), ÀÌ°ÍÀ» PDF Æû¿¡ ¹èÄ¡½ÃÅ°¸é µÈ´Ù. (fdf_set_file()) ¸¶Áö¸·À¸·Î ÀÌ°ÍÀº application/vnd.fdf¶ó´Â MimeTypeÀ» °¡Áö°í ºê¶ó¿ìÀú·Î Àü¼ÛµÇ¾î¾ß ÇÑ´Ù. ¿©·¯ºÐÀÇ ºê¶ó¿ìÀú¿¡ ÀÖ´Â Acrobat reader pluginÀº ÀÌ ¸¶ÀÓ Å¸ÀÔÀ» ÀνÄÇÏ°í, ÀÌ °áÇÕµÈ PDF formÀ» Àоî FDF ¹®¼­·ÎºÎÅÍ µ¥ÀÌÅ͸¦ ÀÐ¾î µ¥ÀÌÅ͸¦ ä¿î´Ù.

´ÙÀ½Àº form data¸¦ »ç¿ëÇغ¸´Â ¿¹Á¦ÀÌ´Ù.

Example 1. Evaluating a FDF document

  1 
  2 <?php
  3 // Save the FDF data into a temp file
  4 $fdffp = fopen("test.fdf", "w");
  5 fwrite($fdffp, $HTTP_FDF_DATA, strlen($HTTP_FDF_DATA));
  6 fclose($fdffp);
  7 
  8 // Open temp file and evaluate data
  9 // The pdf form contained several input text fields with the names
 10 // volume, date, comment, publisher, preparer, and two checkboxes
 11 // show_publisher and show_preparer.
 12 $fdf = fdf_open("test.fdf");
 13 $volume = fdf_get_value($fdf, "volume");
 14 echo "The volume field has the value '<B>$volume</B>'<BR>";
 15 
 16 $date = fdf_get_value($fdf, "date");
 17 echo "The date field has the value '<B>$date</B>'<BR>";
 18 
 19 $comment = fdf_get_value($fdf, "comment");
 20 echo "The comment field has the value '<B>$comment</B>'<BR>";
 21 
 22 if(fdf_get_value($fdf, "show_publisher") == "On") {
 23   $publisher = fdf_get_value($fdf, "publisher");
 24   echo "The publisher field has the value '<B>$publisher</B>'<BR>";
 25 } else
 26   echo "Publisher shall not be shown.<BR>";
 27 
 28 if(fdf_get_value($fdf, "show_preparer") == "On") {
 29   $preparer = fdf_get_value($fdf, "preparer");
 30   echo "The preparer field has the value '<B>$preparer</B>'<BR>";
 31 } else
 32   echo "Preparer shall not be shown.<BR>";
 33 fdf_close($fdf);
 34 ?>
 35      
Table of Contents
fdf_open ¡¦ Opens a new fdf document
fdf_close ¡¦ Closes the fdf document
fdf_create ¡¦ Creates a new fdf document
fdf_save ¡¦ Saves a fdf document
fdf_get_value ¡¦ Gets the value of a field
fdf_set_value ¡¦ Sets the value of a field
fdf_next_field_name ¡¦ Next field name
fdf_set_ap ¡¦ Sets the appearence of a field
fdf_set_status ¡¦ Sets the value of the /STATUS key
fdf_get_status ¡¦ Gets the value of the /STATUS key
fdf_set_file ¡¦ Sets the value of the /F key
fdf_get_file ¡¦ Gets the value of the /F key

fdf_open

fdf_open -- »õ fdf document¸¦ ¿¬´Ù

Description

int pdf_open(string filename);

The fdf_open() function opens a file with form data. This file must contain the data as returned from a PDF form. Currently, the file has to be created 'manually' by using fopen() and writing the content of HTTP_FDF_DATA with fwrite() into it. A mechanism like for HTML form data where for each input field a variable is created does not exist.

Example 1. Accessing the form data

<?php
// Save the FDF data into a temp file
$fdffp = fopen("test.fdf", "w");
fwrite($fdffp, $HTTP_FDF_DATA, strlen($HTTP_FDF_DATA));
fclose($fdffp);
// Open temp file and evaluate data
$fdf = fdf_open("test.fdf");
...
fdf_close($fdf);
?>
     

See also fdf_close().

fdf_close

fdf_close -- fdf document¸¦ ´Ý´Â´Ù.

Description

void fdf_close(int fdf_document);

The fdf_close() function closes the fdf document.

See also fdf_open().

fdf_create

fdf_create -- »õ fdf document¸¦ ¸¸µç´Ù.

Description

int fdf_create(void );

The fdf_create() creates a new FDF document. This function is needed if one would like to populate input fields in a PDF document with data.

Example 1. Populating a PDF document

<?php
$outfdf = fdf_create();
fdf_set_value($outfdf, "volume", $volume, 0);
fdf_set_file($outfdf, "http:/testfdf/resultlabel.pdf");
fdf_save($outfdf, "outtest.fdf");
fdf_close($outfdf);
Header("Content-type: application/vnd.fdf");
$fp = fopen("outtest.fdf", "r");
fpassthru($fp);
unlink("outtest.fdf");
?>
     

See also fdf_close(), fdf_save(), fdf_open().

fdf_save

fdf_save -- fdf document¸¦ ÀúÀåÇÑ´Ù.

Description

int fdf_save(string filename);

The fdf_save() function saves a FDF document. The FDF Toolkit provides a way to output the document to stdout if the parameter filename is '.'. This does not work if PHP is used as an apache module. In such a case one will have to write to a file and use e.g. fpassthru(). to output it.

See also fdf_close() and example for fdf_create().

fdf_get_value

fdf_get_value -- ÇÑ ÇʵåÀÇ °ªÀ» Àоî¿Â´Ù.

Description

string fdf_get_value(int fdf_document, string fieldname);

The fdf_get_value() function returns the value of a field.

See also fdf_set_value().

fdf_set_value

fdf_set_value -- ÇÑ ÇʵåÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù.

Description

void fdf_set_value(int fdf_document, string fieldname, string value, int isName);

The fdf_set_value() function sets the value of a field. The last parameter determines if the field value is to be converted to a PDF Name (isName = 1) or set to a PDF String (isName = 0).

See also fdf_get_value().

fdf_next_field_name

fdf_next_field_name -- ´ÙÀ½ ÇʵåÀÇ À̸§À» ¹ÝȯÇÑ´Ù.

Description

string fdf_next_field_name(int fdf_document, string fieldname);

The fdf_next_field_name() function returns the name of the field after the field in fieldname or the field name of the first field if the second paramter is NULL.

See also fdf_set_field(), fdf_get_field().

fdf_set_ap

fdf_set_ap -- ÇÑ ÇʵåÀÇ appearance¸¦ ¼³Á¤ÇÑ´Ù.

Description

void fdf_set_ap(int fdf_document, string field_name, int face, string filename, int page_number);

The fdf_set_ap() function sets the appearance of a field (i.e. the value of the /AP key). The possible values of face are 1=FDFNormalAP, 2=FDFRolloverAP, 3=FDFDownAP.

fdf_set_status

fdf_set_status -- /STATUS Å°ÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù.

Description

void fdf_set_status(int fdf_document, string status);

The fdf_set_status() sets the value of the /STATUS key.

See also fdf_get_status().

fdf_get_status

fdf_get_status -- /STATUS Å°ÀÇ °ªÀ» Àоî¿Â´Ù.

Description

string fdf_get_status(int fdf_document);

The fdf_get_status() returns the value of the /STATUS key.

See also fdf_set_status().

fdf_set_file

fdf_set_file -- /F Å°ÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù.

Description

void fdf_set_file(int fdf_document, string filename);

The fdf_set_file() sets the value of the /F key. The /F key is just a reference to a PDF form which is to be populated with data. In a web environment it is a URL (e.g. http:/testfdf/resultlabel.pdf).

See also fdf_get_file() and example for fdf_create().

fdf_get_file

fdf_get_file -- /F Å°ÀÇ °ªÀ» Àоî¿Â´Ù.

Description

string fdf_get_file(int fdf_document);

The fdf_set_file() returns the value of the /F key.

See also fdf_set_file().


XXII. FTP functions

File Transfer ProtocolÀÎ FTP ÇÔ¼öµéÀÌ´Ù.

FTP_ASCII ¿Í FTP_BINARY ÀÇ µÎ °³ÀÇ »ó¼ö°¡ FTP ¸ðµâ¿¡ ¹Ì¸® Á¤ÀǵǾî ÀÖ´Ù.

Table of Contents
ftp_connect ¡¦ Opens up an FTP connection
ftp_login ¡¦ Logs in an FTP connection
ftp_pwd ¡¦ Returns the current directory name
ftp_cdup ¡¦ Changes to the parent directory
ftp_chdir ¡¦ Changes directories on a FTP server
ftp_mkdir ¡¦ Creates a directory
ftp_rmdir ¡¦ Removes a directory
ftp_nlist ¡¦ Returns a list of files in the given directory.
ftp_rawlist ¡¦ Returns a detailed list of files in the given directory.
ftp_systype ¡¦ Returns the system type identifier of the remote FTP server.
ftp_pasv ¡¦ Turns passive mode on or off.
ftp_get ¡¦ Downloads a file from the FTP server.
ftp_fget ¡¦ Downloads a file from the FTP server and saves to an open file.
ftp_put ¡¦ Uploads a file to the FTP server.
ftp_fput ¡¦ Uploads from an open file to the FTP server.
ftp_size ¡¦ Returns the size of the given file.
ftp_mdtm ¡¦ Returns the last modified time of the given file.
ftp_rename ¡¦ Renames a file on the ftp server.
ftp_delete ¡¦ Deletes a file on the ftp server.
ftp_site ¡¦ Sends a SITE command to the server.
ftp_quit ¡¦ Closes an FTP connection

ftp_connect

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_connect -- FTP ¿¬°áÀ» ¿¬´Ù.

Description

int ftp_connect (string host [, int port])

Returns a FTP stream on success, false on error.

ftp_connect() opens up a FTP connection to the specified host. The port parameter specifies an alternate port to connect to. If it is omitted or zero, then the default FTP port, 21, will be used.

ftp_login

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_login -- FTP ¿¬°á¿¡ ·Î±×ÀÎÇÑ´Ù.

Description

int ftp_login (int ftp_stream, string username, string password)

Returns true on success, false on error.

Logs in the given FTP stream.

ftp_pwd

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_pwd -- ÇöÀç µð·ºÅ丮¸íÀ» ¹ÝȯÇÑ´Ù.

Description

int ftp_pwd (int ftp_stream)

Returns the current directory, or false on error.

ftp_cdup

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_cdup -- ºÎ¸ð µð·ºÅ丮·Î À̵¿ÇÑ´Ù.

Description

int ftp_cdup (int ftp_stream)

Returns true on success, false on error.

Changes to the parent directory.

ftp_chdir

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_chdir -- FTP ¼­¹öÀÇ Æ¯Á¤ µð·ºÅ丮·Î À̵¿ÇÑ´Ù.

Description

int ftp_chdir (int ftp_stream, string directory)

Returns true on success, false on error.

Changes to the specified directory.

ftp_mkdir

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_mkdir -- µð·ºÅ丮¸¦ ¸¸µç´Ù.

Description

string ftp_mkdir (int ftp_stream, string directory)

Returns the newly created directory name on success, false on error.

Creates the specified directory.

ftp_rmdir

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_rmdir -- µð·ºÅ丮¸¦ Áö¿î´Ù.

Description

int ftp_rmdir (int ftp_stream, string directory)

Returns true on success, false on error.

Removes the specified directory.

ftp_nlist

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_nlist -- ÁÖ¾îÁø µð·ºÅ丮ÀÇ ÆÄÀϸíÀÇ ¸ñ·ÏÀ» ¹è¿­·Î µ¹·ÁÁØ´Ù.

Description

int ftp_nlist (int ftp_stream, string directory)

Returns an array of filenames on success, false on error.

ftp_rawlist

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_rawlist -- ÁÖ¾îÁø µð·ºÅ丮ÀÇ ÆÄÀÏÀÇ ÀÚ¼¼ÇÑ ¸ñ·ÏÀ» ¹è¿­·Î µ¹·ÁÁØ´Ù.

Description

int ftp_rawlist (int ftp_stream, string directory)

ftp_rawlist() executes the FTP LIST command, and returns the result as an array. Each array element corresponds to one line of text. The output is not parsed in any way. The system type identifier returned by ftp_systype() can be used to determine how the results should be interpreted.

ftp_systype

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_systype --  ¿ø°Ý FTP ¼­¹öÀÇ ½Ã½ºÅÛ Á¾·ù ½Äº°ÀÚ(system type identifier)¸¦ ¹ÝȯÇÑ´Ù.

Description

int ftp_systype (int ftp_stream)

Returns the remote system type, or false on error.

ftp_pasv

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_pasv -- passive ¸ðµå¸¦ ÄѰųª ²ö´Ù.

Description

int ftp_pasv (int ftp_stream, int pasv)

Returns true on success, false on error.

ftp_pasv() turns on passive mode if the pasv parameter is true (it turns off passive mode if pasv is false.) In passive mode, data connections are initiated by the client, rather than by the server.

ftp_get

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_get -- FTP ¼­¹ö·ÎºÎÅÍ ÇÑ ÆÄÀÏÀ» °¡Á®¿Â´Ù.

Description

int ftp_get (int ftp_stream, string local_file, string remote_file, int mode)

Returns true on success, false on error.

ftp_get() retrieves remote_file from the FTP server, and saves it to local_file locally. The transfer mode specified must be either FTP_ASCII or FTP_BINARY.

ftp_fget

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_fget -- FTP ¼­¹ö·ÎºÎÅÍ ÇÑ ÆÄÀÏÀ» °¡Á®¿Í ±âÁ¸¿¡ ¿­·ÁÁø ÆÄÀÏ·Î ÀúÀåÇÑ´Ù.

Description

int ftp_fget (int ftp_stream, int fp, string remote_file, int mode)

Returns true on success, false on error.

ftp_fget() retrieves remote_file from the FTP server, and writes it to the given file pointer, fp. The transfer mode specified must be either FTP_ASCII or FTP_BINARY.

ftp_put

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_put -- FTP ¼­¹ö·Î ÇÑ ÆÄÀÏÀ» ¿Ã¸°´Ù.

Description

int ftp_put (int ftp_stream, string remote_file, string local_file, int mode)

Returns true on success, false on error.

ftp_put() stores local_file on the FTP server, as remote_file. The transfer mode specified must be either FTP_ASCII or FTP_BINARY.

ftp_fput

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_fput -- ¿­·ÁÁ® ÀÖ´Â ÆÄÀÏÀ» FTP ¼­¹ö·Î ¿Ã¸°´Ù.

Uploads from an open file to the FTP server.

Description

int ftp_fput (int ftp_stream, string remote_file, int fp, int mode)

Returns true on success, false on error.

ftp_fput() uploads the data from the file pointer fp until end of file. The results are stored in remote_file on the FTP server. The transfer mode specified must be either FTP_ASCII or FTP_BINARY.

ftp_size

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_size -- ÆÄÀÏÀÇ Å©±â¸¦ ¹ÝȯÇÑ´Ù.

Description

int ftp_size (int ftp_stream, string remote_file)

Returns the file size on success, or -1 on error.

ftp_size() returns the size of a file. If an error occurs, of if the file does not exist, -1 is returned. Not all servers support this feature.

ftp_mdtm

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_mdtm -- ÆÄÀÏÀÌ ¸¶Áö¸·À¸·Î ¼öÁ¤µÈ ½Ã°¢À» ¹ÝȯÇÑ´Ù.

Description

int ftp_mdtm (int ftp_stream, string remote_file)

Returns a UNIX timestamp on success, or -1 on error.

ftp_mdtm() checks the last-modified time for a file, and returns it as a UNIX timestamp. If an error occurs, or the file does not exist, -1 is returned. Note that not all servers support this feature.

ftp_rename

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_rename -- FTP ¼­¹ö¿¡ ÀÖ´Â ÆÄÀÏÀÇ À̸§À» ¹Ù²Û´Ù.

Description

int ftp_rename (int ftp_stream, string from, string to)

Returns true on success, false on error.

ftp_rename() renames the file specified by from to the new name to.

ftp_delete

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_delete -- FTP ¼­¹ö¿¡ ÀÖ´Â ÆÄÀÏÀ» Áö¿î´Ù.

Description

int ftp_delete (int ftp_stream, string path)

Returns true on success, false on error.

ftp_delete() deletes the file specified by path from the FTP server.

ftp_site

(PHP3 >= 3.0.15, PHP4 >= 4.0RC1)

ftp_site -- SITE ¸í·ÉÀ» ¼­¹ö¿¡ º¸³½´Ù.

Description

int ftp_site (int ftp_stream, string cmd)

Returns true on success, false on error.

ftp_site() sends the command specified by cmd to the FTP server. SITE commands are not standardized, and vary from server to server. They are useful for handling such things as file permissions and group membership.

ftp_quit

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

ftp_quit -- FTP ¿¬°áÀ» ´Ý´Â´Ù.

Description

int ftp_quit (int ftp_stream)

ftp_connect() closes ftp_stream.


XXIII. GNU Gettext

Table of Contents
bindtextdomain ¡¦ Sets the path for a domain
dcgettext ¡¦ Overrides the domain for a single lookup
dgettext ¡¦ Override the current domain
gettext ¡¦ Lookup a message in the current domain
textdomain ¡¦ Sets the default domain

bindtextdomain

(PHP3 >= 3.0.7, PHP4 )

bindtextdomain -- domainÀÇ path¸¦ ¼³Á¤ÇÑ´Ù.

Description

string bindtextdomain (string domain, string directory)

The bindtextdomain() function sets the path for a domain.

dcgettext

(PHP3 >= 3.0.7, PHP4 )

dcgettext -- Overrides the domain for a single lookup

Description

string dcgettext (string domain, string message, int category)

This function allows you to override the current domain for a single message lookup. It also allows you to specify a category.

dgettext

(PHP3 >= 3.0.7, PHP4 )

dgettext -- Override the current domain

Description

string dgettext (string domain, string message)

The dgettext() function allows you to override the current domain for a single message lookup.

gettext

(PHP3 >= 3.0.7, PHP4 )

gettext -- Lookup a message in the current domain

Description

string gettext (string message)

This function returns a translated string if one is found in the translation table, or the submitted message if not found. You may use an underscore character as an alias to this function.

Example 1. Gettext()-check

  1 
  2 <?php
  3 // Set language to German
  4 putenv ("LANG=de");
  5 
  6 // Specify location of translation tables
  7 bindtextdomain ("myPHPApp", "./locale");
  8 
  9 // Choose domain
 10 textdomain ("myPHPApp");
 11 
 12 // Print a test message
 13 print (gettext ("Welcome to My PHP Application"));
 14 ?>
 15      

textdomain

(PHP3 >= 3.0.7, PHP4 )

textdomain -- Sets the default domain

Description

int textdomain ([string library])

This function sets the domain to search within when calls are made to gettext(), usually the named after an application. The previous default domain is returned. Call it with no parameters to get the current setting without changing it.


XXIV. Hash functions

ÀÌ ÇÔ¼öµéÀº mhash¿Í ÇÔ²² µ¿ÀÛÇϵµ·Ï ¸¸µé¾îÁ³´Ù.

ÀÌ°ÍÀº mhash ¶óÀ̺귯¸®¿¡ ´ëÇÑ ÀÎÅÍÆäÀ̽ºÀÌ´Ù. mhash´Â MD5³ª SHA1, GOST¿Í ¿©Å¸ÀÇ ±¤¹üÀ§ÇÑ Çؽ¬ ¾Ë°í¸®ÁòÀ» µð¿øÇÑ´Ù.

ÀÌ°ÍÀ» »ç¿ëÇÏ°í ½ÍÀ¸¸é ¿ì¼± mhash ȨÆäÀÌÁö¿¡¼­ mhash-x.x.x.tar.gz¸¦ ´Ù¿î¹Þ°í Æ÷ÇÔµÈ ¼³Ä¡¼³¸í¼­´ë·Î ¼³Ä¡ÇÑ´Ù. PHP¿¡¼­ ÀÌ È®ÀåÀ» »ç¿ëÇÏ·Á¸é ÄÄÆÄÀϽÿ¡ --with-mhash ÆĶó¸ÞÅ͸¦ ÁÖ°í ÄÄÆÄÀÏÇÏ¿©¾ß ÇÑ´Ù.

mhash´Â checksumsÀ̳ª message digests µîÀÇ °ÍÀ» ¸¸µå´Âµ¥ »ç¿ëµÉ ¼ö ÀÖ´Ù.

Example 1. Compute the SHA1 key and print it out as hex

  1 
  2 <?php
  3 $input = "Let us meet at 9 o' clock at the secret place.";
  4 $hash = mhash(MHASH_SHA1, $input);
  5 
  6 print "The hash is ".bin2hex($hash)."\n";
  7 
  8 ?>
  9      

À§ÀÇ ¿¹´Â ´ÙÀ½°ú °°Àº °á°ú¸¦ Ãâ·ÂÇÑ´Ù.:

  1 
  2 The hash is d3b85d710d8f6e4e5efd4d5e67d041f9cecedafe
  3     

Áö¿øµÇ´Â hash ¾Ë°í¸®Áò¿¡ ´ëÇÑ ¿Ïº®ÇÑ ¸®½ºÆ®´Â mhash¾È¿¡ ÀÖ´Â ¹®¼­¸¦ ÂüÁ¶ÇÏÀÚ. PHP¿¡¼­ hash ¹æ½ÄÀ» ÁöĪÇÏ´Â ÀϹÝÀûÀÎ ¹ýÄ¢Àº "MHASH_Çؽ¬À̸§"ÀÇ ÇüÅÂÀÌ´Ù.

ÇöÀç mhash¿¡¼¼ Áö¿øÇÏ´Â Çؽ¬ÀÇ ¸®½ºÆ®´Â ´ÙÀ½°ú °°´Ù. mhash¿¡¼­ Áö¿øÇÑ´Ù°í Ç¥½ÃµÇ¾î ÀÖÀ¸³ª, ¿©±â¿¡ ³ª¿ÍÀÖÁö ¾ÊÀº °ÍÀº ÀÌ ¸Å´º¾ó ÀÌÈÄ¿¡ Ãß°¡·Î Áö¿øµÈ °ÍÀ̹ǷΠ¾È½ÉÇÏ°í »ç¿ëÇÏ¿©µµ µÈ´Ù.

Table of Contents
mhash_get_hash_name ¡¦ Get the name of the specified hash
mhash_get_block_size ¡¦ Get the block size of the specified hash
mhash_count ¡¦ Get the highest available hash id
mhash ¡¦ Compute hash

mhash_get_hash_name

mhash_get_hash_name -- ÁöÁ¤µÈ hashÀÇ À̸§À» ±¸ÇÑ´Ù.

Description

string mhash_get_hash_name (int hash)

mhash_get_hash_name() is used to get the name of the specified hash.

mhash_get_hash_name() takes the hash id as an argument and returns the name of the hash or false, if the hash does not exist.

Example 1. mhash_get_hash_name example

  1 
  2 <?php
  3 $hash = MHASH_MD5;
  4 
  5 print mhash_get_hash_name($hash);
  6 ?>
  7       
The above example will print out:
  1 
  2 MD5
  3      

mhash_get_block_size

mhash_get_block_size -- ÁöÁ¤µÈ hashÀÇ ºí·Ï Å©±â¸¦ ±¸ÇÑ´Ù.

Description

int mhash_get_block_size(int hash);

mhash_get_block_size() is used to get the size of a block of the specified hash.

mhash_get_block_size() takes one argument, the hash and returns the size in bytes or false, if the hash does not exist.

mhash_count

mhash_count -- °¡´ÉÇÑ °¡Àå Å« hash id¸¦ ±¸ÇÑ´Ù.

Description

int mhash_count (void)

mhash_count() returns the highest available hash id. Hashes are numbered from 0 to this hash id.

Example 1. Traversing all hashes

  1 
  2 <?php
  3 
  4 $nr = mhash_count();
  5 
  6 for($i = 0; $i <= $nr; $i++) {
  7     echo sprintf("The blocksize of %s is %d\n", 
  8             mhash_get_hash_name($i),
  9             mhash_get_block_size($i));
 10 }
 11 ?>
 12       

mhash

mhash -- hash °ªÀ» °è»êÇÑ´Ù.

Description

string mhash(int hash, string data);

mhash() applies a hash function specified by hash to the data and returns the resulting hash (also called digest).


XXV. Functions related to HTTP

ÀÌ ÇÔ¼öµéÀº HTTP protocol leve¿¡¼­ µ¥ÀÌŸ¸¦ remote browser·Î Á÷Á¢ Àü¼ÛÇÒ ¼ö ÀÖµµ·Ï ÇØ ÁØ´Ù.

Table of Contents
header ¡¦ Send a raw HTTP header
setcookie ¡¦ Send a cookie

header

header -- HTTP Çì´õ µ¥ÀÌŸ¸¦ Àû¾îÁØ ±×´ë·Î º¸³½´Ù.

Description

int header(string string);

The Header() function is used at the top of an HTML file to send raw HTTP header strings. See the HTTP 1.1 Specification for more information on raw http headers. Note: Remember that the Header() function must be called before any actual output is sent either by normal HTML tags or from PHP. It is a very common error to read code with include() or with auto_prepend and have spaces or empty lines in this code that force output before header() is called.

There are two special-case header calls. The first is the "Location" header. Not only does it send this header back to the browser, it also returns a REDIRECT status code to Apache. From a script writer's point of view this should not be important, but for people who understand Apache internals it is important to understand.

  1 
  2 header ("Location: http://www.php.net"); /* Redirect browser 
  3                                             to PHP web site */
  4 exit;                 /* Make sure that code below does 
  5                          not get executed when we redirect. */
  6       

The second special-case is any header that starts with the string, "HTTP/" (case is not significant). For example, if you have your ErrorDocument 404 Apache directive pointed to a PHP script, it would be a good idea to make sure that your PHP script is actually generating a 404. The first thing you do in your script should then be:

  1 
  2 header ("http/1.0 404 Not Found");
  3       

PHP scripts often generate dynamic HTML that must not be cached by the client browser or any proxy caches between the server and the client browser. Many proxies and clients can be forced to disable caching with

  1 
  2 header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
  3 header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
  4                                                       // always modified
  5 header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
  6 header ("Pragma: no-cache");                          // HTTP/1.0
  7       

setcookie

setcookie -- cookie¸¦ ¼³Á¤Çϵµ·Ï µ¥ÀÌŸ¸¦ ºê¶ó¿ìÀú·Î º¸³½´Ù.

Description

int setcookie(string name, string value, int expire, string path, string domain, int secure);

setcookie() defines a cookie to be sent along with the rest of the header information. Cookies must be sent before any other headers are sent (this is a restriction of cookies, not PHP). This requires you to place calls to this function before any <html> or <head> tags.

All the arguments except the name argument are optional. If only the name argument is present, the cookie by that name will be deleted from the remote client. You may also replace any argument with an empty string ("") in order to skip that argument. The expire and secure arguments are integers and cannot be skipped with an empty string. Use a zero (0) instead. The expire argument is a regular Unix time integer as returned by the time() or mktime() functions. The secure indicates that the cookie should only be transmitted over a secure HTTPS connection.

Common Pitfalls:

Cookies will not become visible until the next loading of a page that the cookie should be visible for.

In PHP3, multiple calls to setcookie() in the same script will be performed in reverse order. If you are trying to delete one cookie before inserting another you should put the insert before the delete. In PHP4, multiple calls to setcookie() are performed in the order called.

Some examples follow:

Example 1. setcookie() examples

  1 
  2 setcookie ("TestCookie", "Test Value");
  3 setcookie ("TestCookie", $value,time()+3600);  /* expire in 1 hour */
  4 setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".utoronto.ca", 1);
  5       

Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and when it is received, it is automatically decoded and assigned to a variable by the same name as the cookie name. To see the contents of our test cookie in a script, simply use one of the following examples:

  1 
  2 echo $TestCookie;
  3 echo $HTTP_COOKIE_VARS["TestCookie"];
  4       

You may also set array cookies by using array notation in the cookie name. This has the effect of setting as many cookies as you have array elements, but when the cookie is received by your script, the values are all placed in an array with the cookie's name:

  1 
  2 setcookie ("cookie[three]", "cookiethree");
  3 setcookie ("cookie[two]", "cookietwo");
  4 setcookie ("cookie[one]", "cookieone");
  5 if (isset ($cookie)) {
  6     while (list ($name, $value) = each ($cookie)) {
  7         echo "$name == $value<br>\n";
  8     }
  9 }
 10       

For more information on cookies, see Netscape's cookie specification at http://www.netscape.com/newsref/std/cookie_spec.html.

Microsoft Internet Explorer 4 with Service Pack 1 applied does not correctly deal with cookies that have their path parameter set.

Netscape Communicator 4.05 and Microsoft Internet Explorer 3.x appear to handle cookies incorrectly when the path and time are not set.


XXVI. Hyperwave functions

( ¿ªÀÚÁÖ : À̺κÐÀº ¹ø¿ªÀÌ ¹«Ã´ ¾î·Á¿ü´Ù. À߸øµÈ ´Ü¾îµµ ¸¹¾Ò°í, Àǹ̰¡ ¸íÈ®ÇÏÁö ¾ÊÀº ºÎºÐµµ ¸¹¾Ò´Ù. ¶ÇÇÑ ¿ªÀÚ°¡ »ç¿ëÇØ º¸Áö ¸øÇÑ ±â´ÉÀ̱⠶§¹®¿¡ ±× ³»¿ëÀ» Àß ¾ËÁö ¸øÇÏ´Â ÀÌÀ¯µµ ÀÖ´Ù. ¿À¿ªÀÌ ÀÖÀ» ¼öµµ ÀÖÀ¸¹Ç·Î °¡´ÉÇÏ¸é ¿ø¹®µµ ÇÔ²² º¸µµ·Ï ÇÑ´Ù.)

Introduction

Hyperwave´Â GrazÀÇ IICM¿¡¼­ °³¹ßµÇ¾ú´Ù. ÀÌ°ÍÀº óÀ½¿¡´Â Hyper-G¶ó´Â À̸§À¸·Î ½ÃÀ۵Ǿú´Ù°¡ »ó¾÷È­µÇ¸é°Å Hyperwave¶ó´Â À̸§À¸·Î ¹Ù²î¾ú´Ù. (¾Æ¸¶ ±â¾ï¿¡´Â 1996³âÀÎ °Í °°´Ù.)

Hyperwave´Â free software°¡ ¾Æ´Ï´Ù. ÇöÀç ¹öÀüÀº 4.0ÀÌ°í ÀÌ ¹öÀüÀº www.hyperwave.com¿¡¼­ ±¸ÇÒ ¼ö ÀÖ´Ù. 30ÀÏ°£ »ç¿ëÇØ º¼ ¼ö ÀÖ´Â ½Ã°£ Á¦¾àÀÌ ÀÖ´Â ¹öÀüÀ» ¹ÞÀ» ¼ö ÀÖÀ» °ÍÀÌ´Ù.

Hyperwave ´Â µ¥ÀÌÅͺ£À̽º¿Í ºñ½ÁÇÑ information ½Ã½ºÅÛ(HIS, Hyperwave Information Server)ÀÌ´Ù. ÀÌ°ÍÀÇ ÃÊÁ¡Àº ¹®¼­¸¦ º¸°üÇÏ°í °ü¸®ÇÏ´Â °ÍÀÌ´Ù. ¿©±â¼­ ¹®¼­´Â ÆÄÀÏ·Î ÀúÀåµÉ ¼ö ÀÖ´Â ¸ðµç Á¾·ùÀÇ µ¥ÀÌÅ͸¦ ÀǹÌÇÑ´Ù. °¢°¢ÀÇ ¹®¼­´Â ±×°ÍÀÇ object ·¹Äڵ带 µ¿¹ÝÇÑ´Ù. ±× object ·¹Äڵ忡´Â ÇØ´ç ¹®¼­¿¡ ´ëÇÑ °¢Á¾ meta data°¡ ÀúÀåµÈ´Ù. ±× meta data´Â »ç¿ëÀÚ°¡ È®Àå°¡´ÉÇÑ ¼Ó¼º(attribute)µéÀÇ ¸ñ·Ï(list)À¸·Î µÇ¾îÀÖ´Ù. ¾î¶² ¼Ó¼ºµéÀº Hyperwave ¼­¹ö¿¡ ÀÇÇؼ­ ¼³Á¤µÈ´Ù. ´Ù¸¥ ¼Ó¼ºµéÀº »ç¿ëÀÚ°¡ ¼öÁ¤ÇØ ÁÙ ¼ö ÀÖ´Ù.

¹®¼­¿Ü¿¡µµ ¹®¼­¿¡ Æ÷ÇÔµÈ ¸ðµç hyper link±îÁöµµ object ·¹ÄÚµå·Î ÀúÀåµÈ´Ù. ¹®¼­¸¦ µ¥ÀÌÅͺ£À̽º¿¡ ÀúÀåÇÒ ¶§ ¹®¼­¿¡ Æ÷ÇÔµÈ hyper link´Â ¹®¼­¿¡¼­´Â »èÁ¦µÇ°í °³°³ÀÇ object·Î ÀúÀåµÈ´Ù. ÇØ´ç linkÀÇ object ·¹ÄÚµå´Â ±× ¸µÅ©°¡ ¹®¼­¿¡¼­ Â÷ÁöÇÏ´Â ½ÃÀÛ À§Ä¡¿Í ³¡³ª´Â À§Ä¡¿¡ ´ëÇÑ Á¤º¸¸¦ ÀúÀåÇÏ°í ÀÖ°Ô µÈ´Ù. ¿ø·¡ÀÇ ¹®¼­¸¦ ¾ò±â À§Çؼ­ ¿©·¯ºÐÀº ¿ì¼± ¸µÅ©°¡ ¾ø´Â ¹®¼­¸¦ °Ë»öÇÑ ÈÄ¿¡ ¸µÅ©¸¦ ¸®½ºÆ®ÇÏ°í, ±×°ÍµéÀ» ³¢¿ö ³Ö´Â´Ù. (hw_pipedocument()¿Í hw_gettext() ÇÔ¼ö°¡ À̸¦ À§ÇØ »ç¿ëµÈ´Ù.) ¹®¼­¿¡¼­ link¸¦ ºÐ¸®ÇÏ´Â °ÍÀÇ ÀåÁ¡Àº ¸íÈ®ÇÏ´Ù. ¿ì¼± ¸µÅ©ÀÇ ³»¿ëÀ» ¼öÁ¤ÇÏ´Â °ÍÀÌ °£´ÜÇÏ´Ù. ¸µÅ©ÀÇ ¼öÁ¤ÀÌ ¹®¼­ Àüü¿¡ ¿µÇâÀ» ¹ÌÄ¡Áö ¾Ê±â ¶§¹®ÀÌ´Ù. ¶ÇÇÑ ¹®¼­¸¦ ¼öÁ¤ÇÏÁö ¾Ê°íµµ ¸µÅ©¸¦ Ãß°¡ÇÒ ¼öµµ ÀÖ´Ù.

hw_pipedocument()¿Í hw_gettext()¸¦ »ç¿ëÇÏ¿© ¸µÅ©¸¦ »ðÀÔÇÏ´Â °ÍÀº º¸±âº¸´Ù ½¬¿îÀÏÀÌ ¾Æ´Ï´Ù. ¸µÅ©ÀÇ »ðÀÔÀº ¹®¼­ÀÇ ¸íÈ®ÇÑ °èÃþ ±¸Á¶¸¦ ¿ä±¸ÇÑ´Ù. À¥ ¼­¹ö¿¡¼­ ÀÌ°ÍÀº ÆÄÀÏ ½Ã½ºÅÛÀ¸·Î ¼³Á¤ÇÑ´Ù. ±×·¯³ª Hyperwave´Â ÇØ´ç ÆÄÀÏ ½Ã½ºÅÛ °èÃþ ±¸Á¶¿Í´Â °ü°è¾ø´Â °íÀ¯ÀÇ °èÃþ±¸Á¶¿Í À̸§À» °¡Áö°Ô µÈ´Ù. ±×·¯¹Ç·Î, ¸µÅ©¸¦ ¸¸µé ¶§´Â ¿ì¼± Hyperwave °èÃþ ±¸Á¶¿Í namespace¸¦ À¥ÀÇ °èÃþ±¸Á¶¿Í namespace·Î ¸ÊÇÎÇÏ´Â °ÍºÎÅÍ ÇÏ¿©¾ß ÇÑ´Ù. Hyperwave¿Í À¥ °£ÀÇ °¡Àå ±âº»ÀûÀÎ Â÷ÀÌ´Â À̸§ÀÇ ¸íÈ®ÇÑ ±¸º°¼º°ú Hyperwave °èÃþ±¸Á¶¿¡ ÀÖ´Ù. Hyperwave¿¡¼­ À̸§Àº object°¡ °èÃþ±¸Á¶¿¡¼­ÀÇ À§Ä¡¿¡ ´ëÇÑ Á¤º¸´Â ÀüÇô °¡Áö°í ÀÖÁö ¾Ê´Ù. ±×·¯³ª À¥¿¡¼­´Â À̸§ÀÌ °èÃþ±¸Á¶ÀÇ ¾îµð¿¡ À§Ä¡Çϴ°¡¿¡ ´ëÇÑ Á¤º¸¸¦ Æ÷ÇÔÇÏ°í ÀÖ°Ô µÈ´Ù. À̷μ­ µÎ°¡Áö ¸ÊÇÎ ¹æ¹ýÀÌ °¡´ÉÇÏ´Ù. Hyperwave objectÀÇ Hyperwave °èÃþ±¸Á¶¿Í À̸§À» »ç¿ëÇÏ¿© URL¿¡ ¹Ý¿µÇÏ´Â ¹æ¹ý°ú À̸§¸¸À» »ç¿ëÇÏ´Â ¹æ¹ýÀÌ´Ù. ÀϹÝÀûÀ¸·Î °£´ÜÇÑ ¹æ¹ýÀº À̸§¸¸À» »ç¿ëÇÏ´Â ¹æ¹ýÀÌ´Ù. Hyperwave °èÃþ±¸Á¶ ¾È¿¡ Á¸ÀçÇÏ´Â 'my_object'À̶ó´Â À̸§À» °¡Áø Hyperwave object´Â 'http://host/my_object' ·Î ¸ÊÇεȴÙ. Hyperwave °èÃþ±¸Á¶¿¡¼­´Â 'parent/my_object' ¶ó´Â À̸§À» °¡Áø object°¡ 'my_object'ÀÇ ¹Ø¿¡(child) ÀÖÀ» ¼öµµ ÀÖ´Ù. ¹°·Ð, À¥ namespace¿¡¼­´Â ±×°ÍÀÌ »ó¹ÝµÇ´Â °ÍÀÌ¸ç »ç¿ëÀڵ鿡°Ô È¥¶õÀ» °¡Á®´Ù ÁØ´Ù. ÀûÀýÇÑ obect À̸§À» ¼±ÅÃÇÏ´Â °Í¸¸ÀÌ ÀÌ È¥¶õÀ» ÇÇÇÒ ¼ö ÀÖ´Ù.

ÀÌ °áÁ¤À» ³»¸®°Ô µÇ¸é µÎºÐ° ¹®Á¦°¡ »ý±ä´Ù. ¾î¶»°Ô PHP¿¡ Æ÷ÇÔ½Ãų °ÍÀΰ¡? http://host/my_objectÀÇ URL·Î´Â ¾î¶² PHP½ºÅ©¸³Æ®µµ È£ÃâÇÏÁö ¸øÇÑ´Ù. À̸¦ À§Çؼ­´Â ¿©·¯ºÐÀÌ À¥¼­¹ö¿¡ ÀÌÁÖ¼Ò¸¦ 'http://host/php3_script/my_object'°°Àº ÁÖ¼Ò·Î Àç¼³Á¤Çϵµ·Ï ¾Ë·ÁÁÖ¾î¾ß ÇÏ°í, $PATH_INFO º¯¼ö¿Í Hyperwave serverÀÇ 'my_object'¶ó´Â À̸§ÀÇ object¸¦ °Ë»öÇÏ¿© Æò°¡ÇÏ´Â 'php3_script'¶ó´Â ½ºÅ©¸³Æ®°¡ ÀÖ¾î¾ß ÇÑ´Ù.

¿©±â¿¡´Â ½±°Ô °íÄ¥ ¼ö ÀÖ´Â °áÁ¡ÀÌ Çϳª ÀÖ´Ù. À¥¼­¹ö¿¡¼­ ¾ðÁ¦³ª ´Ù¸¥ ¹®¼­·ÎÀÇ Á¢±ÙÀÌ °¡´ÉÇÑ URLÀ» Àç¼³Á¤ÇÒ ¼ö ÀÖ´Â °ÍÀº ¾Æ´Ï¶ó´Â °ÍÀÌ´Ù. Hyperwave ¼­¹ö·ê °Ë»öÇϱâ À§ÇÑ PHP ½ºÅ©¸³Æ®´Â ¾Æ¸¶ ºÒ°¡´ÉÇÒ °ÍÀÌ´Ù. ±×·¯¹Ç·Î ¿©·¯ºÐÀº ÃÖ¼ÒÇÑ http://host/Hyperwave·Î ½ÃÀÛÇÏ´Â °Í °°Àº ƯÁ¤ URLÀº Á¦¿Ü½ÃÅ°´Â µÎ ¹ø° Àç¼³Á¤ ±ÔÄ¢À» ¼³Á¤ÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. ÀÌ°ÍÀÌ À¥ÀÇ namespace¿Í Hyperwave ¼­¹ö¸¦ °øÀ¯ÇÏ´Â ±âº»ÀÌ µÈ´Ù.

¸µÅ©ÀÇ »ðÀÔÀº À§ÀÇ ¸ÞÄ«´ÏÁòÇÏ¿¡¼­ ÀÌ·ç¾î Áø´Ù. ¸¸¾à PHP°¡ moduleÀ̳ª CGI ½ºÅ©¸³Æ®°¡ ¾Æ´Ñ µ¶¸³ ½ÇÇà ÇÁ·Î±×·¥À̶ó¸é(¿¹¸¦µé¾î CD-ROM¿¡ ÀÖ´Â Hyperwave ¼­¹öÀÇ ³»¿ëÀ» ´ýÇÁÇØ º»´Ù´øÁö ÇÏ´Â) ÀÌ µ¿ÀÛÀº ¸Å¿ì º¹ÀâÇØÁø´Ù. ÀÌ·± °æ¿ì¶ó¸é Hyperwave °èÃþ±¸Á¶¸¦ À¯ÁöÇÏ°í À̸¦ ¹ÙÅÁÀ¸·Î ÆÄÀÏ ½Ã½ºÅÛ¿¡ ¸ÊÇÑ´Ù. ¸¸¾à Hyperwave °èÃþ±¸Á¶¸¦ ÆÄÀÏ ½Ã½ºÅÛÀÇ °èÃþ±¸Á¶¿¡ ±×´ë·Î ¹Ý¿µÇÏ°íÀÚ ÇÑ´Ù¸é °èÃþ±¸Á¶¿Í object À̸§°£¿¡ ¸ð¼øÀÌ »ý±æ ¼ö ÀÖ´Ù ('/'ÀÌ Æ÷ÇÔµÈ À̸§ÀÇ °æ¿ì). µû¶ó¼­ '/'´Â ¹Ýµå½Ã '_'°°Àº ´Ù¸¥ ±ÛÀÚ·Î ´ëÄ¡µÇ¾î¾ß¸¸ ÇÑ´Ù.

Hyperwave ¼­¹ö¿Í Åë½ÅÇÏ´Â ³×Æ®¿öÅ© ÇÁ·ÎÅäÄÝÀº HG-CSP (Hyper-G Client/Server Protocol)À̶ó°í ºÒ¸°´Ù. ÀÌ°ÍÀº ƯÁ¤ µ¿ÀÛ(object ·¹Äڵ带 ÀÏ°Å¿À´Â °Í °°Àº)À» ½ÃÀÛÇÏ´Â ¸Þ¼¼Áö¿¡ ±â¹ÝÇÑ´Ù. Hyperwave ¼­¹öÀÇ Ãʱ⠹öÀü¿¡´Â ¼­¹ö¿ÍÀÇ Åë½ÅÀ» Á¦°øÇϱâ À§ÇØ Harmony¿Í Amadeus¶ó´Â µÎ °³ÀÇ °íÀ¯ÇÑ Å¬¶óÀ̾ðÆ®°¡ ÀÖ¾ú´Ù. ±×·¯³ª ÀÌ µÎ°¡Áö´Â Hyperwave°¡ »ó¿ëÈ­µÇ¸é¼­ »ç¶óÁö°í, wavemaster ¶ó´Â °ÍÀ¸·Î ´ëÄ¡µÇ¾ú´Ù. wavemaster´Â HTTP¿¡¼­ HG-CSP·ÎÀÇ ÇÁ·ÎÅäÄÝ º¯È¯±â(protocol converter) °°Àº °ÍÀÌ´Ù. ÀÌ°ÍÀº µ¥ÀÌÅͺ£À̽ºÀÇ °ü¸®¿Í ¹®¼­ÀÇ Ç¥½Ã µî ¸ðµç °ÍÀ» À¥ ȯ°æ¿¡¼­ ÇØ°áÇÏ·Á´Â »ý°¢ÀÌ´Ù. wavemaster´Â »ç¿ëÀÚ°¡ ÀÎÅÍÆäÀ̽º¸¦ ¼öÁ¤Çϴ ƯÁ¤ µ¿ÀÛÀ» À§ÇÑ ÀÏ·ÃÀÇ placeholderµéÀ» Á¦°øÇÑ´Ù. ÀÌ ÀÏ·ÃÀÇ placeholderµéÀ» PLACE ¾ð¾î¶ó°í ºÎ¸¥´Ù. PLACE´Â ÁøÁ¤ÇÑ ÇÁ·Î±×·¡¹Ö ¾ð¾î³ª À̸¦ À§ÇÑ ´Ù¸¥ extension¿¡ ºñÇؼ­´Â ¸¹Àº ¸é¿¡¼­ ºÎÁ·ÇÏ´Ù. PLACE´Â ´ÜÁö placeholder °³¼ö¸¦ ´Ã·ÁÁÖ´Â °Í »ÓÀÌ´Ù. µû¶ó¼­ JavascriptÀÇ »ç¿ëÀÌ ÇʼöÀûÀ¸·Î ¿ä±¸µÈ´Ù.

PHP¿¡ Hyperwave Áö¿øÀ» Ãß°¡ÇÔÀ¸·Î½á, interface customisationºÎºÐ¿¡¼­ PHPÀÇ ÇÁ·Î±×·¡¹Ö ¾ð¾îÀÇ ºÎÁ·ÇÑ ºÎºÐÀ» º¸ÃæÇÒ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº HG-CSP¿¡ ÀÇÇØ Á¤ÀÇµÈ ¸ðµç ¸Þ½ÃÁö¸¦ ±¸ÇöÇÏ´Â °ÍÀÌ°í, ³ª¾Æ°¡ ¿Ï¼ºµÈ ¹®¼­¸¦ °Ë»öÇÏ´Â µîÀÇ ´õ °­·ÂÇÑ ¸í·ÉµéÀ» Ãß°¡ÇÏ¿´´Ù.

Hyperwave´Â Á¤º¸ÀÇ Æ¯Á¤ÇÑ ´ÜÆíµé¿¡ À̸§À» ºÙÀ̱â À§ÇÑ ÀڽŸ¸ÀÇ ÀÛ¸í¹ý(terminology)À» °¡Áö°í ÀÖ´Ù. ÀÌ°ÍÀº ±¤¹üÀ§ÇÏ°Ô È®´ëµÇ°í ÀÖ´Ù. ´ëºÎºÐÀÇ ÇÔ¼öµéÀº ´ÙÀ½ µ¥ÀÌÅÍ Å¸ÀÔ Áß¿¡ Çϳª¿¡ ÀÛ¿ëÇÑ´Ù.

object ·¹ÄÚµåÀÇ ¹è¿­¸¦ ¹ÝȯÇÏ´Â ¸î¸î ÇÔ¼öµéÀ» ÇØ´ç ·¹ÄÚµåµé¿¡ ´ëÇÑ Åë°èÀû Á¤º¸¸¦ °¡Áø ¿¬ÇÕ ¹è¿­µµ ÇÔ²² ¹ÝȯÇÑ´Ù. ¹ÝȯµÈ Àüü object ·¹ÄÚµåÀÇ ¹è¿­ÀÇ ¸¶Áö¸· ¿ø¼Ò°¡ ÀÌ ¹è¿­ÀÌ´Ù. Åë°èÀû Á¤º¸¸¦ °¡Áø ¹è¿­¿¡´Â ´ÙÀ½°ú °°Àº ¿ä¼ÒµéÀÇ Á¤º¸°¡ ÀÖ´Ù.

 
Hidden

PresentationHints ¼Ó¼ºÀÌ HiddenÀ¸·Î ¼³Á¤µÈ object ·¹ÄÚµåÀÇ °³¼ö
(Number of object records with attribute PresentationHints set to Hidden.)

CollectionHead

PresentationHints ¼Ó¼ºÀÌ CollectionHeadÀ¸·Î ¼³Á¤µÈ object ·¹ÄÚµåÀÇ °³¼ö
(Number of object records with attribute PresentationHints set to CollectionHead.)

FullCollectionHead

PresentationHints ¼Ó¼ºÀÌ FullCollectionHeadÀ¸·Î ¼³Á¤µÈ object ·¹ÄÚµåÀÇ °³¼ö
(Number of object records with attribute PresentationHints set to FullCollectionHead.)

CollectionHeadNr

PresentationHints ¼Ó¼ºÀÌ CollectionHeadÀ¸·Î ¼³Á¤µÈ object ·¹ÄÚµå ¹è¿­ÀÇ index
(Index in array of object records with attribute PresentationHints set to CollectionHead.)

FullCollectionHeadNr

PresentationHints ¼Ó¼ºÀÌ FullCollectionHeadÀ¸·Î ¼³Á¤µÈ object ·¹ÄÚµå ¹è¿­ÀÇ index
(Index in array of object records with attribute PresentationHints set to FullCollectionHead.)

Total

object ·¹ÄÚµåÀÇ Àüü °³¼ö
(Total number of object records.)

 


Apache¿ÍÀÇ ÅëÇÕ (Integration with Apache)

Hyperwave ¸ðµâÀº PHP°¡ ¾ÆÆÄÄ¡ ¸ðµâ·Î ÄÄÆÄÀϵǾúÀ» ¶§ °¡Àå Àß »ç¿ëµÉ ¼ö ÀÖ´Ù. ÀÌ °æ¿ì¿¡ ¾ÆÆÄÄ¡°¡ ÀÚ½ÅÀÇ ÀçÀÛ¼º(rewriting) ¿£ÁøÀ» »ç¿ëÇÏ°Ô µÇ¸é Hyperwave ¼­¹öÀÇ Á¸Àç´Â »ç¿ëÀÚ°¡ °ÅÀÇ ´À³¥ ¼ö ¾ø°Ô µÈ´Ù. ´ÙÀ½ÀÇ ³»¿ëµéÀÌ ÀÌ°ÍÀ» ¼³¸íÇØ ÁÙ °ÍÀÌ´Ù.

Hyperwave¸¦ Áö¿øÇÏ´Â ¾ÆÆÄÄ¡·Î ¸¸µé¾îÁø PHP°¡ wavemaster±â¹ÝÀÇ µ¶ÀÚÀûÀÎ Hyperwave ¼Ö·ç¼ÇÀ» ´ë½ÅÇÏ·Á ÇÒ ¶§ºÎÅÍ, ¾ÆÆÄÄ¡ ¼­¹ö°¡ Hyperwave À¥ ÀÎÅÍÆäÀ̽º¸¦ Áö¿øÇÏ´Â À¯ÀÏÇÑ ¼­¹ö°¡ µÇ¸®¶ó ´ç¿¬È÷ ÃßÁ¤µÇ¾ú´Ù.

ÀÌ°ÍÀº ¹Ýµå½Ã ÇÊ¿äÇÑ °ÍÀº ¾Æ´ÏÁö¸¸ ¼³Á¤À» ½±°Ô ÇØÁØ´Ù. °³³äÀº ´Ü¼øÇÏ´Ù. ¿ì¼±, ¿©·¯ºÐÀº PATH_INFO º¯¼ö¸¦ Æò°¡ÇÏ°í ÀÌ º¯¼öÀÇ °ªÀ» Hyperwave object·Î ´Ù·ê PHP ½ºÅ©¸³Æ®°¡ ÇÊ¿äÇÏ´Ù. ÀÌÁ¦ ÀÌ ½ºÅ©¸³Æ®ÀÇ À̸§À» 'Hyperwave'¶ó°í ºÎ¸£ÀÚ. http://your.hostname/Hyperwave/name_of_object¶ó´Â URLÀº ¾Æ¸¶µµ 'name_of_object'¶ó´Â À̸§À» °¡Áø Hyperwave object¸¦ ¹ÝȯÇÒ °ÍÀÌ´Ù. ½ºÅ©¸³Æ®´Â ±× objectÀÇ Å¸ÀÔ¿¡ µû¶ó¼­ ÀûÀýÈ÷ ¹ÝÀÀÇÑ´Ù. ¸¸¾à ŸÀÔÀÌ collectionÀ̶ó¸é ¾Æ¸¶µµ childrenÀÇ ¸®½ºÆ®¸¦ ¹ÝȯÇÑ´Ù. ¸¸¾à ŸÀÔÀÌ ¹®¼­(document)¶ó¸é mime ŸÀÔ°ú ±× ³»¿ëÀ» ¹ÝȯÇÑ´Ù. ¾ÆÆÄÄ¡ ÀçÀÛ¼º ¿£Áø (apache rewriting engine)ÀÌ »ç¿ëµÈ´Ù¸é ¾à°£ÀÇ °³¼±À» ¾òÀ» ¼ö ÀÖ´Ù. http://your.hostname/name_of_object°°Àº ÇüÅ·ΠURLÀ» »ç¿ëÇÏ¿© object¸¦ ¹ÝȯÇÑ´Ù¸é »ç¿ëÀÚ ÀÔÀå¿¡¼­ Á»´õ Á÷°üÀûÀÏ ¼ö ÀÖ´Ù. À̸¦ À§ÇÑ ÀçÀÛ¼º(rewriting) ±ÔÄ¢Àº ´ÙÀ½°ú °°ÀÌ ¸Å¿ì ½±´Ù. :

  1 
  2 RewriteRule ^/(.*) /usr/local/apache/htdocs/HyperWave/$1 [L]
  3 

ÀÌÁ¦ ¸ðµç URLÀº Hyperwave ¼­¹öÀÇ object¿Í ¿¬°áµÈ´Ù. ÀÌ°ÍÀº ºñ±³Àû °£´ÜÈ÷ ÇØ°áÇÒ ¼ö ÀÖ´Â ÇÑ°¡Áö ¹®Á¦¸¦ ¸¸µé¾î ³½´Ù. À̷νá 'Hyperwave' ½ºÅ©¸³Æ® ÀÌ¿ÜÀÇ ´Ù¸¥ ½ºÅ©¸³Æ®(¿¹¸¦µé¾î, °Ë»öÀ» À§ÇÑ ½ºÅ©¸³Æ® µî)´Â ½ÇÇàÇÒ ¼ö ¾ø°Ô µÈ´Ù. À̸¦ ÇØ°áÇϱâ À§ÇÑ ¶Ç´Ù¸¥ ÀÛ¼º(rewriting) ±ÔÄ¢À» ´ÙÀ½°ú °°ÀÌ ÀÛ¼ºÇØ ÁØ´Ù.

  1 
  2 RewriteRule ^/hw/(.*) /usr/local/apache/htdocs/hw/$1 [L]
  3 

ÀÌ°ÍÀ¸·Î Ãß°¡ÀûÀÎ ½ºÅ©¸³Æ®¿Í ÆÄÀϵéÀ» À§ÇÑ /usr/local/apache/htdocs/hw µð·ºÅ丮¸¦ ³²°ÜµÎ°Ô µÈ´Ù. ±×¸®°í ÀÌ ±ÔÄ¢À» À§ÀÇ ±ÔÄ¢º¸´Ù ¸ÕÀú Æò°¡µÇµµ·Ï ÇÑ´Ù. ¾à°£ÀÇ °áÁ¡ÀÌ Àִµ¥, 'hw/'·Î ½ÃÀÛÇÏ´Â À̸§À» °¡Áø Hyperwave object´Â Á¢±ÙÇÒ ¼ö ¾ø°Ô µÈ´Ù. ±×·¯¹Ç·Î ¿©·¯ºÐÀº ±×·± À̸§Àº ¾²Áö ¾Êµµ·Ï ÇÑ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ´õ ¸¹Àº µð·ºÅ丮(¿¹¸¦µé¾î, À̹ÌÁö¸¦ À§ÇÑ µð·ºÅ丮)°¡ ÇÊ¿äÇÏ´Ù¸é, »õ·Î¿î ±ÔÄ¢À» ÷°¡Çϰųª ¿øÇÏ´Â µð·ºÅ丮µéÀ» ¸ðµÎ ÇÑ µð·ºÅ丮 ¹Ø¿¡ ³õÀ¸¸é µÈ´Ù. ¸¶Áö¸·À¸·Î, ´ÙÀ½°ú °°ÀÌÇÏ¿© ÀçÀÛ¼º ¿£Áø(rewriting engine)À» Äѵµ·Ï ÇÑ´Ù. :

  1 
  2 RewriteEngine on
  3 

³» °æÇèÀ¸·Î º¸¾ÒÀ» ¶§ ¿©·¯ºÐÀ» ´ÙÀ½ÀÇ ½ºÅ©¸³Æ®µéÀÌ ÇÊ¿äÇÏ°Ô µÉ °ÍÀÌ´Ù. :


Todo

¾ÆÁ÷ ÇؾßÇÒ ÀÏÀº ´ÙÀ½°ú °°´Ù. :


Table of Contents
hw_Array2Objrec ¡¦ convert attributes from object array to object record
hw_Children ¡¦ object ids of children
hw_ChildrenObj ¡¦ object records of children
hw_Close ¡¦ closes the Hyperwave connection
hw_Connect ¡¦ opens a connection
hw_Cp ¡¦ copies objects
hw_Deleteobject ¡¦ deletes object
hw_DocByAnchor ¡¦ object id object belonging to anchor
hw_DocByAnchorObj ¡¦ object record object belonging to anchor
hw_DocumentAttributes ¡¦ object record of hw_document
hw_DocumentBodyTag ¡¦ body tag of hw_document
hw_DocumentContent ¡¦ returns content of hw_document
hw_DocumentSetContent ¡¦ sets/replaces content of hw_document
hw_DocumentSize ¡¦ size of hw_document
hw_ErrorMsg ¡¦ returns error message
hw_EditText ¡¦ retrieve text document
hw_Error ¡¦ error number
hw_Free_Document ¡¦ frees hw_document
hw_GetParents ¡¦ object ids of parents
hw_GetParentsObj ¡¦ object records of parents
hw_GetChildColl ¡¦ object ids of child collections
hw_GetChildCollObj ¡¦ object records of child collections
hw_GetRemote ¡¦ Gets a remote document
hw_GetRemoteChildren ¡¦ Gets children of remote document
hw_GetSrcByDestObj ¡¦ Returns anchors pointing at object
hw_GetObject ¡¦ object record
hw_GetAndLock ¡¦ return bject record and lock object
hw_GetText ¡¦ retrieve text document
hw_GetObjectByQuery ¡¦ search object
hw_GetObjectByQueryObj ¡¦ search object
hw_GetObjectByQueryColl ¡¦ search object in collection
hw_GetObjectByQueryCollObj ¡¦ search object in collection
hw_GetChildDocColl ¡¦ object ids of child documents of collection
hw_GetChildDocCollObj ¡¦ object records of child documents of collection
hw_GetAnchors ¡¦ object ids of anchors of document
hw_GetAnchorsObj ¡¦ object records of anchors of document
hw_Mv ¡¦ moves objects
hw_Identify ¡¦ identifies as user
hw_InCollections ¡¦ check if object ids in collections
hw_Info ¡¦ info about connection
hw_InsColl ¡¦ insert collection
hw_InsDoc ¡¦ insert document
hw_InsertDocument ¡¦ upload any document
hw_InsertObject ¡¦ inserts an object record
hw_mapid ¡¦ Maps global id on virtual local id
hw_Modifyobject ¡¦ modifies object record
hw_New_Document ¡¦ create new document
hw_Objrec2Array ¡¦ convert attributes from object record to object array
hw_OutputDocument ¡¦ prints hw_document
hw_pConnect ¡¦ make a persistent database connection
hw_PipeDocument ¡¦ retrieve any document
hw_Root ¡¦ root object id
hw_Unlock ¡¦ unlock object
hw_Who ¡¦ List of currently logged in users
hw_Username ¡¦ name of currently logged in user

hw_Array2Objrec

hw_Array2Objrec -- object arrayÀÇ ¼Ó¼º(attributes)À» object record·Î º¯È¯ÇÑ´Ù.

Description

strin hw_array2objrec (array object_array)

Converts an object_array into an object record. Multiple attributes like 'Title' in different languages are treated properly.

See also hw_objrec2array().

hw_Children

hw_Children -- childrenÀÇ object idµé

Description

array hw_children(int connection, int objectID);

Returns an array of object ids. Each id belongs to a child of the collection with ID objectID. The array contains all children both documents and collections.

hw_ChildrenObj

hw_ChildrenObj -- childrenÀÇ object recordµé

Description

array hw_childrenobj(int connection, int objectID);

Returns an array of object records. Each object record belongs to a child of the collection with ID objectID. The array contains all children both documents and collections.

hw_Close

hw_Close -- Hyperwave connectionÀ» ´Ý´Â´Ù.

Description

int hw_close(int connection);

Returns false if connection is not a valid connection index, otherwise true. Closes down the connection to a Hyperwave server with the given connection index.

hw_Connect

hw_Connect -- Hyperwave connectionÀ» ¿¬´Ù.

Description

int hw_connect(string host, int port, string username, string password);

Opens a connection to a Hyperwave server and returns a connection index on success, or false if the connection could not be made. Each of the arguments should be a quoted string, except for the port number. The username and password arguments are optional and can be left out. In such a case no identification with the server will be done. It is similar to identify as user anonymous. This function returns a connection index that is needed by other Hyperwave functions. You can have multiple connections open at once. Keep in mind, that the password is not encrypted.

See also hw_pConnect().

hw_Cp

hw_Cp -- ÁöÁ¤ÇÑ objectµéÀ» º¹»çÇÑ´Ù.

Description

int hw_cp(int connection, array object_id_array, int destination id);

Copies the objects with object ids as specified in the second parameter to the collection with the id destination id.

The value return is the number of copied objects.

See also hw_mv().

hw_Deleteobject

hw_Deleteobject -- ƯÁ¤ object¸¦ »èÁ¦ÇÑ´Ù.

Description

int hw_deleteobject(int connection, int object_to_delete);

Deletes the the object with the given object id in the second parameter. It will delete all instances of the object.

Returns TRUE if no error occurs otherwise FALSE.

See also hw_mv().

hw_DocByAnchor

hw_DocByAnchor -- ÁöÁ¤µÈ anchor¿¡ ¼ÓÇÏ´Â objectÀÇ object id

Description

int hw_docbyanchor(int connection, int anchorID);

Returns an th object id of the document to which anchorID belongs.

hw_DocByAnchorObj

hw_DocByAnchorObj -- ÁöÁ¤µÈ anchor¿¡ ¼ÓÇÏ´Â objectÀÇ object record

Description

string hw_docbyanchorobj(int connection, int anchorID);

Returns an th object record of the document to which anchorID belongs.

hw_DocumentAttributes

hw_DocumentAttributes -- hw_documentÀÇ object record

Description

string hw_documentattributes(int hw_document);

Returns the object record of the document.

See also hw_DocumentBodyTag(), hw_DocumentSize().

hw_DocumentBodyTag

hw_DocumentBodyTag -- hw_documentÀÇ body tagÀ» ¹ÝȯÇÑ´Ù.

Description

string hw_documentbodytag(int hw_document);

Returns the BODY tag of the document. If the document is an HTML document the BODY tag should be printed before the document.

See also hw_DocumentAttributes(), hw_DocumentSize().

hw_DocumentContent

hw_DocumentContent -- hw_documentÀÇ ³»¿ëÀ» ¹ÝȯÇÑ´Ù.

Description

string hw_documentcontent(int hw_document);

Returns the content of the document. If the document is an HTML document the content is everything after the BODY tag. Information from the HEAD and BODY tag is in the stored in the object record.

See also hw_DocumentAttributes(), hw_DocumentSize(), hw_DocumentSetContent().

hw_DocumentSetContent

hw_DocumentSetContent -- hw_documentÀÇ ³»¿ëÀ» ¼³Á¤Çϰųª ÀçÁöÁ¤ÇÑ´Ù.

Description

string hw_documentsetcontent(int hw_document, string content);

Sets or replaces the content of the document. If the document is an HTML document the content is everything after the BODY tag. Information from the HEAD and BODY tag is in the stored in the object record. If you provide this information in the content of the document too, the Hyperwave server will change the object record accordingly when the document is inserted. Probably not a very good idea. If this functions fails the document will retain its old content.

See also hw_DocumentAttributes(), hw_DocumentSize(), hw_DocumentContent().

hw_DocumentSize

hw_DocumentSize -- hw_documentÀÇ Å©±â

Description

int hw_documentsize(int hw_document);

Returns the size in bytes of the document.

See also hw_DocumentBodyTag(), hw_DocumentAttributes().

hw_ErrorMsg

hw_ErrorMsg -- error message¸¦ ¹ÝȯÇÑ´Ù.

Description

string hw_errormsg(int connection);

Returns a string containing the last error message or 'No Error'. If false is returned, this function failed. The message relates to the last command.

hw_EditText

hw_EditText -- text ¹®¼­¸¦ ¿ø·¡´ë·Î º¹±¸(retrieve)ÇÑ´Ù.

Description

int hw_edittext(int connection, int hw_document);

Uploads the text document to the server. The object record of the document may not be modified while the document is edited. This function will only works for pure text documents. It will not open a special data connection and therefore blocks the control connection during the transfer.

See also hw_PipeDocument(), hw_FreeDocument(), hw_DocumentBodyTag(), hw_DocumentSize(), hw_OutputDocument(), hw_GetText().

hw_Error

hw_Error -- error ¹øÈ£¸¦ ¹ÝȯÇÑ´Ù.

Description

int hw_error(int connection);

Returns the last error number. If the return value is 0 no error has occurred. The error relates to the last command.

hw_Free_Document

hw_Free_Document -- hw_document°¡ Á¡À¯ÇÏ°í ÀÖ´Â ÀÚ¿øµéÀ» Ç®¾îÁØ´Ù.

Description

int hw_free_document(int hw_document);

Frees the memory occupied by the Hyperwave document.

hw_GetParents

hw_GetParents -- parentµéÀÇ object idµé

Description

array hw_getparentsobj(int connection, int objectID);

Returns an indexed array of object ids. Each object id belongs to a parent of the object with ID objectID.

hw_GetParentsObj

hw_GetParentsObj -- parentµéÀÇ object recordµé

Description

array hw_getparentsobj(int connection, int objectID);

Returns an indexed array of object records plus an associated array with statistical information about the object records. The associated array is the last entry of the returned array. Each object record belongs to a parent of the object with ID objectID.

hw_GetChildColl

hw_GetChildColl -- child collectionµéÀÇ object idµé

Description

array hw_getchildcoll(int connection, int objectID);

Returns an array of object ids. Each object ID belongs to a child collection of the collection with ID objectID. The function will not return child documents.

See also hw_GetChildren(), hw_GetChildDocColl().

hw_GetChildCollObj

hw_GetChildCollObj -- child collectionµéÀÇ object recordµé

Description

array hw_getchildcollobj(int connection, int objectID);

Returns an array of object records. Each object records belongs to a child collection of the collection with ID objectID. The function will not return child documents.

See also hw_ChildrenObj(), hw_GetChildDocCollObj().

hw_GetRemote

hw_GetRemote -- remote document¸¦ ±¸ÇÑ´Ù.

Description

int hw_getremote(int connection, int objectID);

Returns a remote document. Remote documents in Hyperwave notation are documents retrieved from an external source. Common remote documents are for example external web pages or queries in a database. In order to be able to access external sources throught remote documents Hyperwave introduces the HGI (Hyperwave Gateway Interface) which is similar to the CGI. Currently, only ftp, http-servers and some databases can be accessed by the HGI. Calling hw_GetRemote() returns the document from the external source. If you want to use this function you should be very familiar with HGIs. You should also consider to use PHP instead of Hyperwave to access external sources. Adding database support by a Hyperwave gateway should be more difficult than doing it in PHP.

See also hw_GetRemoteChildren().

hw_GetRemoteChildren

hw_GetRemoteChildren -- remote documentÀÇ childrenÀ» ±¸ÇÑ´Ù.

Description

int hw_getremotechildren(int connection, string object record);

Returns the children of a remote document. Children of a remote document are remote documents itself. This makes sense if a database query has to be narrowed and is explained in Hyperwave Programmers' Guide. If the number of children is 1 the function will return the document itself formated by the Hyperwave Gateway Interface (HGI). If the number of children is greater than 1 it will return an array of object record with each maybe the input value for another call to hw_GetRemoteChildren(). Those object records are virtual and do not exist in the Hyperwave server, therefore they do not have a valid object ID. How exactely such an object record looks like is up to the HGI. If you want to use this function you should be very familiar with HGIs. You should also consider to use PHP instead of Hyperwave to access external sources. Adding database support by a Hyperwave gateway should be more difficult than doing it in PHP.

See also hw_GetRemote().

hw_GetSrcByDestObj

hw_GetSrcByDestObj -- ÁöÁ¤µÈ object¸¦ Áö½ÃÇÏ´Â anchorµéÀ» ¹ÝȯÇÑ´Ù.

Description

array hw_getsrcbydestobj(int connection, int objectID);

Returns the object records of all anchors pointing to the object with ID objectID. The object can either be a document or an anchor of type destination.

See also hw_GetAnchors().

hw_GetObject

hw_GetObject -- ÁöÁ¤ÇÑ object record¸¦ ¹ÝȯÇÑ´Ù.

Description

array hw_getobject(int connection, [int|array] objectID, string query);

Returns the object record for the object with ID objectID if the second parameter is an integer. If the second parameter is an array of integer the function will return an array of object records. In such a case the last parameter is also evaluated which is a query string.

The query string has the following syntax:

<expr> ::= "(" <expr> ")" |

"!" <expr> | /* NOT */

<expr> "||" <expr> | /* OR */

<expr> "&&" <expr> | /* AND */

<attribute> <operator> <value>

<attribute> ::= /* any attribute name (Title, Author, DocumentType ...) */

<operator> ::= "=" | /* equal */

"<" | /* less than (string compare) */

">" | /* greater than (string compare) */

"~" /* regular expression matching */

The query allows to further select certain objects from the list of given objects. Unlike the other query functions, this query may use not indexed attributes. How many object records are returned depends on the query and if access to the object is allowed.

See also hw_GetAndLock(), hw_GetObjectByQuery().

hw_GetAndLock

hw_GetAndLock -- object record¸¦ ¹ÝȯÇÏ°í ÇØ´ç object¸¦ lockÇÑ´Ù.

Description

string hw_getandlock(int connection, int objectID);

Returns the object record for the object with ID objectID. It will also lock the object, so other users cannot access it until it is unlocked.

See also hw_Unlock(), hw_GetObject().

hw_GetText

hw_GetText -- text ¹®¼­¸¦ ¿ø·¡´ë·Î º¹±¸(retrieve)ÇÑ´Ù.

Description

int hw_gettext(int connection, int objectID, mixed [rootID/prefix] );

Returns the document with object ID objectID. If the document has anchors which can be inserted, they will be inserted already. The optional parameter rootID/prefix can be a string or an integer. If it is an integer it determines how links are inserted into the document. The default is 0 and will result in links that are constructed from the name of the link's destination object. This is useful for web applications. If a link points to an object with name 'internet_movie' the HTML link will be <A HREF="/internet_movie">. The actual location of the source and destination object in the document hierachy is disregarded. You will have to set up your web browser, to rewrite that URL to for example '/my_script.php3/internet_movie'. 'my_script.php3' will have to evaluate $PATH_INFO and retrieve the document. All links will have the prefix '/my_script.php3/'. If you do not want this you can set the optional parameter rootID/prefix to any prefix which is used instead. Is this case it has to be a string.

If rootID/prefix is an integer and unequal to 0 the link is constructed from all the names starting at the object with the id rootID/prefix separated by a slash relative to the current object. If for example the above document 'internet_movie' is located at 'a-b-c-internet_movie' with '-' being the seperator between hierachy levels on the Hyperwave server and the source document is located at 'a-b-d-source' the resulting HTML link would be: <A HREF="../c/internet_movie">. This is useful if you want to download the whole server content onto disk and map the document hierachy onto the file system.

This function will only work for pure text documents. It will not open a special data connection and therefore blocks the control connection during the transfer.

See also hw_PipeDocument(), hw_FreeDocument(), hw_DocumentBodyTag(), hw_DocumentSize(), hw_OutputDocument().

hw_GetObjectByQuery

hw_GetObjectByQuery -- object¸¦ ã´Â´Ù.

Description

array hw_getobjectbyquery(int connection, string query, int max_hits);

Searches for objects on the whole server and returns an array of object ids. The maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum number of matches is unlimited.

The query will only work with indexed attributes.

See also hw_GetObjectByQueryObj().

hw_GetObjectByQueryObj

hw_GetObjectByQueryObj -- object¸¦ ã´Â´Ù.

Description

array hw_getobjectbyqueryobj(int connection, string query, int max_hits);

Searches for objects on the whole server and returns an array of object records. The maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum number of matches is unlimited.

The query will only work with indexed attributes.

See also hw_GetObjectByQuery().

hw_GetObjectByQueryColl

hw_GetObjectByQueryColl -- collection ¾È¿¡¼­ objectÀ» ã´Â´Ù.

Description

array hw_getobjectbyquerycoll(int connection, int objectID, string query, int max_hits);

Searches for objects in collection with ID objectID and returns an array of object ids. The maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum number of matches is unlimited.

The query will only work with indexed attributes.

See also hw_GetObjectByQueryCollObj().

hw_GetObjectByQueryCollObj

hw_GetObjectByQueryCollObj -- collection ¾È¿¡¼­ objectÀ» ã´Â´Ù.

Description

array hw_getobjectbyquerycollobj(int connection, int objectID, string query, int max_hits);

Searches for objects in collection with ID objectID and returns an array of object records. The maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum number of matches is unlimited.

The query will only work with indexed attributes.

See also hw_GetObjectByQueryColl().

hw_GetChildDocColl

hw_GetChildDocColl -- collection ¾ÈÀÇ child ¹®¼­µéÀÇ object id¸¦ ±¸ÇÑ´Ù.

Description

array hw_getchilddoccoll(int connection, int objectID);

Returns array of object ids for child documents of a collection.

See also hw_GetChildren(), hw_GetChildColl().

hw_GetChildDocCollObj

hw_GetChildDocCollObj -- collection ¾ÈÀÇ child ¹®¼­µéÀÇ object record¸¦ ±¸ÇÑ´Ù.

Description

array hw_getchilddoccollobj(int connection, int objectID);

Returns an array of object records for child documents of a collection.

See also hw_ChildrenObj(), hw_GetChildCollObj().

hw_GetAnchors

hw_GetAnchors -- ¹®¼­ÀÇ anchorµéÀÇ object id

Description

array hw_getanchors(int connection, int objectID);

Returns an array of object ids with anchors of the document with object ID objectID.

hw_GetAnchorsObj

hw_GetAnchorsObj -- ¹®¼­ÀÇ anchorµéÀÇ object record

Description

array hw_getanchorsobj(int connection, int objectID);

Returns an array of object records with anchors of the document with object ID objectID.

hw_Mv

hw_Mv -- objectµéÀ» ¿Å±ä´Ù.

Description

int hw_mv(int connection, array object id array, int source id, int destination id);

Moves the objects with object ids as specified in the second parameter from the collection with id source id to the collection with the id destination id. If the destination id is 0 the objects will be unlinked from the source collection. If this is the last instance of that object it will be deleted. If you want to delete all instances at once, use hw_deleteobject().

The value return is the number of moved objects.

See also hw_cp(), hw_deleteobject().

hw_Identify

hw_Identify -- »ç¿ëÀÚ¸¦ identifyÇÑ´Ù.

Description

int hw_identify(string username, string password);

Identifies as user with username and password. Identification is only valid for the current session. I do not thing this function will be needed very often. In most cases it will be easier to identify with the opening of the connection.

See also hw_Connect().

hw_InCollections

hw_InCollections -- object idÀÇ object°¡ collection¿¡ ¼ÓÇϴ°¡ °Ë»çÇÑ´Ù.

Description

array hw_incollections(int connection, array object_id_array, array collection_id array, int return_collections);

Checks whether a set of objects (documents or collections) specified by the object_id_array is part of the collections listed in collection_id_array. When the fourth parameter return_collections is 0, the subset of object ids that is part of the collections (i.e., the documents or collections that are children of one or more collections of collection ids or their subcollections, recursively) is returned as an array. When the fourth parameter is 1, however, the set of collections that have one or more objects of this subset as children are returned as an array. This option allows a client to, e.g., highlight the part of the collection hierarchy that contains the matches of a previous query, in a graphical overview.

hw_Info

hw_Info -- connection¿¡ ´ëÇÑ Á¤º¸

Description

string hw_info(int connection);

Returns information about the current connection. The returned string has the following format: <Serverstring>, <Host>, <Port>, <Username>, <Port of Client>, <Byte swapping>

hw_InsColl

hw_InsColl -- collectionÀ» »ðÀÔÇÑ´Ù.

Description

int hw_inscoll(int connection, int objectID, array object_array);

Inserts a new collection with attributes as in object_array into collection with object ID objectID.

hw_InsDoc

hw_InsDoc -- document¸¦ »ðÀÔÇÑ´Ù.

Description

int hw_insdoc(int connection, int parentID, string object_record, string text);

Inserts a new document with attributes as in object_record into collection with object ID parentID. This function inserts either an object record only or an object record and a pure ascii text in text if text is given. If you want to insert a general document of any kind use hw_insertdocument() instead.

See also hw_InsertDocument(), hw_InsColl().

hw_InsertDocument

hw_InsertDocument -- ¾î¶² document¸¦ collectionÀ¸·Î upload ÇÑ´Ù.

Description

int hw_insertdocument(int connection, int parent_id, int hw_document);

Uploads a document into the collection with parent_id. The document has to be created before with hw_NewDocument(). Make sure that the object record of the new document contains at least the attributes: Type, DocumentType, Title and Name. Possibly you also want to set the MimeType. The functions returns the object id of the new document or false.

See also hw_PipeDocument().

hw_InsertObject

hw_InsertObject -- object record¸¦ Ãß°¡ÇÑ´Ù.

Description

int hw_insertobject(int connection, string object rec, string parameter);

Inserts an object into the server. The object can be any valid hyperwave object. See the HG-CSP documentation for a detailed information on how the parameters have to be.

Note: If you want to insert an Anchor, the attribute Position has always been set either to a start/end value or to 'invisible'. Invisible positions are needed if the annotation has no correspondig link in the annotation text.

See also hw_PipeDocument(), hw_InsertDocument(), hw_InsDoc(), hw_InsColl().

hw_mapid

(PHP3 >= 3.0.13, PHP4 >= 4.0b4)

hw_mapid -- global id ¸¦ °¡»óÀÇ local id·Î ¸ÊÇνÃŲ´Ù.

Description

int hw_mapid (int connection, int server id, int object id)

Maps a global object id on any hyperwave server, even those you did not connect to with hw_connect(), onto a virtual object id. This virtual object id can then be used as any other object id, e.g. to obtain the object record with hw_getobject(). The server id is the first part of the global object id (GOid) of the object which is actually the IP number as an integer.

Note: In order to use this function you will have to set the F_DISTRIBUTED flag, which can currently only be set at compile time in hg_comm.c. It is not set by default. Read the comment at the beginning of hg_comm.c

hw_Modifyobject

hw_Modifyobject -- object ·¹Äڵ带 ¼öÁ¤ÇÑ´Ù.

Description

int hw_modifyobject(int connection, int object_to_change, array remove, array add, int mode);

This command allows to remove, add, or modify individual attributes of an object record. The object is specified by the Object ID object_to_change. The first array remove is a list of attributes to remove. The second array add is a list of attributes to add. In order to modify an attribute one will have to remove the old one and add a new one. hw_modifyobject() will always remove the attributes before it adds attributes unless the value of the attribute to remove is not a string or array.

The last parameter determines if the modification is performed recursively. 1 means recurive modification. If some of the objects cannot be modified they will be skiped without notice. hw_error() may not indicate an error though some of the objects could not be modified.

The keys of both arrays are the attributes name. The value of each array element can either be an array, a string or anything else. If it is an array each attribute value is constructed by the key of each element plus a colon and the value of each element. If it is a string it is taken as the attribute value. An empty string will result in a complete removal of that attribute. If the value is neither a string nor an array but something else, e.g. an integer, no operation at all will be performed on the attribute. This is neccessary if you want to to add a completely new attribute not just a new value for an existing attribute. If the remove array contained an empty string for that attribute, the attribute would be tried to be removed which would fail since it doesn't exist. The following addition of a new value for that attribute would also fail. Setting the value for that attribute to e.g. 0 would not even try to remove it and the addition will work.

If you would like to change the attribute 'Name' with the current value 'books' into 'articles' you will have to create two arrays and call hw_modifyobject().

Example 1. modifying an attribute

  1 
  2        // $connect is an existing connection to the Hyperwave server
  3        // $objid is the ID of the object to modify
  4        $remarr = array("Name" => "books");
  5        $addarr = array("Name" => "articles");
  6        $hw_modifyobject($connect, $objid, $remarr, $addarr);
  7       
In order to delete/add a name=value pair from/to the object record just pass the remove/add array and set the last/third parameter to an empty array. If the attribute is the first one with that name to add, set attribute value in the remove array to an integer.

Example 2. adding a completely new attribute

  1 
  2        // $connect is an existing connection to the Hyperwave server
  3        // $objid is the ID of the object to modify
  4        $remarr = array("Name" => 0);
  5        $addarr = array("Name" => "articles");
  6        $hw_modifyobject($connect, $objid, $remarr, $addarr);
  7       

Note: Multilingual attributes, e.g. 'Title', can be modified in two ways. Either by providing the attributes value in its native form 'language':'title' or by providing an array with elements for each language as described above. The above example would than be:

Example 3. modifying Title attribute

  1 
  2        $remarr = array("Title" => "en:Books");
  3        $addarr = array("Title" => "en:Articles");
  4        $hw_modifyobject($connect, $objid, $remarr, $addarr);
  5       
or

Example 4. modifying Title attribute

  1 
  2        $remarr = array("Title" => array("en" => "Books"));
  3        $addarr = array("Title" => array("en" => "Articles", "ge"=>"Artikel"));
  4        $hw_modifyobject($connect, $objid, $remarr, $addarr);
  5       
This removes the english title 'Books' and adds the english title 'Articles' and the german title 'Artikel'.

Example 5. removing attribute

  1 
  2        $remarr = array("Title" => "");
  3        $addarr = array("Title" => "en:Articles");
  4        $hw_modifyobject($connect, $objid, $remarr, $addarr);
  5       

Note: This will remove all attributes with the name 'Title' and adds a new 'Title' attribute. This comes in handy if you want to remove attributes recursively.

Note: If you need to delete all attributes with a certain name you will have to pass an empty string as the attribute value.

Note: Only the attributes 'Title', 'Description' and 'Keyword' will properly handle the language prefix. If those attributes don't carry a language prefix, the prefix 'xx' will be assigned.

Note: The 'Name' attribute is somewhat special. In some cases it cannot be complete removed. You will get an error message 'Change of base attribute' (not clear when this happens). Therefore you will always have to add a new Name first and than remove the old one.

Note: You may not suround this function by calls to hw_getandlock() and hw_unlock(). hw_modifyobject() does this internally.

Returns TRUE if no error occurs otherwise FALSE.

hw_New_Document

hw_New_Document -- »õ document¸¦ ¸¸µç´Ù.

Description

int hw_new_document(string object_record, string document_data, int document_size);

Returns a new Hyperwave document with document data set to document_data and object record set to object_record. The length of the document_data has to passed in document_sizeThis function does not insert the document into the Hyperwave server.

See also hw_FreeDocument(), hw_DocumentSize(), hw_DocumentBodyTag(), hw_OutputDocument(), hw_InsertDocument().

hw_Objrec2Array

hw_Objrec2Array -- object recordÀÇ ¼Ó¼º(attributes)À» object array·Î º¯È¯ÇÑ´Ù.

Description

array hw_objrec2array(string object_record);

Converts an object_record into an object array. The keys of the resulting array are the attributes names. Multiple attributes like 'Title' in different languages form its own array. The keys of this array are the left part to the colon of the attribute value. Currently only the attributes 'Title', 'Description' and 'Keyword' are treated properly.

See also hw_Array2Objrec().

hw_OutputDocument

hw_OutputDocument -- hw_document¸¦ printÇÑ´Ù.

Description

int hw_outputdocument(int hw_document);

Prints the document without the BODY tag.

hw_pConnect

hw_pConnect -- ¿µ±¸ÀûÀÎ(persistent) database connectionÀ» ¸¸µç´Ù.

Description

int hw_pconnect(string host, int port, string username, string password);

Returns a connection index on success, or false if the connection could not be made. Opens a persistent connection to a Hyperwave server. Each of the arguments should be a quoted string, except for the port number. The username and password arguments are optional and can be left out. In such a case no identification with the server will be done. It is similar to identify as user anonymous. This function returns a connection index that is needed by other Hyperwave functions. You can have multiple persistent connections open at once.

See also hw_Connect().

hw_PipeDocument

hw_PipeDocument -- document¸¦ ¿ø·¡´ë·Î º¹±¸(retrieve)ÇÑ´Ù.

Description

int hw_pipedocument(int connection, int objectID);

Returns the Hyperwave document with object ID objectID. If the document has anchors which can be inserted, they will have been inserted already. The document will be transfered via a special data connection which does not block the control connection.

See also hw_GetText() for more on link insertion, hw_FreeDocument(), hw_DocumentSize(), hw_DocumentBodyTag(), hw_OutputDocument().

hw_Root

hw_Root -- root objectÀÇ object id

Description

int hw_root();

Returns the object ID of the hyperroot collection. Currently this is always 0. The child collection of the hyperroot is the root collection of the connected server.

hw_Unlock

hw_Unlock -- object¸¦ unlock ÇÑ´Ù.

Description

int hw_unlock(int connection, int objectID);

Unlocks a document, so other users regain access.

See also hw_GetAndLock().

hw_Who

hw_Who -- ÇöÀç login µÇ¾î ÀÖ´Â »ç¿ëÀÚµéÀ» listÇÑ´Ù.

Description

int hw_who(int connection);

Returns an array of users currently logged into the Hyperwave server. Each entry in this array is an array itself containing the elements id, name, system, onSinceDate, onSinceTime, TotalTime and self. 'self' is 1 if this entry belongs to the user who initianted the request.

hw_Username

hw_Username -- ÇöÀç log in ÇÏ°í ÀÖ´Â userÀÇ À̸§

Description

string hw_getusername(int connection);

Returns the username of the connection.


XXVII. Image functions

¿©·¯ºÐÀº ¿©±âÀÇ ÇÔ¼öµé·Î JPEG, GIF, PNG À̹ÌÁöÀÇ Å©±â¸¦ ¾Ë¾Æº¼ ¼ö ÀÖ´Ù. ¶ÇÇÑ ¿©·¯ºÐÀÌ GD library(http://www.boutell.com/gd/¿¡ ÀÖ´Ù.)¸¦ °¡Áö°í ÀÖ´Ù¸é, ¿©·¯ºÐÀº GIF À̹ÌÁö¸¦ ¸¸µé°Å³ª ¼öÁ¤ÇÒ ¼ö ÀÖ´Ù.

Table of Contents
GetImageSize ¡¦ get the size of a GIF, JPG or PNG image
ImageArc ¡¦ draw a partial ellipse
ImageChar ¡¦ draw a character horizontally
ImageCharUp ¡¦ draw a character vertically
ImageColorAllocate ¡¦ allocate a color for an image
ImageColorDeAllocate ¡¦ De-allocate a color for an image
ImageColorAt ¡¦ get the index of the color of a pixel
ImageColorClosest ¡¦ get the index of the closest color to the specified color
ImageColorExact ¡¦ get the index of the specified color
ImageColorResolve ¡¦ get the index of the specified color or its closest possible alternative
ImageGammaCorrect ¡¦ Apply a gamma correction to a GD image
ImageColorSet ¡¦ set the color for the specified palette index
ImageColorsForIndex ¡¦ get the colors for an index
ImageColorsTotal ¡¦ find out the number of colors in an image's palette
ImageColorTransparent ¡¦ define a color as transparent
ImageCopy ¡¦ copy part of an image
ImageCopyResized ¡¦ copy and resize part of an image
ImageCreate ¡¦ create a new image
ImageCreateFromGif ¡¦ create a new image from file or URL
ImageCreateFromJPEG ¡¦ Create a new image from file or URL
ImageCreateFromPNG ¡¦ Create a new image from file or URL
ImageDashedLine ¡¦ draw a dashed line
ImageDestroy ¡¦ destroy an image
ImageFill ¡¦ flood fill
ImageFilledPolygon ¡¦ draw a filled polygon
ImageFilledRectangle ¡¦ draw a filled rectangle
ImageFillToBorder ¡¦ flood fill to specific color
ImageFontHeight ¡¦ get font height
ImageFontWidth ¡¦ get font width
ImageGif ¡¦ output image to browser or file
ImagePng ¡¦ Output a PNG image to either the browser or a file
ImageJPEG ¡¦ Output image to browser or file
ImageInterlace ¡¦ enable or disable interlace
ImageLine ¡¦ draw a line
ImageLoadFont ¡¦ load a new font
ImagePolygon ¡¦ draw a polygon
ImagePSBBox ¡¦ give the bounding box of a text rectangle using PostScript Type1 fonts
ImagePSEncodeFont ¡¦ change the character encoding vector of a font
ImagePSFreeFont ¡¦ free memory used by a PostScript Type 1 font
ImagePSLoadFont ¡¦ load a PostScript Type 1 from file
ImagePsExtendFont ¡¦ Extend or condense a font
ImagePsSlantFont ¡¦ Slant a font
ImagePSText ¡¦ to draw a text string over an image using PostScript Type1 fonts
ImageRectangle ¡¦ draw a rectangle
ImageSetPixel ¡¦ set a single pixel
ImageString ¡¦ draw a string horizontally
ImageStringUp ¡¦ draw a string vertically
ImageSX ¡¦ get image width
ImageSY ¡¦ get image height
ImageTTFBBox ¡¦ give the bounding box of a text using TypeType fonts
ImageTTFText ¡¦ write text to the image using a TrueType fonts

GetImageSize

GetImageSize -- GIF³ª JPG, PNG ±×¸²ÀÇ Å©±â¸¦ ±¸ÇÑ´Ù.

Description

array getimagesize (string filename [, array imageinfo])

The GetImageSize() function will determine the size of any GIF, JPG or PNG image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML IMG tag.

Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 a flag indicating the type of the image. 1 = GIF, 2 = JPG, 3 = PNG. Index 3 is a text string with the correct "height=xxx width=xxx" string that can be used directly in an IMG tag.

Example 1. GetImageSize

  1 
  2 <?php $size = GetImageSize ("img/flag.jpg"); ?>
  3 <IMG SRC="img/flag.jpg" <?php echo $size[3]; ?>
  4       

The optional imageinfo parameter allows you to extract some extended information from the image file. Currently this will return the diffrent JPG APP markers in an associative Array. Some Programs use these APP markers to embedd text information in images. A very common one in to embed IPTC http://www.xe.net/iptc/ information in the APP13 marker. You can use the iptcparse() function to parse the binary APP13 marker into something readable.

Example 2. GetImageSize returning IPTC

  1 
  2 <?php 
  3     $size = GetImageSize ("testimg.jpg",&$info);
  4     if (isset ($info["APP13"])) {
  5         $iptc = iptcparse ($info["APP13"]);
  6         var_dump ($iptc);
  7     }
  8 ?>
  9       

ImageArc

ImageArc -- Ÿ¿ø È£¸¦ ±× ¸° ´Ù.

Description

int imagearc (int im, int cx, int cy, int w, int h, int s, int e, int col)

ImageArc() draws a partial ellipse centered at cx, cy (top left is 0, 0) in the image represented by im. W and h specifies the ellipse's width and height respectively while the start and end points are specified in degrees indicated by the s and e. arguments.

ImageChar

ImageChar -- ÇÑ ±ÛÀÚ¸¦ ¼öÆòÀ¸·Î ±×¸°´Ù.

Description

int imagechar (int im, int font, int x, int y, string c, int col)

ImageChar() draws the first character of c in the image identified by id with its upper-left at x,y (top left is 0, 0) with the color col. If font is 1, 2, 3, 4 or 5, a built-in font is used (with higher numbers corresponding to larger fonts).

See also imageloadfont().

ImageCharUp

ImageCharUp -- ÇÑ ±ÛÀÚ¸¦ ¼öÁ÷À¸·Î ±×¸°´Ù.

Description

int imagecharup (int im, int font, int x, int y, string c, int col)

ImageCharUp() draws the character c vertically in the image identified by im at coordinates x, y (top left is 0, 0) with the color col. If font is 1, 2, 3, 4 or 5, a built-in font is used.

See also imageloadfont().

ImageColorAllocate

ImageColorAllocate -- ±×¸²À» À§ÇÑ »ö±òÀ» ÇÒ´çÇÑ´Ù.

Description

int imagecolorallocate (int im, int red, int green, int blue)

ImageColorAllocate() returns a color identifier representing the color composed of the given RGB components. The im argument is the return from the imagecreate() function. ImageColorAllocate() must be called to create each color that is to be used in the image represented by im.

  1 
  2 $white = ImageColorAllocate ($im, 255, 255, 255);
  3 $black = ImageColorAllocate ($im, 0, 0, 0);
  4       

ImageColorDeAllocate

ImageColorDeAllocate -- ±×¸²À» À§ÇÑ ÇÒ´çÇß´ø »öÀ» ÇØÁ¦ÇÑ´Ù.

Description

int imagecolordeallocate (int im, int index)

The ImageColorDeAllocate() function de-allocates a color previously allocated with the ImageColorAllocate() function.

  1 
  2 $white = ImageColorAllocate($im, 255, 255, 255);
  3 ImageColorDeAllocate($im, $white);
  4           

ImageColorAt

ImageColorAt -- ÇØ´ç pixel »ö±òÀÇ index¸¦ ±¸ÇÑ´Ù.

Description

int imagecolorat (int im, int x, int y)

Returns the index of the color of the pixel at the specified location in the image.

See also imagecolorset() and imagecolorsforindex().

ImageColorClosest

ImageColorClosest -- ÁöÁ¤µÈ »ö°ú °¡Àå °¡±î¿î »öÀÇ index¸¦ ±¸ÇÑ´Ù.

Description

int imagecolorclosest (int im, int red, int green, int blue);

Returns the index of the color in the palette of the image which is "closest" to the specified RGB value.

The "distance" between the desired color and each color in the palette is calculated as if the RGB values represented points in three-dimensional space.

See also imagecolorexact().

ImageColorExact

ImageColorExact -- ÁöÁ¤µÈ »öÀÇ index¸¦ ±¸ÇÑ´Ù.

Description

iint imagecolorexact (int im, int red, int green, int blue);

Returns the index of the specified color in the palette of the image.

If the color does not exist in the image's palette, -1 is returned.

See also imagecolorclosest().

ImageColorResolve

ImageColorResolve -- ƯÁ¤»öÀ̳ª ±×¿¡ °¡Àå °¡±î¿î »öÀÇ index¸¦ ±¸ÇÑ´Ù.

Description

int imagecolorresolve (int im, int red, int green, int blue);

This function is guaranteed to return a color index for a requested color, either the exact color or the closest possible alternative.

See also imagecolorclosest().

ImageGammaCorrect

ImageGammaCorrect -- GD À̹ÌÁö¿¡ °¨¸¶°ª º¸Á¤À» Àû¿ë½ÃŲ´Ù.

Description

int imagegammacorrect (int im, double inputgamma, double outputgamma)

The ImageGammaCorrect() function applies gamma correction to a gd image stream (im) given an input gamma, the parameter inputgamma and an output gamma, the parameter outputgamma.

ImageColorSet

ImageColorSet -- ÁöÁ¤ÇÑ »öÀ» ƯÁ¤ palette index·Î Á¤ÇÑ´Ù.

Description

bool imagecolorset (int im, int index, int red, int green, int blue);

This sets the specified index in the palette to the specified color. This is useful for creating flood-fill-like effects in paletted images without the overhead of performing the actual flood-fill.

See also imagecolorat().

ImageColorsForIndex

ImageColorsForIndex -- ÁöÁ¤ÇÑ indexÀÇ »öÀ» ±¸ÇÑ´Ù.

Description

array imagecolorsforindex (int im, int index);

This returns an associative array with red, green, and blue keys that contain the appropriate values for the specified color index.

See also imagecolorat() and imagecolorexact().

ImageColorsTotal

ImageColorsTotal -- ±×¸²ÀÇ palette¿¡ ÀÖ´Â »öÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

int imagecolorstotal (int im);

This returns the number of colors in the specified image's palette.

See also imagecolorat() and imagecolorsforindex().

ImageColorTransparent

ImageColorTransparent -- Åõ¸íÇÑ »ö±òÀ» ÁöÁ¤ÇÑ´Ù.

Description

int imagecolortransparent (int im [, int col])

ImageColorTransparent() sets the transparent color in the im image to col. Im is the image identifier returned by ImageCreate() and col is a color identifier returned by ImageColorAllocate().

The identifier of the new (or current, if none is specified) transparent color is returned

ImageCopy

ImageCopy --  ±×¸²ÀÇ ÀϺκÐÀ» º¹»çÇÑ´Ù.

Description

int ImageCopy (int dst_im, int src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h)

Copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.

ImageCopyResized

ImageCopyResized -- ±×¸²ÀÇ ÀϺκÐÀ» º¹»çÇÏ°í Å©±â¸¦ ¹Ù²Û´Ù.

Description

int imagecopyresized (int dst_im, int src_im, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);

ImageCopyResized() copies a rectangular portion of one image to another image. Dst_im is the destination image, src_im is the source image identifier. If the source and destination coordinates and width and heights differ, appropriate stretching or shrinking of the image fragment will be performed. The coordinates refer to the upper left corner. This function can be used to copy regions within the same image (if dst_im is the same as src_im) but if the regions overlap the results will be unpredictable.

ImageCreate

ImageCreate -- »õ image¸¦ ¸¸µç´Ù.

Description

int imagecreate (int x_size, int y_size);

ImageCreate returns an image identifier representing a blank image of size x_size by y_size.

ImageCreateFromGif

ImageCreateFromGif -- GIF ÇüÅÂÀÇ ÆÄÀÏÀ̳ª URL·ÎºÎÅÍ »õ image¸¦ ¸¸µç´Ù.

Description

int imagecreatefromgif (string filename)

ImageCreateFromGif() returns an image identifier representing the image obtained from the given filename.

ImageCreateFromGif() returns an empty string on failure. It also outputs an error message, which unfortunately displays as a broken link in a browser. To ease debugging the following example will produce an error GIF:

Example 1. Example to handle an error during creation (courtesy vic@zymsys.com)

  1 
  2 function LoadGif ($imgname) {
  3     $im = @imagecreatefromgif ($imgname); /* Attempt to open */
  4     if ($im == "") { /* See if it failed */
  5         $im = ImageCreate (150, 30); /* Create a blank image */
  6         $bgc = ImageColorAllocate ($im, 255, 255, 255);
  7         $tc  = ImageColorAllocate ($im, 0, 0, 0);
  8         ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc); 
  9         /* Output an errmsg */
 10         ImageString($im, 1, 5, 5, "Error loading $imgname", $tc); 
 11     }
 12     return $im;
 13 }
 14       

Note: Since all GIF support was removed from the GD library in version 1.6, this function is not available if you are using that version of the GD library.

ImageCreateFromJPEG

ImageCreateFromJPEG -- JPEG ÇüÅÂÀÇ ÆÄÀÏÀ̳ª URL·ÎºÎÅÍ »õ image¸¦ ¸¸µç´Ù.

Description

int imagecreatefromjpeg (string filename)

ImageCreateFromJPEG() returns an image identifier representing the image obtained from the given filename.

ImagecreateFromJPEG() returns an empty string on failure. It also outputs an error message, which unfortunately displays as a broken link in a browser. To ease debugging the following example will produce an error JPEG:

Example 1. Example to handle an error during creation (courtesy vic@zymsys.com )

  1 
  2 function LoadJpeg ($imgname) {
  3     $im = @imagecreatefromjpeg ($imgname); /* Attempt to open */
  4     if ($im == "") { /* See if it failed */
  5         $im = ImageCreate (150, 30); /* Create a blank image */
  6         $bgc = ImageColorAllocate ($im, 255, 255, 255);
  7         $tc  = ImageColorAllocate ($im, 0, 0, 0);
  8         ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
  9         /* Output an errmsg */
 10         ImageString ($im, 1, 5, 5, "Error loading $imgname", $tc); 
 11     }
 12     return $im;
 13 }
 14       

ImageCreateFromPNG

ImageCreateFromPNG -- PNG ÇüÅÂÀÇ ÆÄÀÏÀ̳ª URL·ÎºÎÅÍ »õ image¸¦ ¸¸µç´Ù.

Description

int imagecreatefrompng (string filename)

ImageCreateFromPNG() returns an image identifier representing the image obtained from the given filename.

ImageCreateFromPNG() returns an empty string on failure. It also outputs an error message, which unfortunately displays as a broken link in a browser. To ease debugging the following example will produce an error PNG:

Example 1. Example to handle an error during creation (courtesy vic@zymsys.com)

  1 
  2 function LoadPNG ($imgname) {
  3     $im = @imagecreatefrompng ($imgname); /* Attempt to open */
  4     if ($im == "") { /* See if it failed */
  5         $im = ImageCreate (150, 30); /* Create a blank image */
  6         $bgc = ImageColorAllocate ($im, 255, 255, 255);
  7         $tc  = ImageColorAllocate ($im, 0, 0, 0);
  8         ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
  9         /* Output an errmsg */
 10         ImageString ($im, 1, 5, 5, "Error loading $imgname", $tc); 
 11     }
 12     return $im;
 13 }
 14       

ImageDashedLine

ImageDashedLine -- Á¡¼±À» ±×¸°´Ù.

Description

int imagedashedline (int im, int x1, int y1, int x2, int y2, int col);

ImageDashedLine() draws a dashed line from x1, y1 to x2, y2 (top left is 0, 0) in image im of color col.

See also imageline().

ImageDestroy

ImageDestroy -- image¸¦ ¾ø¾Ø´Ù.

Description

int imagedestroy (int im));

ImageDestroy() frees any memory associated with image im. im is the image identifier returned by the imagecreate() function.

ImageFill

ImageFill -- »öÀ» ä¿î´Ù.

Description

int imagefill (int im, int x, int y, int col)

ImageFill() performs a flood fill starting at coordinate x, y (top left is 0, 0) with color col in the image im.

ImageFilledPolygon

ImageFilledPolygon -- »öÀÌ Ã¤¿öÁø ´Ù°¢ÇüÀ» ±×¸°´Ù.

Description

int imagefilledpolygon (int im, array points, int num_points, int col)

ImageFilledPolygon() creates a filled polygon in image im. Points is a PHP array containing the polygon's vertices, ie. points[0] = x0, points[1] = y0, points[2] = x1, points[3] = y1, etc. Num_points is the total number of vertices.

ImageFilledRectangle

ImageFilledRectangle -- »öÀÌ Ã¤¿öÁø Á÷»ç°¢ÇüÀ» ±×¸°´Ù.

Description

int imagefilledrectangle (int im, int x1, int y1, int x2, int y2, int col)

ImageFilledRectangle() creates a filled rectangle of color col() in image im starting at upper left coordinates x1, y1 and ending at bottom right coordinates x2, y2. 0, 0 is the top left corner of the image.

ImageFillToBorder

ImageFillToBorder -- ÁöÁ¤µÈ »öÀ¸·Î ä¿î´Ù.

Description

int imagefilltoborder (int im, int x, int y, int border, int col)

ImageFillToBorder() performs a flood fill whose border color is defined by border. The starting point for the fill is x, y (top left is 0, 0) and the region is filled with color col.

ImageFontHeight

ImageFontHeight -- ÆùÆ®ÀÇ ³ôÀ̸¦ ±¸ÇÑ´Ù.

Description

int imagefontheight (int font)

Returns the pixel height of a character in the specified font.

See also imagefontwidth() and imageloadfont().

ImageFontWidth

ImageFontWidth -- ÆùÆ®ÀÇ ³ÐÀ̸¦ ±¸ÇÑ´Ù.

Description

int imagefontwidth (int font)

Returns the pixel width of a character in font.

See also imagefontheight() and imageloadfont().

ImageGif

ImageGif -- ºê¶ó¿ìÀú³ª ÆÄÀÏ·Î GIF ÇüÅÂÀÇ À̹ÌÁö¸¦ Ãâ·ÂÇÑ´Ù.

Description

int imagegif (int im [, string filename]);

imagegif() creates the GIF file in filename from the image im. The im argument is the return from the imagecreate() function.

The image format will be GIF87a unless the image has been made transparent with imagecolortransparent(), in which case the image format will be GIF89a.

The filename argument is optional, and if left off, the raw image stream will be output directly. By sending an image/gif content-type using header(), you can create a PHP script that outputs GIF images directly.

Note: Since all GIF support was removed from the GD library in version 1.6, this function is not available if you are using that version of the GD library.

ImagePng

ImagePng -- ºê¶ó¿ìÀú³ª ÆÄÀÏ·Î PNG ÇüÅÂÀÇ À̹ÌÁö¸¦ Ãâ·ÂÇÑ´Ù.

Description

int imagepng (int im [, string filename])

The ImagePng() outputs a GD image stream (im) in PNG format to standard output (usually the browser) or, if a filename is given by the filename it outputs the image to the file.

  1 
  2 $im = ImageCreateFromPng("test.png");
  3 ImagePng($im);
  4           

ImageJPEG

ImageJPEG -- Output image to browser or file

Description

int imagejpeg (int im [, string filename [, int quality]])

ImageJPEG() creates the JPEG file in filename from the image im. The im argument is the return from the ImageCreate() function.

The filename argument is optional, and if left off, the raw image stream will be output directly. To skip the filename argument in order to provide a quality argument just use an empty string (''). By sending an image/jpg content-type using header(), you can create a PHP script that outputs JPEG images directly.

Note: JPEG support is only available in PHP if PHP was compiled against GD-1.8 or later.

ImageInterlace

ImageInterlace -- ±×¸²ÀÌ ¼¯ÀÌ°Ô ÇÏ´Â interlace ¼³Á¤À» ÄѰųª ²ö´Ù.

Description

int imageinterlace (int im [, int interlace]);

ImageInterlace() turns the interlace bit on or off. If interlace is 1 the im image will be interlaced, and if interlace is 0 the interlace bit is turned off.

This functions returns whether the interlace bit is set for the image.

ImageLine

ImageLine -- ¼±À» ±×¸°´Ù.

Description

int imageline (int im, int x1, int y1, int x2, int y2, int col)

ImageLine() draws a line from x1, y1 to x2, y2 (top left is 0, 0) in image im of color col.

See also imagecreate() and imagecolorallocate().

ImageLoadFont

ImageLoadFont -- »õ ÆùÆ®¸¦ loadÇÑ´Ù.

Description

int imageloadfont (string file)

ImageLoadFont() loads a user-defined bitmap font and returns an identifier for the font (that is always greater than 5, so it will not conflict with the built-in fonts).

The font file format is currently binary and architecture dependent. This means you should generate the font files on the same type of CPU as the machine you are running PHP on.

Table 1. Font file format

byte position C data type description
byte 0-3 int number of characters in the font
byte 4-7 int value of first character in the font (often 32 for space)
byte 8-11 int pixel width of each character
byte 12-15 int pixel height of each character
byte 16- char array with character data, one byte per pixel in each character, for a total of (nchars*width*height) bytes.

See also ImageFontWidth() and ImageFontHeight().

ImagePolygon

ImagePolygon -- ´Ù°¢ÇüÀ» ±×¸°´Ù.

Description

int imagepolygon (int im, array points, int num_points, int col)

ImagePolygon() creates a polygon in image id. Points is a PHP array containing the polygon's vertices, ie. points[0] = x0, points[1] = y0, points[2] = x1, points[3] = y1, etc. Num_points is the total number of vertices.

See also imagecreate().

ImagePSBBox

ImagePSBBox -- PostScript Type1 ÆùÆ®¸¦ »ç¿ëÇÏ¿© Ãâ·ÂÇÒ ÅؽºÆ®ÀÇ °æ°è°¡ µÇ´Â ¿µ¿ªÀ» ÁöÁ¤ÇÑ´Ù.

Description

array imagepsbbox (string text, int font, int size [, int space [, int tightness [, float angle]]])

Size is expressed in pixels.

Space allows you to change the default value of a space in a font. This amount is added to the normal value and can also be negative.

Tightness allows you to control the amount of white space between characters. This amount is added to the normal character width and can also be negative.

Angle is in degrees.

Parameters space and tightness are expressed in character space units, where 1 unit is 1/1000th of an em-square.

Parameters space, tightness, and angle are optional.

The bounding box is calculated using information available from character metrics, and unfortunately tends to differ slightly from the results achieved by actually rasterizing the text. If the angle is 0 degrees, you can expect the text to need 1 pixel more to every direction.

This function returns an array containing the following elements:

0 lower left x-coordinate
1 lower left y-coordinate
2 upper right x-coordinate
3 upper right y-coordinate

See also imagepstext().

ImagePSEncodeFont

ImagePSEncodeFont -- ÆùÆ®ÀÇ character encoding vector¸¦ ¹Ù²ãÁØ´Ù.

Description

int imagepsencodefont (string encodingfile)

Loads a character encoding vector from from a file and changes the fonts encoding vector to it. As a PostScript fonts default vector lacks most of the character positions above 127, you'll definitely want to change this if you use an other language than english. The exact format of this file is described in T1libs documentation. T1lib comes with two ready-to-use files, IsoLatin1.enc and IsoLatin2.enc.

If you find yourself using this function all the time, a much better way to define the encoding is to set ps.default_encoding in the configuration file to point to the right encoding file and all fonts you load will automatically have the right encoding

ImagePSFreeFont

ImagePSFreeFont -- PostScript Type 1 ÆùÆ®¿¡ »ç¿ëµÈ ¸Þ¸ð¸®¸¦ Ç®¾îÁØ´Ù.

Description

void imagepsfreefont (int fontindex);

See also imagepsloadfont().

ImagePSLoadFont

ImagePSLoadFont -- PostScript Type 1 ÆùÆ®¸¦ ÆÄÀϷκÎÅÍ Àоî¿Â´Ù.

Description

int imagepsloadfont (string filename)

In the case everything went right, a valid font index will be returned and can be used for further purposes. Otherwise the function returns false and prints a message describing what went wrong.

See also imagepsfreefont().

ImagePsExtendFont

ImagePsExtendFont -- ÆùÆ®¸¦ ´ÃÀ̰ųª ÁÙÀδÙ.

Description

bool imagepsextendfont (int font_index, double extend)

Extend or condense a font (font_index), if the value of the extend parameter is less than one you will be condensing the font.

ImagePsSlantFont

ImagePsSlantFont --  ÆùÆ®¸¦ ±â¿ï¾îÁö°Ô ÇÑ´Ù.

Description

bool imagepsslantfont (int font_index, double slant)

Slant a font given by the font_index parameter with a slant of the value of the slant parameter.

ImagePSText

ImagePSText -- À̹ÌÁö¿¡ PostScript Type1 ÆùÆ®¸¦ »ç¿ëÇÏ¿© ¹®ÀÚ¿­À» ±×¸°´Ù.

Descriptiom

array imagepstext (int image, string text, int font, int size, int foreground, int background, int x, int y [, int space [, int tightness [, float angle [, int antialias_steps]]]])

Size is expressed in pixels.

Foreground is the color in which the text will be painted. Background is the color to which the text will try to fade in with antialiasing. No pixels with the color background are actually painted, so the background image does not need to be of solid color.

The coordinates given by x, y will define the origin (or reference point) of the first character (roughly the lower-left corner of the character). This is different from the ImageString(), where x, y define the upper-right corner of the first character. Refer to PostScipt documentation about fonts and their measuring system if you have trouble understanding how this works.

Space allows you to change the default value of a space in a font. This amount is added to the normal value and can also be negative.

Tightness allows you to control the amount of white space between characters. This amount is added to the normal character width and can also be negative.

Angle is in degrees.

Antialias_steps allows you to control the number of colours used for antialiasing text. Allowed values are 4 and 16. The higher value is recommended for text sizes lower than 20, where the effect in text quality is quite visible. With bigger sizes, use 4. It's less computationally intensive.

Parameters space and tightness are expressed in character space units, where 1 unit is 1/1000th of an em-square.

Parameters space, tightness, angle and antialias are optional.

This function returns an array containing the following elements:

0

lower left x-coordinate

1

lower left y-coordinate

2

upper right x-coordinate

3

upper right y-coordinate

See also imagepsbbox().

ImageRectangle

ImageRectangle -- Á÷»ç°¢ÇüÀ» ±×¸°´Ù.

Description

int imagerectangle (int im, int x1, int y1, int x2, int y2, int col)

ImageRectangle() creates a rectangle of color col in image im starting at upper left coordinate x1, y1 and ending at bottom right coordinate x2, y2. 0, 0 is the top left corner of the image.

ImageSetPixel

ImageSetPixel -- ÁöÁ¤ÇÑ »öÀ¸·Î Á¡À» Âï´Â´Ù.

Description

int imagesetpixel (int im, int x, int y, int col)

ImageSetPixel() draws a pixel at x, y (top left is 0, 0) in image im of color col.

See also imagecreate() and imagecolorallocate().

ImageString

ImageString -- ¹®ÀÚ¿­À» ¼öÆòÀ¸·Î ±×¸°´Ù.

Description

int imagestring (int im, int font, int x, int y, string s, int col)

ImageString() draws the string s in the image identified by im at coordinates x, y (top left is 0, 0) in color col. If font is 1, 2, 3, 4 or 5, a built-in font is used.

See also imageloadfont().

ImageStringUp

ImageStringUp -- ¹®ÀÚ¿­À» ¼öÁ÷À¸·Î ±×¸°´Ù.

Description

int imagestringup (int im, int font, int x, int y, string s, int col)

ImageStringUp() draws the string s vertically in the image identified by im at coordinates x, y (top left is 0, 0) in color col. If font is 1, 2, 3, 4 or 5, a built-in font is used.

See also imageloadfont().

ImageSX

ImageSX -- ±×¸²ÀÇ ÆøÀ» ±¸ÇÑ´Ù.

Description

int imagesx (int im)

ImageSX() returns the width of the image identified by im.

See also imagecreate() and imagesy().

ImageSY

ImageSY -- ±×¸²ÀÇ ³ôÀ̸¦ ±¸ÇÑ´Ù.

Description

int imagesy (int im)

ImageSY() returns the height of the image identified by im.

See also imagecreate() and imagesx().

ImageTTFBBox

ImageTTFBBox -- TrueType font¸¦ »ç¿ëÇÏ¿© ¹®ÀÚ¿­ ¾²°í, ÁÖÀ§ÀÇ ¹®ÀÚ ÁÖÀ§¿¡ °æ°è¼±À» ±×¸°´Ù.

Description

array imagettfbbox (int size, int angle, string fontfile, string text)

This function calculates and returns the bounding box in pixels a TrueType text.

ImageTTFBBox() returns an array with 8 elements representing four points making the bounding box of the text:

0

lower left corner, X position

1

lower left corner, Y position

2

lower right corner, X position

3

lower right corner, Y position

4

upper right corner, X position

5

upper right corner, Y position

6

upper left corner, X position

7

upper left corner, Y position

The points are relative to the text regardless of the angle, so "upper left" means in the top left-hand corner seeing the text horizontallty.

This function requires both the GD library and the Freetype library.

See also ImageTTFText().

ImageTTFText

ImageTTFText -- TrueType ÆùÆ®¸¦ »ç¿ëÇÏ¿© ¹®ÀÚ¿­À» ¾´´Ù.

Description

array imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text);

ImageTTFText() draws the string text in the image identified by im, starting at coordinates x, y (top left is 0, 0), at an angle of angle in color col, using the TrueType font file identified by fontfile.

The coordinates given by x, y will define the basepoint of the first character (roughly the lower-left corner of the character). This is different from the ImageString(), where x, y define the upper-right corner of the first character.

Angle is in degrees, with 0 degrees being left-to-right reading text (3 o'clock direction), and higher values representing a counter-clockwise rotation. (i.e., a value of 90 would result in bottom-to-top reading text).

Fontfile is the path to the TrueType font you wish to use.

Text is the text string which may include UTF-8 character sequences (of the form: &#123;) to access characters in a font beyond the first 255.

Col is the color index. Using the negative of a color index has the effect of turning off antialiasing.

ImageTTFText() returns an array with 8 elements representing four points making the bounding box of the text. The order of the points is upper left, upper right, lower right, lower left. The points are relative to the text regardless of the angle, so "upper left" means in the top left-hand corner when you see the text horizontallty.

This example script will produce a black GIF 400x30 pixels, with the words "Testing..." in white in the font Arial.

Example 1. ImageTTFText

  1 
  2 <?php
  3 Header ("Content-type: image/gif");
  4 $im = imagecreate (400, 30);
  5 $black = ImageColorAllocate ($im, 0, 0, 0);
  6 $white = ImageColorAllocate ($im, 255, 255, 255);
  7 ImageTTFText ($im, 20, 0, 10, 20, $white, "/path/arial.ttf", 
  8               "Testing... Omega: &#937;");
  9 ImageGif ($im);
 10 ImageDestroy ($im);
 11 ?>
 12       

This function requires both the GD library and the FreeType library.

See also ImageTTFBBox().


XXVIII. IMAP, POP3 and NNTP functions

ÀÌ ÇÔ¼öµéÀ» µ¿ÀÛ½ÃÅ°·Á¸é PHP¸¦ --with-imap ¿É¼ÇÀ» ÁÖ°í ÄÄÆÄÀÏ ÇÏ¿©¾ß ÇÑ´Ù. ¶ÇÇÑ ÀÌ°ÍÀÌ ¼³Ä¡µÇ±â À§Çؼ­´Â c-client library°¡ ÇÊ¿äÇÏ´Ù. °¡Àå ÃֽŠ¹öÀüÀº ftp://ftp.cac.washington.edu/imap/¿¡ ÀÖÀ¸¹Ç·Î, ±¸ÇÏ¿© ÄÄÆÄÀÏÇÏ¸é µÈ´Ù. ÄÄÆÄÀÏ ÈÄ c-client/c-client.a¸¦ /usr/local/lib³ª ¿©·¯ºÐÀÌ ¼³Á¤ÇØ ³õÀº link pathÀÇ µð·ºÅ丮·Î º¹»çÇÏ°í, c-client/rfc822.h¿Í mail.h, linkage.h¸¦ /usr/local/include³ª ¿©·¯ºÐÀÇ include path¿¡ º¹»çÇØ µÐ´Ù.

ºñ·Ï ÇÔ¼öµéÀÇ À̸§ÀÌ imap_*ÀÌ¶óµµ ÀÌ ÇÔ¼öµéÀÌ IMAP ÇÁ·ÎÅäÄÝ¿¡ ´ëÇؼ­¸¸ »ç¿ëÇÒ ¼ö ÀÖ´Â °ÍÀº ¾Æ´Ï´Ù. c-client ¶óÀ̺귯¸®¿¡ ±Ù°£ÇÏ°í ÀÖ´Â ÀÌ ÇÔ¼öµéÀº NNTP¿Í POP3 ½ÉÁö¾î local mailbox¿¡ Á¢±ÙÇÏ´Â ¹æ¹ýµµ Á¦°øÇÑ´Ù.

ÀÌ ¹®¼­´Â Á¦°øµÇ´Â ÇÔ¼öÀÇ ¸ðµç ¼¼¼¼ÇÑ ³»¿ëÀ» ¼³¸íÇÏÁö ¸øÇÏ°í ÀÖ´Ù. ÀÚ¼¼ÇÑ Á¤º¸´Â c-client library ¼Ò½º¿Í °°ÀÌ Á¦°øµÇ´Â ¹®¼­(docs/internal.txt)¿Í ´ÙÀ½ÀÇ RFC¹®¼­µéÀ» ÂüÁ¶Çϱ⠹ٶõ´Ù.

David Wood °¡ ¾´ Programming Internet Email À̶ó´Â Ã¥¿¡µµ ºñ±³Àû Àß ¼³¸íµÇ¾î ÀÖ´Ù.

Table of Contents
imap_append ¡¦ Append a string message to a specified mailbox
imap_base64 ¡¦ Decode BASE64 encoded text
imap_body ¡¦ Read the message body
imap_check ¡¦ Check current mailbox
imap_close ¡¦ Close an IMAP stream
imap_createmailbox ¡¦ Create a new mailbox
imap_delete ¡¦ Mark a messge for deletion from current mailbox
imap_deletemailbox ¡¦ Delete a mailbox
imap_expunge ¡¦ Delete all messages marked for deletion
imap_fetchbody ¡¦ Fetch a particular section of the body of the message
imap_fetchstructure ¡¦ Read the structure of a particular message
imap_header ¡¦ Read the header of the message
imap_rfc822_parse_headers ¡¦ Parse mail headers from a string
imap_headers ¡¦ Returns headers for all messages in a mailbox
imap_listmailbox ¡¦ Read the list of mailboxes
imap_getmailboxes ¡¦ Read the list of mailboxes, returning detailed information on each one
imap_listsubscribed ¡¦ List all the subscribed mailboxes
imap_getsubscribed ¡¦ List all the subscribed mailboxes
imap_mail_copy ¡¦ Copy specified messages to a mailbox
imap_mail_move ¡¦ Move specified messages to a mailbox
imap_num_msg ¡¦ Gives the number of messages in the current mailbox
imap_num_recent ¡¦ Gives the number of recent messages in current mailbox
imap_open ¡¦ Open an IMAP stream to a mailbox
imap_ping ¡¦ Check if the IMAP stream is still active
imap_renamemailbox ¡¦ Rename an old mailbox to new mailbox
imap_reopen ¡¦ Reopen IMAP stream to new mailbox
imap_subscribe ¡¦ Subscribe to a mailbox
imap_undelete ¡¦ Unmark the message which is marked deleted
imap_unsubscribe ¡¦ Unsubscribe from a mailbox
imap_qprint ¡¦ Convert a quoted-printable string to an 8 bit string
imap_8bit ¡¦ Convert an 8bit string to a quoted-printable string.
imap_binary ¡¦ Convert an 8bit string to a base64 string.
imap_scanmailbox ¡¦ Read the list of mailboxes, takes a string to search for in the text of the mailbox
imap_mailboxmsginfo ¡¦ Get information about the current mailbox
imap_rfc822_write_address ¡¦ Returns a properly formatted email address given the mailbox, host, and personal info.
imap_rfc822_parse_adrlist ¡¦ Parses an address string
imap_setflag_full ¡¦ Sets flags on messages
imap_clearflag_full ¡¦ Clears flags on messages
imap_sort ¡¦
imap_fetchheader ¡¦ Returns header for a message
imap_uid ¡¦ This function returns the UID for the given message sequence number.
imap_msgno ¡¦ This function returns the message sequence number for the given UID.
imap_search ¡¦ This function returns an array of messages matching the given search criteria.
imap_last_error ¡¦ This function returns the last IMAP error (if any) that occurred during this page request.
imap_errors ¡¦ This function returns all of the IMAP errors (if any) that have occurred during this page request or since the error stack was reset.
imap_alerts ¡¦ This function returns all IMAP alert messages (if any) that have occurred during this page request or since the alert stack was reset.
imap_status ¡¦ This function returns status information on a mailbox other than the current one.
imap_utf7_decode ¡¦ Decodes a modified UTF-7 encoded string.
imap_utf7_encode ¡¦ Converts 8bit data to modified UTF-7 text.
imap_utf8 ¡¦ Converts text to UTF8
imap_fetch_overview ¡¦ Read an overview of the information in the headers of the given message
imap_mime_header_decode ¡¦ Decode MIME header elements
imap_mail_compose ¡¦ Create a MIME message based on given envelope and body sections
imap_mail ¡¦ Send an email message

imap_append

imap_append -- ÁöÁ¤ÇÑ ÆíÁöÇÔ¿¡ ¹®ÀÚ¿­ ¸Þ¼¼Áö¸¦ µ¡ºÙÀδÙ.

Description

int imap_append (int imap_stream, string mbox, string message [, string flags])

Returns true on sucess, false on error.

imap_append() appends a string message to the specified mailbox mbox. If the optional flags is specified, writes the flags to that mailbox also.

When talking to the Cyrus IMAP server, you must use "\r\n" as your end-of-line terminator instead of "\n" or the operation will fail.

Example 1. imap_append() example

  1 
  2 $stream = imap_open("{your.imap.host}INBOX.Drafts","username", "password");
  3 
  4 $check = imap_check($stream);
  5 print "Msg Count before append: ". $check->Nmsgs."\n";
  6 
  7 imap_append($stream,"{your.imap.host}INBOX.Drafts"
  8                    ,"From: me@my.host\r\n"
  9                    ."To: you@your.host\r\n"
 10                    ."Subject: test\r\n"
 11                    ."\r\n"
 12                    ."this is a test message, please ignore\r\n"
 13                    );
 14 
 15 $check = imap_check($stream);
 16 print "Msg Count after append : ". $check->Nmsgs."\n";
 17 
 18 imap_close($stream);
 19       

imap_base64

imap_base64 -- BASE64·Î encodeµÈ text¸¦ decodeÇÑ´Ù.

Description

string imap_base64 (string text)

imap_base64() function decodes BASE-64 encoded text (see RFC2045, Section 6.8). The decoded message is returned as a string.

See also imap_binary().

imap_body

imap_body -- message body¸¦ Àд´Ù.

Description

string imap_body (int imap_stream, int msg_number [, int flags])

imap_body() returns the body of the message, numbered msg_number in the current mailbox. The optional flags are a bit mask with one or more of the following:

imap_check

imap_check -- Çö mailbox¸¦ °Ë»çÇÑ´Ù.

Description

object imap_check (int imap_stream)

Returns information about the current mailbox. Returns FALSE on failure.

The imap_check() function checks the current mailbox status on the server and returns the information in an object with following properties:

imap_close

imap_close -- IMAP streamÀ» ´Ý´Â´Ù.

Description

int imap_close (int imap_stream [, int flags])

Close the imap stream. Takes an optional flag CL_EXPUNGE, which will silently expunge the mailbox before closing, removing all messages marked for deletion.

imap_createmailbox

imap_createmailbox -- »õ ÆíÁöÇÔÀ» ¸¸µç´Ù.

Description

int imap_createmailbox (int imap_stream, string mbox)

imap_createmailbox() creates a new mailbox specified by mbox. Names containing international characters should be encoded by imap_utf7_encode().

Returns true on success and false on error.

See also imap_renamemailbox(), imap_deletemailbox() and imap_open() for the format of mbox names.

Example 1. imap_createmailbox() example

  1 
  2 $mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
  3      || die("can't connect: ".imap_last_error());
  4 
  5 $name1 = "phpnewbox";
  6 $name2 = imap_utf7_encode("phpnewböx");
  7 
  8 $newname = $name1;
  9 
 10 echo "Newname will be '$name1'<br>\n";
 11 
 12 # we will now create a new mailbox "phptestbox" in your inbox folder,
 13 # check its status after creation and finaly remove it to restore
 14 # your inbox to its initial state 
 15 if(@imap_createmailbox($mbox,imap_utf7_encode("{your.imap.host}INBOX.$newname"))) {
 16   $status = @imap_status($mbox,"{your.imap.host}INBOX.$newname",SA_ALL);
 17   if($status) {
 18     print("your new mailbox '$name1' has the following status:<br>\n");
 19     print("Messages:   ". $status->messages   )."<br>\n";
 20     print("Recent:     ". $status->recent     )."<br>\n";
 21     print("Unseen:     ". $status->unseen     )."<br>\n";
 22     print("UIDnext:    ". $status->uidnext    )."<br>\n";
 23     print("UIDvalidity:". $status->uidvalidity)."<br>\n";
 24     
 25     if(imap_renamemailbox($mbox,"{your.imap.host}INBOX.$newname","{your.imap.host}INBOX.$name2")) {
 26       echo "renamed new mailbox from '$name1' to '$name2'<br>\n";
 27       $newname=$name2;
 28     } else {
 29       print "imap_renamemailbox on new mailbox failed: ".imap_last_error()."<br>\n";
 30     }
 31   } else {
 32     print  "imap_status on new mailbox failed: ".imap_last_error()."<br>\n";
 33   }
 34   if(@imap_deletemailbox($mbox,"{your.imap.host}INBOX.$newname")) {
 35     print "new mailbox removed to restore initial state<br>\n";
 36   } else {
 37     print  "imap_deletemailbox on new mailbox failed: ".implode("<br>\n",imap_errors())."<br>\n";
 38   }
 39   
 40 } else {
 41   print  "could not create new mailbox: ".implode("<br>\n",imap_errors())."<br>\n";
 42 }
 43 
 44 imap_close($mbox);
 45       

imap_delete

imap_delete -- ÇöÀç ÆíÁöÇÔ¿¡¼­ ¾î¶² messge¿¡ »èÁ¦ ¸¶Å©¸¦ ÇÑ´Ù.

Description

int imap_delete (int imap_stream, int msg_number [, int flags])

Returns true.

imap_delete() function marks message pointed by msg_number for deletion. The optional flags parameter only has a single option, FT_UID, which tells the function to treat the msg_number argument as a UID. Messages marked for deletion will stay in the mailbox until either imap_expunge() is called or imap_close() is called with the optional parameter CL_EXPUNGE.

imap_deletemailbox

imap_deletemailbox -- ÆíÁöÇÔÀ» Áö¿î´Ù.

Description

int imap_deletemailbox (int imap_stream, string mbox)

imap_deletemailbox() deletes the specified mailbox (see imap_open() for the format of mbox names).

Returns true on success and false on error.

See also imap_createmailbox(), imap_reanmemailbox(), and imap_open() for the format of mbox

imap_expunge

imap_expunge -- »èÁ¦ ¸¶Å©°¡ µÇ¾î ÀÖ´Â ¸ðµç ¸Þ¼¼Áö¸¦ Áö¿î´Ù.

Description

int imap_expunge (int imap_stream)

imap_expunge() deletes all the messages marked for deletion by imap_delete(), imap_move_mail(), or imap_setflag_full().

Returns true.

imap_fetchbody

imap_fetchbody -- messageÀÇ bodyÁß particular sectionÀ» °¡Áö°í ¿Â´Ù.

Description

string imap_fetchbody (int imap_stream, int msg_number, string part_number [, flags flags])

This function causes a fetch of a particular section of the body of the specified messages as a text string and returns that text string. The section specification is a string of integers delimited by period which index into a body part list as per the IMAP4 specification. Body parts are not decoded by this function.

The options for imap_fetchbody() is a bitmask with one or more of the following:

imap_fetchstructure

imap_fetchstructure -- particular messageÀÇ ±¸Á¶¸¦ Àоî¿Â´Ù.

Description

object imap_fetchstructure (int imap_stream, int msg_number [, int flags])

This function fetches all the structured information for a given message. The optional flags parameter only has a single option, FT_UID, which tells the function to treat the msg_number argument as a UID. The returned object includes the envelope, internal date, size, flags and body structure along with a similar object for each mime attachement. The structure of the returned objects is as follows:

Table 1. Returned Objects for imap_fetchstructure()

type Primary body type
encoding Body transfer encoding
ifsubtype True if there is a subtype string
subtype MIME subtype
ifdescription True if there is a description string
description Content description string
ifid True if there is an identification string
id Identification string
lines Number of lines
bytes Number of bytes
ifdisposition True if there is a disposition string
disposition Disposition string
ifdparameters True if the dparameters array exists
dparameters Disposition parameter array
ifparameters True if the parameters array exists
parameters MIME parameters array
parts Array of objects describing each message part

  1. dparameters is an array of objects where each object has an "attribute" and a "value" property.
  2. Parameter is an array of objects where each object has an "attributte" and a "value" property.
  3. Parts is an array of objects identical in structure to the top-level object, with the limitation that it cannot contain further 'parts' objects.

Table 2. Primary body type

0 text
1 multipart
2 message
3 application
4 audio
5 image
6 video
7 other

Table 3. Transfer encodings

0 7BIT
1 8BIT
2 BINARY
3 BASE64
4 QUOTED-PRINTABLE
5 OTHER

imap_header

imap_header -- messageÀÇ header¸¦ Àоî¿Â´Ù.

Description

object imap_header (int imap_stream, int msg_number [, int fromlength [, int subjectlength [, string defaulthost]]])

This function returns an object of various header elements.


       remail, date, Date, subject, Subject, in_reply_to, message_id,
       newsgroups, followup_to, references

message flags:
   Recent -  'R' if recent and seen, 
             'N' if recent and not seen, 
             ' ' if not recent
   Unseen -  'U' if not seen AND not recent, 
             ' ' if seen OR not seen and recent
   Answered -'A' if answered, 
             ' ' if unanswered
   Deleted - 'D' if deleted, 
             ' ' if not deleted
   Draft -   'X' if draft, 
             ' ' if not draft
   Flagged - 'F' if flagged, 
             ' ' if not flagged

NOTE that the Recent/Unseen behavior is a little odd. If you want to
know if a message is Unseen, you must check for

Unseen == 'U' || Recent == 'N'

toaddress (full to: line, up to 1024 characters)

to[] (returns an array of objects from the To line, containing):
   personal
   adl
   mailbox
   host

fromaddress (full from: line, up to 1024 characters)

from[] (returns an array of objects from the From line, containing):
   personal
   adl
   mailbox
   host

ccaddress (full cc: line, up to 1024 characters)
cc[] (returns an array of objects from the Cc line, containing):
   personal
   adl
   mailbox
   host

bccaddress (full bcc line, up to 1024 characters)
bcc[] (returns an array of objects from the Bcc line, containing):
   personal
   adl
   mailbox
   host

reply_toaddress (full reply_to: line, up to 1024 characters)
reply_to[] (returns an array of objects from the Reply_to line,
containing):
   personal
   adl
   mailbox
   host

senderaddress (full sender: line, up to 1024 characters)
sender[] (returns an array of objects from the sender line, containing):
   personal
   adl
   mailbox
   host

return_path (full return-path: line, up to 1024 characters)
return_path[] (returns an array of objects from the return_path line,
containing):
   personal
   adl
   mailbox
   host

udate (mail message date in unix time)

fetchfrom (from line formatted to fit fromlength 
characters)

fetchsubject (subject line formatted to fit subjectlength characters)

imap_rfc822_parse_headers

(PHP4 >= 4.0RC1)

imap_rfc822_parse_headers -- ÁÖ¾îÁø ¹®ÀÚ¿­³»ÀÇ ¸ÞÀÏ Çì´õ¿¡ ´ëÇÑ Á¤º¸¸¦ ºÐ¼®ÇÑ´Ù.

Description

object imap_rfc822_parse_headers (string headers [, string defaulthost])

This function returns an object of various header elements, similar to imap_header(), except without the flags and other elements that come from the IMAP server

imap_headers

imap_headers -- ÇÑ ÆíÁöÇÔÀÇ ¸ðµç messageµéÀÇ header¸¦ Àоî¿Â´Ù.

Description

array imap_headers (int imap_stream)

Returns an array of string formatted with header info. One element per mail message.

imap_listmailbox

imap_listmailbox -- ÆíÁöÇÔÀÇ ¸ñ·ÏÀ» ÀÐ¾î ¿Â´Ù.

Description

array imap_listmailbox (int imap_stream, string ref, string pattern)

Returns an array containing the names of the mailboxes. See imap_getmailboxes() for a description of ref and pattern.

Example 1. imap_listmailbox() example

  1 
  2 $mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
  3       || die("can't connect: ".imap_last_error());
  4  
  5 $list = imap_listmailbox($mbox,"{your.imap.host}","*");
  6 if(is_array($list)) {
  7   reset($list);
  8   while (list($key, $val) = each($list))
  9     print imap_utf7_decode($val)."<br>\n";
 10 } else
 11   print "imap_listmailbox failed: ".imap_last_error()."\n";
 12  
 13 imap_close($mbox);                                                                
 14       

imap_getmailboxes

(PHP3 >= 3.0.12, PHP4 >= 4.0b4)

imap_getmailboxes -- ÆíÁöÇÔµéÀÇ ¸ñ·ÏÀ» Àаí, °¢°¢¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ Á¤º¸¸¦ ¹ÝȯÇÑ´Ù.

Description

array imap_getmailboxes (int imap_stream, string ref, string pattern)

Returns an array of objects containing mailbox information. Each object has the attributes name, specifying the full name of the mailbox; delimiter, which is the hierarchy delimiter for the part of the hierarchy this mailbox is in; and attributes. Attributes is a bitmask that can be tested against:

Mailbox names containing international Characters outside the printable ASCII range will be encoded and may be decoded by imap_utf7_decode().

ref should normally be just the server specification as described in imap_open(), and pattern specifies where in the mailbox hierarchy to start searching. If you want all mailboxes, pass '*' for pattern.

There are two special characters you can pass as part of the pattern: '*' and '%'. '*' means to return all mailboxes. If you pass pattern as '*', you will get a list of the entire mailbox hierarchy. '%' means to return the current level only. '%' as the pattern parameter will return only the top level mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory.

Example 1. imap_getmailboxes() example

  1 
  2 $mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
  3       || die("can't connect: ".imap_last_error());
  4  
  5 $list = imap_getmailboxes($mbox,"{your.imap.host}","*");
  6 if(is_array($list)) {
  7   reset($list);
  8   while (list($key, $val) = each($list))
  9   {
 10     print "($key) ";
 11     print imap_utf7_decode($val->name).",";
 12     print "'".$val->delimiter."',";
 13     print $val->attributes."<br>\n";
 14   }
 15 } else
 16   print "imap_getmailboxes failed: ".imap_last_error()."\n";
 17  
 18 imap_close($mbox);                                                                
 19       

imap_listsubscribed

imap_listsubscribed -- ¸ðµç subscribed ÆíÁöÇÔÀÇ ¸ñ·ÏÀ» ÀÐ¾î ¿Â´Ù.

Description

array imap_listsubscribed (int imap_stream, string ref, string pattern)

Returns an array of all the mailboxes that you have subscribed. This is almost identical to imap_listmailbox(), but will only return mailboxes the user you logged in as has subscribed.

imap_getsubscribed

imap_getsubscribed -- ¸ðµç subscribed ÆíÁöÇÔµéÀÇ ¸ñ·ÏÀ» ¹ÝȯÇÑ´Ù.

Description

array imap_getsubscribed (int imap_stream, string ref, string pattern)

This function is identical to imap_getmailboxes(), except that it only returns mailboxes that the user is subscribed to.

imap_mail_copy

imap_mail_copy -- ƯÁ¤ messageµéÀ» ´Ù¸¥ ÆíÁöÇÔÀ¸·Î º¹»çÇÑ´Ù.

Description

int imap_mail_copy (int imap_stream, string msglist, string mbox [, int flags])

Returns true on success and false on error.

Copies mail messages specified by msglist to specified mailbox. msglist is a range not just message numbers (as described in RFC2060).

Flags is a bitmask of one or more of

imap_mail_move

imap_mail_move -- ƯÁ¤ messageµéÀ» ´Ù¸¥ ÆíÁöÇÔÀ¸·Î ¿Å±ä´Ù.

Description

int imap_mail_move (int imap_stream, string msglist, string mbox [, int flags])

Moves mail messages specified by msglist to specified mailbox. msglist is a range not just message numbers (as described in RFC2060).

Flags is a bitmask and may contain the single option

Returns true on success and false on error.

imap_num_msg

imap_num_msg -- ÇöÀç ÆíÁöÇÔÀÇ ¸Þ¼¼Áö °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

int imap_num_msg (int imap_stream)

Return the number of messages in the current mailbox.

imap_num_recent

imap_num_recent -- ÇöÀç ÆíÁöÇÔÀÇ ÃÖ±Ù ¸Þ¼¼Áö °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

int imap_num_recent (int imap_stream)

Returns the number of recent messages in the current mailbox.

imap_open

imap_open -- ÇÑ ÆíÁöÇÔ¿¡ ´ëÇØ IMAP streamÀ» ¿¬´Ù.

Description

int imap_open (string mailbox, string username, string password [, int flags])

Returns an IMAP stream on success and false on error. This function can also be used to open streams to POP3 and NNTP servers, but some functions and features are not available on IMAP servers.

A mailbox name consists of a server part and a mailbox path on this server. The special name INBOX stands for the current users personal mailbox. The server part, which is enclosed in '{' and '}', consists of the servers name or ip address, a protocol secification (beginning with '/') and an optional port specifier beginnung with ':'. The server part is mandatory in all mailbox parameters. Mailbos names that contain international characters besides those in the printable ASCII space have to be encoded with imap_utf7_encode().

The options are a bit mask with one or more of the following:

To connect to an IMAP server running on port 143 on the local machine, do the following:

  1  
  2 $mbox = imap_open ("{localhost:143}INBOX", "user_id", "password");
  3       

To connect to a POP3 server on port 110 on the local server, use:

  1 
  2 $mbox = imap_open ("{localhost/pop3:110}INBOX", "user_id", "password");
  3       

To connect to an NNTP server on port 119 on the local server, use:

  1 
  2 $nntp = imap_open ("{localhost/nntp:119}comp.test", "", "");
  3       

To connect to a remote server replace "localhost" with the name or the IP address of the server you want to connect to.

Example 1. imap_open() example

  1 
  2 $mbox = imap_open ("{your.imap.host:143}", "username", "password");
  3 
  4 echo "<p><h1>Mailboxes</h1>\n";
  5 $folders = imap_listmailbox ($mbox, "{your.imap.host:143}", "*");
  6 
  7 if ($folders == false) {
  8     echo "Call failed<br>\n";
  9 } else {
 10     while (list ($key, $val) = each ($folders)) {
 11         echo $val."<br>\n";
 12     }
 13 }
 14 
 15 echo "<p><h1>Headers in INBOX</h1>\n";
 16 $headers = imap_headers ($mbox);
 17 
 18 if ($headers == false) {
 19     echo "Call failed<br>\n";
 20 } else {
 21     while (list ($key,$val) = each ($headers)) {
 22         echo $val."<br>\n";
 23     }
 24 }
 25 
 26 imap_close($mbox);
 27       

imap_ping

imap_ping -- IMAP streamÀÌ ¿©ÀüÈ÷ activeÀÎÁö °Ë»çÇÑ´Ù.

Description

int imap_ping (int imap_stream)

Returns true if the stream is still alive, false otherwise.

imap_ping() function pings the stream to see it is still active. It may discover new mail; this is the preferred method for a periodic "new mail check" as well as a "keep alive" for servers which have inactivity timeout. (As PHP scripts do not tend to run that long, i can hardly imagine that this function will be usefull to anyone.)

imap_renamemailbox

imap_renamemailbox -- ÆíÁöÇÔÀÇ À̸§À» ¹Ù²Û´Ù.

Description

int imap_renamemailbox (int imap_stream, string old_mbox, string new_mbox)

This function renames on old mailbox to new mailbox (see imap_open() for the format of mbox names).

Returns true on success and false on error.

See also imap_createmailbox(), imap_deletemailbox(), and imap_open() for the format of mbox.

imap_reopen

imap_reopen -- ±âÁ¸¿¡ ¿­·ÁÀÖ´Â IMAP streamÀ» »õ ÆíÁöÇÔÀ¸·Î ¿¬´Ù.

Description

int imap_reopen (string imap_stream, string mailbox [, string flags])

This function reopens the specified stream to a new mailbox on an IMAP or NNTP server.

The options are a bit mask with one or more of the following:

Returns true on success and false on error.

imap_subscribe

imap_subscribe -- »õ ÆíÁöÇÔÀ» subscribeÇÑ´Ù.

Description

int imap_subscribe (int imap_stream, string mbox)

Subscribe to a new mailbox.

Returns true on success and false on error.

imap_undelete

imap_undelete -- »èÁ¦ Ç¥½ÃµÈ messageÀÇ »èÁ¦ Ç¥½Ã¸¦ Áö¿î´Ù .

Description

int imap_undelete (int imap_stream, int msg_number)

This function removes the deletion flag for a specified message, which is set by imap_delete() or imap_mail_move().

Returns true on success and false on error.

imap_unsubscribe

imap_unsubscribe -- ÆíÁöÇÔÀ» unsubscribeÇÑ´Ù.

Description

int imap_unsubscribe (int imap_stream, string mbox)

Unsubscribe from a specified mailbox.

Returns true on success and false on error.

imap_qprint

imap_qprint -- quoted-printable ¹®ÀÚ¿­À» 8 bit ¹®ÀÚ¿­·Î ¹Ù²Û´Ù.

Description

string imap_qprint (string string)

Convert a quoted-printable string to an 8 bit string (according to RFC2045, section 6.7).

Returns an 8 bit (binary) string.

See also imap_8bit().

imap_8bit

imap_8bit -- 8 bit ¹®ÀÚ¿­À» quoted-printable ¹®ÀÚ¿­·Î ¹Ù²Û´Ù.

Description

string imap_8bit (string string)

Convert an 8bit string to a quoted-printable string (according to RFC2045, section 6.7).

Returns a quoted-printable string.

See also imap_qprint().

imap_binary

imap_binary -- 8bit ¹®ÀÚ¿­À» base64 ¹®ÀÚ¿­·Î ¹Ù²Û´Ù.

Description

string imap_binary (string string)

Convert an 8bit string to a base64 string (according to RFC2045, Section 6.8).

Returns a base64 string.

See also imap_base64().

imap_scanmailbox

imap_scanmailbox -- mailboxµéÀÇ list¸¦ Àаí, °Ë»öÇÒ ¹®ÀÚ¿­À» mailboxÀÇ text¿¡¼­ ÃëÇÑ´Ù.

Description

array imap_scanmailbox (int imap_stream, string content)

Returns an array containing the names of the mailboxes that have string in the text of the mailbox. This function is simmilar to imap_listmailbox(), but it will additionally check for the presence of the string content inside the mailbox data.

imap_mailboxmsginfo

imap_mailboxmsginfo -- ÇöÀç mailbox¿¡ ´ëÇÑ Á¤º¸¸¦ ±¸ÇÑ´Ù.

Description

object imap_mailboxmsginfo (int imap_stream)

Returns information about the current mailbox. Returns FALSE on failure.

The imap_mailboxmsginfo() function checks the current mailbox status on the server. It is similar to imap_status(), but will additionally sum up the size of all messages in the mailbox, which will take some additional time to execute. It returns the information in an object with following properties.

Table 1. Mailbox properties

Date date of last change
Driver driver
Mailbox name of the mailbox
Nmsgs number of messages
Recent number of recent messages
Unread number of unread messages

Size

mailbox size

 

Example 1. imap_mailboxmsginfo() example

  1 
  2 $mbox = imap_open("{your.imap.host}INBOX","username", "password")
  3       || die("can't connect: ".imap_last_error());
  4  
  5 $check = imap_mailboxmsginfo($mbox);
  6  
  7 if($check) {
  8   print "Date: "    . $check->Date    ."<br>\n" ;
  9   print "Driver: "  . $check->Driver  ."<br>\n" ;
 10   print "Mailbox: " . $check->Mailbox ."<br>\n" ;
 11   print "Messages: ". $check->Nmsgs   ."<br>\n" ;
 12   print "Recent: "  . $check->Recent  ."<br>\n" ;
 13   print "Size: "    . $check->Size    ."<br>\n" ;
 14 } else
 15   print "imap_check() failed: ".imap_lasterror(). "<br>\n";
 16  
 17 imap_close($mbox);
 18       

imap_rfc822_write_address

imap_rfc822_write_address -- ÁÖ¾îÁø mailbox¿Í host, personal info·Î ÀûÇÕÇÑ ¸ð¾çÀÇ email address¸¦ ¸¸µé¾î ³½´Ù.

Description

string imap_rfc822_write_address (string mailbox, string host, string personal)

Returns a properly formatted email address as defined in RFC822 given the mailbox, host, and personal info.

Example 1. imap_rfc822_write_address() example

  1 
  2 print imap_rfc822_write_address("hartmut","cvs.php.net","Hartmut Holzgraefe")."\n";      
  3       

imap_rfc822_parse_adrlist

imap_rfc822_parse_adrlist -- address ¹®ÀÚ¿­À» parsingÇÑ´Ù.

Description

array imap_rfc822_parse_adrlist (string address, string default_host)

This function parses the address string as defined in RFC822 and for each address, returns an array of objects. The objects properties are:

 

Example 1. imap_rfc822_parse_adrlist() example

  1 
  2 $address_string = "Hartmut Holzgraefe <hartmut@cvs.php.net>, postmaster@somedomain.net, root";
  3 $address_array  = imap_rfc822_parse_adrlist($address_string,"somedomain.net");
  4 if(! is_array($address_array)) die("somethings wrong\n");
  5  
  6 reset($address_array);
  7 while(list($key,$val)=each($address_array)){
  8   print "mailbox : ".$val->mailbox."<br>\n";
  9   print "host    : ".$val->host."<br>\n";
 10   print "personal: ".$val->personal."<br>\n";
 11   print "adl     : ".$val->adl."<p>\n";
 12 } 
 13       

imap_setflag_full

imap_setflag_full -- messageµéÀÇ ¿©·¯ flag¸¦ ¼³Á¤(set)ÇÑ´Ù.

Description

string imap_setflag_full (int stream, string sequence, string flag, string options)

This function causes a store to add the specified flag to the flags set for the messages in the specified sequence.

The flags which you can set are "\\Seen", "\\Answered", "\\Flagged", "\\Deleted", "\\Draft", and "\\Recent" (as defined by RFC2060).

The options are a bit mask with one or more of the following:

 

Example 1. imap_setflag_full() example

  1 
  2 $mbox = imap_open("{your.imap.host:143}","username","password")
  3      || die("can't connect: ".imap_last_error());
  4  
  5 $status = imap_setflag_full($mbox,"2,5","\\Seen \\Flagged");
  6  
  7 print gettype($status)."\n";
  8 print $status."\n";
  9  
 10 imap_close($mbox);
 11       

imap_clearflag_full

imap_clearflag_full -- messageµéÀÇ ¿©·¯ flag¸¦ clear ÇÑ´Ù.

Description

string imap_clearflag_full (int stream, string sequence, string flag, string options)

This function causes a store to delete the specified flag to the flags set for the messages in the specified sequence. The flags which you can unset are "\\Seen", "\\Answered", "\\Flagged", "\\Deleted", "\\Draft", and "\\Recent" (as defined by RFC2060).

The options are a bit mask with one or more of the following:

imap_sort

imap_sort -- ¸Þ½ÃÁöµéÀ» ÁÖ¾îÁø ¹æ½Ä´ë·Î Á¤·ÄÇÑ ¸Þ½ÃÁö ¹øÈ£ÀÇ ¹è¿­À» ±¸ÇÑ´Ù.

Description

string imap_sort (int stream, int criteria, int reverse, int options)

Returns an array of message numbers sorted by the given parameters.

Reverse is 1 for reverse-sorting.

Criteria can be one (and only one) of the following:

The flags are a bitmask of one or more of the following:

imap_fetchheader

imap_fetchheader -- messageÀÇ Çì´õ¸¦ ¹ÝȯÇÑ´Ù.

Description

string imap_fetchheader (int imap_stream, int msgno, int flags)

This function causes a fetch of the complete, unfiltered RFC822 format header of the specified message as a text string and returns that text string.

The options are:

  • FT_INTERNAL  The return string is in "internal" format, without any attempt to canonicalize to CRLF newlines
  • FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the same time. 
                         This avoids an extra RTT on an IMAP connection if a full message text is desired (e.g. in a "save to local file" operation)
  • imap_uid

    imap_uid -- ¼±ÅÃÇÑ messageÀÇ ÀÏ·Ã ¹øÈ£(sequence number)ÀÎ UID¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int imap_uid (int imap_stream, int msgno)

    This function returns the UID for the given message sequence number. An UID is an unique identifier that will not change over time while a message sequence number may change whenever the content of the mailbox changes. This function is the inverse of imap_msgno().

    imap_msgno

    imap_msgno -- ÁÖ¾îÁø UID¿¡ ÇØ´çÇÏ´Â ¸Þ¼¼Áö ¼ø¼­ ¹øÈ£¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int imap_msgno (int imap_stream, int uid)

    This function returns the message sequence number for the given UID. It is the inverse of imap_uid().

    imap_search

    imap_search -- ÁÖ¾îÁø °Ë»ö ±âÁØ¿¡ ¸Â´Â ¸Þ¼¼ÁöµéÀÇ ¹è¿­À» ¹ÝȯÇÑ´Ù.

    Description

    array imap_search (int imap_stream, string criteria, int flags)

    This function performs a search on the mailbox currently opened in the given imap stream. criteria is a string, delimited by spaces, in which the following keywords are allowed. Any multi-word arguments (eg. FROM "joey smith") must be quoted.

    For example, to match all unanswered messages sent by Mom, you'd use: "UNANSWERED FROM mom". Searches appear to be case insensitive. This list of criteria is from a reading of the UW c-client source code and may be uncomplete or inaccurate (see also RFC2060, section 6.4.4).

    Valid values for flags are SE_UID, which causes the returned array to contain UIDs instead of messages sequence numbers.

    imap_last_error

    imap_last_error -- ¿ä±¸µÈ ÇöÀç ÆäÀÌÁö¿¡¼­ IMAP ¿¡·¯Áß °¡Àå ÃÖ±Ù¿¡ ¹ß»ýÇÑ °ÍÀ» ¹ÝȯÇÑ´Ù.

    Description

    string imap_last_error (void)

    This function returns the full text of the last IMAP error message that occurred on the current page. The error stack is untouched; calling imap_last_error() subsequently, with no intervening errors, will return the same error.

    imap_errors

    imap_errors -- ¿ä±¸µÈ ÇöÀç ÆäÀÌÁö¿¡¼­ óÀ½ºÎÅÍ, ȤÀº ¿¡·¯ ½ºÅÃÀÌ resetµÈ ÀûÀÌ ÀÖ´Ù¸é ±× ÀÌÈÄ¿¡ ¹ß»ýÇÑ ¸ðµç IMAP ¿¡·¯¸¦ ¹ÝȯÇÑ´Ù.

    Description

    array imap_errors (void)

    This function returns an array of all of the IMAP error messages generated since the last imap_errors() call, or the beginning of the page. When imap_errors() is called, the error stack is subsequently cleared.

    imap_alerts

    imap_alerts -- ¿ä±¸µÈ ÇöÀç ÆäÀÌÁö¿¡¼­ óÀ½ºÎÅÍ, ȤÀº ¿¡·¯ ½ºÅÃÀÌ resetµÈ ÀûÀÌ ÀÖ´Ù¸é ±× ÀÌÈÄ¿¡ ¹ß»ýÇÑ ¸ðµç IMAP ÁÖÀÇ(alert) ¸Þ¼¼Áö¸¦ ¹ÝȯÇÑ´Ù.

    Description

    array imap_alerts (void)

    This function returns an array of all of the IMAP alert messages generated since the last imap_alerts() call, or the beginning of the page. When imap_alerts() is called, the alert stack is subsequently cleared. The IMAP specification requires that these messages be passed to the user.

    imap_status

    imap_status -- ÇöÀçÀÇ ÆíÁöÇÔÀÌ¿ÜÀÇ ´Ù¸¥ ÆíÁöÇÔÀÇ »óÅ Á¤º¸¸¦ ¹ÝȯÇÑ´Ù.

    Description

    object imap_status (int imap_stream, string mailbox, int options)

    This function returns an object containing status information. Valid flags are:

    status->flags is also set, which contains a bitmask which can be checked against any of the above constants.

    Example 1. imap_status() example

      1 
      2 $mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
      3       || die("can't connect: ".imap_last_error());
      4  
      5 $status = imap_status($mbox,"{your.imap.host}INBOX",SA_ALL);
      6 if($status) {
      7   print("Messages:   ". $status->messages   )."<br>\n";
      8   print("Recent:     ". $status->recent     )."<br>\n";
      9   print("Unseen:     ". $status->unseen     )."<br>\n";
     10   print("UIDnext:    ". $status->uidnext    )."<br>\n";
     11   print("UIDvalidity:". $status->uidvalidity)."<br>\n"; 
     12 } else
     13   print "imap_status failed: ".imap_lasterror()."\n";
     14  
     15 imap_close($mbox);
     16       

    imap_utf7_decode

    (PHP3 >= 3.0.15, PHP4 >= 4.0b4)

    imap_utf7_decode -- modified UTF-7 À¸·Î ¿£ÄÚµùµÈ ¹®ÀÚ¿­À» µðÄÚµåÇÑ´Ù.

    Description

    string imap_utf7_decode (string text)

    Decodes modified UTF-7 text into 8bit data.

    Returns the decoded 8bit data, or false if the input string was not valid modified UTF-7. This function is needed to decode mailbox names that contain international characters outside of the printable ASCII range. The modified UTF-7 encoding is defined in RFC 2060, section 5.1.3 (original UTF-7 was defned in RFC1642).

    imap_utf7_encode

    (PHP3 >= 3.0.15, PHP4 >= 4.0b4)

    imap_utf7_encode --  8bit µ¥ÀÌÅ͸¦ modified UTF-7 ¹®ÀÚ¿­·Î º¯È¯ÇÑ´Ù.

    Description

    string imap_utf7_encode (string data)

    Converts 8bit data to modified UTF-7 text. This is needed to encode mailbox names that contain international characters outside of the printable ASCII range. The modified UTF-7 encoding is defined in RFC 2060, section 5.1.3 (original UTF-7 was defned in RFC1642).

    Returns the modified UTF-7 text.

    imap_utf8

    (PHP3 >= 3.0.13, PHP4 >= 4.0RC1)

    imap_utf8 --  ÅؽºÆ®¸¦ UTF8 ÇüÅ·Πº¯È¯ÇÑ´Ù.

    Description

    string imap_utf8 (string text)

    Converts the given text to UTF8 (as defined in RFC2044).

    imap_fetch_overview

    (PHP3 >= 3.0.4, PHP4 )

    imap_fetch_overview -- ÁÖ¾îÁø ¸Þ½ÃÁöÀÇ Çì´õ¿¡ ÀÖ´Â Á¤º¸¸¦ ÀüüÀûÀ¸·Î Àоî¿Â´Ù.

    Description

    array imap_fetch_overview (int imap_stream, string sequence [, int flags])

    This function fetches mail headers for the given sequence and returns an overview of their contents. sequence will contain a sequence of message indices or UIDs, if flags contains FT_UID. The returned value is an array of objects describing one message header each:

     

    Example 1. imap_fetch_overview() example

      1 
      2 $mbox = imap_open("{your.imap.host:143}","username","password")
      3      || die("can't connect: ".imap_last_error());
      4  
      5 $overview = imap_fetch_overview($mbox,"2,4:6",0);
      6  
      7 if(is_array($overview)) {
      8         reset($overview);
      9         while( list($key,$val) = each($overview)) {
     10                 print     $val->msgno
     11                 . " - " . $val->date
     12                 . " - " . $val->subject
     13                 . "\n";
     14         }
     15 }
     16  
     17 imap_close($mbox);
     18       

    imap_mime_header_decode

    (PHP3 CVS only, PHP4 >= 4.0RC1)

    imap_mime_header_decode -- MIME Çì´õ ¿ä¼Ò¸¦ µðÄÚµåÇÑ´Ù.

    Description

    array imap_header_decode (string text)

    imap_mime_header_decode() function decodes MIME message header extensions that are non ASCII text (see RFC2047) The decoded elements are returned in an array of objects, where each object has two properties, "charset" & "text". If the element hasn't been encoded, and in other words is in plain US-ASCII,the "charset" property of that element is set to "default".

    Example 1. imap_mime_header_decode() example

      1 
      2 $text="=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>";
      3 
      4 $elements=imap_mime_header_decode($text);
      5 for($i=0;$i<count($elements);$i++) {
      6 	echo "Charset: {$elements[$i]->charset}\n";
      7 	echo "Text: {$elements[$i]->text}\n\n";
      8 }
      9 
     10       

    imap_mail_compose

    (PHP3 >= 3.0.5, PHP4 )

    imap_mail_compose -- ÁÖ¾îÁø envelope ¿Í body ºÎºÐÀ» °¡Áö°í MIME ¸Þ½ÃÁö¸¦ ¸¸µé¾î³½´Ù.

    Description

    string imap_mail_compose (array envelope, array body)

    imap_mail

    (PHP3 >= 3.0.14, PHP4 >= 4.0b4)

    imap_mail --  email ¸Þ½ÃÁö¸¦ º¸³½´Ù.

    Description

    string imap_mail (string to, string subject, string message [, string additional_headers [, string cc [, string bcc [, string rpath]]]])

    This function is currently only available in PHP3.


    XXIX. Informix functions

    Informix (IDS) 7.x, SE 7.x, Universal Server (IUS) 9.x and IDS 2000 ¸¦ À§ÇÑ µå¶óÀ̹ö´Â informix extension µð·ºÅ丮ÀÇ "ifx.ec"¿Í "php3_ifx.h"¿¡ ±¸ÇöµÇ¾î ÀÖ´Ù. IDS 7.x ¿¡ ´ëÇÑ Áö¿øÀº, BYTE and TEXT Ä®·³¿¡ ´ëÇÑ ¿ÏÀüÇÑ Áö¿øÀ» Æ÷ÇÔÇÏ¿©, ÃæºÐÇÑ Á¤µµ·Î(fairly) ¿Ï¼ºµÇ¾ú´Ù. IUS 9.x¿¡ ´ëÇÑ Áö¿øÀº ºÎºÐÀûÀ¸·Î¸¸ ¿Ï·áµÇ¾ú´Ù. »õ·Î¿î µ¥ÀÌÅÍ Å¸ÀÔµéÀº ¿Ï·áµÇ¾úÀ¸³ª, SLOB¿Í CLOB¿¡ ´ëÇÑ Áö¿øÀº ¾ÆÁ÷ ÁøÇàÁßÀÌ´Ù.

    ¼³Á¤½Ã ÁÖÀÇ »çÇ× (Configuration notes) :

    PHP Informix µå¶óÀ̹ö¸¦ ÄÄÆÄÀÏÇÏ·Á¸é ESQL/C ¹öÀüÀÌ ÇÊ¿äÇÏ´Ù. 7.2x ÀÌÈÄÀÇ ESQL/C ¹öÀüÀÌ¸é ¹®Á¦ ¾ø´Ù. ESQL/C´Â ÀÌÁ¦ Informix Client SDKÀÇ ÇÑ ºÎºÐÀÌ µÇ¾îÀÖ´Ù.

    "configure" ½ºÅ©¸³Æ®¸¦½ÇÇàÇϱâ Àü¿¡, ¹Ýµå½Ã "INFORMIXDIR" ȯ°æ º¯¼ö¸¦ ¼³Á¤ÇØ ³õ¾Æ¾ß ÇÏ°í, $INFORMIXDIR/bin µð·ºÅ丮°¡ ¿©·¯ºÐÀÇ PATH ¿¡ Æ÷ÇԵǾî ÀÖ¾î¾ß ÇÑ´Ù.

    ÀÌ·¸°Ô ÇØ ³õ°í "configure --with_informix=yes"·Î ½ºÅ©¸³Æ® ÆÄÀÏÀ» ½ÇÇàÇϸé, configure ½ºÅ©¸³Æ®´Â ¶óÀ̺귯¸®¿Í include°¡ ÀÖ´Â µð·ºÅ丮¸¦ ÀÚµ¿À¸·Î ã´Â´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ¼ÕÀ¸·Î ¼³Á¤ ³»¿ëÀ» ÁöÁ¤ÇÏ°í ½Í´Ù¸é "IFX_LIBDIR", "IFX_LIBS", "IFX_INCDIR"ÀÇ È¯°æº¯¼ö¿¡ ¿øÇÏ´Â °ªÀ» ÁöÁ¤ÇÏ¸é µÈ´Ù. ¶ÇÇÑ, configure ½ºÅ©¸³Æ®´Â ¿©·¯ºÐÀÌ »ç¿ëÁßÀÎ InformixÀÇ ¹öÀüÀ» üũÇÑ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ Informix ¹öÀüÀÌ 9.00ÀÌ»óÀ̶ó¸é ÀÌ °ªÀÌ "HAVE_IFX_IUS" ¶ó´Â conditional compilation variable¿¡ ¼³Á¤ÇÑ´Ù.

    BLOB »ç¿ë½Ã ÁÖÀÇ »çÇ× (Some notes on the use of BLOBs(TEXT and BYTE columns)) :

    ÇöÀç ¹öÀü(September 18, 1998)Àº select/insert/update¿¡¼­ BLOB Ä÷³À» ¿Ïº®ÇÏ°Ô Áö¿øÇÑ´Ù.

    BLOB´Â º¸Åë Á¤¼ö°ªÀÎ BLOB identifier¸¦ »ç¿ëÇÏ¿© ÁÖ¼ÒÈ­(addressed)µÈ´Ù. Select ÁúÀÇ´Â ¸ðµç BYTE¿Í TEXT Ä÷³¿¡ ´ëÇÑ "blob id"¸¦ ¹ÝȯÇÑ´Ù. ¿©·¯ºÐÀÌ "ifx_blobinfile(0);"¸¦ »ç¿ëÇÏ¿© BLOB¸¦ ¸Þ¸ð¸®¿¡¼­ °¡Á®¿À±â·Î °áÁ¤ÇØ µÎ¾ú´Ù¸é, ¿©·¯ºÐÀº "string_var = ifx_get_blob($blob_id);" °°Àº ¸í·ÉÀ» »ç¿ëÇÏ¿© ±× ³»¿ëÀ» ¾ò¾î¿Ã ¼ö ÀÖ´Ù. ¸¸¾à, "ifx_blobinfile(1);"¸¦ »ç¿ëÇÏ¿© ÆÄÀÏ¿¡ ÀÖ´Â BLOB Ä÷³ÀÇ ³»¿ëÀ» ÀÚÁ®¿À±â·Î ÇÏ¿´´Ù¸é, "ifx_get_blob($blob_id);"¸¦ »ç¿ëÇÏ¿© ÇØ´ç ÆÄÀÏ À̸§À» ¾òÀ» ¼ö ÀÖ´Ù. À̶§ ¾òÀº ÆÄÀÏ À̸§Àº ÀϹÝÀûÀÎ ÆÄÀÏ I/O ¹æ½ÄÀ» »ç¿ëÇÏ¿© ±× ³»¿ëÀ» Àоî¿Ã ¼ö ÀÖ´Ù.

    insert/update ÁúÀÇÀÇ °æ¿ì ¿©·¯ºÐÀº "ifx_create_blob(..);"¸¦ »ç¿ëÇÏ¿© "blob id(µé)"¸¦ ¼Õ¼ö ¸¸µé¾î ÁÖ¾î¾ß ÇÑ´Ù. ¸¸µç blob idµéÀº ¹è¿­¿¡ ÀúÀåÇÑ ÈÄ¿¡, blob Ä÷³Àº ÁúÀÇ ¹®ÀÚ¿­ÀÇ ¹°À½Ç¥(?)·Î ¹Ù²Û´Ù. updates/inserts¸¦ À§Çؼ­ ¿©·¯ºÐÀº ifx_update_blob(...)¸¦ »ç¿ëÇÏ¿© blobÀÇ ³»¿ëÀ» ¼³Á¤ÇÏ¿©¾ß ÇÑ´Ù.

    BLOB Ä÷³¿¡ ´ëÇÑ µ¿ÀÛÀº ´ÙÀ½°ú °°Àº ¼³Á¤ º¯¼ö(configuration variables)¿¡ µû¶ó ´Þ¶óÁø´Ù. ÀÌ ¼³Á¤ º¯¼ö(configuration variables)Àº ½ÇÇàÁß¿¡µµ º¯°æÇÒ ¼ö ÀÖ´Ù. :

    ¼³Á¤º¯¼ö(configuration variable) :

    ½ÇÇà ÇÔ¼ö(runtime functions) :

    ¼³Á¤º¯¼ö(configuration variable) :

    ½ÇÇà ÇÔ¼ö(runtime functions) :

    ¸¸¾à ¿©·¯ºÐÀÌ ifx_text/byteasvarchar¸¦ 1·Î ¼³Á¤Çϸé, ¿©·¯ºÐÀº select ÁúÀÇ¿¡¼­ TEXT¿Í BYTE Ä÷³À» ÀϹÝÀûÀÎ (±×·¯³ª º¸´Ù ±ä) VARCHAR Çʵåó·³ »ç¿ëÇÒ ¼ö ÀÖ´Ù. PHP¿¡¼­ ¸ðµç ¹®ÀÚ¿­ÀÌ °è»ê("counted") µÇ¾îÁö´Â ÇÑ, ÀÌ°ÍÀº "binary safe"ÇÑ »óÅ·ΠÀÖ°Ô µÈ´Ù. ÀÌ°ÍÀ» ¿Ã¹Ù¸£°Ô »ç¿ëÇÏ´Â °ÍÀº ¿©·¯ºÐ¿¡°Ô ´Þ·ÁÀÖ´Ù. µ¹·Á¹ÞÀ» µ¥ÀÌÅÍ´Â ¿©·¯ºÐÀÌ ±× ³»¿ë¿¡ ´ëÇØ Ã¥ÀÓÁú ¼ö ÀÖ´Ù¸é, ¾î¶² ³»¿ëµµ Æ÷ÇÔÇÒ ¼ö ÀÖ´Ù.

    ¸¸¾à ¿©·¯ºÐÀÌ ifx_blobinfileÀ» 1·Î ¼³Á¤Çϸé, blobÀÇ ³»¿ëÀ» °¡Á®¿À±â À§ÇØ ifx_get_blob(..)¸¦ »ç¿ëÇÏ¿© ¹Ýȯ ¹ÞÀº ÆÄÀϸíÀ» »ç¿ëÇÏ¿©¾ß ÇÑ´Ù. ÀÌ °æ¿ì¿¡ ¾î¶² row¸¦ °¡Á®¿À°Ô(fetch) µÇ¸é ¿©·¯ºÐÀº INFORMIX°¡ ¸¸µç Àӽà ÆÄÀϵéÀ» Áö¿öÁ٠åÀÓÀÌ ÀÖ´Ù. Informix´Â »õ row fetch¶§ ¸¶´Ù ¸ðµç BYTE Ä÷³¿¡ Çϳª¾¿ »õ Àӽà ÆÄÀÏÀ» ¸¸µç´Ù.

    Àӽà ÆÄÀÏÀÌ ÀÖ´Â µð·ºÅ丮´Â ȯ°æº¯¼öÀÎ "blobdir"¿¡ ¼³Á¤µÈ µÈ °ªÀ» »ç¿ëÇÑ´Ù. ±âº»°ªÀº ÇöÀç µð·ºÅ丮ÀÎ "." ÀÌ´Ù. putenv(blobdir=tmpblob"); °°ÀÌ »ç¿ëÇÏ¸é ³²°ÜÁø ("blb"·Î ½ÃÀÛÇÏ´Â À̸§À» °¡Áø) Àӽà ÆÄÀϵéÀ» ½±°Ô û¼ÒÇÒ ¼ö ÀÖ´Ù.

    ÀÚµ¿ °ø¹é Á¦°Å (Automatically trimming "char" <SQLCHAR and SQLNCHAR> data) :

    ÀÌ ±â´ÉÀº ´ÙÀ½ ¼³Á¤ º¯¼ö(configuration variable)·Î ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.

    ifx.charasvarchar : 1·Î ¼³Á¤µÇ¾îÀÖÀ¸¸é µÚ¿¡ ºÙÀº °ø¹é¹®ÀÚ¸¦ ÀÚµ¿À¸·Î Á¦°ÅÇÑ´Ù.


    Table of Contents
    ifx_connect ¡¦ Open Informix server connection
    ifx_pconnect ¡¦ Open persistent Informix connection
    ifx_close ¡¦ Close Informix connection
    ifx_query ¡¦ Send Informix query
    ifx_prepare ¡¦ Prepare an SQL-statement for execution
    ifx_do ¡¦ Execute a previously prepared SQL-statement
    ifx_error ¡¦ Returns error code of last Informix call
    ifx_errormsg ¡¦ Returns error message of last Informix call
    ifx_affected_rows ¡¦ Get number of rows affected by a query
    ifx_getsqlca ¡¦ Get the contents of sqlca.sqlerrd[0..5] after a query
    ifx_fetch_row ¡¦ Get row as enumerated array
    ifx_htmltbl_result ¡¦ Formats all rows of a query into a HTML table
    ifx_fieldtypes ¡¦ List of Informix SQL fields
    ifx_fieldproperties ¡¦ List of SQL fieldproperties
    ifx_num_fields ¡¦ Returns the number of columns in the query
    ifx_num_rows ¡¦ Count the rows already fetched a query
    ifx_free_result ¡¦ Releases resources for the query
    ifx_create_char ¡¦ Creates an char object
    ifx_free_char ¡¦ Deletes the char object
    ifx_update_char ¡¦ Updates the content of the char object
    ifx_get_char ¡¦ Return the content of the char object
    ifx_create_blob ¡¦ Creates an blob object
    ifx_copy_blob ¡¦ Duplicates the given blob object
    ifx_free_blob ¡¦ Deletes the blob object
    ifx_get_blob ¡¦ Return the content of a blob object
    ifx_update_blob ¡¦ Updates the content of the blob object
    ifx_blobinfile_mode ¡¦ Set the default blob mode for all select queries
    ifx_textasvarchar ¡¦ Set the default text mode
    ifx_byteasvarchar ¡¦ Set the default byte mode
    ifx_nullformat ¡¦ Sets the default return value on a fetch row
    ifxus_create_slob ¡¦ Creates an slob object and opens it
    ifx_free_slob ¡¦ Deletes the slob object
    ifxus_close_slob ¡¦ Deletes the slob object
    ifxus_open_slob ¡¦ Opens an slob object
    ifxus_tell_slob ¡¦ Returns the current file or seek position
    ifxus_seek_slob ¡¦ Sets the current file or seek position
    ifxus_read_slob ¡¦ Reads nbytes of the slob object
    ifxus_write_slob ¡¦ Writes a string into the slob object

    ifx_connect

    ifx_connect -- Informix ¼­¹ö connectionÀ» ¿¬´Ù.

    Description

    int ifx_connect (string [database] , string [userid] , string [password] );

    Returns an connection identifier on success, or FALSE on error.

    ifx_connect() establishes a connection to an Informix server. All of the arguments are optional, and if they're missing, defaults are taken from values supplied in php3.ini (ifx.default_host for the host (Informix libraries will use $INFORMIXSERVER environment value if not defined), ifx.default_user for user, ifx.default_password for the password (none if not defined).

    In case a second call is made to ifx_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned.

    The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling ifx_close().

    See also ifx_pconnect(), and ifx_close().

    Example 1. Connect to a Informix database

      1 
      2 $conn_id = ifx_pconnect ("mydb@ol_srv1", "imyself", "mypassword");
      3       

    ifx_pconnect

    ifx_pconnect -- ¿µ±¸ÀûÀÎ(persistent) Informix ¼­¹ö connectionÀ» ¿¬´Ù.

    Description

    int ifx_pconnect (string [database] , string [userid] , string [password] );

    Returns: A positive Informix persistent link identifier on success, or false on error

    ifx_pconnect() acts very much like ifx_connect() with two major differences.

    This function behaves exactly like ifx_connect() when PHP is not running as an Apache module. First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

    Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (ifx_close() will not close links established by ifx_pconnect()).

    This type of links is therefore called 'persistent'.

    See also: ifx_connect().

    ifx_close

    ifx_close -- Informix connectionÀ» ´Ý´Â´Ù.

    Description

    int ifx_close (int [link_identifier] );

    Returns: always true.

    ifx_close() closes the link to an Informix database that's associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed.

    Note that this isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.

    ifx_close() will not close persistent links generated by ifx_pconnect().

    See also: ifx_connect(), and ifx_pconnect().

    Example 1. Closing a Informix connection

      1 
      2 $conn_id = ifx_connect ("mydb@ol_srv", "itsme", "mypassword");
      3 ... some queries and stuff ...
      4 ifx_close($conn_id);
      5       

    ifx_query

    ifx_query -- Informix ÁúÀǸ¦ Àü¼ÛÇÑ´Ù.

    Description

    int ifx_query (string query, int [link_identifier] , int [cursor_type] , mixed [blobidarray] );

    Returns: A positive Informix result identifier on success, or false on error.

    An integer "result_id" used by other functions to retrieve the query results. Sets "affected_rows" for retrieval by the ifx_affected_rows() function.

    ifx_query() sends a query to the currently active database on the server that's associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed. If no link is open, the function tries to establish a link as if ifx_connect() was called, and use it.

    Executes query on connection conn_id. For "select-type" queries a cursor is declared and opened. The optional cursor_type parameter allows you to make this a "scroll" and/or "hold" cursor. It's a mask and can be either IFX_SCROLL, IFX_HOLD, or both or'ed together. Non-select queries are "execute immediate".

    For either query type the number of (estimated or real) affected rows is saved for retrieval by ifx_affected_rows().

    If you have BLOB (BYTE or TEXT) columns in an update query, you can add a blobidarray parameter containing the corresponding "blob ids", and you should replace those columns with a "?" in the query text.

    If the contents of the TEXT (or BYTE) column allow it, you can also use "ifx_textasvarchar(1)" and "ifx_byteasvarchar(1)". This allows you to treat TEXT (or BYTE) columns just as if they were ordinary (but long) VARCHAR columns for select queries, and you don't need to bother with blob id's.

    With ifx_textasvarchar(0) or ifx_byteasvarchar(0) (the default situation), select queries will return BLOB columns as blob id's (integer value). You can get the value of the blob as a string or file with the blob functions (see below).

    See also: ifx_connect().

    Example 1. Show all rows of the "orders" table as a html table

      1 
      2 ifx_textasvarchar(1);      // use "text mode" for blobs
      3 $res_id = ifx_query("select * from orders", $conn_id);
      4 if (! $res_id) {
      5     printf("Can't select orders : %s\n<br>%s<br>\n", ifx_error());
      6     ifx_errormsg();
      7     die;
      8 }
      9 ifx_htmltbl_result($res_id, "border=\"1\"");
     10 ifx_free_result($res_id);
     11       

    Example 2. Insert some values into the "catalog" table

      1 
      2                       // create blob id's for a byte and text column
      3 $textid = ifx_create_blob(0, 0, "Text column in memory");
      4 $byteid = ifx_create_blob(1, 0, "Byte column in memory");
      5                       // store blob id's in a blobid array
      6 $blobidarray[] = $textid;
      7 $blobidarray[] = $byteid;
      8                       // launch query
      9 $query = "insert into catalog (stock_num, manu_code, " .
     10          "cat_descr,cat_picture) values(1,'HRO',?,?)";
     11 $res_id = ifx_query($query, $conn_id, $blobidarray);
     12 if (! $res_id) {
     13   ... error ...
     14 }
     15                      // free result id
     16 ifx_free_result($res_id);
     17       

    ifx_prepare

    ifx_prepare -- ½ÇÇàÀ» À§ÇÑ SQL¹®À» ÁغñÇÑ´Ù.

    Description

    int ifx_prepare (string query, int conn_id [, int cursor_def, mixed blobidarray])

    Returns a integer result_id for use by ifx_do(). Sets affected_rows for retrieval by the ifx_affected_rows() function.

    Prepares query on connection conn_id. For "select-type" queries a cursor is declared and opened. The optional cursor_type parameter allows you to make this a "scroll" and/or "hold" cursor. It's a mask and can be either IFX_SCROLL, IFX_HOLD, or both or'ed together.

    For either query type the estimated number of affected rows is saved for retrieval by ifx_affected_rows().

    If you have BLOB (BYTE or TEXT) columns in the query, you can add a blobidarray parameter containing the corresponding "blob ids", and you should replace those columns with a "?" in the query text.

    If the contents of the TEXT (or BYTE) column allow it, you can also use "ifx_textasvarchar(1)" and "ifx_byteasvarchar(1)". This allows you to treat TEXT (or BYTE) columns just as if they were ordinary (but long) VARCHAR columns for select queries, and you don't need to bother with blob id's.

    With ifx_textasvarchar(0) or ifx_byteasvarchar(0) (the default situation), select queries will return BLOB columns as blob id's (integer value). You can get the value of the blob as a string or file with the blob functions (see below).

    See also: ifx_do().

    ifx_do

    ifx_do -- ÀÌÀü¿¡ ÁغñµÈ SQL¹®À» ½ÇÇàÇÑ´Ù.

    Description

    int ifx_do (int result_id);

    Returns TRUE on success, FALSE on error.

    Executes a previously prepared query or opens a cursor for it.

    Does NOT free result_id on error.

    Also sets the real number of ifx_affected_rows() for non-select statements for retrieval by ifx_affected_rows()

    See also: ifx_prepare(). There is a example.

    ifx_error

    ifx_error -- ¸¶Áö¸·¿¡ ¼öÇàÇÑ Informix ¸í·ÉÀÇ ¿¡·¯ Äڵ带 µ¹·ÁÁØ´Ù.

    Description

    string ifx_error (void);

    The Informix error codes (SQLSTATE & SQLCODE) formatted as follows :

    x [SQLSTATE = aa bbb SQLCODE=cccc]

    If the "x" character is anything other than space, SQLSTATE and SQLCODE describe the error in more detail.

    See the Informix manual for the description of SQLSTATE and SQLCODE

    Returns in a string one character describing the general results of a statement and both SQLSTATE and SQLCODE associated with the most recent SQL statement executed. The format of the string is "(char) [SQLSTATE=(two digits) (three digits) SQLCODE=(one digit)]". The first character can be ' ' (space) (success), 'W' (the statement caused some warning), 'E' (an error happened when executing the statement) or 'N' (the statement didn't return any data).

    See also: ifx_errormsg()

    ifx_errormsg

    ifx_errormsg -- ¸¶Áö¸·¿¡ ¼öÇàÇÑ Informix ¸í·ÉÀÇ ¿¡·¯ ¸Þ¼¼Áö¸¦ µ¹·ÁÁØ´Ù.

    Description

    string ifx_errormsg (int [errorcode]);

    Returns the Informix error message associated with the most recent Informix error, or, when the optional "errorcode" param is present, the error message corresponding to "errorcode".

    See also: ifx_error()

      1 
      2 printf("%s\n<br>", ifx_errormsg(-201));
      3      

    ifx_affected_rows

    ifx_affected_rows -- ÁúÀÇ¿¡ ¿µÇâÀ» ¹Þ´Â rowÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int ifx_affected_rows (int result_id)

    result_id is a valid result id returned by ifx_query() or ifx_prepare().

    Returns the number of rows affected by a query associated with result_id.

    For inserts, updates and deletes the number is the real number (sqlerrd[2]) of affected rows. For selects it is an estimate (sqlerrd[0]). Don't rely on it.

    Useful after ifx_prepare() to limit queries to reasonable result sets.

    See also: ifx_num_rows()

    Example 1. Informix affected rows

      1 
      2 $rid = ifx_prepare ("select * from emp 
      3                      where name like " . $name, $connid);
      4 if (! $rid) {
      5     ... error ...
      6 }
      7 $rowcount = ifx_affected_rows ($rid);
      8 if ($rowcount > 1000) {
      9     printf ("Too many rows in result set (%d)\n<br>", $rowcount);
     10     die ("Please restrict your query<br>\n");
     11 }
     12      

    ifx_getsqlca

    ifx_getsqlca -- ÁúÀÇ ÈÄ sqlca.sqlerrd[0..5]ÀÇ ³»¿ëÀ» ±¸ÇÑ´Ù.

    Description

    array ifx_getsqlca (int result_id);

    result_id is a valid result id returned by ifx_query() or ifx_prepare().

    Returns a pseudo-row (assiociative arry) with sqlca.sqlerrd[0] to sqlca.sqlerrd[5] after the query associated with result_id.

    For inserts, updates and deletes the values returned are those as set by the server after executing the query. This gives access to the number of affected rows and the serial insert value. For selects the values are those saved after the prepare statement. This gives access to the estimated number of affected rows. The use of this function saves the overhead of executing a "select dbinfo('sqlca.sqlerrdx')" query, as it retrieves the values that were saved by the ifx driver at the appropriate moment.

    Example 1. Retrieve Informix sqlca.sqlerrd[x] values

      1 
      2 /* assume the first column of 'sometable' is a serial */
      3 $qid = ifx_query("insert into sometable 
      4                   values (0, '2nd column', 'another column' ", $connid);
      5 if (! $qid) {
      6     ... error ...
      7 }
      8 $sqlca = ifx_getsqlca ($qid);
      9 $serial_value = $sqlca["sqlerrd1"];
     10 echo "The serial value of the inserted row is : " . $serial_value<br>\n"; 
     11      

    ifx_fetch_row

    ifx_fetch_row -- row¸¦ ¹è¿­(enumerated array)·Î °¡Á®¿Â´Ù.

    Description

    array ifx_fetch_row (int result_id [, mixed position])

    Returns an associative array that corresponds to the fetched row, or false if there are no more rows.

    Blob columns are returned as integer blob id values for use in ifx_get_blob() unless you have used ifx_textasvarchar(1) or ifx_byteasvarchar(1), in which case blobs are returned as string values. Returns FALSE on error

    result_id is a valid resultid returned by ifx_query() or ifx_prepare() (select type queries only!).

    [position] is an optional parameter for a "fetch" operation on "scroll" cursors: "NEXT", "PREVIOUS", "CURRENT", "FIRST", "LAST" or a number. If you specify a number, an "absolute" row fetch is executed. This parameter is optional, and only valid for scrollcursors.

    ifx_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

    Subsequent call to ifx_fetch_row() would return the next row in the result set, or false if there are no more rows.

    Example 1. Informix fetch rows

      1 
      2 $rid = ifx_prepare ("select * from emp where name like " . $name,
      3                      $connid, IFX_SCROLL);
      4 if (! $rid) {
      5     ... error ...
      6 }
      7 $rowcount = ifx_affected_rows($rid);
      8 if ($rowcount > 1000) {
      9     printf ("Too many rows in result set (%d)\n<br>", $rowcount);
     10     die ("Please restrict your query<br>\n");
     11 }
     12 if (! ifx_do ($rid)) {
     13    ... error ...
     14 }
     15 $row = ifx_fetch_row ($rid, "NEXT");
     16 while (is_array($row)) {
     17     for(reset($row); $fieldname=key($row); next($row)) {
     18         $fieldvalue = $row[$fieldname];
     19         printf ("%s = %s,", $fieldname, $fieldvalue);
     20     }
     21     printf("\n<br>");
     22     $row = ifx_fetch_row ($rid, "NEXT");
     23 }
     24 ifx_free_result ($rid);
     25      

    ifx_htmltbl_result

    ifx_htmltbl_result -- ÁúÀÇÀÇ ¸ðµç °á°ú row¸¦ HTML table ¸ð¾çÀ¸·Î Ãâ·ÂÇÑ´Ù.

    Description

    int ifx_htmltbl_result (int result_id [, string html_table_options])

    Returns the number of rows fetched or FALSE on error.

    Formats all rows of the result_id query into a html table. The optional second argument is a string of <table> tag options

    Example 1. Informix results as HTML table

      1 
      2 $rid = ifx_prepare ("select * from emp where name like " . $name,
      3                      $connid, IFX_SCROLL);
      4 if (! $rid) {
      5    ... error ...
      6 }
      7 $rowcount = ifx_affected_rows ($rid);
      8 if ($rowcount > 1000) {
      9     printf ("Too many rows in result set (%d)\n<br>", $rowcount);
     10     die ("Please restrict your query<br>\n");
     11 }
     12 if (! ifx_do($rid) {
     13   ... error ...
     14 }
     15 
     16 ifx_htmltbl_result ($rid, "border=\"2\"");
     17 
     18 ifx_free_result($rid);
     19      

    ifx_fieldtypes

    ifx_fieldtypes -- Informix SQL ÇʵåµéÀ» listÇÑ´Ù.

    Description

    array ifx_fieldtypes (int result_id)

    Returns an associative array with fieldnames as key and the SQL fieldtypes as data for query with result_id. Returns FALSE on error.

    Example 1. Fielnames and SQL fieldtypes

      1 
      2 $types = ifx_fieldtypes ($resultid);
      3 if (! isset ($types)) {
      4   ... error ...
      5 }
      6 for ($i = 0; $i < count($types); $i++) {
      7     $fname = key($types);
      8     printf("%s :\t type =  %s\n", $fname, $types[$fname]);
      9     next($types);
     10 }
     11      

    ifx_fieldproperties

    ifx_fieldproperties -- SQL Çʵå Ư¼ºÀ» list ÇÑ´Ù.

    Description

    array ifx_fieldproperties (int result_id)

    Returns an associative array with fieldnames as key and the SQL fieldproperties as data for a query with result_id. Returns FALSE on error.

    Returns the Informix SQL fieldproperies of every field in the query as an associative array. Properties are encoded as: "SQLTYPE;length;precision;scale;ISNULLABLE" where SQLTYPE = the Informix type like "SQLVCHAR" etc. and ISNULLABLE = "Y" or "N".

    Example 1. Informix SQL fieldproperties

      1 
      2 $properties = ifx_fieldtypes ($resultid);
      3 if (! isset($properties)) {
      4   ... error ...
      5 }
      6 for ($i = 0; $i < count($properties); $i++) {
      7     $fname = key ($properties);
      8     printf ("%s:\t type =  %s\n", $fname, $properties[$fname]);
      9     next ($properties);
     10 }
     11      

    ifx_num_fields

    ifx_num_fields -- ÁúÀÇÀÇ Ä÷³ °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int ifx_num_fields (int result_id);

    Returns the number of columns in query for result_id or FALSE on error

    After preparing or executing a query, this call gives you the number of columns in the query.

    ifx_num_rows

    ifx_num_rows -- ÁúÀÇ °á°úÀÇ row °³¼ö

    Description

    int ifx_num_rows (int result_id);

    Gives the number of rows fetched so far for a query with result_id after a ifx_query() or ifx_do() query.

    ifx_free_result

    ifx_free_result -- ÁúÀÇ¿¡ »ç¿ëµÈ ÀÚ¿øÀ» Ç®¾îÁØ´Ù.

    Description

    int ifx_free_result (int result_id);

    Releases resources for the query associated with result_id. Returns FALSE on error.

    ifx_create_char

    ifx_create_char -- char object¸¦ ¸¸µç´Ù.

    Description

    int ifx_create_char (string param);

    Creates an char object. param should be the char content.

    ifx_free_char

    ifx_free_char -- char object¸¦ »èÁ¦ÇÑ´Ù.

    Description

    int ifx_free_char (int bid);

    Deletes the charobject for the given char object-id bid. Returns FALSE on error otherwise TRUE.

    ifx_update_char

    ifx_update_char -- char objectÀÇ ³»¿ëÀ» ¼öÁ¤ÇÑ´Ù.

    Description

    int ifx_update_char (int bid, string content);

    Updates the content of the char object for the given char object bid. content is a string with new data. Returns FALSE on error otherwise TRUE.

    ifx_get_char

    ifx_get_char -- char objectÀÇ ³»¿ëÀ» ¹ÝȯÇÑ´Ù.

    Description

    int ifx_get_char (int bid);

    Returns the content of the char object for the given char object-id bid.

    ifx_create_blob

    ifx_create_blob -- blob object¸¦ ¸¸µç´Ù.

    Description

    int ifx_create_blob (int type, int mode, string param);

    Creates an blob object.

    type: 1 = TEXT, 0 = BYTE

    mode: 0 = blob-object holds the content in memory, 1 = blob-object holds the content in file.

    param: if mode = 0: pointer to the content, if mode = 1: pointer to the filestring.

    Return FALSE on error, otherwise the new blob object-id.

    ifx_copy_blob

    ifx_copy_blob -- ÁÖ¾îÁø blob objectÀÇ »çº»À» ¸¸µç´Ù.

    Description

    int ifx_copy_blob (int bid);

    Duplicates the given blob object. bid is the ID of the blob object.

    Returns FALSE on error otherwise the new blob object-id.

    ifx_free_blob

    ifx_free_blob -- blob object¸¦ »èÁ¦ÇÑ´Ù.

    Description

    int ifx_free_blob (int bid);

    Deletes the blobobject for the given blob object-id bid. Returns FALSE on error otherwise TRUE.

    ifx_get_blob

    ifx_get_blob -- blob objectÀÇ ³»¿ëÀ» ¹ÝȯÇÑ´Ù.

    Description

    int ifx_get_blob (int bid);

    Returns the content of the blob object for the given blob object-id bid.

    ifx_update_blob

    ifx_update_blob -- blob objectÀÇ ³»¿ëÀ» ¼öÁ¤ÇÑ´Ù.

    Description

    ifx_update_blob (int bid, string content);

    Updates the content of the blob object for the given blob object bid. content is a string with new data. Returns FALSE on error otherwise TRUE.

    ifx_blobinfile_mode

    ifx_blobinfile_mode -- select ÁúÀÇ¿¡¼­ »ç¿ëµÇ´Â ±âº»(default) blob mode¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    void ifx_blobinfile_mode (int mode);

    Set the default blob mode for all select queries. Mode "0" means save Byte-Blobs in memory, and mode "1" means save Byte-Blobs in a file.

    ifx_textasvarchar

    ifx_textasvarchar -- select ÁúÀÇ¿¡¼­ »ç¿ëµÇ´Â ±âº»(default) text mode¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    void ifx_textasvarchar (int mode);

    Sets the default text mode for all select-queries. Mode "0" will return a blob id, and mode "1" will return a varchar with text content.

    ifx_byteasvarchar

    ifx_byteasvarchar -- select ÁúÀÇ¿¡¼­ »ç¿ëµÇ´Â ±âº»(default) byte mode¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    void ifx_byteasvarchar (int mode);

    Sets the default byte mode for all select-queries. Mode "0" will return a blob id, and mode "1" will return a varchar with text content.

    ifx_nullformat

    ifx_nullformat -- row¸¦ °¡Á®¿Ã ¶§ »ç¿ëÇÒ °á°ú°ªÀÇ ±âº» ÇüŸ¦ Á¤ÇÑ´Ù.

    Description

    void ifx_nullformat (int mode);

    Sets the default return value of a NULL-value on a fetch row. Mode "0" returns "", and mode "1" returns "NULL".

    ifxus_create_slob

    ifxus_create_slob -- slob object¸¦ ¸¸µé°í, ±×°ÍÀ» ¿¬´Ù.

    Description

    int ifxus_create_slob (int mode);

    Creates an slob object and opens it. Modes: 1 = LO_RDONLY, 2 = LO_WRONLY, 4 = LO_APPEND, 8 = LO_RDWR, 16 = LO_BUFFER, 32 = LO_NOBUFFER -> or-mask. You can also use constants named IFX_LO_RDONLY, IFX_LO_WRONLY etc. Return FALSE on error otherwise the new slob object-id.

    ifx_free_slob

    ifx_free_slob -- slob object¸¦ »èÁ¦ÇÑ´Ù.

    Description

    int ifxus_free_slob (int bid);

    Deletes the slob object. bid is the Id of the slob object. Returns FALSE on error otherwise TRUE.

    ifxus_close_slob

    ifxus_close_slob -- slob object¸¦ »èÁ¦ÇÑ´Ù.

    Description

    int ifxus_close_slob (int bid);

    Deletes the slob object on the given slob object-id bid. Return FALSE on error otherwise TRUE.

    ifxus_open_slob

    ifxus_open_slob -- slob object¸¦ ¿¬´Ù.

    Description

    int ifxus_open_slob (long bid, int mode);

    Opens an slob object. bid should be an existing slob id. Modes: 1 = LO_RDONLY, 2 = LO_WRONLY, 4 = LO_APPEND, 8 = LO_RDWR, 16 = LO_BUFFER, 32 = LO_NOBUFFER -> or-mask. Returns FALSE on error otherwise the new slob object-id.

    ifxus_tell_slob

    ifxus_tell_slob -- ÇöÀç ÆÄÀÏÀ̳ª seek À§Ä¡¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int ifxus_tell_slob (long bid);

    Returns the current file or seek position of an open slob object bid should be an existing slob id. Return FALSE on error otherwise the seek position.

    ifxus_seek_slob

    ifxus_seek_slob -- ÇöÀç ÆÄÀÏÀ̳ª seek À§Ä¡¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int ifxus_seek_slob (long bid, int mode, long offset);

    Sets the current file or seek position of an open slob object. bid should be an existing slob id. Modes: 0 = LO_SEEK_SET, 1 = LO_SEEK_CUR, 2 = LO_SEEK_END and offset is an byte offset. Return FALSE on error otherwise the seek position.

    ifxus_read_slob

    ifxus_read_slob -- slob objectÀÇ nbytes¸¦ Àд´Ù.of the

    Description

    int ifxus_read_slob (long bid, long nbytes);

    Reads nbytes of the slob object. bid is a existing slob id and nbytes is the number of bytes zu read. Return FALSE on error otherwise the string.

    ifxus_write_slob

    ifxus_write_slob -- slob object¿¡ ¹®ÀÚ¿­À» ½á ³Ö´Â´Ù.

    Description

    int ifxus_write_slob (long bid, string content);

    Writes a string into the slob object. bid is a existing slob id and content the content to write. Return FALSE on error otherwise bytes written.


    XXX. InterBase functions

    InterBase´Â Borland/Inprise¿¡¼­ Ãâ½ÃµÈ ´ëÁßÀûÀÎ µ¥ÀÌÅͺ£À̽ºÀÌ´Ù. InterBase¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ Á¤º¸´Â http://www.interbase.com/¿¡¼­ ã¾Æº¸±â¹Ù¶õ´Ù. Âü°í·Î InterBase´Â ¿ÀÇ ¼Ò½º ¿îµ¿¿¡ Âü¿©ÇÏ°í ÀÖ´Ù.

    Note: PHP4¿¡¼­´Â InterBase 6 ¿¡ ´ëÇÑ ¿ÏÀüÇÑ Áö¿øÀÌ Ãß°¡µÇ¾ú´Ù.

    Table of Contents
    ibase_connect ¡¦ Open a connection to an InterBase database
    ibase_pconnect ¡¦ Open a connection to an InterBase database
    ibase_close ¡¦ Close a connection to an InterBase database
    ibase_query ¡¦ Execute a query on an InterBase database
    ibase_fetch_row ¡¦ Fetch a row from an InterBase database
    ibase_fetch_object ¡¦ Get an object from a InterBase database
    ibase_free_result ¡¦ Free a result set
    ibase_prepare ¡¦ Prepare a query for later binding of parameter placeholders and execution
    ibase_execute ¡¦ Execute a previously prepared query
    ibase_free_query ¡¦ Free memory allocated by a prepared query
    ibase_timefmt ¡¦ Sets the format of timestamp, date and time type columns returned from queries
    ibase_num_fields ¡¦ Get the number of fields in a result set

    ibase_connect

    ibase_connect -- InterBase µ¥ÀÌÅͺ£À̽º·ÎÀÇ ¿¬°áÀ» ¿¬´Ù.

    Description

    int ibase_connect (string database [, string username [, string password [, string charset [, int buffers [, int dialect [, string role]]]]]])

    Establishes a connection to an InterBase server. The database argument has to be a valid path to database file on the server it resides on. If the server is not local, it must be prefixed with either 'hostname:' (TCP/IP), '//hostname/' (NetBEUI) or 'hostname@' (IPX/SPX), depending on the connection protocol used. username and password can also be specified with PHP configuration directives ibase.default_user and ibase.default_password. charset is the default character set for a database. buffers is the number of database buffers to allocate for the server-side cache. If 0 or omitted, server chooses its own default. dialect selects the default SQL dialect for any statement executed within a connection, and it defaults to the highest one supported by client libraries.

    In case a second call is made to ibase_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling ibase_close().

    Example 1. Ibase_connect() example

      1 
      2 <?php
      3     $dbh = ibase_connect ($host, $username, $password);
      4     $stmt = 'SELECT * FROM tblname';
      5     $sth = ibase_query ($dbh, $stmt);
      6     while ($row = ibase_fetch_object ($sth)) {
      7         print $row->email . "\n";
      8     }
      9     ibase_close ($dbh);
     10 ?>
     11       

    Note: buffers was added in PHP4-RC2.

    Note: dialect was added in PHP4-RC2. It is functional only with InterBase 6 and versions higher than that.

    Note: role was added in PHP4-RC2. It is functional only with InterBase 5 and versions higher than that.

    See also: ibase_pconnect().

    ibase_pconnect

    ibase_pconnect -- InterBase µ¥ÀÌÅͺ£À̽º·ÎÀÇ ¿µ±¸ÀûÀÎ(persistent) ¿¬°áÀ» ¿¬´Ù.

    Description

    int ibase_connect (string database [, string username [, string password [, string charset [, string role]]]])

    ibase_pconnect() acts very much like ibase_connect() with two major differences. First, when connecting, the function will first try to find a (persistent) link that's already opened with the same parameters. If one is found, an identifier for it will be returned instead of opening a new connection. Second, the connection to the InterBase server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (ibase_close() will not close links established by ibase_pconnect()). This type of link is therefore called 'persistent'.

    See also ibase_connect() for the meaning of parameters passed to this function. They are exactly the same.

    ibase_close

    ibase_close -- InterBase µ¥ÀÌÅͺ£À̽º¿ÍÀÇ ¿¬°áÀ» ´Ý´Â´Ù.

    Description

    int ibase_close ([int connection_id])

    Closes the link to an InterBase database that's associated with a connection id returned from ibase_connect(). If the connection id is omitted, the last opened link is assumed. Default transaction on link is committed, other transactions are rolled back.

    ibase_query

    ibase_query -- InterBase µ¥ÀÌÅͺ£À̽ºÀÇ ÁúÀǸ¦ ¼öÇàÇÑ´Ù.

    Description

    int ibase_query ([int link_identifier, string query [, int bind_args]])

    Performs a query on an InterBase database, returning a result identifier for use with ibase_fetch_row(), ibase_fetch_object(), ibase_free_result() and ibase_free_query().

    Note: Although this function supports variable binding to parameter placeholders, there is not very much meaning using this capability with it. For real life use and an example, see ibase_prepare() and ibase_execute().

    ibase_fetch_row

    ibase_fetch_row -- InterBase µ¥ÀÌÅͺ£À̽º·ÎºÎÅÍ ÇÑ ·¹ÄÚµå(row)¸¦ °¡Á®¿Â´Ù.

    Description

    array ibase_fetch_row (int result_identifier)

    Returns the next row specified by the result identifier obtained using the ibase_query().

    ibase_fetch_object

    (PHP3 >= 3.0.7, PHP4 >= 4.0RC1)

    ibase_fetch_object -- Get an object from a InterBase database

    Description

    object ibase_fetch_object (int result_id)

    Fetches a row as a pseudo-object from a result_id obtained either by ibase_query() or ibase_execute().

      1 
      2 <php
      3     $dbh = ibase_connect ($host, $username, $password);
      4     $stmt = 'SELECT * FROM tblname';
      5     $sth = ibase_query ($dbh, $stmt);
      6     while ($row = ibase_fetch_object ($sth)) {
      7         print $row->email . "\n";
      8     }
      9     ibase_close ($dbh);
     10 ?>
     11       

    See also ibase_fetch_row().

    ibase_free_result

    ibase_free_result -- result setÀ» ÇØÁ¦ÇÑ´Ù.

    Description

    int ibase_free_result (int result_identifier)

    Free's a result set the has been created by ibase_query().

    ibase_prepare

    ibase_prepare -- ÆĶó¸ÞÅ͸¦ ¹ÙÀεùÇÏ°í ½ÇÇàÇϱâ À§ÇÑ ÁúÀǸ¦ ÁغñÇÑ´Ù.

    Description

    int ibase_prepare ([int link_identifier, string query])

    Prepare a query for later binding of parameter placeholders and execution (via ibase_execute()).

    ibase_execute

    ibase_execute -- ¹Ì¸® ÁغñµÈ ÁúÀǸ¦ ¼öÇàÇÑ´Ù.

    Description

    int ibase_execute (int query [, int bind_args])

    Execute a query prepared by ibase_prepare(). This is a lot more effective than using ibase_query() if you are repeating a same kind of query several times with only some parameters changing.

      1 
      2 <?php
      3     $updates = array(
      4         1 => 'Eric',
      5         5 => 'Filip',
      6         7 => 'Larry'
      7     );
      8 
      9     $query = ibase_prepare("UPDATE FOO SET BAR = ? WHERE BAZ = ?");
     10 
     11     while (list($baz, $bar) = each($updates)) {
     12         ibase_execute($query, $bar, $baz);
     13     }
     14 ?>
     15       

    ibase_free_query

    ibase_free_query -- ÁúÀǸ¦ ÁغñÇϴµ¥ »ç¿ëµÈ ¸Þ¸ð¸®¸¦ ÇØÁ¦ÇÑ´Ù.

    Description

    int ibase_free_query (int query)

    Free a query prepared by ibase_prepare().

    ibase_timefmt

    ibase_timefmt -- ÁúÀÇ °á°úÁß timestamp³ª ³¯Â¥¿Í ½Ã°£ ÇüÅÂÀÇ Ä®·³ÀÌ Ãâ·ÂµÉ ÇüŸ¦ Á¤ÇÑ´Ù.

    Description

    int ibase_timefmt (string format [, int columntype])

    Sets the format of timestamp, date or time type columns returned from queries. Internally, the columns are formatted by c-function strftime(), so refer to it's documentation regarding to the format of the string. columntype is one of the constants IBASE_TIMESTAMP, IBASE_DATE and IBASE_TIME. If omitted, defaults to IBASE_TIMESTAMP for backwards compatibility.

      1 
      2 <?php
      3     // InterBase 6 TIME-type columns will be returned in
      4     // the form '05 hours 37 minutes'. 
      5     ibase_timefmt("%H hours %M minutes", IBASE_TIME);
      6 ?>
      7       

    You can also set defaults for these formats with PHP configuration directives ibase.timestampformat, ibase.dateformat and ibase.timeformat.

    Note: columntype was added in PHP 4.0. It has any meaning only with InterBase version 6 and higher.

    Note: A backwards incompatible change happened in PHP 4.0 when PHP configuration directive ibase.timeformat was renamed to ibase.timestampformat and directives ibase.dateformat and ibase.timeformat were added, so that the names would match better their functionality.

    ibase_num_fields

    (PHP3 >= 3.0.7, PHP4 >= 4.0RC1)

    ibase_num_fields -- ÁúÀÇ °á°ú(result set)ÀÇ ÇÊµå °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int ibase_num_fields (int result_id)

    Returns an integer containing the number of fields in a result set.

      1 
      2 <?php
      3     $dbh = ibase_connect ($host, $username, $password);
      4     $stmt = 'SELECT * FROM tblname';
      5     $sth = ibase_query ($dbh, $stmt);
      6 
      7     if (ibase_num_fields($sth) > 0) {
      8         while ($row = ibase_fetch_object ($sth)) {
      9             print $row->email . "\n";
     10         }
     11     } else {
     12         die ("No Results were found for your query");
     13     }
     14 
     15     ibase_close ($dbh);
     16 ?>
     17       

    See also: ibase_field_info().

    Note: Ibase_num_fields() is currently not functional in PHP4.


    XXXI. LDAP functions

    Introduction to LDAP

    LDAPÀº Lightweight Directory Access ProtocolÀÇ ¾àÀÚ·Î, "Directory Servers"¿¡ Á¢±ÙÇϴµ¥ »ç¿ëµÇ´Â ÇÁ·ÎÅäÄÝÀÌ´Ù. Directory ¶ó´Â °ÍÀº Æ®¸® ±¸Á¶¸¦ °¡Áö°í Á¤º¸¸¦ ÀúÀåÇϴ Ưº°ÇÑ Á¾·ùÀÇ Database¶ó°í ÇÒ ¼ö ÀÖ´Ù.

    ±âº» °³³äÀº Çϵåµð½ºÅ©ÀÇ µð·ºÅ丮 ±¸Á¶¿Í ºñ½ÁÇÏ´Ù. ´Ù¸¥ Á¡Àº root µð·ºÅ丮°¡ "world(Áö±¸ Àüü)"ÀÌ°í, ù ¹ø° ·¹º§ÀÌ "±¹°¡µé", ±× ÀÌÇÏÀÇ ·¹º§ÀÌ È¸»ç³ª, °¢Á¾ Á¶Á÷, Àå¼Ò µîÀÌ µÈ´Ù´Â Á¡ÀÌ´Ù. ±× ÀÌÇÏ·Î °è¼Ó ³»·Á°¡´Ù º¸¸é ƯÁ¤ÀÎÀ̳ª ¼³ºñ, ¹®¼­ µîÀÇ Ç׸ñ±îÁöµµ ³»·Á°¥ ¼ö ÀÖ´Ù.

    Çϵåµð½ºÅ©ÀÇ subdirectory¿¡ ÀÖ´Â ÆÄÀÏÀ» ÂüÁ¶ÇÒ ¶§ º¸Åë ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÑ´Ù. :

    ÀÌ ÆÄÀÏ ·¹ÆÛ·±½ºÀÇ °¢ºÎºÐÀº ½½·¡½Ã(/) ±âÈ£·Î ±¸ºÐµÇ°í, Àд ¼ø¼­´Â ¿ÞÂÊ¿¡¼­ ¿À¸¥ÂÊÀ¸·Î Àо°£´Ù.

    LDAP¿¡¼­ ÆÄÀÏ ·¹ÆÛ·±½º¿Í °°Àº °ÍÀº º¸Åë "dn"À¸·Î Ç¥½ÃµÇ´Â "distinguished name"ÀÌ´Ù. dnÀÇ ¿¹´Â ´ÙÀ½°ú °°´Ù. :

    ·¹ÆÛ·±½ºÀÇ °¢ ºÎºÐÀº ½°Ç¥(,)·Î ±¸ºÐµÇ°í, ¿À¸¥ÂÊ¿¡¼­ ¿ÞÂÊÀÇ ¼ø¼­·Î Àд´Ù. ¿©·¯ºÐÀº ÀÌ dnÀ» ´ÙÀ½°ú °°Àº Àǹ̷ΠÀд´Ù. :

    Çϵåµð½ºÅ©¿¡¼­ ¿©·¯ºÐÀÌ µð·ºÅ丮 ±¸¼ºÀ» ¾î¶»°Ô Çϴ°¡¿¡ ´ëÇÑ Æ¯º°ÇÑ ±ÔÄ¢ÀÌ ¾øµíÀÌ, µð·ºÅ丮 ¼­¹öÀÇ °ü¸®µµ ¸ñÀû¿¡ µû¶ó ÀǹÌÀÖ°Ô ±¸¼ºµÈ´Ù¸é ¾î¶² ¸ð½ÀÀ» ÇÏ°í À־ »ó°ü¾ø´Ù. ÇÏÁö¸¸, »ç¿ëµÇ°í ÀÖ´Â ¾à°£ÀÇ °ü½ÀÀÌ ÀÖ´Ù. ±× ¸Þ½ÃÁö´Â ¿©·¯ºÐÀÌ µ¥ÀÌŸº£À̽º¿¡ ¾î¶² Á¤º¸°¡ »ç¿ë°¡´ÉÇÑÁö ¾ËÁö ¸øÇÑ´Ù¸é ±× µ¥ÀÌÅͺ£À̽º¸¦ »ç¿ëÇÒ ¼ö ¾øµíÀÌ, ¿©·¯ºÐÀÌ µð·ºÅ丮 ±¸Á¶¿¡ ´ëÇØ ¾ËÁö ¸øÇÑ´Ù¸é ¿©·¯ºÐÀº ±× µð·ºÅ丮 ¼­¹ö¿¡ Á¢±ÙÇϱâ À§ÇÑ Äڵ带 ¸¸µé ¼ö ¾ø´Ù´Â °ÍÀÌ´Ù.


    ¿¹Á¦ (Complete code example)

    µð·ºÅ丮 ¼­¹ö¿¡¼­ "S"·Î ½ÃÀÛÇÏ´Â ¼ºÀ» °¡Áø Ç׸ñ¿¡ ´ëÇÑ Á¤º¸¸¦ °Ë»öÇÏ°í, À̸§°ú email ÁÖ¼Ò¸¦ Ãâ·ÂÇÑ´Ù.

    Example 1. LDAP search example

      1 
      2 <?php
      3 // basic sequence with LDAP is connect, bind, search, interpret search
      4 // result, close connection
      5 
      6 echo "<h3>LDAP query test</h3>";
      7 echo "Connecting ...";
      8 $ds=ldap_connect("localhost");  // must be a valid LDAP server!
      9 echo "connect result is ".$ds."<p>";
     10 
     11 if ($ds) { 
     12     echo "Binding ..."; 
     13     $r=ldap_bind($ds);     // this is an "anonymous" bind, typically
     14                            // read-only access echo "Bind result is
     15     echo "Bind result is ".$r."<p>";
     16 
     17     echo "Searching for (sn=S*) ...";
     18     // Search surname entry
     19     $sr=ldap_search($ds,"o=My Company, c=US", "sn=S*");  
     20     echo "Search result is ".$sr."<p>";
     21 
     22     echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."<p>";
     23 
     24     echo "Getting entries ...<p>";
     25     $info = ldap_get_entries($ds, $sr);
     26     echo "Data for ".$info["count"]." items returned:<p>";
     27 
     28     for ($i=0; $i<$info["count"]; $i++) {
     29         echo "dn is: ". $info[$i]["dn"] ."<br>";
     30         echo "first cn entry is: ". $info[$i]["cn"][0] ."<br>";
     31         echo "first email entry is: ". $info[$i]["mail"][0] ."<p>";
     32     }
     33 
     34     echo "Closing connection";
     35     ldap_close($ds);
     36 
     37 } else {
     38     echo "<h4>Unable to connect to LDAP server</h4>";
     39 }
     40 ?>
     41 


    PHP¿¡¼­ LDAP È£Ãâ »ç¿ëÇϱâ (Using the PHP LDAP calls)

    ¿©·¯ºÐÀº University of Michigan ldap-3.3 package³ª Netscape Directory SDK°°Àº LDAP client libraries¸¦ ¾ò¾î¼­ ÄÄÆÄÀÏÇÒ ÇÊ¿äÇÏ ÀÖ´Ù. ¶ÇÇÑ PHP¸¦ LDAPÁö¿øÀ¸·Î ´Ù½Ã ÄÄÆÄÀÏÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.

    LDAP È£ÃâÀ» »ç¿ëÇϱâ Àü¿¡ ¿©·¯ºÐÀº ´ÙÀ½°ú °°Àº °ÍÀ» ¾Ë°í ÀÖ¾î¾ß ÇÑ´Ù.

    ¿©·¯ºÐÀÌ applicationÀ» ÀÛ¼ºÇÒ ¶§ »ç¿ëÇÒ ÀüÇüÀûÀÎ LDAP È£ÃâÀº ´ÙÀ½ÀÇ Çü½ÄÀ» µû¸¥´Ù. :

      ldap_connect()    // ¼­¹ö¿¡ connectionÀ» ¸¸µç´Ù.
         |
      ldap_bind()       // À͸í(anonymous)À̳ª ÀÎÁõµÈ "login"
         |
      µð·ºÅ丮ÀÇ °Ë»öÀ̳ª ¼öÁ¤ °°Àº ÀÛ¾÷À» ÇÏ°í °á°ú¸¦ Ãâ·ÂÇÑ´Ù.
         |
      ldap_close()      // "logout"


    More Information

    LDAP¿¡ °üÇÑ ÀÚ¼¼ÇÑ ÀÚ·á´Â ´ÙÀ½ »çÀÌÆ®¿¡ °¡ º¸ÀÚ.

    Netscape SDK¿¡´Â Programmer's Guide°¡ .html ÇüÅ·ΠÀÖ½À´Ï´Ù.


    Table of Contents
    ldap_add ¡¦ Add entries to LDAP directory
    ldap_mod_add ¡¦ Add attribute values to current attributes
    ldap_mod_del ¡¦ Delete attribute values from current attributes
    ldap_mod_replace ¡¦ Replace attribute values with new ones
    ldap_bind ¡¦ Bind to LDAP directory
    ldap_close ¡¦ Close link to LDAP server
    ldap_connect ¡¦ Connect to an LDAP server
    ldap_count_entries ¡¦ Count the number of entries in a search
    ldap_delete ¡¦ Delete an entry from a directory
    ldap_dn2ufn ¡¦ Convert DN to User Friendly Naming format
    ldap_explode_dn ¡¦ Splits DN into its component parts
    ldap_first_attribute ¡¦ Return first attribute
    ldap_first_entry ¡¦ Return first result id
    ldap_free_result ¡¦ Free result memory
    ldap_get_attributes ¡¦ Get attributes from a search result entry
    ldap_get_dn ¡¦ Get the DN of a result entry
    ldap_get_entries ¡¦ Get all result entries
    ldap_get_values ¡¦ Get all values from a result entry
    ldap_get_values_len ¡¦ Get all binary values from a result entry
    ldap_list ¡¦ Single-level search
    ldap_modify ¡¦ Modify an LDAP entry
    ldap_next_attribute ¡¦ Get the next attribute in result
    ldap_next_entry ¡¦ Get next result entry
    ldap_read ¡¦ Read an entry
    ldap_search ¡¦ Search LDAP tree
    ldap_unbind ¡¦ Unbind from LDAP directory
    ldap_err2str ¡¦ Convert LDAP error number into string error message
    ldap_errno ¡¦ Return the LDAP error number of the last LDAP command
    ldap_error ¡¦ Return the LDAP error message of the last LDAP command

    ldap_add

    ldap_add -- LDAP directory¿¡ entry¸¦ Ãß°¡ÇÑ´Ù.

    Description

    int ldap_add (int link_identifier, string dn, array entry)

    returns true on success and false on error.

    The ldap_add() function is used to add entries in the LDAP directory. The DN of the entry to be added is specified by dn. Array entry specifies the information about the entry. The values in the entries are indexed by individual attributes. In case of multiple values for an attribute, they are indexed using integers starting with 0.

        entry["attribute1"] = value
        entry["attribute2"][0] = value1
        entry["attribute2"][1] = value2

    Example 1. Complete example with authenticated bind

      1 
      2 <?php
      3 $ds=ldap_connect("localhost");  // assuming the LDAP server is on this host
      4 
      5 if ($ds) {
      6     // bind with appropriate dn to give update access
      7     $r=ldap_bind($ds,"cn=root, o=My Company, c=US", "secret");
      8 
      9     // prepare data
     10     $info["cn"]="John Jones";
     11     $info["sn"]="Jones";
     12     $info["mail"]="jonj@here.and.now";
     13     $info["objectclass"]="person";
     14 
     15     // add data to directory
     16     $r=ldap_add($ds, "cn=John Jones, o=My Company, c=US", $info);
     17 
     18     ldap_close($ds);
     19 } else {
     20     echo "Unable to connect to LDAP server"; 
     21 }
     22 ?>
     23 

    ldap_mod_add

    ldap_mod_add -- ÇöÀç ¼Ó¼º¿¡ ƯÁ¤ ¼Ó¼º°ªÀ» ´õÇÑ´Ù.

    Description

    int ldap_mod_add (int link_identifier, string dn, array entry);

    returns true on success and false on error.

    This function adds attribute(s) to the specified dn. It performs the modification at the attribute level as opposed to the object level. Object-level additions are done by the ldap_add() function.

    ldap_mod_del

    ldap_mod_del -- ÇöÀç ¼Ó¼º¿¡ ƯÁ¤ ¼Ó¼º°ªÀ» »«´Ù.

    Description

    int ldap_mod_del (int link_identifier, string dn, array entry);

    returns true on success and false on error.

    This function removes attribute(s) from the specified dn. It performs the modification at the attribute level as opposed to the object level. Object-level deletions are done by the ldap_del() function.

    ldap_mod_replace

    ldap_mod_replace -- ÇöÀç ¼Ó¼º°ªµéÀ» »õ·Î¿î °ªÀ¸·Î ¹Ù²Û´Ù.

    Description

    int ldap_mod_replace (int link_identifier, string dn, array entry);

    returns true on success and false on error.

    This function replaces attribute(s) from the specified dn. It performs the modification at the attribute level as opposed to the object level. Object-level modifications are done by the ldap_modify() function.

    ldap_bind

    ldap_bind -- LDAP directory¿¡ bind ÇÑ´Ù.

    Description

    int ldap_bind (int link_identifier, string [bind_rdn], string [bind_password]);

    Binds to the LDAP directory with specified RDN and password. Returns true on success and false on error.

    ldap_bind() does a bind operation on the directory. bind_rdn and bind_password are optional. If not specified, anonymous bind is attempted.

    ldap_close

    ldap_close -- LDAP server¿ÍÀÇ ¿¬°áÀ» ´Ý´Â´Ù.

    Description

    int ldap_close (int link_identifier);

    Returns true on success, false on error.

    ldap_close() closes the link to the LDAP server that's associated with the specified link_identifier.

    This call is internally identical to ldap_unbind(). The LDAP API uses the call ldap_unbind(), so perhaps you should use this in preference to ldap_close().

    ldap_connect

    ldap_connect -- LDAP server¿Í ¿¬°áÇÑ´Ù.

    Description

    int ldap_connect ([string hostname [, int port]])

    Returns a positive LDAP link identifier on success, or false on error.

    ldap_connect() establishes a connection to a LDAP server on a specified hostname and port. Both the arguments are optional. If no arguments are specified then the link identifier of the already opened link will be returned. If only hostname is specified, then the port defaults to 389.

    ldap_count_entries

    ldap_count_entries -- Ž»ö ¹üÀ§ ¾È¿¡ ÀÖ´Â entryÀÇ °³¼ö

    Description

    int ldap_count_entries (int link_identifier, int result_identifier)

    Returns number of entries in the result or false on error.

    ldap_count_entries() returns the number of entries stored in the result of previous search operations. result_identifier identifies the internal ldap result.

    ldap_delete

    ldap_delete -- directory¾ÈÀÇ ÇÑ entry¸¦ »èÁ¦ÇÑ´Ù..

    Description

    int ldap_delete (int link_identifier, string dn)

    Returns true on success and false on error.

    ldap_delete() function delete a particular entry in LDAP directory specified by dn.

    ldap_dn2ufn

    ldap_dn2ufn -- DNÀ» User Friendly Naming Çü½ÄÀ¸·Î º¯È¯ÇÑ´Ù.

    Description

    int ldap_delete (int link_identifier, string dn)

    Returns true on success and false on error.

    ldap_delete() function delete a particular entry in LDAP directory specified by dn.

    ldap_explode_dn

    ldap_explode_dn -- DNÀ» ±×°ÍÀÇ ±¸¼º ºÎºÐÀ¸·Î ³ª´«´Ù.

    Description

    array ldap_explode_dn (string dn, int with_attrib)

    ldap_explode_dn() function is used to split the a DN returned by ldap_get_dn() and breaks it up into its component parts. Each part is known as Relative Distinguished Name, or RDN. ldap_explode_dn() returns an array of all those components. with_attrib is used to request if the RDNs are returned with only values or their attributes as well. To get RDNs with the attributes (i.e. in attribute=value format) set with_attrib to 0 and to get only values set it to 1.

    ldap_first_attribute

    ldap_first_attribute -- ù¹ø° ¼Ó¼ºÀ» ¹ÝȯÇÑ´Ù.

    Description

    string ldap_first_attribute (int link_identifier, int result_entry_identifier, int ber_identifier)

    Returns the first attribute in the entry on success and false on error.

    Similar to reading entries, attributes are also read one by one from a particular entry. ldap_first_attribute() returns the first attribute in the entry pointed by the entry identifier. Remaining attributes are retrieved by calling ldap_next_attribute() successively. ber_identifier is the identifier to internal memory location pointer. It is passed by reference. The same ber_identifier is passed to the ldap_next_attribute() function, which modifies that pointer.

    see also ldap_get_attributes()

    ldap_first_entry

    ldap_first_entry -- ù¹ø° result id¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int ldap_first_entry (int link_identifier, int result_identifier)

    Returns the result entry identifier for the first entry on success and false on error.

    Entries in the LDAP result are read sequentially using the ldap_first_entry() and ldap_next_entry() functions. ldap_first_entry() returns the entry identifier for first entry in the result. This entry identifier is then supplied to lap_next_entry() routine to get successive entries from the result.

    see also ldap_get_entries().

    ldap_free_result

    ldap_free_result -- result memory¸¦ Ç®¾îÁØ´Ù.

    Description

    int ldap_free_result (int result_identifier)

    Returns true on success and false on error.

    ldap_free_result() frees up the memory allocated internally to store the result and pointed by the result_identifier. All result memory will be automatically freed when the script terminates.

    Typically all the memory allocated for the ldap result gets freed at the end of the script. In case the script is making successive searches which return large result sets, ldap_free_result() could be called to keep the runtime memory usage by the script low.

    ldap_get_attributes

    ldap_get_attributes -- search result entry·ÎºÎÅÍ ¼Ó¼ºÀ» ±¸ÇÑ´Ù.

    Description

    array ldap_get_attributes (int link_identifier, int result_entry_identifier)

    Returns a complete entry information in a multi-dimensional array on success and false on error.

    ldap_get_attributes() function is used to simplify reading the attributes and values from an entry in the search result. The return value is a multi-dimensional array of attributes and values.

    Having located a specific entry in the directory, you can find out what information is held for that entry by using this call. You would use this call for an application which "browses" directory entries and/or where you do not know the structure of the directory entries. In many applications you will be searching for a specific attribute such as an email address or a surname, and won't care what other data is held.

    return_value["count"] = number of attributes in the entry
    return_value[0] = first attribute
    return_value[n] = nth attribute

    return_value["attribute"]["count"] = number of values for attribute
    return_value["attribute"][0] = first value of the attribute
    return_value["attribute"][i] = ith value of the attribute

    Example 1. Show the list of attributes held for a particular directory entry

      1 
      2 // $ds is the link identifier for the directory
      3 
      4 // $sr is a valid search result from a prior call to
      5 // one of the ldap directory search calls
      6 
      7 $entry = ldap_first_entry($ds, $sr);
      8 
      9 $attrs = ldap_get_attributes($ds, $entry);
     10 
     11 echo $attrs["count"]." attributes held for this entry:<p>";
     12 
     13 for ($i=0; $i<$attrs["count"]; $i++)
     14     echo $attrs[$i]."<br>";
     15 

    see also ldap_first_attribute() and ldap_next_attribute()

    ldap_get_dn

    ldap_get_dn -- result entryÀÇ DNÀ» ±¸ÇÑ´Ù.

    Description

    string ldap_get_dn (int link_identifier, int result_entry_identifier)

    Returns the DN of the result entry and false on error.

    ldap_get_dn() function is used to find out the DN of an entry in the result.

    ldap_get_entries

    ldap_get_entries -- ¸ðµç result entryµéÀ» ±¸ÇÑ´Ù.

    Description

    array ldap_get_entries (int link_identifier, int result_identifier)

    Returns a complete result information in a multi-dimenasional array on success and false on error.

    ldap_get_entries() function is used to simplify reading multiple entries from the result and then reading the attributes and multiple values. The entire information is returned by one function call in a multi-dimensional array. The structure of the array is as follows.

    The attribute index is converted to lowercase. (Attributes are case-insensitive for directory servers, but not when used as array indices)

    return_value["count"] = number of entries in the result
    return_value[0] : refers to the details of first entry

    return_value[i]["dn"] =  DN of the ith entry in the result

    return_value[i]["count"] = number of attributes in ith entry
    return_value[i][j] = jth attribute in the ith entry in the result

    return_value[i]["attribute"]["count"] = number of values for attribute in ith entry
    return_value[i]["attribute"][j] = jth value of attribute in ith entry

    see also ldap_first_entry() and ldap_next_entry()

    ldap_get_values

    ldap_get_values -- result entry·Î ºÎÅÍ ¸ðµç °ªÀ» ±¸ÇÑ´Ù.

    Description

    array ldap_get_values (int link_identifier, int result_entry_identifier, string attribute)

    Returns an array of values for the attribute on success and false on error.

    ldap_get_values() function is used to read all the values of the attribute in the entry in the result. entry is specified by the result_entry_identifier. The number of values can be found by indexing "count" in the resultant array. Individual values are accessed by integer index in the array. The first index is 0.

    This call needs a result_entry_identifier, so needs to be preceded by one of the ldap search calls and one of the calls to get an individual entry.

    You application will either be hard coded to look for certain attributes (such as "surname" or "mail") or you will have to use the ldap_get_attributes() call to work out what attributes exist for a given entry.

    LDAP allows more than one entry for an attribute, so it can, for example, store a number of email addresses for one person's directory entry all labeled with the attribute "mail"

    return_value["count"] = number of values for attribute
    return_value[0] = first value of attribute
    return_value[i] = ith value of attribute

    Example 1. List all values of the "mail" attribute for a directory entry

      1 
      2 // $ds is a valid link identifier for a directory server
      3 
      4 // $sr is a valid search result from a prior call to
      5 //     one of the ldap directory search calls
      6 
      7 // $entry is a valid entry identifier from a prior call to
      8 //        one of the calls that returns a directory entry
      9 
     10 $values = ldap_get_values($ds, $entry,"mail");
     11 
     12 echo $values["count"]." email addresses for this entry.<p>";
     13 
     14 for ($i=0; $i < $values["count"]; $i++)
     15     echo $values[$i]."<br>";
     16 

    ldap_get_values_len

    (PHP3 >= 3.0.13, PHP4 >= 4.0RC2)

    ldap_get_values_len -- result entry·Î ºÎÅÍ ¸ðµç binary °ªÀ» ±¸ÇÑ´Ù.

    Description

    array ldap_get_values_len (int link_identifier, int result_entry_identifier, string attribute)

    Returns an array of values for the attribute on success and false on error.

    ldap_get_values_len() function is used to read all the values of the attribute in the entry in the result. entry is specified by the result_entry_identifier. The number of values can be found by indexing "count" in the resultant array. Individual values are accessed by integer index in the array. The first index is 0.

    This function is used exactly like ldap_get_values() except that it handles binary data and not string data.

    Note: This function was added in 4.0.

    ldap_list

    ldap_list -- Single-level °Ë»ö (search)

    Description

    int ldap_list (int link_identifier, string base_dn, string filter [, array attributes])

    Returns a search result identifier or false on error.

    ldap_list() performs the search for a specified filter on the directory with the scope LDAP_SCOPE_ONELEVEL.

    LDAP_SCOPE_ONELEVEL means that the search should only return information that is at the level immediately below the base dn given in the call. (Equivalent to typing "ls" and getting a list of files and folders in the current working directory.)

    This call takes an optional fourth parameter which is an array of the attributes required. See ldap_search() notes.

    Example 1. Produce a list of all organizational units of an organization

      1 
      2 // $ds is a valid link identifier for a directory server
      3 
      4 $basedn = "o=My Company, c=US";
      5 $justthese = array("ou");
      6 
      7 $sr=ldap_list($ds, $basedn, "ou=*", $justthese);
      8 
      9 $info = ldap_get_entries($ds, $sr);
     10 
     11 for ($i=0; $i<$info["count"]; $i++)
     12     echo $info[$i]["ou"][0] ;
     13 

    ldap_modify

    ldap_modify -- LDAP entry¸¦ ¼öÁ¤ÇÑ´Ù.

    Description

    int ldap_modify (int link_identifier, string dn, array entry)

    Returns true on success and false on error.

    ldap_modify() function is used to modify the existing entries in the LDAP directory. The structure of the entry is same as in ldap_add().

    ldap_next_attribute

    ldap_next_attribute -- resultÀÇ ´ÙÀ½ ¼Ó¼ºÀ» ±¸ÇÑ´Ù.

    Description

    string ldap_next_attribute (int link_identifier, int result_entry_identifier, int ber_identifier)

    Returns the next attribute in an entry on success and false on error.

    ldap_next_attribute() is called to retrieve the attributes in an entry. The internal state of the pointer is maintained by the ber_identifier. It is passed by reference to the function. The first call to ldap_next_attribute() is made with the result_entry_identifier returned from ldap_first_attribute().

    see also ldap_get_attributes()

    ldap_next_entry

    ldap_next_entry -- ´ÙÀ½ result entry¸¦ ±¸ÇÑ´Ù.

    Description

    int ldap_next_entry (int link_identifier, int result_entry_identifier)

    Returns entry identifier for the next entry in the result whose entries are being read starting with ldap_first_entry(). If there are no more entries in the result then it returns false.

    ldap_next_entry() function is used to retrieve the entries stored in the result. Successive calls to the ldap_next_entry() return entries one by one till there are no more entries. The first call to ldap_next_entry() is made after the call to ldap_first_entry() with the result_identifier as returned from the ldap_first_entry().

    see also ldap_get_entries()

    ldap_read

    ldap_read -- entry¸¦ Àд´Ù.

    Description

    int ldap_read (int link_identifier, string base_dn, string filter, array [attributes]);

    Returns a search result identifier or false on error.

    ldap_read() performs the search for a specified filter on the directory with the scope LDAP_SCOPE_BASE. So it is equivalent to reading an entry from the directory.

    An empty filter is not allowed. If you want to retrieve absolutely all information for this entry, use a filter of "objectClass=*". If you know which entry types are used on the directory server, you might use an appropriate filter such as "objectClass=inetOrgPerson".

    This call takes an optional fourth parameter which is an array of the attributes required. See ldap_search() notes.

    ldap_search

    ldap_search -- LDAP tree¸¦ °Ë»öÇÑ´Ù.

    Description

    int ldap_search (int link_identifier, string base_dn, string filter [, array attributes])

    Returns a search result identifier or false on error.

    ldap_search() performs the search for a specified filter on the directory with the scope of LDAP_SCOPE_SUBTREE. This is equivalent to searching the entire directory. base_dn specifies the base DN for the directory.

    There is a optional fourth parameter, that can be added to restrict the attributes and values returned by the server to just those required. This is much more efficient than the default action (which is to return all attributes and their associated values). The use of the fourth parameter should therefore be considered good practice.

    The fourth parameter is a standard PHP string array of the required attributes, eg array("mail","sn","cn") Note that the "dn" is always returned irrespective of which attributes types are requested.

    Note too that some directory server hosts will be configured to return no more than a preset number of entries. If this occurs, the server will indicate that it has only returned a partial results set.

    The search filter can be simple or advanced, using boolean operators in the format described in the LDAP doumentation (see the Netscape Directory SDK for full information on filters).

    The example below retrieves the organizational unit, surname, given name and email address for all people in "My Company" where the surname or given name contains the substring $person. This example uses a boolean filter to tell the server to look for information in more than one attribute.

    Example 1. LDAP search

      1 
      2 // $ds is a valid link identifier for a directory server
      3 
      4 // $person is all or part of a person's name, eg "Jo"
      5 
      6 $dn = "o=My Company, c=US";
      7 $filter="(|(sn=$person*)(givenname=$person*))";
      8 $justthese = array( "ou", "sn", "givenname", "mail");
      9 
     10 $sr=ldap_search($ds, $dn, $filter, $justthese);
     11 
     12 $info = ldap_get_entries($ds, $sr);
     13 
     14 print $info["count"]." entries returned<p>";
     15 

    ldap_unbind

    ldap_unbind -- LDAP directory·ÎºÎÅÍ unbindÇÑ´Ù.

    Description

    int ldap_unbind (int link_identifier)

    Returns true on success and false on error.

    ldap_unbind() function unbinds from the LDAP directory.

    ldap_err2str

    (PHP3 >= 3.0.13, PHP4 >= 4.0RC2)

    ldap_err2str --  LDAP ¿¡·¯¹øÈ£¸¦ ¿¡·¯ ¸Þ½ÃÁö ¹®ÀÚ¿­·Î º¯È¯ÇÑ´Ù.

    Description

    string ldap_err2str (int errno)

    returns string error message.

    This function returns the string error message explaining the error number errno. While LDAP errno numbers are standardized, different libraries return different or even localized textual error messages. Never check for a specific error message text, but always use an error number to check.

    See also ldap_errno() and ldap_error().

    Example 1. Enumerating all LDAP error messages

      1 
      2 <?php
      3   for($i=0; $i<100; $i++) {
      4     printf("Error $i: %s<br>\n", ldap_str2err($i));
      5   }
      6 ?>
      7 

    ldap_errno

    (PHP3 >= 3.0.12, PHP4 >= 4.0RC2)

    ldap_errno -- ÃÖ±Ù¿¡ »ç¿ëÇÑ LDAP ¸í·É¿¡ ´ëÇÑ LDAP ¿¡·¯ ¹øÈ£¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int ldap_errno (int link_id)

    return the LDAP error number of the last LDAP command for this link.

    This function returns the standardized error number returned by the last LDAP command for the given link identifier. This number can be converted into a textual error message using ldap_err2str().

    Unless you lower your warning level in your php3.ini sufficiently or prefix your LDAP commands with @ (at) characters to suppress warning output, the errors generated will also show up in your HTML output.

    Example 1. Generating and catching an error

      1 
      2 <?php
      3 // This example contains an error, which we will catch.
      4 $ld = ldap_connect("localhost");
      5 $bind = ldap_bind($ld);
      6 // syntax error in filter expression (errno 87),
      7 // must be "objectclass=*" to work.
      8 $res =  @ldap_search($ld, "o=Myorg, c=DE", "objectclass");
      9 if (!$res) {
     10     printf("LDAP-Errno: %s<br>\n", ldap_errno($ld));
     11     printf("LDAP-Error: %s<br>\n", ldap_error($ld));
     12     die("Argh!<br>\n");
     13 }
     14 $info = ldap_get_entries($ld, $res);
     15 printf("%d matching entries.<br>\n", $info["count"]);
     16 ?>
     17 

    ldap_error

    (PHP3 >= 3.0.12, PHP4 >= 4.0RC2)

    ldap_error --  ÃÖ±Ù¿¡ »ç¿ëÇÑ LDAP ¸í·É¿¡ ´ëÇÑ LDAP ¿¡·¯ ¸Þ¼¼Áö¸¦ ¹ÝȯÇÑ´Ù.

    Description

    string ldap_error (int link_id)

    returns string error message.

    This function returns the string error message explaining the error generated by the last LDAP command for the given link identifier. While LDAP errno numbers are standardized, different libraries return different or even localized textual error messages. Never check for a specific error message text, but always use an error number to check.

    Unless you lower your warning level in your php3.ini sufficiently or prefix your LDAP commands with @ (at) characters to suppress warning output, the errors generated will also show up in your HTML output.

    see also ldap_err2str() and ldap_errno().


    XXXII. Mail functions

    mail() ÇÔ¼ö´Â ÆíÁö¸¦ º¸³¾ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù.

    Table of Contents
    mail ¡¦ send mail

    mail

    mail -- ÆíÁö¸¦ º¸³½´Ù.

    Description

    bool mail (string to, string subject, string message [, string additional_headers])

    Mail() automatically mails the message specified in message to the receiver specified in to. Multiple recipients can be specified by putting a comma between each address in to.

    Example 1. Sending mail.

      1 
      2 mail("rasmus@lerdorf.on.ca", "My Subject", "Line 1\nLine 2\nLine 3");
      3       

    If a fourth string argument is passed, this string is inserted at the end of the header. This is typically used to add extra headers. Multiple extra headers are separated with a newline.

    Example 2. Sending mail with extra headers.

      1 
      2 mail("nobody@aol.com", "the subject", $message,
      3      "From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" . phpversion());
      4       


    XXXII. Mathematical functions

    Introduction

    ÀÌ ¼öÇÐ ÇÔ¼öµéÀº ¿©·¯ºÐÀÇ ÄÄÇ»ÅÍÀÇ long°ú double ÇüÅ·θ¸ »ç¿ëµË´Ï´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ÀÌ ÀÌ»óÀÇ ¼ýÀÚ¸¦ ´Ù·ç¾î¾ßÇÑ´Ù¸é arbitrary precision math functions¸¦ »ç¿ëÇϵµ·ÏÇÑ´Ù.


    Math constants

    PHPÀÇ ¼öÇÐ ÇÔ¼ö È®Àå¿¡¼­ ´ÙÀ½°ªÀÌ »ó¼ö·Î ÁöÁ¤µÇ¾îÀÖ´Ù. :

    Table 1. Math constants

    Constant Value Description
    M_PI 3.14159265358979323846 Der Wert ¥ð (Pi)
    M_E 2.7182818284590452354 e
    M_LOG2E 1.4426950408889634074 log_2 e
    M_LOG10E 0.43429448190325182765 log_10 e
    M_LN2 0.69314718055994530942 log_e 2
    M_LN10 2.30258509299404568402 log_e 10
    M_PI_2 1.57079632679489661923 pi/2
    M_PI_4 0.78539816339744830962 pi/4
    M_1_PI 0.31830988618379067154 1/pi
    M_2_PI 0.63661977236758134308 2/pi
    M_2_SQRTPI 1.12837916709551257390 2/sqrt(pi)
    M_SQRT2 1.41421356237309504880 sqrt(2)
    M_SQRT1_2 0.70710678118654752440 1/sqrt(2)
    PHP4RC1°ú ±× ÀÌÀü ¹öÀü¿¡¼­´Â M_PI ¸¸ÀÌ »ó¼ö·Î Á¦°øµÇ¾ú´Ù. ´Ù¸¥ »ó¼öµéÀº PHP4.0ºÎÅÍ Áö¿øµÈ´Ù.
    Table of Contents
    Abs ¡¦ absolute value
    Acos ¡¦ arc cosine
    Asin ¡¦ arc sine
    Atan ¡¦ arc tangent
    Atan2 ¡¦ arc tangent of two variables
    base_convert ¡¦ convert a number between arbitrary bases
    BinDec ¡¦ binary to decimal
    Ceil ¡¦ round fractions up
    Cos ¡¦ cosine
    DecBin ¡¦ decimal to binary
    DecHex ¡¦ decimal to hexadecimal
    DecOct ¡¦ decimal to octal
    deg2rad ¡¦ Converts the number in degrees to the radian equivalent
    Exp ¡¦ e to the power of...
    Floor ¡¦ round fractions down
    getrandmax ¡¦ show largest possible random value
    HexDec ¡¦ hexadecimal to decimal
    Log ¡¦ natural logarithm
    Log10 ¡¦ base-10 logarithm
    max ¡¦ find highest value
    min ¡¦ find lowest value
    mt_rand ¡¦ generate a better random value
    mt_srand ¡¦ seed the better random number generator
    mt_getrandmax ¡¦ show largest possible random value
    number_format ¡¦ format a number with grouped thousands
    OctDec ¡¦ octal to decimal
    pi ¡¦ get value of pi
    pow ¡¦ exponential expression
    rad2deg ¡¦ Converts the radian number to the equivalent number in degrees
    rand ¡¦ generate a random value
    round ¡¦ Rounds a float.
    Sin ¡¦ sine
    Sqrt ¡¦ square root
    srand ¡¦ seed the random number generator
    Tan ¡¦ tangent

    Abs

    Abs -- Àý´ë°ª

    Description

    mixed abs(mixed number);

    Returns the absolute value of number. If the argument number is float, return type is also float, otherwise it is int.

    Acos

    Acos -- arc cosine

    Description

    float acos(float arg);

    Returns the arc cosine of arg in radians.

    See also asin() and atan().

    Asin

    Asin -- arc sine

    Description

    float asin(float arg);

    Returns the arc sine of arg in radians.

    See also acos() and atan().

    Atan

    Atan -- arc tangent

    Description

    float atan(float arg);

    Returns the arc tangent of arg in radians.

    See also acos() and atan().

    Atan2

    Atan2 -- arc tangent of two variables

    Description

    float atan2(float y, float x);

    This function calculates the arc tangent of the two variables x and y. It is similar to calculating the arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result.

    The function returns the result in radians, which is between -PI and PI (inclusive).

    See also acos() and atan().

    base_convert

    base_convert -- ¼ýÀÚ¸¦ Áø¹ý°£¿¡ º¯È¯ÇÑ´Ù.

    Description

    strin base_convert (string number, int frombase, int tobase)

    Returns a string containing number represented in base tobase. The base in which number is given is specified in frombase. Both frombase and tobase have to be between 2 and 36, inclusive. Digits in numbers with a base higher than 10 will be represented with the letters a-z, with a meaning 10, b meaning 11 and z meaning 36.

    Example 1. base_convert()

      1 
      2 $binary = base_convert($hexadecimal, 16, 2);
      3 

    BinDec

    BinDec -- 2Áø¼ö¸¦ 10Áø¼ö·Î ¹Ù²Û´Ù.

    Description

    int bindec(string binary_string);

    Returns the decimal equivalent of the binary number represented by the binary_string argument.

    BinDec converts a binary number to a decimal number. The largest number that can be converted is 31 bits of 1's or 2147483647 in decimal.

    See also the decbin() function.

    Ceil

    Ceil -- ¿Ã¸²À» ÇÑ °ª

    Description

    int ceil(float number);

    Returns the next highest integer value from number. Using ceil() on integers is absolutely a waste of time.

    NOTE: PHP/FI 2's ceil() returned a float. Use: $new = (double)ceil($number); to get the old behaviour.

    See also floor() and round().

    Cos

    Cos -- cosine

    Description

    float cos(float arg);

    Returns the cosine of arg in radians.

    See also sin() and tan().

    DecBin

    DecBin -- 10Áø¼ö¸¦ 2Áø¼ö·Î ¹Ù²Û´Ù.

    Description

    string decbin(int number);

    Returns a string containing a binary representation of the given number argument. The largest number that can be converted is 2147483647 in decimal resulting to a string of 31 1's.

    See also the bindec() function.

    DecHex

    DecHex -- ½ÊÁø¼ö¸¦ 16Áø¼ö·Î

    Description

    string dechex(int number);

    Returns a string containing a hexadecimal representation of the given number argument. The largest number that can be converted is 2147483647 in decimal resulting to "7fffffff".

    See also the hexdec() function.

    DecOct

    DecOct -- ½ÊÁø¼ö¸¦ 8Áø¼ö·Î ¹Ù²Û´Ù

    Description

    string decoct(int number);

    Returns a string containing an octal representation of the given number argument. The largest number that can be converted is 2147483647 in decimal resulting to "17777777777". See also octdec().

    deg2rad

    (PHP3 >= 3.0.4, PHP4 )

    deg2rad -- degrees °¢µµ °ªÀ» radian °¢µµ°ªÀ¸·Î º¯È¯ÇÑ´Ù.

    Description

    double deg2rad (double number)

    This function converts number from degrees to the radian equivalent.

    See also rad2deg().

    Exp

    Exp -- ÀÚ¿¬´ë¼ö eÀÇ n Á¦°ö°ª

    Description

    float exp(float arg);

    Returns e raised to the power of arg.

    See also pow().

    Floor

    Floor -- ³»¸²À» ÇÑ °ª

    Description

    int floor(float number);

    Returns the next lowest integer value from number. Using floor() on integers is absolutely a waste of time.

    NOTE: PHP/FI 2's floor() returned a float. Use: $new = (double)floor($number); to get the old behaviour.

    See also ceil() and round().

    getrandmax

    getrandmax -- °¡´ÉÇÑ ³­¼öÀÇ ÃÖ´ë°ª

    Description

    int getrandmax(void );

    Returns the maximum value that can be returned by a call to rand().

    See also rand(), srand(), mt-rand() ,mt_srand() and mt_getrandmax(),

    HexDec

    HexDec -- 16Áø¼ö¸¦ 10Áø¼ö·Î

    Description

    int hexdec(string hex_string);

    Returns the decimal equivalent of the hexadecimal number represented by the hex_string argument. HexDec converts a hexadecimal string to a decimal number. The largest number that can be converted is 7fffffff or 2147483647 in decimal.

    See also the dechex() function.

    Log

    Log -- ÀÚ¿¬ ·Î±×

    Description

    float log(float arg);

    Returns the natural logarithm of arg.

    Log10

    Log10 -- »ó¿ë ·Î±×

    Description

    float log10(float arg);

    Returns the base-10 logarithm of arg.

    max

    max -- °¡Àå Å« °ªÀ» ã´Â´Ù.

    Description

    mixed max(mixed arg1, mixed arg2, mixed argn);

    max() returns the numerically highest of the parameter values.

    If the first parameter is an array, max() returns the highest value in that array. If the first parameter is an integer, string or double, you need at least two parameters and max() returns the biggest of these values. You can compare an unlimited number of values.

    If one or more of the values is a double, all the values will be treated as doubles, and a double is returned. If none of the values is a double, all of them will be treated as integers, and an integer is returned.

    min

    min -- °¡Àå ÀÛÀº °ªÀ» ã´Â´Ù.

    Description

    mixed min(mixed arg1, mixed arg2, mixed argn);

    min() returns the numerically lowest of the parameter values.

    If the first parameter is an array, min() returns the lowest value in that array. If the first parameter is an integer, string or double, you need at least two parameters and min() returns the lowest of these values. You can compare an unlimited number of values.

    If one or more of the values is a double, all the values will be treated as doubles, and a double is returned. If none of the values is a double, all of them will be treated as integers, and an integer is returned.

    mt_rand

    mt_rand -- ´õ ÁÁÀº ³­¼ö °ªÀ» ¸¸µé¾î ³½´Ù.

    Description

    int mt_rand([int min], [int max]);

    Many random number generators of older libcs have dubious or unknown characteristics and are slow. By default, PHP uses the libc random number generator with the rand() function. mt_rand() function is a drop-in replacement for this. It uses a random number generator with known characteristics, the Mersenne Twister, which will produce random numbers that should be suitable for cryptographic purposes and is four times faster than what the average libc provides. The Homepage of the Mersenne Twister can be found at http://www.math.keio.ac.jp/~matumoto/emt.html, and an optimized version of the MT source is available from http://www.scp.syr.edu/~marc/hawk/twister.html.

    If called without the optional min,max arguments mt_rand() returns a pseudo-random value between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use mt_rand(5,15).

    Remember to seed the random number generator before use with mt_srand().

    See also mt_srand(), mt_getrandmax(), srand(), rand() and getrandmax().

    mt_srand

    mt_srand -- ´õ ÁÁÀº ³­¼ö ¹ß»ý±â¿¡ ÃʱⰪÀ» Á¤ÇÑ´Ù.

    Description

    void mt_srand(int seed);

    Seeds the random number generator with seed.

    // seed with microseconds since last "whole" second
    mt_srand((double)microtime()*1000000);
    $randval = mt_rand();

    See also mt_rand(), mt_getrandmax(), srand(), rand() and getrandmax().

    mt_getrandmax

    mt_getrandmax -- °¡´ÉÇÑ °¡Àå Å« ³­¼ö°ª

    Description

    int mt_getrandmax(void );

    Returns the maximum value that can be returned by a call to mt_rand().

    See also mt_rand(), mt_srand(), rand(), srand() and getrandmax().

    number_format

    number_format -- ¼ýÀÚ¸¦ 1000´ÜÀ§¿Í ¼Ò¼öÁ¡¿¡ ,¿Í .µîÀ» Âï¾îÁØ´Ù.

    Description

    string number_format(float number, int decimals, string dec_point, string thousands_sep);

    number_format() returns a formatted version of number. This function accepts either one, two or four parameters (not three):

    If only one parameter is given, number will be formatted without decimals, but with a comma (",") between every group of thousands.

    If two parameters are given, number will be formatted with decimals decimals with a dot (".") in front, and a comma (",") between every group of thousands.

    If all four parameters are given, number will be formatted with decimals decimals, dec_point instead of a dot (".") before the decimals and thousands_sep instead of a comma (",") between every group of thousands.

    OctDec

    OctDec -- 8Áø¼ö¸¦ 10Áø¼ö·Î

    Description

    int octdec(string octal_string);

    Returns the decimal equivalent of the octal number represented by the octal_string argument. OctDec converts an octal string to a decimal number. The largest number that can be converted is 17777777777 or 2147483647 in decimal.

    See also decoct().

    pi

    pi -- ÆÄÀÌ °ª

    Description

    double pi(void);

    Returns an approximation of pi.

    pow

    pow -- Áö¼ö Ç¥Çö½Ä(xÀÇ y½Â)

    Description

    float pow(float base, float exp);

    Returns base raised to the power of exp.

    See also exp().

    rad2deg

    (PHP3 >= 3.0.4, PHP4 )

    rad2deg -- radian °¢µµ °ªÀ» degrees °¢µµ°ªÀ¸·Î º¯È¯ÇÑ´Ù.

    Description

    double rad2deg (double number)

    This function converts number from radian to degrees.

    See also deg2rad().

    rand

    rand -- ³­¼öÀÇ ¹ß»ý

    Description

    int rand([int min], [int max]);

    If called without the optional min,max arguments rand() returns a pseudo-random value between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use rand(5,15).

    Remember to seed the random number generator before use with srand().

    See also srand(), getrandmax(), mt-rand() ,mt_srand() and mt_getrandmax(),

    round

    round -- ¹Ý¿Ã¸² ÇÑ °ª

    Description

    double round(double val);

    Returns the rounded value of val.

    $foo = round( 3.4 );   // $foo == 3.0
    $foo = round( 3.5 );   // $foo == 4.0
    $foo = round( 3.6 );   // $foo == 4.0
          

    See also ceil() and floor().

    Sin

    Sin -- sine

    Description

    float sin(float arg);

    Returns the sine of arg in radians.

    See also cos() and tan().

    Sqrt

    Sqrt -- Á¦°ö±Ù

    Description

    float sqrt(float arg);

    Returns the square root of arg.

    srand

    srand -- ³­¼ö ¹ß»ý½Ã »ç¿ëÇÏ´Â seed °ª

    Description

    void srand(int seed);

    Seeds the random number generator with seed.

    // seed with microseconds since last "whole" second
    srand((double)microtime()*1000000);
    $randval = rand();
          

    See also rand(), getrandmax(), mt-rand() ,mt_srand() and mt_getrandmax(),

    Tan

    Tan -- tangent

    Description

    float tan(float arg);

    Returns the tangent of arg in radians.

    See also sin() and cos().


    XXXIV. MCAL functions

    MCALÀº Modular Calendar Access LibraryÀÇ ÁÙÀÓ¸»ÀÌ´Ù.

    LibmcalÀº ÀÏÁ¤°ü¸®(calandar)¸¦ ÇÏ´Â C ¶óÀ̺귯¸®ÀÌ´Ù. ÀÌ°ÍÀº Ãß°¡/»èÁ¦°¡ °¡´ÉÇÑ µå¶óÀ̹öµé·Î Àß ¸ðµâÈ­µÇ¾î ÀÖ´Ù. IMAP ¸ðµâÀÌ ¸ÞÀϹڽº¿¡ ´ëÇØ ¸ðµâÈ­ µÇ¾î ÀÖ´Â °Í°ú °°ÀÌ MCALÀº ÀÏÁ¤°ü¸®¿¡ ¸ðµâÈ­ µÇ¾î ÀÖ´Ù.

    IMAP¿¡¼­ÀÇ mailbox stream°°ÀÌ mcal¿¡¼­´Â ÀÏÁ¤ streamÀÌ ¿­¸± ¼ö ÀÖ´Ù. ÀÏÁ¤°ü¸® ³»¿ëÀº Áö¿ªÆÄÀÏ·Î ÀúÀåµÉ ¼öµµ ÀÖ°í, ¿ø°Ý ICAP ¼­¹ö¿¡ ÀúÀåµÉ ¼öµµ ÀÖÀ¸¸ç, mcal ¶óÀ̺귯¸®°¡ Áö¿øÇÏ´Â ´Ù¸¥ ÇüÅ·ΠÀúÀåµÉ ¼öµµ ÀÖ´Ù.

    °³°³ÀÇ ÀÏÁ¤(event)Àº ¼­¹ö¿¡¼­ °¡Á®¿Ã ¼ö ÀÖ°í, °Ë»öÇÒ ¼ö ÀÖ°í, ÀúÀåµÇ±âµµ ÇÑ´Ù. ¶ÇÇÑ ¾Ë¶÷±â´ÉÀ» ÇÏ´Â ³¯Â¥ Æ®¸®°Å(triggers)¸¦ Áö¿øÇÏ°í ¹Ýº¹ÀûÀÎ ÀÏÁ¤µµ Áö¿øÇÑ´Ù.

    libmcalÀº Áß¾Ó ÁýÁß ÀÏÁ¤ ¼­¹ö¸¦ »ç¿ëÇÏ¿© ƯÁ¤ µ¥ÀÌÅͺ£À̽º³ª ·ÎÄà ÆÄÀÏÀ» Á÷Á¢ ´Ù·ç¾î¾ß ÇÏ´Â Çʿ並 ¾ø¾Ù ¼ö ÀÖ´Ù.

    ÀÌ ÇÔ¼öµéÀ» µ¿ÀÛ½ÃÅ°·Á¸é, PHP¸¦ --with-mcal ¿É¼ÇÀ» ÁÖ°í ÄÄÆÄÀÏ ÇÏ¿©¾ß ÇÑ´Ù. ±×¸®°í, ´ç¿¬È÷ mcal ¶óÀ̺귯¸®´Â ¹Ì¸® ¼³Ä¡µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù. http://mcal.chek.com/ ¿¡¼­ ÃֽŠ¹öÀüÀ» ¹Þ¾Æ´Ù ÄÄÆÄÀÏÇÏ¿© ¼³Ä¡ÇÏ¸é µÈ´Ù.

    MCAL ¸ðµâÀÌ »ç¿ëµÉ ¼ö ÀÖ´Ù¸é ´ÙÀ½°ú °°Àº ÇÔ¼ö°¡ ¹Ì¸® Á¤ÀǵǾî ÀÖ´Ù. : MCAL_SUNDAY, MCAL_MONDAY, MCAL_TUESDAY, MCAL_WEDNESDAY, MCAL_THURSDAY, MCAL_FRIDAY, MCAL_SATURDAY, MCAL_RECUR_NONE, MCAL_RECUR_DAILY, MCAL_RECUR_WEEKLY, MCAL_RECUR_MONTHLY_MDAY, MCAL_RECUR_MONTHLY_WDAY, MCAL_RECUR_YEARLY, MCAL_JANUARY, MCAL_FEBRUARY, MCAL_MARCH, MCAL_APRIL, MCAL_MAY, MCAL_JUNE, MCAL_JULY, MCAL_AUGUGT, MCAL_SEPTEMBER, MCAL_OCTOBER, MCAL_NOVEMBER, MCAL_DECEMBER. ´ëºÎºÐÀÇ ÇÔ¼ö´Â °¢°¢ÀÇ ½ºÆ®¸²¿¡ ´ëÇØ Çϳª¾¿ ¼³Á¤µÇ¾î ÀÖ´Â ³»ºÎÀûÀÎ ÀÏÁ¤ ±¸Á¶Ã¼(internal event structure)¸¦ »ç¿ëÇÑ´Ù. ÀÌ°ÍÀº ÇÔ¼öµé°£¿¡ Å©±â°¡ Å« °´Ã¼¸¦ Àü´ÞÇϱ⠼ö¿ùÇÏ°Ô ÇÑ´Ù. ¿©±â¿¡¼­´Â ÀÏÁ¤ ±¸Á¶Ã¼ (event structure)ÀÇ °ªÀ» ¼³Á¤ÇÏ°í, ÃʱâÈ­ÇÏ°í, Á¶È¸Çϴµ¥ »ç¿ëÇϱ⠽¬¿î ÇÔ¼öµéÀ» Á¦°øÇÑ´Ù.

    Table of Contents
    mcal_open ¡¦ Opens up an MCAL connection
    mcal_close ¡¦ Close an MCAL stream
    mcal_fetch_event ¡¦ Fetches an event from the calendar stream
    mcal_list_events ¡¦ Return a list of events between two given datetimes
    mcal_append_event ¡¦ Store a new event into an MCAL calendar
    mcal_store_event ¡¦ Modify an existing event in an MCAL calendar
    mcal_delete_event ¡¦ Delete an event from an MCAL calendar
    mcal_snooze ¡¦ Turn off an alarm for an event
    mcal_list_alarms ¡¦ Return a list of events that has an alarm triggered at the given datetime
    mcal_event_init ¡¦ Initializes a streams global event structure
    mcal_event_set_category ¡¦ Sets the category of the streams global event structure
    mcal_event_set_title ¡¦ Sets the title of the streams global event structure
    mcal_event_set_description ¡¦ Sets the description of the streams global event structure
    mcal_event_set_start ¡¦ Sets the start date and time of the streams global event structure
    mcal_event_set_end ¡¦ Sets the end date and time of the streams global event structure
    mcal_event_set_alarm ¡¦ Sets the alarm of the streams global event structure
    mcal_event_set_class ¡¦ Sets the class of the streams global event structure
    mcal_is_leap_year ¡¦ Returns if the given year is a leap year or not
    mcal_days_in_month ¡¦ Returns the number of days in the given month
    mcal_date_valid ¡¦ Returns true if the given year, month, day is a valid date
    mcal_time_valid ¡¦ Returns true if the given year, month, day is a valid time
    mcal_day_of_week ¡¦ Returns the day of the week of the given date
    mcal_day_of_year ¡¦ Returns the day of the year of the given date
    mcal_date_compare ¡¦ Compares two dates
    mcal_next_recurrence ¡¦ Returns the next recurrence of the event
    mcal_event_set_recur_none ¡¦ Sets the recurrence of the streams global event structure
    mcal_event_set_recur_daily ¡¦ Sets the recurrence of the streams global event structure
    mcal_event_set_recur_weekly ¡¦ Sets the recurrence of the streams global event structure
    mcal_event_set_recur_monthly_mday ¡¦ Sets the recurrence of the streams global event structure
    mcal_event_set_recur_monthly_wday ¡¦ Sets the recurrence of the streams global event structure
    mcal_event_set_recur_yearly ¡¦ Sets the recurrence of the streams global event structure
    mcal_fetch_current_stream_event ¡¦ Returns an object containing the current streams event structure

    mcal_open

    mcal_open -- MCAL ¿¬°áÀ» ¿¬´Ù.

    Description

    int mcal_open(string calendar, string username, string password, string options);

    Returns an MCAL stream on success, false on error.

    mcal_open() opens up an MCAL connection to the specified calendar store. If the optional options is specified, passes the options to that mailbox also. The streams internal event structure is also initialized upon connection.

    mcal_close

    mcal_close -- MCAL streamÀ» ´Ý´Â´Ù.

    Description

    int mcal_close(int mcal_stream, int flags);

    Closes the given mcal stream.

    mcal_fetch_event

    mcal_fetch_event -- calendar stream ¿¡¼­ event ¸¦ °¡Á®¿Â´Ù.

    Description

    object mcal_fetch_event(int mcal_stream, int event_id, int [options]);

    mcal_fetch_event() fetches an event from the calendar stream specified by id.

    Returns an event object consisting of:

    All datetime entries consist of an object that contains:

    mcal_list_events

    mcal_list_events -- µÎ °³ÀÇ ½Ã°£ »çÀÌ¿¡ ÀÖ´Â ÀÏÁ¤µé(events)ÀÇ ¸ñ·ÏÀ» ¹ÝȯÇÑ´Ù.

    Description

    array mcal_list_events(int mcal_stream, int [begin_year] , int [begin_month] , int [begin_day] , int [end_year] , int [end_month] , int [end_day] );

    Returns an array of event ID's that are between the start and end dates, or if just a stream is given, uses the start and end dates in the global event structure.

    mcal_list_events() function takes in an optional beginning date and an end date for a calendar stream. An array of event id's that are between the given dates or the internal event dates are returned.

    mcal_append_event

    mcal_append_event -- MCAL calendar¿¡ »õ·Î¿î ÀÏÁ¤(event)¸¦ ÀúÀåÇÑ´Ù.

    Description

    int mcal_append_event(int mcal_stream);

    mcal_append_event() Stores the global event into an MCAL calendar for the given stream.

    Returns the uid of the newly inserted event.

    mcal_store_event

    mcal_store_event -- MCAL calendarÀÇ ±âÁ¸ ÀÏÁ¤(event)¸¦ ¼öÁ¤ÇÑ´Ù.

    Description

    int mcal_store_event(int mcal_stream);

    mcal_store_event() Stores the modifications to the current global event for the given stream.

    Returns true on success and false on error.

    mcal_delete_event

    mcal_delete_event -- MCAL calendarÀÇ ¾î¶² ÀÏÁ¤(event)¸¦ »èÁ¦ÇÑ´Ù.

    Delete an event from an MCAL calendar

    Description

    int mcal_delete_event(int uid);

    mcal_delete_event() deletes the calendar event specified by the uid.

    Returns true.

    mcal_snooze

    mcal_snooze -- ÇÑ ÀÏÁ¤(event)¿¡ ´ëÇÑ ¾Ë¶÷À» ²ö´Ù.

    Turn off an alarm for an event

    Description

    int mcal_snooze(int uid);

    mcal_snooze() turns off an alarm for a calendar event specified by the uid.

    Returns true.

    mcal_list_alarms

    mcal_list_alarms -- ÁÖ¾îÁø ½Ã°£(datetime)¿¡ ¾Ë¶÷ÀÌ ½ÇÇàÇϵµ·Ï(triggered) ¸ÂÃçÁ® ÀÖ´Â ÀÏÁ¤ÀÇ ¸ñ·ÏÀ» ¹ÝȯÇÑ´Ù.

    Description

    array mcal_list_events(int mcal_stream, int [begin_year] , int [begin_month] , int [begin_day] , int [end_year] , int [end_month] , int [end_day] );

    Returns an array of event ID's that has an alarm going off between the start and end dates, or if just a stream is given, uses the start and end dates in the global event structure.

    mcal_list_events() function takes in an optional beginning date and an end date for a calendar stream. An array of event id's that are between the given dates or the internal event dates are returned.

    mcal_event_init

    mcal_event_init -- streamsÀÇ global event structure¸¦ ÃʱâÈ­ ÇÑ´Ù.

    Description

    int mcal_event_init(int stream);

    mcal_event_init() initializes a streams global event structure. this effectively sets all elements of the structure to 0, or the default settings.

    Returns true.

    mcal_event_set_category

    mcal_event_set_category -- streamsÀÇ global event structureÀÇ category¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_category(int stream, string category);

    mcal_event_set_category() sets the streams global event structure's category to the given string.

    Returns true.

    mcal_event_set_title

    mcal_event_set_title -- streamsÀÇ global event structureÀÇ Á¦¸ñ(title)À» ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_title(int stream, string title);

    mcal_event_set_title() sets the streams global event structure's title to the given string.

    Returns true.

    mcal_event_set_description

    mcal_event_set_description -- streamsÀÇ global event structureÀÇ ¼³¸í(description)À» ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_description (int stream, string description);

    mcal_event_set_description() sets the streams global event structure's description to the given string.

    Returns true.

    mcal_event_set_start

    mcal_event_set_start -- streamsÀÇ global event structureÀÇ ½ÃÀÛ ½Ã°¢(start date and time)À» ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_start(int stream, int year, int month, int [day] , int [hour] , int [min] , int [sec] );

    mcal_event_set_start() sets the streams global event structure's start date and time to the given values.

    Returns true.

    mcal_event_set_end

    mcal_event_set_end -- streamsÀÇ global event structureÀÇ Á¾·á ½Ã°¢(end date and time)À» ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_end(int stream, int year, int month, int [day] , int [hour] , int [min] , int [sec] );

    mcal_event_set_end() sets the streams global event structure's end date and time to the given values.

    Returns true.

    mcal_event_set_alarm

    mcal_event_set_alarm -- streamsÀÇ global event structureÀÇ ¾Ë¶÷(alarm)À» ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_alarm(int stream, int alarm);

    mcal_event_set_alarm() sets the streams global event structure's alarm to the given minutes before the event.

    Returns true.

    mcal_event_set_class

    mcal_event_set_class -- streamsÀÇ global event structureÀÇ class¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_class(int stream, int class);

    mcal_event_set_class() sets the streams global event structure's class to the given value. The class is either 0 for public, or 1 for private.

    Returns true.

    mcal_is_leap_year

    mcal_is_leap_year -- ÁÖ¾îÁø ¿¬µµ°¡ À±³âÀΰ¡ ¾Æ´Ñ°¡ ¹ÝȯÇÑ´Ù.

    Description

    int mcal_is_leap_year(int year);

    mcal_is_leap_year() returns 1 if the given year is a leap year, 1 if not. (¿ªÀÚÁÖ: ¿øº»ÀÌ Á» ÀÌ»óÇѵ¥, ¾Æ¸¶ À±³âÀÌ ¾Æ´Ï¸é 0À» ¹ÝȯÇÒ °ÍÀÌ´Ù)

    mcal_days_in_month

    mcal_days_in_month -- ÁÖ¾îÁø ¿ùÀÇ ³¯Â¥¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int mcal_days_in_month(int month, int leap year);

    mcal_days_in_month() Returns the number of days in the given month, taking into account if the given year is a leap year or not.

    mcal_date_valid

    mcal_date_valid -- ÁÖ¾îÁø ¿¬, ¿ù, ÀÏÀÌ ³¯Â¥·Î º¯È¯¿¡ ¹®Á¦ ¾øÀ¸¸é true¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int mcal_date_valid(int year, int month, int day);

    mcal_date_valid() Returns true if the given year, month and day is a valid date, false if not.

    mcal_time_valid

    mcal_time_valid -- ÁÖ¾îÁø ½Ã, ºÐ, ÃÊ°¡ ³¯Â¥·Î º¯È¯¿¡ ¹®Á¦ ¾øÀ¸¸é true¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int mcal_time_valid(int hour, int minutes, int seconds);

    mcal_time_valid() Returns true if the given hour, minutes and seconds is a valid time, false if not.

    mcal_day_of_week

    mcal_day_of_week -- ÁÖ¾îÁø ³¯Â¥ÀÇ ¿äÀÏÀ» ¹ÝȯÇÑ´Ù.

    Description

    int mcal_(int year, int month, int day);

    mcal_day_of_week() returns the day of the week of the given date

    mcal_day_of_year

    mcal_day_of_year -- ÁÖ¾îÁø ³¯Â¥°¡ ÇØ´ç ¿¬µµÀÇ ¸î ¹ø° ³¯ÀÎÁö ¹ÝȯÇÑ´Ù.

    Description

    int mcal_(int year, int month, int day);

    mcal_day_of_year() returns the day of the year of the given date.

    mcal_date_compare

    mcal_date_compare -- µÎ ³¯Â¥¸¦ ºñ±³ÇÑ´Ù.

    Description

    int mcal_date_compare(int a_year, int a_month, int a_day, int b_year, int b_month, int b_day);

    mcal_date_compare() Compares the two given dates, returns <0, 0, >0 if a<b, a==b, a>b respectively

    mcal_next_recurrence

    mcal_next_recurrence -- ´ÙÀ½¿¡ ÀçÇöÇÒ(recurrence) ÀÏÁ¤À» ¹ÝȯÇÑ´Ù.

    Description

    int mcal_next_recurrence(int stream, int weekstart, array next);

    mcal_next_recurrence() returns an object filled with the next date the event occurs, on or after the supplied date. Returns empty date field if event does not occur or something is invalid. Uses weekstart to determine what day is considered the beginning of the week.

    mcal_event_set_recur_none

    mcal_event_set_recur_none -- streamsÀÇ global event structureÀÇ recurrence¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_recur_none (int stream);

    mcal_event_set_recur_none() sets the streams global event structure to not recur (event->recur_type is set to MCAL_RECUR_NONE).

    mcal_event_set_recur_daily

    mcal_event_set_recur_daily -- streamsÀÇ global event structureÀÇ recurrence¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_recur_daily (int stream, int year, int month, int day, int interval);

    mcal_event_set_recur_daily() sets the streams global event structure's recurrence to the given value to be reoccuring on a daily basis, ending at the given date.

    mcal_event_set_recur_weekly

    mcal_event_set_recur_weekly -- streamsÀÇ global event structureÀÇ recurrence¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_recur_weekly (int stream, int year, int month, int day, int interval, int weekdays);

    mcal_event_set_recur_weekly() sets the streams global event structure's recurrence to the given value to be reoccuring on a weekly basis, ending at the given date.

    mcal_event_set_recur_monthly_mday

    mcal_event_set_recur_monthly_mday -- streamsÀÇ global event structureÀÇ recurrence¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_recur_monthly_mday (int stream, int year, int month, int day, int interval);

    mcal_event_set_recur_monthly_mday() sets the streams global event structure's recurrence to the given value to be reoccuring on a monthly by month day basis, ending at the given date.

    mcal_event_set_recur_monthly_wday

    mcal_event_set_recur_monthly_wday -- streamsÀÇ global event structureÀÇ recurrence¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_recur_monthly_wday (int stream, int year, int month, int day, int interval);

    mcal_event_set_recur_monthly_wday() sets the streams global event structure's recurrence to the given value to be reoccuring on a monthly by week basis, ending at the given date.

    mcal_event_set_recur_yearly

    mcal_event_set_recur_yearly -- streamsÀÇ global event structureÀÇ recurrence¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int mcal_event_set_recur_yearly (int stream, int year, int month, int day, int interval);

    mcal_event_set_recur_yearly() sets the streams global event structure's recurrence to the given value to be reoccuring on a yearly basis,ending at the given date .

    mcal_fetch_current_stream_event

    mcal_fetch_current_stream_event -- ÇöÀç streams event structure¸¦ °¡Áö°í ÀÖ´Â °´Ã¼¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int mcal_fetch_current_stream_event (int stream);

    mcal_event_fetch_current_stream_event() returns the current stream's event structure as an object containing:

    All datetime entries consist of an object that contains:


    XXXV. Microsoft SQL Server functions

    Table of Contents
    mssql_close ¡¦ close MS SQL Server connection
    mssql_connect ¡¦ open MS SQL server connection
    mssql_data_seek ¡¦ move internal row pointer
    mssql_fetch_array ¡¦ fetch row as array
    mssql_fetch_field ¡¦ get field information
    mssql_fetch_object ¡¦ fetch row as object
    mssql_fetch_row ¡¦ get row as enumerated array
    mssql_field_length ¡¦ Get the length of a field
    mssql_field_name ¡¦ Get the name of a field
    mssql_field_seek ¡¦ set field offset
    mssql_field_type ¡¦ Get the type of a field
    mssql_free_result ¡¦ free result memory
    mssql_get_last_message ¡¦ Returns the last message from server (over min_message_severity?)
    mssql_min_error_severity ¡¦ Sets the lower error severity
    mssql_min_message_severity ¡¦ Sets the lower
    mssql_num_fields ¡¦ get number of fields in result
    mssql_num_rows ¡¦ get number of rows in result
    mssql_pconnect ¡¦ open persistent MS SQL connection
    mssql_query ¡¦ send MS SQL query
    mssql_result ¡¦ get result data
    mssql_select_db ¡¦ select MS SQL database

    mssql_close

    mssql_close -- MS SQL Server connectionÀ» ´Ý´Â´Ù.

    Description

    int mssql_close ([int link_identifier])r);

    Returns: true on success, false on error

    mssql_close() closes the link to a MS SQL Server database that's associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed.

    Note that this isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.

    mssql_close() will not close persistent links generated by mssql_pconnect().

    See also: mssql_connect(), mssql_pconnect().

    mssql_connect

    mssql_connect -- MS SQL server connectionÀ» ¿¬´Ù.

    Description

    int mssql_connect ([string servername [, string username [, string password]]])

    Returns: A positive MS SQL link identifier on success, or false on error.

    mssql_connect() establishes a connection to a MS SQL server. The servername argument has to be a valid servername that is defined in the 'interfaces' file.

    In case a second call is made to mssql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned.

    The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mssql_close().

    See also mssql_pconnect(), mssql_close().

    mssql_data_seek

    mssql_data_seek -- internal row pointer¸¦ ¿Å±ä´Ù.

    Description

    int mssql_data_seek (int result_identifier, int row_number)

    Returns: true on success, false on failure

    mssql_data_seek() moves the internal row pointer of the MS SQL result associated with the specified result identifier to pointer to the specifyed row number. The next call to mssql_fetch_row() would return that row.

    See also: mssql_data_seek().

    mssql_fetch_array

    mssql_fetch_array -- row¸¦ ¹è¿­·Î °¡Á®¿Â´Ù.

    Description

    int mssql_fetch_array (int result)

    Returns: An array that corresponds to the fetched row, or false if there are no more rows.

    mssql_fetch_array() is an extended version of mssql_fetch_row(). In addition to storing the data in the numeric indices of the result array, it also stores the data in associative indices, using the field names as keys.

    An important thing to note is that using mssql_fetch_array() is NOT significantly slower than using mssql_fetch_row(), while it provides a significant added value.

    For further details, also see mssql_fetch_row()

    mssql_fetch_field

    mssql_fetch_field -- ÇʵåÀÇ Á¤º¸¸¦ ±¸ÇÑ´Ù.

    Description

    object mssql_fetch_field (int result [, int field_offset])

    Returns an object containing field information.

    mssql_fetch_field() can be used in order to obtain information about fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retreived by mssql_fetch_field() is retreived.

    The properties of the object are:

    See also mssql_field_seek()

    mssql_fetch_object

    mssql_fetch_object -- row¸¦ object·Î °¡Á®¿Â´Ù.

    Description

    int mssql_fetch_object (int result)

    Returns: An object with properties that correspond to the fetched row, or false if there are no more rows.

    mssql_fetch_object() is similar to mssql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

    Speed-wise, the function is identical to mssql_fetch_array(), and almost as quick as mssql_fetch_row() (the difference is insignificant).

    See also: mssql_fetch-array() and mssql_fetch-row().

    mssql_fetch_row

    mssql_fetch_row -- row¸¦ ¹è¿­(enumerated array)·Î °¡Á®¿Â´Ù.

    Description

    array mssql_fetch_row (int result)

    Returns: An array that corresponds to the fetched row, or false if there are no more rows.

    Mssql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

    Subsequent call to mssql_fetch_rows() would return the next row in the result set, or false if there are no more rows.

    See also: mssql_fetch_array(), mssql_fetch_object(), mssql_data_seek(), mssql_fetch_lengths(), and mssql_result().

    mssql_field_length

    (PHP3 >= 3.0.3, PHP4 >= 4.0b4)

    mssql_field_length -- ÇʵåÀÇ ±æÀ̸¦ ±¸ÇÑ´Ù.

    Description

    int mssql_field_length (int result [, int offset])

    mssql_field_name

    (PHP3 >= 3.0.3, PHP4 >= 4.0b4)

    mssql_field_name -- ÇʵåÀÇ À̸§À» ±¸ÇÑ´Ù.

    Description

    int mssql_field_name (int result [, int offset])

    mssql_field_seek

    mssql_field_seek -- ÇʵåÀÇ offsetÀ» ¼³Á¤ÇÑ´Ù.

    Description

    int mssql_field_seek (int result, int field_offset);

    Seeks to the specified field offset. If the next call to mssql_fetch_field() won't include a field offset, this field would be returned.

    See also: mssql_fetch_field().

    mssql_field_type

    (PHP3 >= 3.0.3, PHP4 >= 4.0b4)

    mssql_field_type -- ÇʵåÀÇ Å¸ÀÔÀ» ±¸ÇÑ´Ù.

    Description

    string mssql_field_type (int result [, int offset])

    mssql_free_result

    mssql_free_result -- result memory¸¦ Ç®¾îÁØ´Ù.

    Description

    int mssql_free_result (int result)

    mssql_free_result() only needs to be called if you are worried about using too much memory while your script is running. All result memory will automatically be freed when the script, you may call mssql_free_result() with the result identifier as an argument and the associated result memory will be freed.

    mssql_get_last_message

    mssql_get_last_message -- ¼­¹ö·ÎºÎÅÍ °¡Àå ÃÖ±Ù¿¡ ¿Â ¸Þ½ÃÁö¸¦ ¹ÝȯÇÑ´Ù (over min_message_severity?)

    Description

    string mssql_get_last_message (void )

    mssql_min_error_severity

    mssql_min_error_severity -- Àú¼öÁØ ¿¡·¯ÀÇ ¾ö°ÝÇÑ Á¤µµ(lower error severity)¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    void mssql_min_error_severity (int severity)

    mssql_min_message_severity

    mssql_min_message_severity -- Àú¼öÁØ ¸ÞÁ¦ÁöÀÇ ¾ö°ÝÇÑ Á¤µµ(lower message severity)¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    void mssql_min_message_severity (int severity)

    mssql_num_fields

    mssql_num_fields -- resultÀÇ field °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int mssql_num_fields (int result)

    Mssql_num_fields() returns the number of fields in a result set.

    See also: mssql_db_query(), mssql_query(), mssql_fetch_field(), mssql_num_rows().

    mssql_num_rows

    mssql_num_rows -- resultÀÇ row °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int mssql_num_rows (string result);

    mssql_num_rows() returns the number of rows in a result set.

    See also: mssql_db_query(), mssql_query() and, mssql_fetch_row().

    mssql_pconnect

    mssql_pconnect -- ¿µ±¸ÀûÀÎ(persistent) MS SQL connectionÀ» ¿¬´Ù.

    Description

    int mssql_pconnect (string servername, string username, string password);

    Returns: A positive MS SQL persistent link identifier on success, or false on error

    mssql_pconnect() acts very much like mssql_connect() with two major differences.

    First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

    Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mssql_close() will not close links established by mssql_pconnect()).

    This type of links is therefore called 'persistent'.

    mssql_query

    mssql_query -- MS SQL ÁúÀǸ¦ Àü¼ÛÇÑ´Ù.

    Description

    int mssql_query (string query, int link_identifier);

    Returns: A positive MS SQL result identifier on success, or false on error.

    mssql_query() sends a query to the currently active database on the server that's associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed. If no link is open, the function tries to establish a link as if mssql_connect() was called, and use it.

    See also: mssql_db_query(), mssql_select_db(), and mssql_connect().

    mssql_result

    mssql_result -- result data¸¦ ±¸ÇÑ´Ù.

    Description

    int mssql_result (int result, int i, mixed field);

    Returns: The contents of the cell at the row and offset in the specified MS SQL result set.

    mssql_result() returns the contents of one cell from a MS SQL result set. The field argument can be the field's offset, or the field's name, or the field's table dot field's name (fieldname.tablename). If the column name has been aliased ('select foo as bar from...'), use the alias instead of the column name.

    When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than mssql_result(). Also, note that specifying a numeric offset for the field argument is much quicker than specifying a fieldname or tablename.fieldname argument.

    Recommended high-performance alternatives: mssql_fetch_row(), mssql_fetch_array(), and mssql_fetch_object().

    mssql_select_db

    mssql_select_db -- »ç¿ëÇÒ MS SQL database¸¦ ¼±ÅÃÇÑ´Ù.

    Description

    int mssql_select_db (string database_name, int link_identifier);

    Returns: true on success, false on error

    mssql_select_db() sets the current active database on the server that's associated with the specified link identifier. If no link identifier is specified, the last opened link is assumed. If no link is open, the function will try to establish a link as if mssql_connect() was called, and use it.

    Every subsequent call to mssql_query() will be made on the active database.

    See also: mssql_connect(), mssql_pconnect(), and mssql_query()


    XXX. Miscellaneous functions

    ÀÌ ÇÔ¼öµéÀº ±âÁ¸ ¹üÁÖ¿¡ Æ÷ÇÔ½ÃÅ°±â °ï¶õÇÑ °ÍµéÀÌ´Ù.

    Table of Contents
    connection_aborted ¡¦ Return true if client disconnected
    connection_status ¡¦ Returns connection status bitfield
    connection_timeout ¡¦ Return true if script timed out
    define ¡¦ Defines a named constant.
    defined ¡¦ Checks whether a given named constant exists
    die ¡¦ Output a message and terminate the current script
    eval ¡¦ Evaluate a string as PHP code
    exit ¡¦ Terminate current script
    func_get_arg ¡¦ Return an item from the argument list
    func_get_args ¡¦ Returns an array comprising a function's argument list
    func_num_args ¡¦ Returns the number of arguments passed to the function
    function_exists ¡¦ Return true if the given function has been defined
    get_browser ¡¦ Tells what the user's browser is capable of
    ignore_user_abort ¡¦ Set whether a client disconnect should abort script execution
    iptcparse ¡¦ Parse a binary IPTC http://www.xe.net/iptc/ block into single tags.
    leak ¡¦ Leak memory
    pack ¡¦ pack data into binary string
    register_shutdown_function ¡¦ Register a function for execution on shutdown.
    serialize ¡¦ generates a storable representation of a value
    sleep ¡¦ Delay execution
    uniqid ¡¦ generate a unique id
    unpack ¡¦ unpack data from binary string
    unserialize ¡¦ creates a PHP value from a stored representation
    usleep ¡¦ Delay execution in microseconds

    connection_aborted

    (PHP3 >= 3.0.7, PHP4 >= 4.0b4)

    connection_aborted -- Ŭ¶óÀ̾ðÆ®°¡ Á¢¼ÓÀ» ²÷¾ú´Ù¸é true¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int connection_aborted (void )

    Returns true if client disconnected. See the Connection Handling description in the Feature chapter for a complete explanation.

    connection_status

    (PHP3 >= 3.0.7, PHP4 >= 4.0b4)

    connection_status -- ¿¬°á »óŸ¦ bit´ÜÀ§ÀÇ °ªÀ¸·Î ¹ÝȯÇÑ´Ù.

    Description

    int connection_status (void )

    Returns the connection status bitfield. See the Connection Handling description in the Feature chapter for a complete explanation.

    connection_timeout

    (PHP3 >= 3.0.7, PHP4 >= 4.0b4)

    connection_timeout -- ½ºÅ©¸³Æ®°¡ ¼³Á¤µÈ ½Ã°£À» ÃÊ°úÇÏ¿© timed outµÇ¾úÀ¸¸é true¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int connection_timeout (void )

    Returns true if script timed out. See the Connection Handling description in the Feature chapter for a complete explanation.

    define

    (PHP3 , PHP4 )

    define -- »ó¼ö¸¦ ¼±¾ðÇÑ´Ù.

    Description

    int define (string name, mixed value [, int case_insensitive])

    Defines a named constant, which is similar to a variable except:

    The name of the constant is given by name; the value is given by value.

    The optional third parameter case_insensitive is also available. If the value 1 is given, then the constant will be defined case-insensitive. The default behaviour is case-sensitive; i.e. CONSTANT and Constant represent different values.

    Example 1. Defining Constants

      1 
      2 <?php
      3 define ("CONSTANT", "Hello world.");
      4 echo CONSTANT; // outputs "Hello world."
      5 ?>
      6       

    Define() returns TRUE on success and FALSE if an error occurs.

    See also defined() and the section on Constants.

    defined

    (PHP3 , PHP4 )

    defined -- ÁÖ¾îÁø À̸§ÀÇ »ó¼ö°¡ ¼±¾ðµÇ¾î Àִ°¡ °Ë»çÇÑ´Ù.

    Description

    int defined (string name)

    Returns true if the named constant given by name has been defined, false otherwise.

    See also define() and the section on Constants.

    die

    die -- ¸Þ½ÃÁö¸¦ Ãâ·ÂÇÏ°í ÇöÀç ½ºÅ©¸³Æ®ÀÇ ½ÇÇàÀ» Áß´ÜÇÑ´Ù.

    Description

    void die (string message)

    This language construct outputs a message and terminates parsing of the script. It does not return anything.

    Example 1. die example

      1 
      2 <?php
      3 $filename = '/path/to/data-file';
      4 $file = fopen ($filename, 'r')
      5     or die("unable to open file ($filename)");
      6 ?>
      7       

    See also exit().

    eval

    eval -- PHP Äڵ带 °¡Áø ¹®ÀÚ¿­À» ½ÇÇàÇÑ´Ù.

    Description

    void eval (string code_str)

    eval() evaluates the string given in code_str as PHP code. Among other things, this can be useful for storing code in a database text field for later execution.

    There are some factors to keep in mind when using eval(). Remember that the string passed must be valid PHP code, including things like terminating statements with a semicolon so the parser doesn't die on the line after the eval(), and properly escaping things in code_str.

    Also remember that variables given values under eval() will retain these values in the main script afterwards.

    Example 1. Eval() example - simple text merge

      1 
      2 <?php
      3 $string = 'cup';
      4 $name = 'coffee';
      5 $str = 'This is a $string with my $name in it.<br>';
      6 echo $str;
      7 eval ("\$str = \"$str\";");
      8 echo $str;
      9 ?>
     10       

    exit

    exit -- ÇöÀç ½ºÅ©¸³Æ®ÀÇ ½ÇÇàÀ» Áß´ÜÇÑ´Ù.

    Description

    void exit(void);

    This language construct terminates parsing of the script. It does not return.

    See also die().

    func_get_arg

    (PHP4 >= 4.0b4)

    func_get_arg -- ÇÔ¼öÀÇ ÆĶó¸ÞÅÍ·Î ³Ñ¾î¿Â ¾ÆÀÌÅÛÀ» ±¸ÇÑ´Ù.

    Description

    int func_get_arg (int arg_num)

    Returns the argument which is at the arg_num'th offset into a user-defined function's argument list. Function arguments are counted starting from zero. Func_get_arg() will generate a warning if called from outside of a function definition.

    If arg_num is greater than the number of arguments actually passed, a warning will be generated and func_get_arg() will return FALSE.

      1 
      2 <?php
      3 function foo() {
      4      $numargs = func_num_args();
      5      echo "Number of arguments: $numargs<br>\n";
      6      if ($numargs >= 2) {
      7          echo "Second argument is: " . func_get_arg (1) . "<br>\n";
      8      }
      9 } 
     10 
     11 foo (1, 2, 3);
     12 ?>
     13       

    Func_get_arg() may be used in conjunction with func_num_args() and func_get_args() to allow user-defined functions to accept variable-length argument lists.

    Note: This function was added in PHP 4.

    func_get_args

    (PHP4 >= 4.0b4)

    func_get_args -- ÇÔ¼öÀÇ ÆĶó¸ÞÅÍ·Î ³Ñ¾î¿Â argumentµéÀ» ¹è¿­·Î ¹ÝȯÇÑ´Ù.

    Description

    int func_get_args (void )

    Returns an array in which each element is the corresponding member of the current user-defined function's argument list. Func_get_args() will generate a warning if called from outside of a function definition.

      1 
      2 <?php
      3 function foo() {
      4     $numargs = func_num_args();
      5     echo "Number of arguments: $numargs<br>\n";
      6     if ($numargs >= 2) {
      7         echo "Second argument is: " . func_get_arg (1) . "<br>\n";
      8     }
      9     $arg_list = func_get_args();
     10     for ($i = 0; $i < $numargs; $i++) {
     11         echo "Argument $i is: " . $arg_list[$i] . "<br>\n";
     12     }
     13 } 
     14 
     15 foo (1, 2, 3);
     16 ?>
     17       

    Func_get_args() may be used in conjunction with func_num_args() and func_get_arg() to allow user-defined functions to accept variable-length argument lists.

    Note: This function was added in PHP 4.

    func_num_args

    (PHP4 >= 4.0b4)

    func_num_args -- ÇÔ¼ö·Î ³Ñ¾î¿Â ÆĶó¸ÞÅÍÀÇ °¹¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int func_num_args (void )

    Returns the number of arguments passed into the current user-defined function. Func_num_args() will generate a warning if called from outside of a function definition.

      1 
      2 <?php
      3 function foo() {
      4     $numargs = func_num_args();
      5     echo "Number of arguments: $numargs\n";
      6 } 
      7 
      8 foo (1, 2, 3);  // Prints 'Number of arguments: 3'
      9 ?>
     10       

    Func_num_args() may be used in conjunction with func_get_arg() and func_get_args() to allow user-defined functions to accept variable-length argument lists.

    Note: This function was added in PHP 4.

    function_exists

    function_exists -- ÁÖ¾îÁø À̸§ÀÇ ÇÔ¼ö°¡ Á¤ÀǵǾî ÀÖ´Ù¸é true¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int function_exists (string function_name)

    Checks the list of defined functions for function_name. Returns true if the given function name was found, false otherwise.

    get_browser

    (PHP3 , PHP4 )

    get_browser -- »ç¿ëÀÚÀÇ ºê¶ó¿ìÀú°¡ ¾î¶² ±â´ÉÀ» °¡Áö°í Àִ°¡¸¦ ¸»ÇØÁØ´Ù.

    Description

    object get_browser ([string user_agent])

    get_browser() attempts to determine the capabilities of the user's browser. This is done by looking up the browser's information in the browscap.ini file. By default, the value of $HTTP_USER_AGENT is used; however, you can alter this (i.e., look up another browser's info) by passing the optional user_agent parameter to get_browser().

    The information is returned in an object, which will contain various data elements representing, for instance, the browser's major and minor version numbers and ID string; true/false values for features such as frames, JavaScript, and cookies; and so forth.

    While browscap.ini contains information on many browsers, it relies on user updates to keep the database current. The format of the file is fairly self-explanatory.

    The following example shows how one might list all available information retrieved about the user's browser.

    Example 1. Get_browser() example

      1 
      2 <?php
      3 function list_array ($array) {
      4     while (list ($key, $value) = each ($array)) {
      5         $str .= "<b>$key:</b> $value<br>\n";
      6     }
      7     return $str;
      8 }
      9 echo "$HTTP_USER_AGENT<hr>\n";
     10 $browser = get_browser();
     11 echo list_array ((array) $browser);
     12 ?>
     13       

    The output of the above script would look something like this:

      1 
      2 Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr>
      3 <b>browser_name_pattern:</b> Mozilla/4\.5.*<br>
      4 <b>parent:</b> Netscape 4.0<br>
      5 <b>platform:</b> Unknown<br>
      6 <b>majorver:</b> 4<br>
      7 <b>minorver:</b> 5<br>
      8 <b>browser:</b> Netscape<br>
      9 <b>version:</b> 4<br>
     10 <b>frames:</b> 1<br>
     11 <b>tables:</b> 1<br>
     12 <b>cookies:</b> 1<br>
     13 <b>backgroundsounds:</b> <br>
     14 <b>vbscript:</b> <br>
     15 <b>javascript:</b> 1<br>
     16 <b>javaapplets:</b> 1<br>
     17 <b>activexcontrols:</b> <br>
     18 <b>beta:</b> <br>
     19 <b>crawler:</b> <br>
     20 <b>authenticodeupdate:</b> <br>
     21 <b>msn:</b> <br>
     22     

    In order for this to work, your browscap configuration file setting must point to the correct location of the browscap.ini file.

    For more information (including locations from which you may obtain a browscap.ini file), check the PHP FAQ at http://www.php.net/FAQ.php3.

    Note: Browscap support was added to PHP in version 3.0b2.

    ignore_user_abort

    ignore_user_abort -- Ŭ¶óÀ̾ðÆ®°¡ Á¢¼ÓÀ» ²÷¾úÀ» ¶§ ½ºÅ©¸³Æ®ÀÇ ¼öÇàÀ» Áß´ÜÇϴ°¡¸¦ Á¤ÇÑ´Ù.

    Description

    int ignore_user_abort (int [setting]);

    This function sets whether a client disconnect should cause a script to be aborted. It will return the previous setting and can be called without an argument to not change the current setting and only return the current setting. See the Connection Handling section in the Features chapter for a complete description of connection handling in PHP.

    iptcparse

    iptcparse -- binary IPTC http://www.xe.net/iptc/ blockÀ» ÇϳªÀÇ ÅÃÀ¸·Î parseÇÑ´Ù.

    Description

    array iptcparse (string iptcblock);

    This function parses a binary IPTC block into its single tags. It returns an array using the tagmarker as an index and the value as the value. It returns false on error or if no IPTC data was found. See GetImageSize() for a sample.

    leak

    leak -- ¸Þ¸ð¸®¸¦ ´©¼³(Leak) ÇÑ´Ù.

    Description

    void leak (int bytes)

    Leak() leaks the specified amount of memory.

    This is useful when debugging the memory manager, which automatically cleans up "leaked" memory when each request is completed.

    pack

    pack -- data¸¦ binary ¹®ÀÚ¿­·Î packÇÑ´Ù.

    Description

    string pack (string format [, mixed args ...])

    Pack given arguments into binary string according to format. Returns binary string containing data.

    The idea to this function was taken from Perl and all formatting codes work the same as there. The format string consists of format codes followed by an optional repeater argument. The repeater argument can be either an integer value or * for repeating to the end of the input data. For a, A, h, H the repeat count specifies how many characters of one data argument are taken, for @ it is the absolute position where to put the next data, for everything else the repeat count specifies how many data arguments are consumed and packed into the resulting binary string. Currently implemented are

    Note that the distinction between signed and unsigned values only affects the function unpack(), where as function pack() gives the same result for signed and unsigned format codes.

    Also note that PHP internally stores integral values as signed values of a machine dependant size. If you give it an unsigned integral value too large to be stored that way it is converted to a double which often yields an undesired result.

    register_shutdown_function

    register_shutdown_function -- ½ºÅ©¸³Æ®°¡ Á¾·áµÉ ¶§ ½ÇÇàµÉ ÇÔ¼ö¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int register_shutdown_function (string func)

    Registers the function named by func to be executed when script processing is complete.

    Common Pitfalls:

    Since no output is allowed to the browser in this function, you will be unable to debug it using statements such as print or echo.

    serialize

    serialize -- ¾î¶² ÇüÅÂÀÇ °ªÀÌ¶óµµ ÀúÀå °¡´ÉÇÑ ÇüÅÂÀÇ ¹®ÀÚ¿­·Î ¸¸µé¾î ÁØ´Ù.

    Description

    string serialize (mixed value)

    Serialize() returns a string containing a byte-stream representation of value that can be stored anywhere.

    This is useful for storing or passing PHP values around without losing their type and structure.

    To make the serialized string into a PHP value again, use unserialize(). Serialize() handles the types integer, double, string, array (multidimensional) and object (object properties will be serialized, but methods are lost).

    Example 1. Serialize() example

      1 
      2 // $session_data contains a multi-dimensional array with session
      3 // information for the current user.  We use serialize() to store
      4 // it in a database at the end of the request.
      5 
      6 $conn = odbc_connect ("webdb", "php", "chicken");
      7 $stmt = odbc_prepare ($conn,
      8                       "UPDATE sessions SET data = ? WHERE id = ?");
      9 $sqldata = array (serialize($session_data), $PHP_AUTH_USER);
     10 if (!odbc_execute ($stmt, &$sqldata)) {
     11     $stmt = odbc_prepare($conn,
     12                          "INSERT INTO sessions (id, data) VALUES(?, ?)");
     13     if (!odbc_execute($stmt, &$sqldata)) {
     14         /* Something went wrong.  Bitch, whine and moan. */
     15     }
     16 }
     17       

    sleep

    sleep -- ½ÇÇàÀ» Àá½Ã Áö¿¬½ÃŲ´Ù.

    Description

    void sleep (int seconds)

    The sleep function delays program execution for the given number of seconds.

    See also usleep().

    uniqid

    uniqid -- À¯ÀÏÇÑ id¸¦ »ý¼ºÇÑ´Ù.

    Description

    int uniqid (string prefix [, boolean lcg])

    Uniqid() returns a prefixed unique identifier based on the current time in microseconds. The prefix can be useful for instance if you generate identifiers simultaneously on several hosts that might happen to generate the identifier at the same microsecond. Prefix can be up to 114 characters long.

    If the optional lcg parameter is true, uniqid() will add additional "combined LCG" entropy at the end of the return value, which should make the results more unique.

    With an empty prefix, the returned string will be 13 characters long. If lcg is true, it will be 23 characters.

    Note: The lcg parameter is only available in PHP 4 and PHP 3.0.13 and later.

    If you need a unique identifier or token and you intend to give out that token to the user via the network (i.e. session cookies), it is recommended that you use something along the lines of

      1 
      2 $token = md5 (uniqid ("")); // no random portion
      3 $better_token = md5 (uniqid (rand())); // better, difficult to guess
      4       

    This will create a 32 character identifier (a 128 bit hex number) that is extremely difficult to predict.

    unpack

    unpack -- binary ¹®ÀÚ¿­À» data·Î unpackÇÑ´Ù.

    Description

    array unpack (string format, string data)

    Unpack() from binary string into array according to format. Returns array containing unpacked elements of binary string.

    Unpack() works slightly different from Perl as the unpacked data is stored in an associative array. To accomplish this you have to name the different format codes and separate them by a slash /.

    Example 1. Unpack() format string

      1 
      2 $array = unpack ("c2chars/nint", $binarydata);
      3       

    The resulting array will contain the entries "chars1", "chars2" and "int".

    For an explanation of the format codes see also: pack()

    Note that PHP internally stores integral values as signed. If you unpack a large unsigned long and it is of the same size as PHP internally stored values the result will be a negative number even though unsigned unpacking was specified.

    unserialize

    unserialize -- ÀúÀå°¡´ÉÇÑ ÇüÅ·ΠǥÇöµÈ ¹®ÀÚ¿­À» PHP °ªÀ¸·Î ¸¸µé¾îÁØ´Ù.

    Description

    mixed unserialize (string str)

    unserialize() takes a single serialized variable (see serialize()) and converts it back into a PHP value. The converted value is returned, and can be an integer, double, string, array or object. If an object was serialized, its methods are not preserved in the returned value.

    Example 1. Unserialize() example

      1 
      2 // Here, we use unserialize() to load session data from a database
      3 // into $session_data.  This example complements the one described
      4 // with serialize().
      5 
      6 $conn = odbc_connect ("webdb", "php", "chicken");
      7 $stmt = odbc_prepare ($conn, "SELECT data FROM sessions WHERE id = ?");
      8 $sqldata = array ($PHP_AUTH_USER);
      9 if (!odbc_execute ($stmt, &$sqldata) || !odbc_fetch_into ($stmt, &$tmp)) {
     10     // if the execute or fetch fails, initialize to empty array
     11     $session_data = array();
     12 } else {
     13     // we should now have the serialized data in $tmp[0].
     14     $session_data = unserialize ($tmp[0]);
     15     if (!is_array ($session_data)) {
     16         // something went wrong, initialize to empty array
     17         $session_data = array();
     18     }
     19 }
     20       

    usleep

    usleep -- ½ÇÇàÀ» ¹é¸¸ºÐÀÇ ÀÏÃÊ ´ÜÀ§·Î Áö¿¬½ÃŲ´Ù.

    Description

    void usleep (int micro_seconds)

    The usleep() function delays program execution for the given number of micro_seconds.

    See also sleep().


    XXXVII. mSQL functions

    Table of Contents
    msql ¡¦ send mSQL query
    msql_affected_rows ¡¦ returns number of affected rows
    msql_close ¡¦ close mSQL connection
    msql_connect ¡¦ open mSQL connection
    msql_create_db ¡¦ create mSQL database
    msql_createdb ¡¦ create mSQL database
    msql_data_seek ¡¦ move internal row pointer
    msql_dbname ¡¦ get current mSQL database name
    msql_drop_db ¡¦ drop (delete) mSQL database
    msql_dropdb ¡¦ drop (delete) mSQL database
    msql_error ¡¦ returns error message of last msql call
    msql_fetch_array ¡¦ fetch row as array
    msql_fetch_field ¡¦ get field information
    msql_fetch_object ¡¦ fetch row as object
    msql_fetch_row ¡¦ get row as enumerated array
    msql_fieldname ¡¦ get field name
    msql_field_seek ¡¦ set field offset
    msql_fieldtable ¡¦ get table name for field
    msql_fieldtype ¡¦ get field type
    msql_fieldflags ¡¦ get field flags
    msql_fieldlen ¡¦ get field length
    msql_free_result ¡¦ free result memory
    msql_freeresult ¡¦ free result memory
    msql_list_fields ¡¦ list result fields
    msql_listfields ¡¦ list result fields
    msql_list_dbs ¡¦ list mSQL databases on server
    msql_listdbs ¡¦ list mSQL databases on server
    msql_list_tables ¡¦ list tables in an mSQL database
    msql_listtables ¡¦ list tables in an mSQL database
    msql_num_fields ¡¦ get number of fields in result
    msql_num_rows ¡¦ get number of rows in result
    msql_numfields ¡¦ get number of fields in result
    msql_numrows ¡¦ get number of rows in result
    msql_pconnect ¡¦ open persistent mSQL connection
    msql_query ¡¦ send mSQL query
    msql_regcase ¡¦ make regular expression for case insensitive match
    msql_result ¡¦ get result data
    msql_select_db ¡¦ select mSQL database
    msql_selectdb ¡¦ select mSQL database
    msql_tablename ¡¦ get table name of field

    msql

    msql -- mSQL ÁúÀǸ¦ Àü¼ÛÇÑ´Ù.

    Description

    int msql(string database, string query, int link_identifier);

    Returns a positive mSQL result identifier to the query result, or false on error.

    msql() selects a database and executes a query on it. If the optional link identifier isn't specified, the function will try to find an open link to the mSQL server and if no such link is found it'll try to create one as if msql_connect() was called with no arguments (see msql_connect()).

    msql_affected_rows

    msql_affected_rows -- ÃÖ±Ù ÁúÀÇ¿¡ ¿µÇâÀ» ¹Þ´Â rowÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int msql_affected_rows(int query_identifier);

    Returns number of affected ("touched") rows by a specific query (i.e. the number of rows returned by a SELECT, the number of rows modified by an update, or the number of rows removed by a delete).

    See also: msql_query()

    msql_close

    msql_close -- mSQL connectionÀ» ´Ý´Â´Ù.

    Description

    int msql_close(int link_identifier);

    Returns true on success, false on error.

    msql_close() closes the link to a mSQL database that's associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed.

    Note that this isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.

    msql_close() will not close persistent links generated by msql_pconnect().

    See also: msql_connect() and msql_pconnect().

    msql_connect

    msql_connect -- mSQL connectionÀ» ¿¬´Ù.

    Description

    int msql_connect(string hostname);

    Returns a positive mSQL link identifier on success, or false on error.

    msql_connect() establishes a connection to a mSQL server. The hostname argument is optional, and if it's missing, localhost is assumed.

    In case a second call is made to msql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned.

    The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling msql_close().

    See also msql_pconnect(), msql_close().

    msql_create_db

    msql_create_db -- mSQL database¸¦ ¸¸µç´Ù.

    Description

    int msql_create_db(string database name, int [link_identifier] );

    msql_create_db() attempts to create a new database on the server associated with the specified link identifier.

    See also: msql_drop_db().

    msql_createdb

    msql_createdb -- mSQL database¸¦ ¸¸µç´Ù.

    Description

    int msql_createdb(string database name, int [link_identifier] );

    Identical to msql_create_db().

    msql_data_seek

    msql_data_seek -- ³»ºÎÀûÀÎ row pointer¸¦ À̵¿ÇÑ´Ù.

    Description

    int msql_data_seek(int result_identifier, int row_number);

    Returns true on success, false on failure.

    msql_data_seek() moves the internal row pointer of the mSQL result associated with the specified result identifier to pointer to the specifyed row number. The next call to msql_fetch_row() would return that row.

    See also: msql_fetch_row().

    msql_dbname

    msql_dbname -- ÇöÀç mSQL databaseÀÇ À̸§À» ±¸ÇÑ´Ù.

    Description

    string msql_dbname(string result, int i);

    msql_dbname() returns the database name stored in position i of the result pointer returned from the msql_listdbs() function. The msql_numrows() function can be used to determine how many database names are available.

    msql_drop_db

    msql_drop_db -- mSQL database¸¦ ¹ö¸°´Ù.(drop = delete)

    Description

    int msql_drop_db(string database_name, int link_identifier);

    Returns true on success, false on failure.

    msql_drop_db() attempts to drop (remove) an entire database from the server associated with the specified link identifier.

    See also: msql_create_db().

    msql_dropdb

    msql_dropdb -- mSQL database¸¦ ¹ö¸°´Ù.(drop = delete)

    Description

    See msql_drop_db().

    msql_error

    msql_error -- ¸¶Áö¸· mSQL È£ÃâÀÇ ¿¡·¯ ¸Þ¼¼Áö¸¦ ¹ÝȯÇÑ´Ù.

    Description

    string msql_error( );

    Errors coming back from the mSQL database backend no longer issue warnings. Instead, use these functions to retrieve the error string.

    msql_fetch_array

    msql_fetch_array -- row¸¦ ¹è¿­·Î °¡Á®¿Â´Ù.

    Description

    int msql_fetch_array(int query_identifier, int [result_type] );

    Returns an array that corresponds to the fetched row, or false if there are no more rows.

    msql_fetch_array() is an extended version of msql_fetch_row(). In addition to storing the data in the numeric indices of the result array, it also stores the data in associative indices, using the field names as keys.

    The second optional argument result_type in msql_fetch_array() is a constant and can take the following values: MSQL_ASSOC, MSQL_NUM, and MYSQL_BOTH.

    Be careful if you are retrieving results from a query that may return a record that contains only one field that has a value of 0 (or an empty string, or NULL).

    An important thing to note is that using msql_fetch_array() is NOT significantly slower than using msql_fetch_row(), while it provides a significant added value.

    For further details, also see msql_fetch_row()

    msql_fetch_field

    msql_fetch_field -- Çʵå Á¤º¸¸¦ ±¸ÇÑ´Ù.

    Description

    object msql_fetch_field(int query_identifier, int field_offset);

    Returns an object containing field information

    msql_fetch_field() can be used in order to obtain information about fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retreived by msql_fetch_field() is retreived.

    The properties of the object are:

    See also msql_field_seek().

    msql_fetch_object

    msql_fetch_object -- row¸¦ °´Ã¼(Object)·Î °¡Á®¿Â´Ù.

    Description

    int msql_fetch_object(int query_identifier, int [result_type] );

    Returns an object with properties that correspond to the fetched row, or false if there are no more rows.

    msql_fetch_object() is similar to msql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

    The optional second argument result_type in msql_fetch_array() is a constant and can take the following values: MSQL_ASSOC, MSQL_NUM, and MSQL_BOTH.

    Speed-wise, the function is identical to msql_fetch_array(), and almost as quick as msql_fetch_row() (the difference is insignificant).

    See also: msql_fetch_array() and msql_fetch_row().

    msql_fetch_row

    msql_fetch_row -- row¸¦ ¹è¿­(enumerated array)·Î °¡Á®¿Â´Ù.

    Description

    array msql_fetch_row(int query_identifier);

    Returns an array that corresponds to the fetched row, or false if there are no more rows.

    msql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

    Subsequent call to msql_fetch_row() would return the next row in the result set, or false if there are no more rows.

    See also: msql_fetch_array(), msql_fetch_object(), msql_data_seek(), and msql_result().

    msql_fieldname

    msql_fieldname -- Çʵå À̸§À» ±¸ÇÑ´Ù.

    Description

    string msql_fieldname(int query_identifier, int field);

    msql_fieldname() returns the name of the specified field. query_identifier is the query identifier, and field is the field index. msql_fieldname($result, 2); will return the name of the second field in the result associated with the result identifier.

    msql_field_seek

    msql_field_seek -- ÇʵåÀÇ offsetÀ» ¼³Á¤ÇÑ´Ù.

    Description

    int msql_field_seek(int query_identifier, int field_offset);

    Seeks to the specified field offset. If the next call to msql_fetch_field() won't include a field offset, this field would be returned.

    See also: msql_fetch_field().

    msql_fieldtable

    msql_fieldtable -- ÇØ´ç Çʵ带 °¡Á® ¿Â Table À̸§À» ±¸ÇÑ´Ù.

    Description

    int msql_fieldtable(int result, int field);

    Returns the name of the table field was fetched from.

    msql_fieldtype

    msql_fieldtype -- Çʵå typeÀ» ±¸ÇÑ´Ù.

    Description

    string msql_fieldtype(int query_identifier, int i);

    msql_fieldtype() is similar to the msql_fieldname() function. The arguments are identical, but the field type is returned. This will be one of "int", "string" or "real".

    msql_fieldflags

    msql_fieldflags -- Çʵå flag¸¦ ±¸ÇÑ´Ù.

    Description

    string msql_fieldflags(int query_identifier, int i);

    msql_fieldflags() returns the field flags of the specified field. Currently this is either, "not null", "primary key", a combination of the two or "" (an empty string).

    msql_fieldlen

    msql_fieldlen -- ÇÊµå ±æÀ̸¦ ±¸ÇÑ´Ù.

    Description

    int msql_fieldlen(int query_identifier, int i);

    msql_fieldlen() returns the length of the specified field.

    msql_free_result

    msql_free_result -- result memory¸¦ Ç®¾îÁØ´Ù.

    Description

    int msql_free_result(int query_identifier);

    msql_free_result() frees the memory associated with query_identifier. When PHP completes a request, this memory is freed automatically, so you only need to call this function when you want to make sure you don't use too much memory while the script is running.

    msql_freeresult

    msql_freeresult -- result memory¸¦ Ç®¾îÁØ´Ù.

    Description

    See msql_free_result()

    msql_list_fields

    msql_list_fields -- result fieldµéÀ» ³ª¿­ÇÑ´Ù.

    Description

    int msql_list_fields(string database, string tablename);

    msql_list_fields() retrieves information about the given tablename. Arguments are the database name and the table name. A result pointer is returned which can be used with msql_fieldflags(), msql_fieldlen(), msql_fieldname(), and msql_fieldtype(). A query identifier is a positive integer. The function returns -1 if a error occurs. A string describing the error will be placed in $phperrmsg, and unless the function was called as @msql_list_fields() then this error string will also be printed out.

    See also msql_error().

    msql_listfields

    msql_listfields -- result fieldµéÀ» ³ª¿­ÇÑ´Ù.

    Description

    See msql_list_fields().

    msql_list_dbs

    msql_list_dbs -- serverÀÇ mSQL databaseµéÀ» ³ª¿­ÇÑ´Ù.

    Description

    int msql_list_dbs(void);

    msql_list_dbs() will return a result pointer containing the databases available from the current msql daemon. Use the msql_dbname() function to traverse this result pointer.

    msql_listdbs

    msql_listdbs -- serverÀÇ mSQL databaseµéÀ» ³ª¿­ÇÑ´Ù.

    Description

    See msql_list_dbs().

    msql_list_tables

    msql_list_tables -- mSQL databaseÀÇ tableµéÀ» ³ª¿­ÇÑ´Ù.

    Description

    int msql_list_tables(string database);

    msql_list_tables() takes a database name and result pointer much like the msql() function. The msql_tablename() function should be used to extract the actual table names from the result pointer.

    msql_listtables

    msql_listtables -- mSQL databaseÀÇ tableµéÀ» ³ª¿­ÇÑ´Ù.

    Description

    See msql_list_tables().

    msql_num_fields

    msql_num_fields -- resultÀÇ field °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int msql_num_fields(int result);

    msql_num_fields() returns the number of fields in a result set.

    See also: msql(), msql_query(), msql_fetch_field(), and msql_num_rows().

    msql_num_rows

    msql_num_rows -- resultÀÇ row °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int msql_num_rows(string result);

    msql_num_rows() returns the number of rows in a result set.

    See also: msql(), msql_query(), and msql_fetch_row().

    msql_numfields

    msql_numfields -- resultÀÇ field °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int msql_numfields(void);

    Identical to msql_num_fields().

    msql_numrows

    msql_numrows -- resultÀÇ row °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int msql_numrows(void);

    Identical to msql_num_rows().

    msql_pconnect

    msql_pconnect -- ¿µ±¸ÀûÀÎ mSQL Á¢¼ÓÀ» ¿¬´Ù.

    Description

    int msql_pconnect(string hostname);

    Returns a positive mSQL persistent link identifier on success, or false on error.

    msql_pconnect() acts very much like msql_connect() with two major differences.

    First, when connecting, the function would first try to find a (persistent) link that's already open with the same host. If one is found, an identifier for it will be returned instead of opening a new connection.

    Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (msql_close() will not close links established by msql_pconnect()).

    This type of links is therefore called 'persistent'.

    msql_query

    msql_query -- mSQL ÁúÀǸ¦ Àü¼ÛÇÑ´Ù.

    Description

    int msql_query(string query, int link_identifier);

    msql_query() sends a query to the currently active database on the server that's associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed. If no link is open, the function tries to establish a link as if msql_connect() was called, and use it.

    Returns a positive mSQL result identifier on success, or false on error.

    See also: msql(), msql_select_db(), and msql_connect().

    msql_regcase

    msql_regcase -- Á¤±Ô Ç¥Çö½Ä(regular expression)À» ´ë,¼Ò¹®ÀÚ¸¦ °¡¸®Áö ¾Êµµ·Ï ÇÑ´Ù.

    Description

    See sql_regcase().

    msql_result

    msql_result -- result data¸¦ ±¸ÇÑ´Ù.

    Description

    int msql_result(int query_identifier, int i, mixed field);

    Returns the contents of the cell at the row and offset in the specified mSQL result set.

    msql_result() returns the contents of one cell from a mSQL result set. The field argument can be the field's offset, or the field's name, or the field's table dot field's name (fieldname.tablename). If the column name has been aliased ('select foo as bar from...'), use the alias instead of the column name.

    When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than msql_result(). Also, note that specifying a numeric offset for the field argument is much quicker than specifying a fieldname or tablename.fieldname argument.

    Recommended high-performance alternatives: msql_fetch_row(), msql_fetch_array(), and msql_fetch_object().

    msql_select_db

    msql_select_db -- mSQL database¸¦ ¼±ÅÃÇÑ´Ù.

    Description

    int msql_select_db(string database_name, int link_identifier);

    Returns true on success, false on error.

    msql_select_db() sets the current active database on the server that's associated with the specified link identifier. If no link identifier is specified, the last opened link is assumed. If no link is open, the function will try to establish a link as if msql_connect() was called, and use it.

    Every subsequent call to msql_query() will be made on the active database.

    See also: msql_connect(), msql_pconnect(), and msql_query().

    msql_selectdb

    msql_selectdb -- mSQL database¸¦ ¼±ÅÃÇÑ´Ù.

    Description

    See msql_select_db().

    msql_tablename

    msql_tablename -- ÇØ´ç Çʵ带 °¡Á® ¿Â Table À̸§À» ±¸ÇÑ´Ù.

    Description

    string msql_tablename(int query_identifier, int field);

    msql_tablename() takes a result pointer returned by the msql_list_tables() function as well as an integer index and returns the name of a table. The msql_numrows() function may be used to determine the number of tables in the result pointer.

    Example 1. Msql_tablename() example

      1 
      2 <?php 
      3 msql_connect ("localhost");
      4 $result = msql_list_tables ("wisconsin");
      5 $i = 0;
      6 while ($i < msql_numrows ($result)) {
      7     $tb_names[$i] = msql_tablename ($result, $i);
      8     echo $tb_names[$i] . "<BR>";
      9     $i++; 
     10 }
     11 ?>
     12       

    XXXVIII. MySQL functions

    ÀÌ ÇÔ¼öµéÀº MySQL µ¥ÀÌÅͺ£À̽º ¼­¹ö¿¡ Á¢±ÙÇÒ ¼ö ÀÖµµ·Ï ÇØ ÁØ´Ù.

    MySQL¿¡ ´ëÇÑ Á» ´õ ÀÚ¼¼ÇÑ ¼³¸íÀº http://www.mysql.com/¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.

    ( ¿ªÀÚÁÖ : Solaris MySQL with pthreads note:
    ¸¸¾à ¿©·¯ºÐÀÌ MySQLÀÌ threaded client library(default´Â ¾Æ´Ï´Ù)¸¦ »ç¿ëÇÏ°í, PHP¸¦ MySQLÁö¿øÀ¸·Î ÄÄÆÄÀÏÇÑ´Ù¸é ¾Æ¸¶ ¿©·¯ºÐÀº ´ÙÀ½°ú °°Àº ¿¡·¯¸¦ ¸¸³ª°Ô µÈ´Ù....

    Undefined first referenced
    symbol in file
    pthread_attr_setschedparam /opt/GNUmysql/lib/mysql/libmysqlclient.a(my_pthread.o)
    pthread_setschedparam /opt/GNUmysql/lib/mysql/libmysqlclient.a(my_pthread.o)

    À̶§´Â MakefileÀ» ¼ÕÀ¸·Î °íÃÄÁÖ¾î¾ß ÇÑ´Ù. "LIBS"·Î ½ÃÀ۵Ǵ ÁÙÀ» ã¾Æ "-lpthreads"¸¦ ÁÙÀÇ ¸¶Áö¸·¿¡ »ðÀÔÇÑ´Ù. ±×ÈÄ¿¡ "make"ÇÏ¸é µÉ °ÍÀÌ´Ù.)

    Table of Contents
    mysql_affected_rows ¡¦ Get number of affected rows in previous MySQL operation
    mysql_change_user ¡¦ Change logged in user on active connection
    mysql_close ¡¦ close MySQL connection
    mysql_connect ¡¦ Open a connection to a MySQL Server
    mysql_create_db ¡¦ Create a MySQL database
    mysql_data_seek ¡¦ Move internal result pointer
    mysql_db_query ¡¦ Send an MySQL query to MySQL
    mysql_drop_db ¡¦ Drop (delete) a MySQL database
    mysql_errno ¡¦ Returns the number of the error message from previous MySQL operation
    mysql_error ¡¦ Returns the text of the error message from previous MySQL operation
    mysql_fetch_array ¡¦ Fetch a result row as an associative array
    mysql_fetch_field ¡¦ Get column information from a result and return as an object
    mysql_fetch_lengths ¡¦ Get max data size of each output in a result
    mysql_fetch_object ¡¦ Fetch a result row as an object
    mysql_fetch_row ¡¦ Get a result row as an enumerated array
    mysql_field_name ¡¦ Get the name of the specified field in a result
    mysql_field_seek ¡¦ Set result pointer to a specified field offset
    mysql_field_table ¡¦ Get name of the table the specified field is in
    mysql_field_type ¡¦ Get the type of the specified field in a result
    mysql_field_flags ¡¦ Get the flags associated with the specified field in a result
    mysql_field_len ¡¦ Returns the length of the specified field
    mysql_free_result ¡¦ Free result memory
    mysql_insert_id ¡¦ Get the id generated from the previous INSERT operation
    mysql_list_fields ¡¦ List MySQL result fields
    mysql_list_dbs ¡¦ List databases available on on MySQL server
    mysql_list_tables ¡¦ List tables in a MySQL database
    mysql_num_fields ¡¦ Get number of fields in result
    mysql_num_rows ¡¦ Get number of rows in result
    mysql_pconnect ¡¦ Open a persistent connection to a MySQL Server
    mysql_query ¡¦ Send an SQL query to MySQL
    mysql_result ¡¦ Get result data
    mysql_select_db ¡¦ Select a MySQL database
    mysql_tablename ¡¦ get table name of field

    mysql_affected_rows

    mysql_affected_rows -- ÃÖ±Ù ÁúÀÇ¿¡ ¿µÇâÀ» ¹Þ´Â rowÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int mysql_affected_rows(int [link_identifier] );

    mysql_affected_rows() returns the number of rows affected by the last INSERT, UPDATE or DELETE query on the server associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed.

    If the last query was a DELETE query with no WHERE clause, all of the records will have been deleted from the table but this function will return zero.

    This command is not effective for SELECT statements, only on statements which modify records. To retrieve the number of rows returned from a SELECT, use mysql_num_rows().

    mysql_change_user

    (PHP3 >= 3.0.13)

    mysql_change_user -- ÇöÀç È°¼ºÈ­ µÇ¾îÀÖ´Â ¿¬°á¿¡ LOGINµÇ¾îÀÖ´Â »ç¿ëÀÚ¸¦ ¹Ù²Û´Ù.

    Description

    int mysql_change_user (string user, string password [, string database [, int link_identifier]])

    mysql_change_user() changes the logged in user on the current active connection, or, if specified on the connection given by the link identifier. If a database is specified, this will default or current database after the user has been changed. If the new user/password combination fails to be authorized the current connected user stays active.

    Note: This function was introduced in PHP 3.0.13 and requires MySQL 3.23.3 or higher.

    mysql_close

    mysql_close -- MySQL connectionÀ» ´Ý´Â´Ù.

    Description

    int mysql_close(int [link_identifier] );

    Returns: true on success, false on error

    mysql_close() closes the link to a MySQL database that's associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed.

    Note that this isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.

    mysql_close() will not close persistent links generated by mysql_pconnect().

    See also: mysql_connect(), and mysql_pconnect().

    mysql_connect

    mysql_connect -- MySQL server connectionÀ» ¿¬´Ù.

    Description

    int mysql_connect(string [hostname [:port] [:/path/to/socket] ] , string [username] , string [password] );

    Returns: A positive MySQL link identifier on success, or false on error.

    mysql_connect() establishes a connection to a MySQL server. All of the arguments are optional, and if they're missing, defaults are assumed ('localhost', user name of the user that owns the server process, empty password).

    The hostname string can also include a port number. eg. "hostname:port" or a path to a socket eg. ":/path/to/socket" for the localhost.

    Note: Support for ":port" wass added in 3.0B4.

    Support for the ":/path/to/socket" was added in 3.0.10.

    In case a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned.

    The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mysql_close().

    See also mysql_pconnect(), and mysql_close().

    mysql_create_db

    mysql_create_db -- MySQL database¸¦ ¸¸µç´Ù.

    Description

    int mysql_create_db(string database name, int [link_identifier] );

    mysql_create_db() attempts to create a new database on the server associated with the specified link identifier.

    See also: mysql_drop_db(). For downwards compatibility mysql_createdb() can also be used.

    mysql_data_seek

    mysql_data_seek -- internal row pointer¸¦ ¿Å±ä´Ù.

    Description

    int mysql_data_seek(int result_identifier, int row_number);

    Returns: true on success, false on failure

    mysql_data_seek() moves the internal row pointer of the MySQL result associated with the specified result identifier to point to the specified row number. The next call to mysql_fetch_row() would return that row.

    mysql_db_query

    mysql_db_query -- MySQL ÁúÀǸ¦ Àü¼ÛÇÑ´Ù.

    Description

    int mysql_db_query(string database, string query, int [link_identifier]);

    Returns: A positive MySQL result identifier to the query result, or false on error.

    mysql_db_query() selects a database and executes a query on it. If the optional link identifier isn't specified, the function will try to find an open link to the MySQL server and if no such link is found it'll try to create one as if mysql_connect() was called with no arguments

    See also mysql_connect(). For downwards compatibility mysql() can also be used.

    mysql_drop_db

    mysql_drop_db -- MySQL database¸¦ ¹ö¸°´Ù.(drop = delete)

    Description

    int mysql_drop_db(string database_name, int [link_identifier] );

    Returns: true on success, false on failure.

    mysql_drop_db() attempts to drop (remove) an entire database from the server associated with the specified link identifier.

    See also: mysql_create_db(). For downward compatibility mysql_dropdb() can also be used.

    mysql_errno

    mysql_errno -- ¸¶Áö¸· MySQL È£ÃâÀÇ ¿¡·¯ ¹øÈ£¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int mysql_errno(int [link_identifier] );

    Errors coming back from the mySQL database backend no longer issue warnings. Instead, use these functions to retrieve the error number.

    <?php
    mysql_connect("marliesle");
    echo mysql_errno().": ".mysql_error()."<BR>";
    mysql_select_db("nonexistentdb");
    echo mysql_errno().": ".mysql_error()."<BR>";
    $conn = mysql_query("SELECT * FROM nonexistenttable");
    echo mysql_errno().": ".mysql_error()."<BR>";
    ?>

    See also: mysql_error()

    mysql_error

    mysql_error -- ¸¶Áö¸· MySQL È£ÃâÀÇ ¿¡·¯ ¸Þ¼¼Áö¸¦ ¹ÝȯÇÑ´Ù.

    Description

    string mysql_error(int [link_identifier] );

    Errors coming back from the mySQL database backend no longer issue warnings. Instead, use these functions to retrieve the error string.

    <?php
    mysql_connect("marliesle");
    echo mysql_errno().": ".mysql_error()."<BR>";
    mysql_select_db("nonexistentdb");
    echo mysql_errno().": ".mysql_error()."<BR>";
    $conn = mysql_query("SELECT * FROM nonexistenttable");
    echo mysql_errno().": ".mysql_error()."<BR>";
    ?>

    See also: mysql_errno()

    mysql_fetch_array

    mysql_fetch_array -- row¸¦ ¹è¿­·Î °¡Á®¿Â´Ù.

    Description

    array mysql_fetch_array(int result, int [result_type] );

    Returns an array that corresponds to the fetched row, or false if there are no more rows.

    mysql_fetch_array() is an extended version of mysql_fetch_row(). In addition to storing the data in the numeric indices of the result array, it also stores the data in associative indices, using the field names as keys.

    If two or more columns of the result have the same field names, the last column will take precedence. To access the other column(s) of the same name, you must the numeric index of the column or make an alias for the column.

    select t1.f1 as foo t2.f1 as bar from t1, t2

    An important thing to note is that using mysql_fetch_array() is NOT significantly slower than using mysql_fetch_row(), while it provides a significant added value.

    The optional second argument result_type in mysql_fetch_array() is a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH.

    For further details, also see mysql_fetch_row()

    Example 1. mysql fetch array

    <?php 
    mysql_connect($host,$user,$password);
    $result = mysql_db_query("database","select * from table");
    while($row = mysql_fetch_array($result)) {
        echo $row["user_id"];
        echo $row["fullname"];
    }
    mysql_free_result($result);
    ?>

    mysql_fetch_field

    mysql_fetch_field -- Çʵå Á¤º¸¸¦ ±¸ÇÑ´Ù.

    Description

    object mysql_fetch_field(int result, int [field_offset] );

    Returns an object containing field information.

    mysql_fetch_field() can be used in order to obtain information about fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retreived by mysql_fetch_field() is retreived.

    The properties of the object are:

    See also mysql_field_seek()

    mysql_fetch_lengths

    mysql_fetch_lengths -- output columnÀÇ ÃÖ´ë data ±æÀ̸¦ ±¸ÇÑ´Ù.

    Description

    int mysql_fetch_lengths(int result);

    Returns: An array that corresponds to the lengths of each field in the last row fetched by mysql_fetch_row(), or false on error.

    mysql_fetch_lengths() stores the lengths of each result column in the last row returned by mysql_fetch_row() in an array, starting at offset 0.

    See also: mysql_fetch_row().

    mysql_fetch_object

    mysql_fetch_object -- row¸¦ °´Ã¼(Object)·Î °¡Á®¿Â´Ù.

    Description

    object mysql_fetch_object(int result, int [result_type]);

    Returns an object with properties that correspond to the fetched row, or false if there are no more rows.

    mysql_fetch_object() is similar to mysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

    The optional argument result_typ is a constant and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH.

    Speed-wise, the function is identical to mysql_fetch_array(), and almost as quick as mysql_fetch_row() (the difference is insignificant).

    Example 1. mysql fetch object

    <?php 
    mysql_connect($host,$user,$password);
    $result = mysql_db_query("database","select * from table");
    while($row = mysql_fetch_object($result)) {
        echo $row->user_id;
        echo $row->fullname;
    }
    mysql_free_result($result);
    ?>

    See also: mysql_fetch_array() and mysql_fetch_row().

    mysql_fetch_row

    mysql_fetch_row -- row¸¦ ¹è¿­(enumerated array)·Î °¡Á®¿Â´Ù.

    Description

    array mysql_fetch_row(int result);

    Returns: An array that corresponds to the fetched row, or false if there are no more rows.

    mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

    Subsequent call to mysql_fetch_row() would return the next row in the result set, or false if there are no more rows.

    See also: mysql_fetch_array(), mysql_fetch_object(), mysql_data_seek(), mysql_fetch_lengths(), and mysql_result().

    mysql_field_name

    mysql_field_name -- Çʵå À̸§À» ±¸ÇÑ´Ù.

    Description

    string mysql_field_name(int result, int field_index);

    mysql_field_name() returns the name of the specified field. Arguments to the function is the result identifier and the field index, ie. mysql_field_name($result,2);

    Will return the name of the second field in the result associated with the result identifier.

    For downwards compatibility mysql_fieldname() can also be used.

    mysql_field_seek

    mysql_field_seek -- ÇʵåÀÇ offsetÀ» ¼³Á¤ÇÑ´Ù.

    Description

    int mysql_field_seek(int result, int field_offset);

    Seeks to the specified field offset. If the next call to mysql_fetch_field() won't include a field offset, this field would be returned.

    See also: mysql_fetch_field().

    mysql_field_table

    mysql_field_table -- ÇØ´ç Çʵ带 °¡Á® ¿Â Table À̸§À» ±¸ÇÑ´Ù.

    Description

    string mysql_field_table(int result, int field_offset);

    Get the table name for field. For downward compatibility mysql_fieldtable() can also be used.

    mysql_field_type

    mysql_field_type -- Çʵå typeÀ» ±¸ÇÑ´Ù.

    Description

    string mysql_field_type(int result, int field_offset);

    mysql_field_type() is similar to the mysql_field_name() function. The arguments are identical, but the field type is returned. This will be one of "int", "real", "string", "blob", or others as detailed in the MySQL documentation.

    Example 1. mysql field types

    <?php
    mysql_connect("localhost:3306");
    mysql_select_db("wisconsin");
    $result = mysql_query("SELECT * FROM onek");
    $fields = mysql_num_fields($result);
    $rows   = mysql_num_rows($result);
    $i = 0;
    $table = mysql_field_table($result, $i);
    echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>";
    echo "The table has the following fields <BR>";
    while ($i < $fields) {
        $type  = mysql_field_type  ($result, $i);
        $name  = mysql_field_name  ($result, $i);
        $len   = mysql_field_len   ($result, $i);
        $flags = mysql_field_flags ($result, $i);
        echo $type." ".$name." ".$len." ".$flags."<BR>";
        $i++;
    }
    mysql_close();
    ?>

    For downward compatibility mysql_fieldtype() can also be used.

    mysql_field_flags

    mysql_field_flags -- Çʵå flag¸¦ ±¸ÇÑ´Ù.

    Description

    string mysql_field_flags(string result, int field_offset);

    mysql_field_flags() returns the field flags of the specified field. The flags are reported as a single word per flag separated by a single space, so that you can split the returned value using explode().

    The following flags are reported, if your version of MySQL is current enough to support them: "not_null", "primary_key", "unique_key", "multiple_key", "blob", "unsigned", "zerofill", "binary", "enum", "auto_increment", "timestamp".

    For downward compatibility mysql_fieldflags() can also be used.

    mysql_field_len

    mysql_field_len -- ÇÊµå ±æÀ̸¦ ±¸ÇÑ´Ù.

    Description

    int mysql_field_len(string result, int field_offset);

    mysql_field_len() returns the length of the specified field. For downward compatibility mysql_fieldlen() can also be used.

    mysql_free_result

    mysql_free_result -- result memory¸¦ Ç®¾îÁØ´Ù.

    Description

    int mysql_free_result(int result);

    mysql_free_result() only needs to be called if you are worried about using too much memory while your script is running. All associated result memory for the specified result identifier will automatically be freed.

    For downward compatibility mysql_freeresult() can also be used.

    mysql_insert_id

    mysql_insert_id -- ÃÖ±Ù INSERT¿¡¼­ ¸¸µé¾îÁø id (generated id)¸¦ ±¸ÇÑ´Ù.

    Description

    int mysql_insert_id(int [link_identifier]);

    mysql_insert_id() returns the ID generated for an AUTO_INCREMENTED field. This function takes no arguments. It will return the auto-generated ID returned by the last INSERT query performed.

    mysql_list_fields

    mysql_list_fields -- result fieldµéÀ» ³ª¿­ÇÑ´Ù.

    Description

    int mysql_list_fields(string database_name, string table_name, int [link_identifier] );

    mysql_list_fields() retrieves information about the given tablename. Arguments are the database name and the table name. A result pointer is returned which can be used with mysql_field_flags(), mysql_field_len(), mysql_field_name(), and mysql_field_type().

    A result identifier is a positive integer. The function returns -1 if a error occurs. A string describing the error will be placed in $phperrmsg, and unless the function was called as @mysql() then this error string will also be printed out.

    For downward compatibility mysql_listfields() can also be used.

    mysql_list_dbs

    mysql_list_dbs -- serverÀÇ MySQL databaseµéÀ» ³ª¿­ÇÑ´Ù.

    Description

    int mysql_list_dbs(int [link_identifier] );

    mysql_list_dbs() will return a result pointer containing the databases available from the current mysql daemon. Use the mysql_tablename() function to traverse this result pointer.

    For downward compatibility mysql_listdbs() can also be used.

    mysql_list_tables

    mysql_list_tables -- MySQL databaseÀÇ tableµéÀ» ³ª¿­ÇÑ´Ù.

    Description

    int mysql_list_tables(string database, int [link_identifier] );

    mysql_list_tables() takes a database name and result pointer much like the mysql_db_query() function. The mysql_tablename() function should be used to extract the actual table names from the result pointer.

    For downward compatibility mysql_listtables() can also be used.

    mysql_num_fields

    mysql_num_fields -- resultÀÇ field °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int mysql_num_fields(int result);

    mysql_num_fields() returns the number of fields in a result set.

    See also: mysql_db_query(), mysql_query(), mysql_fetch_field(), mysql_num_rows().

    For downward compatibility mysql_numfields() can also be used.

    mysql_num_rows

    mysql_num_rows -- resultÀÇ row °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int mysql_num_rows(int result);

    mysql_num_rows() returns the number of rows in a result set.

    See also: mysql_db_query(), mysql_query() and, mysql_fetch_row().

    For downward compatibility mysql_numrows() can also be used.

    mysql_pconnect

    mysql_pconnect -- ¿µ±¸ÀûÀÎ MySQL Á¢¼ÓÀ» ¿¬´Ù.

    Description

    int mysql_pconnect(string [hostname [:port] [:/path/to/socket] ] , string [username] , string [password] );

    Returns: A positive MySQL persistent link identifier on success, or false on error

    mysql_pconnect() establishes a connection to a MySQL server. All of the arguments are optional, and if they're missing, defaults are assumed ('localhost', user name of the user that owns the server process, empty password).

    The hostname string can also include a port number. eg. "hostname:port" or a path to a socket eg. ":/path/to/socket" for the localhost.

    Note: Support for ":port" was added in 3.0B4.

    Support for the ":/path/to/socket" was added in 3.0.10.

    mysql_pconnect() acts very much like mysql_connect() with two major differences.

    First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

    Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()).

    This type of links is therefore called 'persistent'.

    mysql_query

    mysql_query -- MySQL ÁúÀǸ¦ Àü¼ÛÇÑ´Ù.

    Description

    int mysql_query(string query, int [link_identifier] );

    mysql_query() sends a query to the currently active database on the server that's associated with the specified link identifier. If link_identifier isn't specified, the last opened link is assumed. If no link is open, the function tries to establish a link as if mysql_connect() was called with no arguments, and use it.

    The query string should not end with a semicolon.

    mysql_query() returns TRUE (non-zero) or FALSE to indicate whether or not the query succeeded. A return value of TRUE means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows.

    The following query is syntactically invalid, so mysql_query() fails and returns FALSE:

    Example 1. mysql_query()

    <?php
    $result = mysql_query ("SELECT * WHERE 1=1")
        or die ("Invalid query");
    ?>
          

    The following query is semantically invalid if my_col is not a column in the table my_tbl, so mysql_query() fails and returns FALSE:

    Example 2. mysql_query()

    <?php
    $result = mysql_query ("SELECT my_col FROM my_tbl")
        or die ("Invalid query");
    ?>
          

    mysql_query() will also fail and return FALSE if you don't have permission to access the table(s) referenced by the query.

    Assuming the query succeeds, you can call mysql_affected_rows() to find out how many rows were affected (for DELETE, INSERT, REPLACE, or UPDATE statements). For SELECT statements, mysql_query() returns a new result identifier that you can pass to mysql_result(). When you are done with the result set, you can free the resources associated with it by calling mysql_free_result().

    See also: mysql_affected_rows(), mysql_db_query(), mysql_free_result(), mysql_result(), mysql_select_db(), and mysql_connect().

    mysql_result

    mysql_result -- result data¸¦ ±¸ÇÑ´Ù.

    Description

    int mysql_result(int result, int row, mixed [field] );

    mysql_result() returns the contents of one cell from a MySQL result set. The field argument can be the field's offset, or the field's name, or the field's table dot field's name (fieldname.tablename). If the column name has been aliased ('select foo as bar from...'), use the alias instead of the column name.

    When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than mysql_result(). Also, note that specifying a numeric offset for the field argument is much quicker than specifying a fieldname or tablename.fieldname argument.

    Calls mysql_result() should not be mixed with calls to other functions that deal with the result set.

    Recommended high-performance alternatives: mysql_fetch_row(), mysql_fetch_array(), and mysql_fetch_object().

    mysql_select_db

    mysql_select_db -- MySQL database¸¦ ¼±ÅÃÇÑ´Ù.

    Description

    int mysql_select_db(string database_name, int [link_identifier] );

    Returns: true on success, false on error

    mysql_select_db() sets the current active database on the server that's associated with the specified link identifier. If no link identifier is specified, the last opened link is assumed. If no link is open, the function will try to establish a link as if mysql_connect() was called, and use it.

    Every subsequent call to mysql_query() will be made on the active database.

    See also: mysql_connect(), mysql_pconnect(), and mysql_query()

    For downward compatibility mysql_selectdb() can also be used.

    mysql_tablename

    mysql_tablename -- ÇØ´ç Çʵ带 °¡Á® ¿Â Table À̸§À» ±¸ÇÑ´Ù.

    Description

    string mysql_tablename(int result, int i);

    mysql_tablename() takes a result pointer returned by the mysql_list_tables() function as well as an integer index and returns the name of a table. The mysql_num_rows() function may be used to determine the number of tables in the result pointer.

    Example 1. mysql_tablename() example

    <?php
    mysql_connect ("localhost:3306");
    $result = mysql_listtables ("wisconsin");
    $i = 0;
    while ($i < mysql_num_rows ($result)) {
        $tb_names[$i] = mysql_tablename ($result, $i);
        echo $tb_names[$i] . "<BR>";
        $i++;
    }
    ?>
     

    XXXIX. Network functions

    Table of Contents
    checkdnsrr ¡¦ Check DNS records corresponding to a given Internet host name or IP address.
    closelog ¡¦ close connection to system logger
    debugger_on ¡¦ enable internal PHP debugger
    debugger_off ¡¦ disable internal PHP debugger
    fsockopen ¡¦ Open Internet or Unix domain socket connection.
    gethostbyaddr ¡¦ Get the Internet host name corresponding to a given IP address.
    gethostbyname ¡¦ Get the IP address corresponding to a given Internet host name.
    gethostbynamel ¡¦ Get a list of IP addresses corresponding to a given Internet host name.
    getmxrr ¡¦ Get MX records corresponding to a given Internet host name.
    getprotobyname ¡¦ Get protocol number associated with protocol name
    getprotobynumber ¡¦ Get protocol name associated with protocol number
    getservbyname ¡¦ Get port number associated with an Internet service and protocol
    getservbyport ¡¦ Get Internet service which corresponds to port and protocol
    openlog ¡¦ open connection to system logger
    pfsockopen ¡¦ Open persistent Internet or Unix domain socket connection.
    set_socket_blocking ¡¦ Set blocking/non-blocking mode on a socket
    syslog ¡¦ generate a system log message

    checkdnsrr

    checkdnsrr -- ÁÖ¾îÁø Internet host name or IP address¿¡ ÇØ´çÇÏ´Â DNS recordµéÀ» °Ë»çÇÑ´Ù .

    Description

    int checkdnsrr (string host [, string type])

    Searches DNS for records of type type corresponding to host. Returns true if any records are found; returns false if no records were found or if an error occurred.

    type may be any one of: A, MX, NS, SOA, PTR, CNAME, or ANY. The default is MX.

    host may either be the IP address in dotted-quad notation or the host name.

    See also getmxrr(), gethostbyaddr(), gethostbyname(), gethostbynamel(), and the named(8) manual page.

    closelog

    closelog -- system logger·ÎÀÇ connectionÀ» ´Ý´Â´Ù.

    Description

    int closelog(void);

    closelog() closes the descriptor being used to write to the system logger. The use of closelog() is optional.

    debugger_on

    debugger_on -- ³»ÀåµÈ PHP debugger¸¦ enable ÇÑ´Ù.

    Description

    void debugger_on (string address);

    Enables the internal PHP debugger, connecting it to address. The debugger is still under development.

    debugger_off

    debugger_off -- ³»ÀåµÈ PHP debugger¸¦ disable ÇÑ´Ù.

    Description

    void debugger_off (string address);

    Disables the internal PHP debugger. The debugger is still under development.

    fsockopen

    fsockopen -- InternetÀ̳ª Unix domainÀÇ socket connectionÀ» ¿¬´Ù.

    Description

    int fsockopen (string hostname, int port [, int errno [, string errstr [, double timeout]]])

    Initiates a stream connection in the Internet (AF_INET) or Unix (AF_UNIX) domain. For the Internet domain, it will open a TCP socket connection to hostname on port port. For the Unix domain, hostname will be used as the path to the socket, port must be set to 0 in this case. The optional timeout can be used to set a timeout in seconds for the connect system call.

    fsockopen() returns a file pointer which may be used together with the other file functions (such as fgets(), fgetss(), fputs(), fclose(), feof()).

    If the call fails, it will return false and if the optional errno and errstr arguments are present they will be set to indicate the actual system level error that occurred on the system-level connect() call. If the returned errno is 0 and the function returned false, it is an indication that the error occurred before the connect() call. This is most likely due to a problem initializing the socket. Note that the errno and errstr arguments must be passed by reference.

    Depending on the environment, the Unix domain or the optional connect timeout may not be available.

    The socket will by default be opened in blocking mode. You can switch it to non-blocking mode by using set_socket_blocking().

    Example 1. Fsockopen() Example

      1 
      2 $fp = fsockopen ("www.php.net", 80, &$errno, &$errstr, 30);
      3 if (!$fp) {
      4     echo "$errstr ($errno)<br>\n";
      5 } else {
      6     fputs ($fp, "GET / HTTP/1.0\n\n");
      7     while (!feof($fp)) {
      8         echo fgets ($fp,128);
      9     }
     10     fclose ($fp);
     11 }
     12       

    See also: pfsockopen()

    gethostbyaddr

    gethostbyaddr -- ÁÖ¾îÁø IP address¿¡ ÇØ´çÇÏ´Â Internet host nameÀ» ±¸ÇÑ´Ù.

    Description

    string gethostbyaddr (string ip_address)

    Returns the host name of the Internet host specified by ip_address. If an error occurs, returns ip_address.

    See also gethostbyname().

    gethostbyname

    gethostbyname -- ÁÖ¾îÁø Internet host name¿¡ ÇØ´çÇÏ´Â IP address¸¦ ±¸ÇÑ´Ù.

    Description

    string gethostbyname (string hostname)

    Returns the IP address of the Internet host specified by hostname.

    See also gethostbyaddr().

    gethostbynamel

    gethostbynamel -- ÁÖ¾îÁø Internet host name¿¡ ÇØ´çÇÏ´Â IP addresseµéÀÇ list¸¦ ±¸ÇÑ´Ù.

    Description

    array gethostbynamel (string hostname)

    Returns a list of IP addresses to which the Internet host specified by hostname resolves.

    See also gethostbyname(), gethostbyaddr(), checkdnsrr(), getmxrr(), and the named(8) manual page.

    getmxrr

    getmxrr -- ÁÖ¾îÁø Internet host name¿¡ ÇØ´çÇÏ´Â MX recordµéÀ» ±¸ÇÑ´Ù.

    Description

    int getmxrr (string hostname, array mxhosts [, array weight])

    Searches DNS for MX records corresponding to hostname. Returns true if any records are found; returns false if no records were found or if an error occurred.

    A list of the MX records found is placed into the array mxhosts. If the weight array is given, it will be filled with the weight information gathered.

    See also checkdnsrr(), gethostbyname(), gethostbynamel(), gethostbyaddr(), and the named(8) manual page.

    getprotobyname

    (PHP4 >= 4.0b4)

    getprotobyname -- ÇÁ·ÎÅäÄÝ À̸§¿¡ ÇØ´çÇÏ´Â ÇÁ·ÎÅäÄÝ ¹øÈ£¸¦ ±¸ÇÑ´Ù.

    Get protocol number associated with protocol name

    Description

    int getprotobyname (string name)

    Getprotobyname() returns the protocol number associated with the protocol name as per /etc/protocols.

    See also: getprotobynumber().

    getprotobynumber

    (PHP4 >= 4.0b4)

    getprotobynumber --  ÇÁ·ÎÅäÄÝ ¹øÈ£¿¡ ÇØ´çÇÏ´Â ÇÁ·ÎÅäÄÝ À̸§À» ±¸ÇÑ´Ù.

    Description

    string getprotobynumber (int number)

    Getprotobynumber() returns the protocol name associated with protocol number as per /etc/protocols.

    See also: getprotobyname().

    getservbyname

    (PHP4 >= 4.0b4)

    getservbyname -- ÁÖ¾îÁø ÀÎÅÍ³Ý ¼­ºñ½º¿Í ÇÁ·ÎÅäÄÝ¿¡ ÇØ´çÇÏ´Â Æ÷Æ® ¹øÈ£¸¦ ±¸ÇÑ´Ù.

    Description

    int getservbyname (string service, string protocol)

    Getservbyname() returns the Internet port which corresponds to service for the specified protocol as per /etc/services. protocol is either TCP or UDP.

    See also: getservbyport().

    getservbyport

    (PHP4 >= 4.0b4)

    getservbyport -- ÁÖ¾îÁø Æ÷Æ®¿Í ÇÁ·ÎÅäÄÝ¿¡ ÇØ´çÇÏ´Â ÀÎÅÍ³Ý ¼­ºñ½º¸¦ ±¸ÇÑ´Ù.

    Get Internet service which corresponds to port and protocol

    Description

    string getservbyport (int port, string protocol)

    Getservbyport() returns the Internet service associated with port for the specified protocol as per /etc/services. protocol is either TCP or UDP.

    See also: getservbyname().

    openlog

    openlog -- system logger·ÎÀÇ connectionÀ» ¿¬´Ù.

    Description

    int openlog (string ident, int option, int facility)

    openlog() opens a connection to the system logger for a program. The string ident is added to each message. Values for option and facility are given in the next section. The use of openlog() is optional; It will automatically be called by syslog() if necessary, in which case ident will default to false. See also syslog() and closelog().

    pfsockopen

    pfsockopen -- ¿µ±¸ÀûÀÎ(persistent) InternetÀ̳ª Unix domainÀÇ socket ¿¬°áÀ» ¿¬´Ù.

    Description

    int pfsockopen (string hostname, int port [, int errno [, string errstr [, int timeout]]])ut]);

    This function behaves exactly as fsockopen() with the difference that the connection is not closed after the script finishes. It is the persistent version of fsockopen().

    set_socket_blocking

    set_socket_blocking -- ¼ÒÄÏÀÇ blocking/non-blocking ¸ðµå¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int set_socket_blocking (int socket descriptor, int mode)

    If mode is false, the given socket descriptor will be switched to non-blocking mode, and if true, it will be switched to blocking mode. This affects calls like fgets() that read from the socket. In non-blocking mode an fgets() call will always return right away while in blocking mode it will wait for data to become available on the socket.

    syslog

    syslog -- system log message¸¦ ¸¸µç´Ù.

    Description

    int syslog (int priority, string message)

    Syslog() generates a log message that will be distributed by the system logger. priority is a combination of the facility and the level, values for which are given in the next section. The remaining argument is the message to send, except that the two characters %m will be replaced by the error message string (strerror) corresponding to the present value of errno.

    More information on the syslog facilities can be found in the man pages for syslog on Unix machines.

    On Windows NT, the syslog service is emulated using the Event Log


    XL. NIS functions

    NIS(°ú°Å¿¡´Â Yellow Pages¶ó ºÒ·È´Ù.)´Â password ÆÄÀÏ °°Àº Áß¿äÇÑ °ü¸® ÆÄÀϵéÀ» ³×Æ®¿÷»ó¿¡¼­ °ü¸®ÇÒ ¼ö ÀÖµµ·Ï ÇØÁØ´Ù. NIS¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ Á¤º¸´Â NIS manpage¿Í Introduction to YP/NIS¿¡¼­ ã¾Æº¸µµ·ÏÇÑ´Ù. Hal SternÀÌ ¾´ Managing NFS and NIS¶ó´Â Ã¥µµ ÀÖ´Ù.

    ÀÌ ÇÔ¼öµéÀÌ ÀÛµ¿ÇÏ·Á¸é --with-yp ¿É¼ÇÀ» ÁÖ°í PHP¸¦ ¼³Á¤ÇÏ¿©¾ß ÇÑ´Ù.

    Table of Contents
    yp_get_default_domain ¡¦ Fetches the machines default NIS domain.
    yp_order ¡¦ Returns the order number for a map.
    yp_master ¡¦ Returns the machine name of the master NIS server for a map.
    yp_match ¡¦ Returns the matched line
    yp_first ¡¦ Returns the first key-value pair from the named map.
    yp_next ¡¦ Returns the next key-value pair in the named map.
    yp_errno ¡¦ Returns the error code of the previous operation
    yp_err_string ¡¦ Returns the error string associated with the previous operation.

    yp_get_default_domain

    yp_get_default_domain -- ÇØ´ç ½Ã½ºÅÛÀÇ µðÆúÆ® NIS µµ¸ÞÀÎÀ» ±¸ÇÑ´Ù.

    Description

    int yp_get_default_domain (void )

    yp_get_default_domain() returns the default domain of the node or FALSE. Can be used as the domain parameter for successive NIS calls.

    A NIS domain can be described a group of NIS maps. Every host that needs to look up information binds itself to a certain domain. Refer to the documents mentioned at the beginning for more detailed information.

    Example 1. Example for the default domain

      1 
      2 <?php
      3     $domain = yp_get_default_domain();
      4     echo "Default NIS domain is: " . $domain;
      5 ?>
      6       

    yp_order

    yp_order -- map¿¡ ´ëÇÑ ¼ø¼­ ¹øÈ£¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int yp_order (string domain, string map)

    yp_order() returns the order number for a map or FALSE.

    Example 1. Example for the NIS order

      1 
      2 <?php
      3     $number = yp_order($domain,$mapname);
      4     echo "Order number for this map is: " . $order;
      5 ?>
      6       

    See also: yp_get_default_domain

    yp_master

    yp_master -- map¿¡¼­ÀÇ ¸¶½ºÅÍ NIS ¼­¹öÀÇ ½Ã½ºÅÛ À̸§À» ¹ÝȯÇÑ´Ù.

    Description

    string yp_master (string domain, string map)

    yp_master() returns the machine name of the master NIS server for a map.

    Example 1. Example for the NIS master

      1 
      2 <?php
      3     $number = yp_master($domain, $mapname);
      4     echo "Master for this map is: " . $master;
      5 ?>
      6       

    See also: yp_get_default_domain

    yp_match

    yp_match -- ´ëÀÀÇÏ´Â °ªÀ» ¹ÝȯÇÑ´Ù.

    Description

    string yp_match (string domain, string map, string key)

    yp_match() returns the value associated with the passed key out of the specified map or FALSE. This key must be exact.

    Example 1. Example for NIS match

      1 
      2 <?php
      3     $entry = yp_match($domain, "passwd.byname", "joe");
      4     echo "Matched entry is: " . $entry;
      5 ?>
      6       

    In this case this could be: joe:##joe:11111:100:Joe User:/home/j/joe:/usr/local/bin/bash

    See also: yp_get_default_domain

    yp_first

    yp_first -- ÁÖ¾îÁø map¿¡¼­ ù ¹ø° key-value ½ÖÀ» ¹ÝȯÇÑ´Ù.

    Description

    string[] yp_first (string domain, string map)

    yp_first() returns the first key-value pair from the named map in the named domain, otherwise FALSE.

    Example 1. Example for the NIS first

      1 
      2 <?php
      3     $entry = yp_first($domain, "passwd.byname");
      4     $key = key($entry);
      5     echo "First entry in this map has key " . $key 
      6           . " and value " . $entry[$key];
      7 ?>
      8       

    See also: yp_get_default_domain

    yp_next

    yp_next -- ÁÖ¾îÁø map¿¡¼­ ´ÙÀ½ key-value ½ÖÀ» ¹ÝȯÇÑ´Ù.

    Description

    string[] yp_next (string domain, string map, string key)

    yp_next() returns the next key-value pair in the named map after the specified key or FALSE.

    Example 1. Example for NIS next

      1 
      2 <?php
      3     $entry = yp_next($domain, "passwd.byname", "joe");
      4 
      5     if(!$entry) {
      6         echo yp_errno() . ": " . yp_err_string();
      7     }
      8 
      9     $key = key($entry);
     10 
     11     echo "The next entry after joe has key " . $key 
     12           . " and value " . $entry[$key];
     13 ?>
     14       

    See also: yp_get_default_domain

    yp_errno

    yp_errno -- ÀÌÀü ÀÛ¾÷¿¡¼­ÀÇ ¿¡·¯ Äڵ带 ¹ÝȯÇÑ´Ù.

    Description

    int yp_errno();

    yp_errno() returns the error code of the previous operation.

    Possible errors are:

    1 args to function are bad

    2 RPC failure - domain has been unbound

    3 can't bind to server on this domain

    4 no such map in server's domain

    5 no such key in map

    6 internal yp server or client error

    7 resource allocation failure

    8 no more records in map database

    9 can't communicate with portmapper

    10 can't communicate with ypbind

    11 can't communicate with ypserv

    12 local domain name not set

    13 yp database is bad

    14 yp version mismatch

    15 access violation

    16 database busy

    See also: yp_err_string

    yp_err_string

    yp_err_string -- ÀÌÀü ÀÛ¾÷¿¡¼­ÀÇ ¿¡·¯ ¹®ÀÚ¿­À» ¹ÝȯÇÑ´Ù.

    Description

    string yp_err_string(void );

    yp_err_string() returns the error message associated with the previous operation. Useful to indicate what exactly went wrong.

    Example 1. Example for NIS errors

    <?php
        echo "Error: " . yp_err_string();
    ?>
          

    See also: yp_errno


    XLI. ODBC functions

    Table of Contents
    odbc_autocommit ¡¦ Toggle autocommit behaviour
    odbc_binmode ¡¦ handling of binary column data
    odbc_close ¡¦ Close an ODBC connection
    odbc_close_all ¡¦ Close all ODBC connections
    odbc_commit ¡¦ Commit an ODBC transaction
    odbc_connect ¡¦ Connect to a datasource
    odbc_cursor ¡¦ Get cursorname
    odbc_do ¡¦ synonym for odbc_exec()
    odbc_exec ¡¦ Prepare and execute a SQL statement
    odbc_execute ¡¦ execute a prepared statement
    odbc_fetch_into ¡¦ Fetch one result row into array
    odbc_fetch_row ¡¦ Fetch a row
    odbc_field_name ¡¦ Get the columnname
    odbc_field_type ¡¦ datatype of a field
    odbc_field_len ¡¦ get the Length of a field
    odbc_field_precision ¡¦ Synonym for odbc_field_len()
    odbc_field_scale ¡¦ Get the scale of a field
    odbc_free_result ¡¦ free resources associated with a result
    odbc_longreadlen ¡¦ handling of LONG columns
    odbc_num_fields ¡¦ number of columns in a result
    odbc_pconnect ¡¦ Open a persistent database connection
    odbc_prepare ¡¦ Prepares a statement for execution
    odbc_num_rows ¡¦ Number of rows in a result
    odbc_result ¡¦ get result data
    odbc_result_all ¡¦ Print result as HTML table
    odbc_rollback ¡¦ Rollback a transaction
    odbc_setoption ¡¦ Adjust ODBC settings. Returns false if an error occurs, otherwise true.
    odbc_tables ¡¦ Get the list of table names stored in a specific data source. Returns a result identifier containing the information.
    odbc_tableprivileges ¡¦ Lists tables and the privileges associated with each table
    odbc_columns ¡¦ Lists the column names in specified tables. Returns a result identifier containing the information.
    odbc_columnprivileges ¡¦ Returns a result identifier that can be used to fetch a list of columns and associated privileges
    odbc_gettypeinfo ¡¦ Returns a result identifier containing information about data types supported by the data source.
    odbc_primarykeys ¡¦ Returns a result identifier that can be used to fetch the column names that comprise the primary key for a table
    odbc_foreignkeys ¡¦ Returns a list of foreign keys in the specified table or a list of foreign keys in other tables that refer to the primary key in the specified table
    odbc_procedures ¡¦ Get the list of procedures stored in a specific data source. Returns a result identifier containing the information.
    odbc_procedurecolumns ¡¦ Retrieve information about parameters to procedures
    odbc_specialcolumns ¡¦ Returns either the optimal set of columns that uniquely identifies a row in the table or columns that are automatically updated when any value in the row is updated by a transaction
    odbc_statistics ¡¦ Retrieve statistics about a table

    odbc_autocommit

    odbc_autocommit -- autocommit ±â´ÉÀ» ÄÑ°í, ²ö´Ù.

    Description

    int odbc_autocommit (int connection_id [, int OnOff])

    Without the OnOff parameter, this function returns auto-commit status for connection_id. True is returned if auto-commit is on, false if it is off or an error occurs.

    If OnOff is true, auto-commit is enabled, if it is false auto-commit is disabled. Returns true on success, false on failure.

    By default, auto-commit is on for a connection. Disabling auto-commit is equivalent with starting a transaction.

    See also odbc_commit() and odbc_rollback().

    odbc_binmode

    odbc_binmode -- binary column data¸¦ ´Ù·é´Ù.

    Description

    int odbc_binmode (int result_id, int mode);

    (ODBC SQL types affected: BINARY, VARBINARY, LONGVARBINARY)

    When binary SQL data is converted to character C data, each byte (8 bits) of source data is represented as two ASCII characters. These characters are the ASCII character representation of the number in its hexadecimal form. For example, a binary 00000001 is converted to "01" and a binary 11111111 is converted to "FF".

    Table 1. LONGVARBINARY handling

    binmode

    longreadlen

    result

    ODBC_BINMODE_PASSTHRU

    0

    passthru

    ODBC_BINMODE_RETURN

    0

    passthru

    ODBC_BINMODE_CONVERT

    0

    passthru

    ODBC_BINMODE_PASSTHRU

    0

    passthru

    ODBC_BINMODE_PASSTHRU

    >0

    passthru

    ODBC_BINMODE_RETURN

    >0

    return as is

    ODBC_BINMODE_CONVERT

    >0

    return as char

    If odbc_fetch_into() is used, passthru means that an empty string is returned for these columns.

    If result_id is 0, the settings apply as default for new results.

    Note: Default for longreadlen is 4096 and binmode defaults to ODBC_BINMODE_RETURN. Handling of binary long columns is also affected by odbc_longreadlen()

    odbc_close

    odbc_close -- ODBC connectionÀ» ´Ý´Â´Ù.

    Description

    void odbc_close (int connection_id)

    odbc_close() will close down the connection to the database server associated with the given connection identifier.

    NOTE: This function will fail if there are open transactions on this connection. The connection will remain open in this case.

    odbc_close_all

    odbc_close_all -- ¸ðµç ODBC connectionµéÀ» ´Ý´Â´Ù.

    Description

    void odbc_close_all(void);

    odbc_close_all() will close down all connections to database server(s).

    NOTE: This function will fail if there are open transactions on a connection. This connection will remain open in this case.

    odbc_commit

    odbc_commit -- ODBC transactionÀ» commitÇÑ´Ù.

    Description

    int odbc_commit (int connection_id)

    Returns: true on success, false on failure. All pending transactions on connection_id are committed.

    odbc_connect

    odbc_connect -- datasource¿Í ¿¬°áÇÑ´Ù.

    Description

    int odbc_connect (string dsn, string user, string password[, int cursor_type]);

    Returns an ODBC connection id or 0 (false) on error.

    The connection id returned by this functions is needed by other ODBC functions. You can have multiple connections open at once. The optional fourth parameter sets the type of cursor to be used for this connection. This parameter is not normally needed, but can be useful for working around problems with some ODBC drivers.

    With some ODBC drivers, executing a complex stored procedure may fail with an error similar to: "Cannot open a cursor on a stored procedure that has anything other than a single select statement in it". Using SQL_CUR_USE_ODBC may avoid that error. Also, some drivers don't support the optional row_number parameter in odbc_fetch_row(). SQL_CUR_USE_ODBC might help in that case, too.

    The following constants are defined for cursortype:

    For persistent connections see odbc_pconnect().

    odbc_cursor

    odbc_cursor -- cursornameÀ» ±¸ÇÑ´Ù.

    Description

    string odbc_cursor (int result_id)

    odbc_cursor will return a cursorname for the given result_id.

    odbc_do

    odbc_do -- odbc_exec()¿Í °°´Ù.

    Description

    string odbc_do (int conn_id, string query);

    odbc_do will execute a query on the given connection

    odbc_exec

    odbc_exec -- SQL ¹®ÀåÀ» ÁغñÇÏ°í ½ÇÇàÇÑ´Ù.

    Description

    int odbc_exec (int connection_id, string query_string);

    Returns false on error. Returns an ODBC result identifier if the SQL command was executed successfully.

    odbc_exec() will send an SQL statement to the database server specified by connection_id. This parameter must be a valid identifier returned by odbc_connect() or odbc_pconnect().

    See also: odbc_prepare() and odbc_execute() for multiple execution of SQL statements.

    odbc_execute

    odbc_execute -- ½ÇÇàÇÒ Áغñ°¡ µÈ ¹®ÀåÀ» ½ÇÇàÇÑ´Ù.

    Description

    int odbc_execute (int result_id[, array parameters_array]);

    Executes a statement prepared with odbc_prepare(). Returns true on successful execution, false otherwise. The array arameters_array only needs to be given if you really have parameters in your statement.

    odbc_fetch_into

    odbc_fetch_into -- ÇÑ°³ÀÇ result row¸¦ ¹è¿­·Î °¡Á®¿Â´Ù.

    Description

    int odbc_fetch_into (int result_id [, int rownumber, array result_array])

    Returns the number of columns in the result; false on error. result_array must be passed by reference, but it can be of any type since it will be converted to type array. The array will contain the column values starting at array index 0.

    odbc_fetch_row

    odbc_fetch_row -- row¸¦ °¡Á®¿Â´Ù.

    Description

    int odbc_fetch_row (int result_id[, int row_number]);

    If odbc_fetch_row() was succesful (there was a row), true is returned. If there are no more rows, false is returned.

    odbc_fetch_row() fetches a row of the data that was returned by odbc_do() / odbc_exec(). After odbc_fetch_row() is called, the fields of that row can be accessed with odbc_result().

    If row_number is not specified, odbc_fetch_row() will try to fetch the next row in the result set. Calls to odbc_fetch_row() with and without row_number can be mixed.

    To step through the result more than once, you can call odbc_fetch_row() with row_number 1, and then continue doing odbc_fetch_row() without row_number to review the result. If a driver doesn't support fetching rows by number, the row_number parameter is ignored.

    odbc_field_name

    odbc_field_name -- columnnameÀ» ±¸ÇÑ´Ù.

    Description

    string odbc_fieldname (int result_id, int field_number);

    odbc_field_name() will return the name of the field occupying the given column number in the given ODBC result identifier. Field numbering starts at 1. false is returned on error.

    odbc_field_type

    odbc_field_type -- fieldÀÇ datatypeÀ» ±¸ÇÑ´Ù.

    Description

    string odbc_field_type (int result_id, mixed field);

    odbc_field_type() will return the SQL type of the field referecend by name or number in the given ODBC result identifier. Field numbering runs from 1.

    odbc_field_len

    odbc_field_len -- fieldÀÇ ±æÀ̸¦ ±¸ÇÑ´Ù.

    Description

    int odbc_field_len (int result_id, int field_number);

    odbc_field_len() will return the length of the field referecend by number in the given ODBC result identifier. Field numbering starts at 1.

    odbc_field_precision

    (PHP4 >= 4.0.0)

    odbc_field_precision -- odbc_field_len()°ú °°´Ù.

    Description

    string odbc_field_precision (int result_id, int field_number)

    odbc_field_precision() will return the precision of the field referecend by number in the given ODBC result identifier.

    See also: odbc_field_scale() to get the scale of a floating point number

    odbc_field_scale

    (PHP4 >= 4.0.0)

    odbc_field_scale --  ÇʵåÀÇ ½ºÄÉÀÏ(scale)À» ±¸ÇÑ´Ù.

    Description

    string odbc_field_scale (int result_id, int field_number)

    odbc_field_precision() will return the scale of the field referecend by number in the given ODBC result identifier.

    odbc_free_result

    odbc_free_result -- ÁöÁ¤µÈ result¿¡ °ü·ÃµÈ resource¸¦ ÇØÁ¦ÇÑ´Ù.

    Description

    int odbc_free_result (int result_id)

    Always returns true.

    odbc_free_result() only needs to be called if you are worried about using too much memory while your script is running. All result memory will automatically be freed when the script is finished. But, if you are sure you are not going to need the result data anymore in a script, you may call odbc_free_result(), and the memory associated with result_id will be freed.

    NOTE: If auto-commit is disabled (see odbc_autocommit()) and you call odbc_free_result() before commiting, all pending transactions are rolled back.

    odbc_longreadlen

    odbc_longreadlen -- LONG columnµéÀ» ´Ù·é´Ù.

    Description

    int odbc_longreadlen (int result_id, int length)

    (ODBC SQL types affected: LONG, LONGVARBINARY) The number of bytes returned to PHP is controled by the parameter length. If it is set to 0, Long column data is passed thru to the client.

    NOTE: Handling of LONGVARBINARY columns is also affected by odbc_binmode()

    odbc_num_fields

    odbc_num_fields -- resultÀÇ column °³¼ö

    Description

    int odbc_num_fields (int result_id)

    odbc_num_fields() will return the number of fields (columns) in an ODBC result. This function will return -1 on error. The argument is a valid result identifier returned by odbc_exec().

    odbc_pconnect

    odbc_pconnect -- ¿µ±¸ÀûÀÎ database connectionÀ» ¿¬´Ù.

    Description

    int odbc_pconnect (string dsn, string user, string password [, int cursor_type])

    Returns an ODBC connection id or 0 (false) on error. This function is much like odbc_connect(), except that the connection is not really closed when the script has finished. Future requests for a connection with the same dsn, user, password combination (via odbc_connect() and odbc_pconnect()) can reuse the persistent connection.

    Note: Persistent connections have no effect if PHP is used as a CGI program.

    For information about the optional cursor_type parameter see the odbc_connect() function. For more information on persistent connections, refer to the PHP FAQ.

    odbc_prepare

    odbc_prepare -- ½ÇÇàÇÒ ¹®ÀåÀ» ÁغñÇÑ´Ù.

    Description

    int odbc_prepare(int connection_id, string query_string);

    Returns false on error.

    Returns an ODBC result identifier if the SQL command was prepared successfully. The result identifier can be used later to execute the statement with odbc_execute().

    odbc_num_rows

    odbc_num_rows -- resultÀÇ row °³¼ö

    Description

    int odbc_num_rows (int result_id);

    odbc_num_rows() will return the number of rows in an ODBC result. This function will return -1 on error. For INSERT, UPDATE and DELETE statements odbc_num_rows() returns the number of rows affected. For a SELECT clause this can be the number of rows available.

    Note: Using odbc_num_rows() to determine the number of rows available after a SELECT will return -1 with many drivers.

    odbc_result

    odbc_result -- result data¸¦ ±¸ÇÑ´Ù.

    Description

    string odbc_result (int result_id, mixed field)

    Returns the contents of the field.

    field can either be an integer containing the column number of the field you want; or it can be a string containing the name of the field. For example:

      1 
      2 $item_3 = odbc_result ($Query_ID, 3);
      3 $item_val = odbc_result ($Query_ID, "val");
      4       

    The first call to odbc_result() returns the value of the third field in the current record of the query result. The second function call to odbc_result() returns the value of the field whose field name is "val" in the current record of the query result. An error occurs if a column number parameter for a field is less than one or exceeds the number of columns (or fields) in the current record. Similarly, an error occurs if a field with a name that is not one of the fieldnames of the table(s) that is(are) being queried.

    Field indices start from 1. Regarding the way binary or long column data is returned refer to odbc_binmode() and odbc_longreadlen().

    odbc_result_all

    odbc_result_all -- result¸¦ HTML table·Î ÀμâÇÑ´Ù.

    Description

    int odbc_result_all (int result_id [, string format])

    Returns the number of rows in the result or false on error.

    odbc_result_all() will print all rows from a result identifier produced by odbc_exec(). The result is printed in HTML table format. With the optional string argument format, additional overall table formatting can be done.

    odbc_rollback

    odbc_rollback -- transactionÀ» Rollback ÇÑ´Ù.

    Description

    int odbc_rollback (int connection_id);

    Rolls back all pending statements on connection_id. Returns true on success, false on failure.

    odbc_setoption

    odbc_setoption -- ODBC ¼³Á¤À» Á¶Á¤ÇÑ´Ù. ¿¡·¯°¡ ¹ß»ýÇÑ °æ¿ì false¸¦ ¹ÝȯÇÏ°í ¾Æ´Ï¸é true¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int odbc_setoption (int id, int function, int option, int param)

    This function allows fiddling with the ODBC options for a particular connection or query result. It was written to help find work arounds to problems in quirky ODBC drivers. You should probably only use this function if you are an ODBC programmer and understand the effects the various options will have. You will certainly need a good ODBC reference to explain all the different options and values that can be used. Different driver versions support different options.

    Because the effects may vary depending on the ODBC driver, use of this function in scripts to be made publicly available is strongly discouraged. Also, some ODBC options are not available to this function because they must be set before the connection is established or the query is prepared. However, if on a particular job it can make PHP work so your boss doesn't tell you to use a commercial product, that's all that really matters.

    ID is a connection id or result id on which to change the settings.For SQLSetConnectOption(), this is a connection id. For SQLSetStmtOption(), this is a result id.

    Function is the ODBC function to use. The value should be 1 for SQLSetConnectOption() and 2 for SQLSetStmtOption().

    Parameter option is the option to set.

    Parameter param is the value for the given option.

    Example 1. ODBC Setoption Examples

      1 
      2 // 1. Option 102 of SQLSetConnectOption() is SQL_AUTOCOMMIT.
      3 //    Value 1 of SQL_AUTOCOMMIT is SQL_AUTOCOMMIT_ON.
      4 //    This example has the same effect as
      5 //    odbc_autocommit($conn, true);
      6 
      7 odbc_setoption ($conn, 1, 102, 1);
      8 
      9 // 2. Option 0 of SQLSetStmtOption() is SQL_QUERY_TIMEOUT.
     10 //    This example sets the query to timeout after 30 seconds.
     11 
     12 $result = odbc_prepare ($conn, $sql);
     13 odbc_setoption ($result, 2, 0, 30);
     14 odbc_execute ($result);
     15       

    odbc_tables

    (PHP4 >= 4.0b4)

    odbc_tables -- ÁöÁ¤µÈ µ¥ÀÌÅÍ ¼Ò½º¿¡ ÀúÀåµÇ¾î ÀÖ´Â Å×À̺íµéÀÇ À̸§À» ¸ñ·ÏÀ¸·Î °¡Á®¿Â´Ù. ÇØ´ç Á¤º¸¸¦ °¡Áø result identifier°¡ ¹ÝȯµÈ´Ù.

    Description

    int odbc_tables (int connection_id [, string qualifier [, string owner [, string name [, string types]]]])

    Lists all tables in the requested range. Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    The result set is ordered by TABLE_TYPE, TABLE_QUALIFIER, TABLE_OWNER and TABLE_NAME.

    The owner and name arguments accept search patterns ('%' to match zero or more characters and '_' to match a single character).

    To support enumeration of qualifiers, owners, and table types, the following special semantics for the qualifier, owner, name, and table_type are available:

    If table_type is not an empty string, it must contain a list of comma-separated values for the types of interest; each value may be enclosed in single quotes (') or unquoted. For example, "'TABLE','VIEW'" or "TABLE, VIEW". If the data source does not support a specified table type, odbc_tables() does not return any results for that type.

    See also odbc_tableprivileges() to retrieve associated privileges.

    odbc_tableprivileges

    (PHP4 >= 4.0b4)

    odbc_tableprivileges -- Å×À̺í°ú, ±× °¢°¢ÀÇ Å×À̺íÀÌ °¡Áö°í ÀÖ´Â ±ÇÇÑ(privileges)À» ¸®½ºÆ®ÇÑ´Ù.

    Description

    int odbc_tableprivileges (int connection_id [, string qualifier [, string owner [, string name]]])

    Lists tables in the requested range and the privileges associated with each table. Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    The result set is ordered by TABLE_QUALIFIER, TABLE_OWNER and TABLE_NAME.

    The owner and name arguments accept search patterns ('%' to match zero or more characters and '_' to match a single character).

    odbc_columns

    (PHP4 >= 4.0b4)

    odbc_columns -- ÁöÁ¤µÈ µ¥ÀÌÅÍ Å×ÀÌºí¿¡ ¼ÓÇÑ Ä÷³µéÀÇ À̸§À» ¸ñ·ÏÀ¸·Î °¡Á®¿Â´Ù. ÇØ´ç Á¤º¸¸¦ °¡Áø result identifier°¡ ¹ÝȯµÈ´Ù.

    Lists the column names in specified tables. Returns a result identifier containing the information.

    Description

    int odbc_columns (int connection_id [, string qualifier [, string owner [, string table_name [, string column_name]]]])

    Lists all columns in the requested range. Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    The result set is ordered by TABLE_QUALIFIER, TABLE_OWNER and TABLE_NAME.

    The owner, table_name and column_name arguments accept search patterns ('%' to match zero or more characters and '_' to match a single character).

    See also odbc_columnprivileges() to retrieve associated privileges.

    odbc_columnprivileges

    (PHP4 >= 4.0b4)

    odbc_columnprivileges -- Ä÷³°ú ±× ±ÇÇÑ(privileges)ÀÇ ¸ñ·ÏÀ» °¡Á®¿À´Âµ¥ »ç¿ëÇÒ result identifier¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int odbc_columnprivileges (int connection_id [, string qualifier [, string owner [, string table_name [, string column_name]]]])

    Lists columns and associated privileges for the given table. Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    The result set is ordered by TABLE_QUALIFIER, TABLE_OWNER and TABLE_NAME.

    The column_name argument accepts search patterns ('%' to match zero or more characters and '_' to match a single character).

    odbc_gettypeinfo

    (PHP4 >= 4.0b4)

    odbc_gettypeinfo -- ÇØ´ç µ¥ÀÌÅÍ ¼Ò½º°¡ Áö¿øÇÏ´Â µ¥ÀÌÅÍ ÇüÅÂ(types)¿¡ ´ëÇÑ Á¤º¸¸¦ °¡Áø result identifier¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int odbc_gettypeinfo (int connection_id [, int data_type])

    Retrieves information about data types supported by the data source. Returns an ODBC result identifier or false on failure. The optional argument data_type can be used to restrict the information to a single data type.

    The result set has the following columns:

    The result set is ordered by DATA_TYPE and TYPE_NAME.

    odbc_primarykeys

    (PHP4 >= 4.0b4)

    odbc_primarykeys -- ÇØ´ç Å×À̺íÀÇ ÇÁ¶óÀ̸Ӹ® Å°¸¦ ±¸¼ºÇÏ´Â Çʵå À̸§ÀÇ ¸ñ·ÏÀ» °¡Á®¿À´Âµ¥ »ç¿ëÇÒ result identifier¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int odbc_primarykeys (int connection_id, string qualifier, string owner, string table)

    Returns the column names that comprise the primary key for a table. Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    odbc_foreignkeys

    (PHP4 >= 4.0b4)

    odbc_foreignkeys -- ÁöÁ¤µÈ Å×À̺íÀÇ ¿ÜºÎÅ°(foreign keys)ÀÇ ¸ñ·ÏÀ» ¹ÝȯÇϰųª, ÁöÁ¤µÈ Å×À̺íÀÇ ÁÖÅ°(primary key)¸¦ ÂüÁ¶ÇÏ´Â ´Ù¸¥Å×À̺íµéÀÇ ¿ÜºÎÅ°(foreign keys)ÀÇ ¸ñ·ÏÀ» ¹ÝȯÇÑ´Ù.

    Description

    int odbc_foreignkeys (int connection_id, string pk_qualifier, string pk_owner, string pk_table, string fk_qualifier, string fk_owner, string fk_table)

    Odbc_foreignkeys() retrieves information about foreign keys. Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    If pk_table contains a table name, odbc_foreignkeys() returns a result set containing the primary key of the specified table and all of the foreign keys that refer to it.

    If fk_table contains a table name, odbc_foreignkeys() returns a result set containing all of the foreign keys in the specified table and the primary keys (in other tables) to which they refer.

    If both pk_table and fk_table contain table names, odbc_foreignkeys() returns the foreign keys in the table specified in fk_table that refer to the primary key of the table specified in pk_table. This should be one key at most.

    odbc_procedures

    (PHP4 >= 4.0b4)

    odbc_procedures -- ÁöÁ¤µÈ µ¥ÀÌÅÍ ¼Ò½º¿¡ ÀúÀåµÇ¾î ÀÖ´Â proceduresÀÇ ¸ñ·ÏÀ» °¡Á®¿Â´Ù. ¹Ýȯ°ªÀº ÇØ´ç Á¤º¸¸¦ °¡Áø result identifier ÀÌ´Ù.

    Description

    int odbc_procedures (int connection_id [, string qualifier [, string owner [, string name]]])

    Lists all procedures in the requested range. Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    The owner and name arguments accept search patterns ('%' to match zero or more characters and '_' to match a single character).

    odbc_procedurecolumns

    (PHP4 >= 4.0b4)

    odbc_procedurecolumns -- proceduresÀÇ ÆĶó¸ÞÅÍ¿¡ ´ëÇÑ Á¤º¸¸¦ °Ë»öÇÑ´Ù.

    Description

    int odbc_procedurecolumns (int connection_id [, string qualifier [, string owner [, string proc [, string column]]]])

    Returns the list of input and output parameters, as well as the columns that make up the result set for the specified procedures. Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    The result set is ordered by PROCEDURE_QUALIFIER, PROCEDURE_OWNER, PROCEDURE_NAME and COLUMN_TYPE.

    The owner, proc and column arguments accept search patterns ('%' to match zero or more characters and '_' to match a single character).

    odbc_specialcolumns

    (PHP4 >= 4.0b4)

    odbc_specialcolumns -- Å×À̺íÀÇ ¿­(row)À» uniquely identifyÇÏ´Â Ä÷³µéÀ̳ª, transactionÀ¸·Î ÇØ´ç ¿­ÀÇ ¾î¶² °ªÀÌ ¼öÁ¤µÉ ¶§ ÀÚµ¿À¸·Î °ªÀÌ ¹Ù²î´Â Ä÷³µéÀÇ ÃÖÀûÀÇ ÁýÇÕÀ» ¹ÝȯÇÑ´Ù.

    Description

    int odbc_specialcolumns (int connection_id, int type, string qualifier, string owner, string table, int scope, int nullable)

    When the type argument is SQL_BEST_ROWID, odbc_specialcolumns() returns the column or columns that uniquely identify each row in the table.

    When the type argument is SQL_ROWVER, odbc_specialcolumns() returns the optimal column or set of columns that, by retrieving values from the column or columns, allows any row in the specified table to be uniquely identified.

    Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    The result set is ordered by SCOPE.

    odbc_statistics

    (PHP4 >= 4.0b4)

    odbc_statistics -- ÇØ´ç Å×ÀÌºí¿¡ ´ëÇÑ Åë°è Á¤º¸¸¦ °Ë»öÇÑ´Ù.

    Description

    int odbc_statistics (int connection_id, string qualifier, string owner, string table_name, int unique, int accuracy)

    Get statistics about a table and it's indexes. Returns an ODBC result identifier or false on failure.

    The result set has the following columns:

    The result set is ordered by NON_UNIQUE, TYPE, INDEX_QUALIFIER, INDEX_NAME and SEQ_IN_INDEX.


    XLII. Oracle functions

    Table of Contents
    Ora_Bind ¡¦ bind a PHP variable to an Oracle parameter
    Ora_Close ¡¦ close an Oracle cursor
    Ora_ColumnName ¡¦ get name of Oracle result column
    Ora_ColumnType ¡¦ get type of Oracle result column
    Ora_Commit ¡¦ commit an Oracle transaction
    Ora_CommitOff ¡¦ disable automatic commit
    Ora_CommitOn ¡¦ enable automatic commit
    Ora_Error ¡¦ get Oracle error message
    Ora_ErrorCode ¡¦ get Oracle error code
    Ora_Exec ¡¦ execute parsed statement on an Oracle cursor
    Ora_Fetch ¡¦ fetch a row of data from a cursor
    Ora_GetColumn ¡¦ get data from a fetched row
    Ora_Logoff ¡¦ close an Oracle connection
    Ora_Logon ¡¦ open an Oracle connection
    Ora_Open ¡¦ open an Oracle cursor
    Ora_Parse ¡¦ parse an SQL statement
    Ora_Rollback ¡¦ roll back transaction

    Ora_Bind

    Ora_Bind -- PHP º¯¼ö¸¦ Oracle ÆĶó¸ÞÅÍ·Î bindÇÑ´Ù.

    Description

    int ora_bind (int cursor, string PHP variable name, string SQL parameter name, int length, int [type]);

    Returns true if the bind succeeds, otherwise false. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions.

    This function binds the named PHP variable with a SQL parameter. The SQL parameter must be in the form ":name". With the optional type parameter, you can define whether the SQL parameter is an in/out (0, default), in (1) or out (2) parameter. As of PHP 3.0.1, you can use the constants ORA_BIND_INOUT, ORA_BIND_IN and ORA_BIND_OUT instead of the numbers.

    ora_bind must be called after ora_parse() and before ora_exec(). Input values can be given by assignment to the bound PHP variables, after calling ora_exec() the bound PHP variables contain the output values if available.

      1 
      2 <?php
      3 ora_parse($curs, "declare tmp INTEGER; begin tmp := :in; :out := tmp; :x := 7.77; end;");
      4 ora_bind($curs, "result", ":x", $len, 2);
      5 ora_bind($curs, "input", ":in", 5, 1);
      6 ora_bind($curs, "output", ":out", 5, 2);
      7 $input = 765;
      8 ora_exec($curs);
      9 echo "Result: $result<BR>Out: $output<BR>In: $input";
     10 ?>
     11 

    Ora_Close

    Ora_Close -- Oracle cursor¸¦ ´Ý´Â´Ù.

    Description

    int ora_close(int cursor);

    Returns true if the close succeeds, otherwise false. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions.

    ( ¿ªÀÚÁÖ : ÀÌ ÇÔ¼ö´Â ¾ðÁ¦³ª "wrong parameter count" À̳ª"true"¸¦ ¹ÝȯÇÑ´Ù. ±×·¯³ª C-APIÀÎ "ora_del_cursor()"´Â ¿ø·¡ ¾Æ¹«°Íµµ ¹ÝȯÇÏÁö ¾Êµµ·ÏµÇ¾î ÀÖÀ¸¹Ç·Î ¹«½ÃÇϵµ·Ï ÇÑ´Ù. )

    This function closes a data cursor opened with ora_open().

    Ora_ColumnName

    Ora_ColumnName -- Oracle result columnÀÇ À̸§À» ±¸ÇÑ´Ù.

    Description

    string Ora_ColumnName(int cursor, int column);

    Returns the name of the field/column column on the cursor cursor. The returned name is in all uppercase letters.

    Ora_ColumnType

    Ora_ColumnType -- Oracle result columnÀÇ typeÀ» ±¸ÇÑ´Ù.

    Description

    string Ora_ColumnType(int cursor, int column);

    Returns the Oracle data type name of the field/column column on the cursor cursor. The returned type will be one of the following:

    "VARCHAR2"

    "VARCHAR"

    "CHAR"

    "NUMBER"

    "LONG"

    "LONG RAW"

    "ROWID"

    "DATE"

    "CURSOR"

    Ora_Commit

    Ora_Commit -- Oracle transactionÀ» commit ÇÑ´Ù.

    Description

    int ora_commit(int conn);

    Returns true on success, false on error. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions. This function commits an Oracle transaction. A transaction is defined as all the changes on a given connection since the last commit/rollback, autocommit was turned off or when the connection was established.

    Ora_CommitOff

    Ora_CommitOff -- automatic commitÀ» disable ÇÑ´Ù.

    Description

    int ora_commitoff(int conn);

    Returns true on success, false on error. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions.

    This function turns off automatic commit after each ora_exec().

    Ora_CommitOn

    Ora_CommitOn -- automatic commitÀ» enable ÇÑ´Ù.

    Description

    int ora_commiton(int conn);

    This function turns on automatic commit after each ora_exec() on the given connection.

    Returns true on success, false on error. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions.

    Ora_Error

    Ora_Error -- Oracle error message¸¦ ±¸ÇÑ´Ù.

    Description

    string Ora_Error(int cursor);

    Returns an error message of the form XXX-NNNNN where XXX is where the error comes from and NNNNN identifies the error message.

    The cursor parameter can as of PHP 3. 0.6 also be a connection id.

    On UNIX versions of Oracle, you can find details about an error message like this: $ oerr ora 00001 00001, 00000, "unique constraint (%s.%s) violated" // *Cause: An update or insert statement attempted to insert a duplicate key // For Trusted ORACLE configured in DBMS MAC mode, you may see // this message if a duplicate entry exists at a different level. // *Action: Either remove the unique restriction or do not insert the key

    Ora_ErrorCode

    Ora_ErrorCode -- Oracle error code¸¦ ±¸ÇÑ´Ù.

    Description

    int Ora_ErrorCode(int cursor);

    Returns the numeric error code of the last executed statement on the specified cursor.

    The cursor parameter can as of PHP 3. 0.6 also be a connection id.

    Ora_Exec

    Ora_Exec -- Oracle cursor¿¡ ÀÖ´Â parseµÈ statementÀ» ½ÇÇàÇÑ´Ù.

    Description

    int ora_exec(int cursor);

    Returns true on success, false on error. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions.

    Ora_Fetch

    Ora_Fetch -- cursor¿¡¼­ dataÀÇ row¸¦ °¡Á®¿Â´Ù.

    Description

    int ora_fetch(int cursor);

    Returns true (a row was fetched) or false (no more rows, or an error occured). If an error occured, details can be retrieved using the ora_error() and ora_errorcode() functions. If there was no error, ora_errorcode() will return 0. Retrieves a row of data from the specified cursor.

    Ora_GetColumn

    Ora_GetColumn -- °¡Á®¿Â row¿¡¼­ data¸¦ ±¸ÇÑ´Ù.

    Description

    mixed ora_getcolumn(int cursor, mixed column);

    Returns the column data. If an error occurs, False is returned and ora_errorcode() will return a non-zero value. Note, however, that a test for False on the results from this function may be true in cases where there is not error as well (NULL result, empty string, the number 0, the string "0"). Fetches the data for a column or function result.

    Ora_Logoff

    Ora_Logoff -- Oracle connectionÀ» ´Ý´Â´Ù.

    Description

    int ora_logoff(int connection);

    Returns true on success, False on error. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions. Logs out the user and disconnects from the server.

    Ora_Logon

    Ora_Logon -- Oracle connectionÀ» ¿¬´Ù.

    Description

    int ora_logon(string user, string password);

    Establishes a connection between PHP and an Oracle database with the given username and password.

    Connections can be made using SQL*Net by supplying the TNS name to user like this:

    $conn = Ora_Logon("user@TNSNAME", "pass");

    If you have character data with non-ASCII characters, you should make sure that NLS_LANG is set in your environment. For server modules, you should set it in the server's environment before starting the server.

    Returns a connection index on success, or false on failure. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions.

    Ora_Open

    Ora_Open -- Oracle cursor¸¦ ¿¬´Ù.

    Description

    int ora_open(int connection);

    Opens an Oracle cursor associated with connection.

    Returns a cursor index or False on failure. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions.

    Ora_Parse

    Ora_Parse -- SQL ¹®ÀåÀ» Çؼ®(parse)ÇÑ´Ù.

    Description

    int ora_parse(int cursor_ind, string sql_statement, int defer);

    This function parses an SQL statement or a PL/SQL block and associates it with the given cursor. Returns 0 on success or -1 on error.

    Ora_Rollback

    Ora_Rollback -- transactionÀ» Rollback ÇÑ´Ù.

    Description

    int ora_rollback(int connection);

    This function undoes an Oracle transaction. (See ora_commit() for the definition of a transaction.)

    Returns true on success, false on error. Details about the error can be retrieved using the ora_error() and ora_errorcode() functions.

     


    ( ¿ªÀÚÁÖ : ÀÌ ÀÌÇÏÀÇ Oracle ºÎºÐÀº ¿µ¹® ¸Å´º¾ó¿¡ ¾ø´Â ºÎºÐÀ¸·Î PHP ȨÆäÀÌÁöÀÇ Note¸¦ Âü°íÇÏ¿´´Ù. )

    ´ÙÀ½°ú °°Àº ÇÔ¼öµéÀÌ PHP3.0.2aºÎÅÍ Ãß°¡µÇ¾ú´Ù.

    Ora_Do($conn, $query)
    Ora_Do()´Â ¸¹ÀÌ »ç¿ëÇÏ´Â 1ȸ¼º ÁúÀǸ¦ À§ÇØ Ora_Parse(), Ora_Exec(), Ora_Fetch()ÀÇ µ¿ÀÛÀ» ÇѲ¨¹ø¿¡ ¼öÇàÇÏ´Â ÇÔ¼öÀÌ´Ù.
    Ora_FetchInto($curs, &$ary)
    Ora_FetchInto´Â Àüü row¸¦ fetchÇÏ¿© °á°ú¸¦ Àü´Þ¹ÞÀº array reference¿¡ ÀúÀåÇÑ´Ù. ÀÌ ÇÔ¼ö´Â ÇØ´ç rowÀÇ Ä÷³ °³¼ö³ª false¸¦ ¹ÝȯÇÑ´Ù.
    ora_columnsize($curs, $colindex)
    ÀÌ ÇÔ¼ö´Â named column¿¡¼­ type(ora_columntype()À» º¸¶ó)ÀÇ Å©±â¸¦ ¹ÝȯÇÑ´Ù. Ä÷³ ¹øÈ£´Â 0ºÎÅÍ ½ÃÀÛÇÑ´Ù.
    ora_numcols($curs)
    resultÀÇ Ä÷³ °³¼ö¸¦ ¹ÝȯÇÑ´Ù. ÀÌ ÇÔ¼ö´Â ora_parse()/ora_exec()/ora_fetch()ÀÇ ÇÔ¼ö°¡ ¼ø¼­´ë·Î ¿Ï·áµÇ¾úÀ» ¶§¸¸ Á¤»óÀûÀÎ °ªÀ» µ¹·ÁÁØ´Ù. (ora_do()¸¦ ½ÇÇàÇÑ Èĵµ µÈ´Ù.)
    ora_numrows($curs)
    Ä÷³ °³¼ö°¡ ¾Æ´Ï¶ó rowÀÇ °³¼ö¶ó´Â °Í¸¸ Á¦¿ÜÇÏ°í´Â À§¿¡ ÀÖ´Â ora_numcols()¿Í °°´Ù.
    ora_plogon()
    ¿µ±¸ÀûÀÎ ¿¬°á(persistent connection)À» ¸¸µç´Ù´Â Á¡À» Á¦¿ÜÇÏ°í´Â ora_login()°ú µ¿ÀÏÇÏ´Ù. ¿µ±¸Àû ¿¬°áÀº mod_php¿¡¼­¸¸ Àǹ̰¡ ÀÖ°í CGI PHP¿¡¼­´Â ¾Æ¹« Àǹ̰¡ ¾ø´Ù. ÀÌ°ÍÀº ¸Þ¸ð¸®¸¦ Á¶±Ý ´õ »ç¿ëÇÏ´Â ´ë°¡·Î ¿©·¯ºÐÀÇ mod_phpÀÇ µ¥ÀÌÅͺ£À̽º ¿¬°áÀ» ¾à°£ ºü¸£°Ô ÇØ ÁØ´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº mysql_pconnect()¸¦ ÂüÁ¶Ç϶ó

     


    Oracle Example

    Prerequisites

    ´ÙÀ½ÀÇ È¯°æº¯¼öÀÇ °ªÀ» ¾Ë°í ÀÖ¾î¾ß ÇÑ´Ù. :

    ORACLE_HOME
    OracleÀÌ ¼³Ä¡µÇ¾î ÀÖ´Â µð·ºÅ丮ÀÇ path. ÀÌ º¯¼ö´Â º¸Åë ÇØ´ç ½Ã½ºÅÛÀÇ oracle »ç¿ëÀÚ·Î ¼³Á¤µÈ »ç¿ëÀÚµéÀº login ½ºÅ©¸³Æ®¿¡¼­ ¼³Á¤µÈ´Ù.
    ORACLE_SID
    ¿¬°áÇϱ⸦ ¿øÇÏ´Â databaseÀÇ À̸§. ÀÌ º¯¼ö´Â º¸Åë »ç¿ëÀÚµéÀº UNIX ȯ°æ¿¡¼­ ¼³Á¤µÈ´Ù.

    ÀÌ º¯¼ö °ªµéÀº database¿¡ ¿¬°áÇÏ¿© sqlplus¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Â »ç¿ëÀÚ·Î loginÇÏ¿© È®ÀÎÇÒ ¼ö ÀÖ´Ù. UNIX shell¿¡¼­ ´ÙÀ½°ú °°ÀÌ È®ÀÎÇÑ´Ù. :

    prompt> echo $ORACLE_HOME
    /opt/oracle/oracle/8.0.3
    prompt> echo $ORACLE_SID
    ORACLE

    ora_* ÇÔ¼öµéÀ» »ç¿ëÇÏ´Â °£´ÜÇÑ PHP ½ºÅ©¸³Æ® (A simple PHP script using ora_* functions)

    <?php
      putenv("ORACLE_SID=ORACLE");
      putenv("ORACLE_HOME=/opt/oracle/oracle/8.0.3");
      $conn = ora_login("scott", "tiger");
      $curs = ora_open($conn);
      ora_commitoff($conn);
      $query = sprintf(&quotselect * from cat");
    /* Long version */
    /*
      ora_parse($curs, $query);
      ora_exec($curs);
      ora_fetch($curs);
    */
    /* Short Version */
      ora_do($conn, $query);
     
      $ncols = ora_numcols($curs);
      $nrows = ora_numrows($curs);
      printf("Result size is $ncols cols by $nrows rows.<br>");
      for ($i=0; $i<$ncols; $i++) {
        printf("col[%s] = %s type[%d] = %s<br>",$i, ora_columnname($curs, $I), $i, ora_columntype($curs, $I));
      }
      for ($j=0; $j<$nrows; $j++) {
        for ($i=0; $i<$ncols; $i++) {
          $col = ora_getcolumn($curs, $I);
          printf("val[%d, %d] = %s * ", $j, $i, ora_getcolumn($curs, $I);
        }
        printf("<br>");
      }
    ?>
    
     
    
     
    
     
    

    ORACLE_HOMEÀÌ /opt/oracle/oracle/8.0.3À̶ó°í °¡Á¤ÇßÀ» ¶§, ¼Ö¶ó¸®½º¿¡¼­ PHP¸¦ OrecleÀ» Áö¿øÇϵµ·Ï ¼³Á¤ÇÏ´Â ¹æ¹ýÀº ´ÙÀ½°ú °°´Ù. :

    ./configure --with-oracle \
                --with-config-file-path=/opt/GNUphp3/lib \
                --with-exec-dir=/opt/bin \
                --enable-debug=yes \
                --enable-safe-mode=no \
                --enable-url-fopen-wrapper=yes \
                --enable-track-vars=yes \
                --prefix=/opt/GNUphp3

    then the resulting PHP binary will be dynamically linked against libclntsh.so in /opt/oracle/oracle/lib. The build process as generated by configure will include this directory with an -L option, but not with an -R option (run-time library search path). This means that the resulting binary will not be able to find libclntsh.so by itself, but depends on an appropriate LD_LIBRARY_PATH set within the web server CGI environment - which usually is not there. To fix this, grab the Makefile generated by configure and duplicate the -L/opt/oracle/oracle/8.0.3/lib option as an -R/opt/oracle/oracle/8.0.3/lib option (your -L and -R strings will look slightly different depending on the values for your oracle version and ORACLE_HOME). The -R option will compile in the corrent search path for libclntsh and you won't have any LD_LIBRARY_PATH pains any more.


    XLIII. Oracle 8 functions

    ÀÌ ÇÔ¼öµéÀº Oracle8°ú Oracle7 µ¥ÀÌÅͺ£À̽º¸¦ Á¢±ÙÇÒ ¼ö ÀÖµµ·Ï ÇØÁØ´Ù. ÀÌ°ÍÀº Oracle8 Call-Interface (OCI8)¸¦ »ç¿ëÇÑ´Ù.ÀÌ µå¶óÀ̹ö¸¦ »ç¿ëÇÏ·Á¸é Oracle8 client libraries°¡ ÇÊ¿äÇÏ´Ù.

    ÀÌ µå¶óÀ̹ö´Â º¸ÅëÀÇ PHP Ora_ µå¶óÀ̹öº¸´Ù ´õ¿í À¯¿¬ÇÏ´Ù. ÀÌ°ÍÀº PHPÀÇ Àü¿ª, Áö¿ª º¯¼öµéÀÇ Oracle placeholder·ÎÀÇ bindingÀ» Áö¿øÇÏ°í, full LOB¿Í FILE, ROWID¸¦ Áö¿øÇϸç, user-supplied define variableÀ» »ç¿ëÇÒ ¼ö ÀÖµµ·Ï ÇØ ÁØ´Ù.

    Table of Contents
    OCIDefineByName ¡¦ Use a PHP variable for the define-step during a SELECT
    OCIBindByName ¡¦ Bind a PHP variable to an Oracle Placeholder
    OCILogon ¡¦ Establishes a connection to Oracle
    OCIPLogon ¡¦ Connect to an Oracle database and log on using a persistant connection. Returns a new session.
    OCINLogon ¡¦ Connect to an Oracle database and log on using a new connection. Returns a new session.
    OCILogOff ¡¦ Disconnects from Oracle
    OCIExecute ¡¦ Execute a statement
    OCICommit ¡¦ Commits outstanding transactions
    OCIRollback ¡¦ Rolls back outstanding transactions
    OCINewDescriptor ¡¦ Initialize a new empty descriptor LOB/FILE (LOB is default)
    OCIRowCount ¡¦ Gets the number of affected rows
    OCINumCols ¡¦ Return the number of result columns in a statement
    OCIResult ¡¦ Returns coulumn value for fetched row
    OCIFetch ¡¦ Fetches the next row into result-buffer
    OCIFetchInto ¡¦ Fetches the next row into result-array
    OCIFetchStatement ¡¦ Fetch all rows of result data into an array.
    OCIColumnIsNULL ¡¦ test whether a result column is NULL
    OCIColumnSize ¡¦ return result column size
    OCIServerVersion ¡¦ Return a string containing server version information.
    OCIStatementType ¡¦ Return the type of an OCI statement.
    OCINewCursor ¡¦ return a new cursor (Statement-Handle) - use this to bind ref-cursors!
    OCIFreeStatement ¡¦ Free all resources associated with a statement.
    OCIFreeCursor ¡¦ Free all resources associated with a cursor.
    OCIColumnName ¡¦ Returns the name of a column.
    OCIColumnType ¡¦ Returns the data type of a column.
    OCIParse ¡¦ Parse a query and return a statement
    OCIError ¡¦ Return the last error of stmt|conn|global. If no error happened returns false.
    OCIInternalDebug ¡¦ Enables or disables internal debug output. By default it is disabled

    OCIDefineByName

    OCIDefineByName -- SELECT ÁßÀÇ degine-stepÀ¸·Î PHP º¯¼ö¸¦ »ç¿ëÇÑ´Ù.

    Description

    int OCIDefineByName(int stmt, string Column-Name, mixed &variable, int [type]);

    OCIDefineByName() uses fetches SQL-Columns into user-defined PHP-Variables. Be careful that Oracle user ALL-UPPERCASE column-names, whereby in your select you can also write lower-case. OCIDefineByName() expects the Column-Name to be in uppercase. If you define a variable that doesn't exists in you select statement, no error will be given!

    If you need to define an abstract Datatype (LOB/ROWID/BFILE) you need to allocate it first using OCINewDescriptor() function. See also the OCIBindByName() function.

    Example 1. OCIDefineByName

    <?php
    /* OCIDefineByPos example thies@digicol.de (980219) */
    $conn = OCILogon("scott","tiger");
    $stmt = OCIParse($conn,"select empno, ename from emp");
    /* the define MUST be done BEFORE ociexecute! */
    OCIDefineByName($stmt,"EMPNO",&$empno);
    OCIDefineByName($stmt,"ENAME",&$ename);
    OCIExecute($stmt);
    while (OCIFetch($stmt)) {
        echo "empno:".$empno."\n";
        echo "ename:".$ename."\n";
    }
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>

    OCIBindByName

    OCIBindByName -- PHP º¯¼ö¸¦ Oracle Placeholder·Î bind ÇÑ´Ù.

    Description

    int OCIBindByName(int stmt, string ph_name, mixed &variable, intlength, int [type]);

    OCIBindByName() binds the PHP variable variable to the Oracle placeholder ph_name. Whether it will be used for input or output will be determined run-time, and the necessary storage space will be allocated. The length paramter sets the maximum length for the bind. If you set length to -1 OCIBindByName() will use the current length of variable to set the maximum length.

    If you need to bind an abstract Datatype (LOB/ROWID/BFILE) you need to allocate it first using OCINewDescriptor() function. The length is not used for abstract Datatypes and should be set to -1. The type variable tells oracle, what kind of descriptor we want to use. Possible values are: OCI_B_FILE (Binary-File), OCI_B_CFILE (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) and OCI_B_ROWID (ROWID).

    Example 1. OCIDefineByName

    <?php
    /* OCIBindByPos example thies@digicol.de (980221)
      inserts 3 resords into emp, and uses the ROWID for updating the 
      records just after the insert.
    */
    $conn = OCILogon("scott","tiger");
    $stmt = OCIParse($conn,"insert into emp (empno, ename) ".
                                               "values (:empno,:ename) ".
                                               "returning ROWID into :rid");
    $data = array(1111 => "Larry", 2222 => "Bill", 3333 => "Jim");
    $rowid = OCINewDescriptor($conn,OCI_D_ROWID);
    OCIBindByName($stmt,":empno",&$empno,32);
    OCIBindByName($stmt,":ename",&$ename,32);
    OCIBindByName($stmt,":rid",&$rowid,-1,OCI_B_ROWID);
    $update = OCIParse($conn,"update emp set sal = :sal where ROWID = :rid");
    OCIBindByName($update,":rid",&$rowid,-1,OCI_B_ROWID);
    OCIBindByName($update,":sal",&$sal,32);
    $sal = 10000;
    while (list($empno,$ename) = each($data)) {
            OCIExecute($stmt);
            OCIExecute($update);
    } 
    $rowid->free();
    OCIFreeStatement($update);
    OCIFreeStatement($stmt);
    $stmt = OCIParse($conn,"select * from emp where empno in (1111,2222,3333)");
    OCIExecute($stmt);
    while (OCIFetchInto($stmt,&$arr,OCI_ASSOC)) {
            var_dump($arr);
    }
    OCIFreeStatement($stmt);
    /* delete our "junk" from the emp table.... */
    $stmt = OCIParse($conn,"delete from emp where empno in (1111,2222,3333)");
    OCIExecute($stmt);
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>

    OCILogon

    OCILogon -- Oracle°ú ¿¬°áÇÑ´Ù.

    Description

    int OCILogon(string username, string password, string [ORACLE_SID]);

    OCILogon() returns an connection identified needed for most other OCI calls. If the optional third parameter is not specified, PHP uses the environment variable ORACLE_SID to determine which database to connect to. Connections are shared at the page level when using OCILogon(). This means that commits and rollbacks apply to all open transactions in the page, even if you have created multiple connections.

    This example demonstrates how the connections are shared.

    Example 1. OCILogon

    <?php
    print "<HTML><PRE>";
    $db = "";
    $c1 = ocilogon("scott","tiger",$db);
    $c2 = ocilogon("scott","tiger",$db);
    function create_table($conn)
    { $stmt = ociparse($conn,"create table scott.hallo (test
    varchar2(32))");
      ociexecute($stmt);
      echo $conn." created table\n\n";
    }
    function drop_table($conn)
    { $stmt = ociparse($conn,"drop table scott.hallo");
      ociexecute($stmt);
      echo $conn." dropped table\n\n";
    }
    function insert_data($conn)
    { $stmt = ociparse($conn,"insert into scott.hallo values($conn || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
      ociexecute($stmt,OCI_DEFAULT);
      echo $conn." inserted hallo\n\n";
    }
    function delete_data($conn)
    { $stmt = ociparse($conn,"delete from scott.hallo");
      ociexecute($stmt,OCI_DEFAULT);
      echo $conn." deleted hallo\n\n";
    }
    function commit($conn)
    { ocicommit($conn);
      echo $conn." commited\n\n";
    }
    function rollback($conn)
    { ocirollback($conn);
      echo $conn." rollback\n\n";
    }
    function select_data($conn)
    { $stmt = ociparse($conn,"select * from scott.hallo");
      ociexecute($stmt,OCI_DEFAULT);
      echo $conn."----selecting\n\n";
      while (ocifetch($stmt))
        echo $conn." <".ociresult($stmt,"TEST").">\n\n";
      echo $conn."----done\n\n";
    }
    create_table($c1);
    insert_data($c1);   // Insert a row using c1
    insert_data($c2);   // Insert a row using c2
    select_data($c1);   // Results of both inserts are returned
    select_data($c2);   
    rollback($c1);      // Rollback using c1
    select_data($c1);   // Both inserts have been rolled back
    select_data($c2);   
    insert_data($c2);   // Insert a row using c2
    commit($c2);        // commit using c2
    select_data($c1);   // result of c2 insert is returned
    delete_data($c1);   // delete all rows in table using c1
    select_data($c1);   // no rows returned
    select_data($c2);   // no rows returned
    commit($c1);        // commit using c1
    select_data($c1);   // no rows returned
    select_data($c2);   // no rows returned
    drop_table($c1);
    print "</PRE></HTML>";
    ?>

    See also OCIPLogon() and OCINLogon().

    OCIPLogon

    OCIPLogon -- Oracle°ú ¿µ±¸ÀûÀÎ Á¢¼ÓÀ¸·Î ¿¬°áÇÏ°í logonÇÑ´Ù. »õ·Î¿î sessionÀ» ¹ÝȯÇÑ´Ù.

    Description

    int OCIPLogon(int conn);

    OCIPLogin() Creates a persistent connection to an Oracle 8 database and logs on. If the optional third parameter is not specified, PHP uses the environment variable ORACLE_SID to determine which database to connect to.

    See also OCILogon() and OCINLogon().

    OCINLogon

    OCINLogon -- Oracle°ú »õ·Î¿î Á¢¼ÓÀ¸·Î ¿¬°áÇÏ°í logonÇÑ´Ù. »õ·Î¿î sessionÀ» ¹ÝȯÇÑ´Ù.

    Description

    int OCINLogon(int conn);

    OCINLogin() Creates a new connection to an Oracle 8 database and logs on. If the optional third parameter is not specified, PHP uses the environment variable ORACLE_SID to determine which database to connect to. OCINLogon() forces a new connection. This is should be used if you need to isolate a set of transactions. By default, connections are shared at the page level if using OCILogon() or at the web server process level if using OCIPLogon(). If you have multiple connections open using OCINLogon(), all commits and rollbacks apply to the specified connection only..

    This example demonstrates how the connections are separated.

    Example 1. OCINLogon

    <?php
    print "<HTML><PRE>";
    $db = "";
    $c1 = ocilogon("scott","tiger",$db);
    $c2 = ocinlogon("scott","tiger",$db);
    function create_table($conn)
    { $stmt = ociparse($conn,"create table scott.hallo (test
    varchar2(32))");
      ociexecute($stmt);
      echo $conn." created table\n\n";
    }
    function drop_table($conn)
    { $stmt = ociparse($conn,"drop table scott.hallo");
      ociexecute($stmt);
      echo $conn." dropped table\n\n";
    }
    function insert_data($conn)
    { $stmt = ociparse($conn,"insert into scott.hallo values($conn || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
      ociexecute($stmt,OCI_DEFAULT);
      echo $conn." inserted hallo\n\n";
    }
    function delete_data($conn)
    { $stmt = ociparse($conn,"delete from scott.hallo");
      ociexecute($stmt,OCI_DEFAULT);
      echo $conn." deleted hallo\n\n";
    }
    function commit($conn)
    { ocicommit($conn);
      echo $conn." commited\n\n";
    }
    function rollback($conn)
    { ocirollback($conn);
      echo $conn." rollback\n\n";
    }
    function select_data($conn)
    { $stmt = ociparse($conn,"select * from scott.hallo");
      ociexecute($stmt,OCI_DEFAULT);
      echo $conn."----selecting\n\n";
      while (ocifetch($stmt))
        echo $conn." <".ociresult($stmt,"TEST").">\n\n";
      echo $conn."----done\n\n";
    }
    create_table($c1);
    insert_data($c1);
    select_data($c1);   
    select_data($c2);   
    rollback($c1);      
    select_data($c1);   
    select_data($c2);   
    insert_data($c2);   
    commit($c2);        
    select_data($c1);   
    delete_data($c1);   
    select_data($c1);   
    select_data($c2);   
    commit($c1);        
    select_data($c1);
    select_data($c2);
    drop_table($c1);
    print "</PRE></HTML>";
    ?>

    See also OCILogon() and OCIPLogon().

    OCILogOff

    OCILogOff -- Oracle°úÀÇ ¿¬°áÀ» ²÷´Â´Ù.

    Description

    int OCILogOff(int connection);

    OCILogOff() closes an Oracle connection.

    OCIExecute

    OCIExecute -- statement¸¦ ½ÇÇàÇÑ´Ù.

    Description

    int OCIExecute(int statement, int [mode]);

    OCIExecute() executes a previously parsed statement. (see OCIParse()). The optional mode allows you to specify the execution-mode (default is OCI_COMMIT_ON_SUCCESS). If you don't want statements to be commited automaticly specify OCI_DEFAULT as your mode.

    OCICommit

    OCICommit -- ¼öÇàµÇ¾ú´ø transactionµéÀ» CommitÇÑ´Ù.

    Description

    int OCICommit(int connection);

    OCICommit() commits all outstanding statements for Oracle connection connection.

    OCIRollback

    OCIRollback -- ¼öÇàµÇ¾ú´ø transactionµéÀ» Rolls backÇÑ´Ù.

    Description

    int OCIRollback(int connection);

    OCICommit() rolls back all outstanding statements for Oracle connection connection.

    OCINewDescriptor

    OCINewDescriptor -- »õ·Î¿î ºó descriptor LOB/FILE (LOB°¡ default)¸¦ ÃʱâÈ­(Initialize) ÇÑ´Ù.

    Description

    string OCINewDescriptor(int connection, int [type]);

    OCINewDescriptor() Allocates storage to hold descriptors or LOB locators. Valid values for the valid type are OCI_D_FILE, OCI_D_LOB, OCI_D_ROWID.

    Example 1. OCINewDescriptor

    <?php   
        /* This script is designed to be called from a HTML form.
         * It expects $user, $password, $table, $where, and $commitsize
         * to be passed in from the form.  The script then deletes
         * the selected rows using the ROWID and commits after each
         * set of $commitsize rows. (Use with care, there is no rollback)
         */
        $conn = OCILogon($user, $password);
        $stmt = OCIParse($conn,"select rowid from $table $where");
        $rowid = OCINewDescriptor($conn,OCI_D_ROWID);
        OCIDefineByName($stmt,"ROWID",&$rowid);   
        OCIExecute($stmt);
        while ( OCIFetch($stmt) ) {      
           $nrows = OCIRowCount($stmt);
           $delete = OCIParse($conn,"delete from $table where ROWID = :rid");
           OCIBindByName($delete,":rid",&$rowid,-1,OCI_B_ROWID);
           OCIExecute($delete);      
           print "$nrows\n";
           if ( ($nrows % $commitsize) == 0 ) {
               OCICommit($conn);      
           }   
        }
        $nrows = OCIRowCount($stmt);   
        print "$nrows deleted...\n";
        OCIFreeStatement($stmt);  
        OCILogoff($conn);
    ?>  
       

    OCIRowCount

    OCIRowCount -- ¿µÇâ¹Þ´Â rowÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int OCIRowCount(int statement);

    OCIRowCounts() returns the number of rows affected for eg update-statements. This funtions will not tell you the number of rows that a select will return!

    Example 1. OCIRowCount

    <?php
        print "<HTML><PRE>";
        $conn = OCILogon("scott","tiger");
        $stmt = OCIParse($conn,"create table emp2 as select * from emp");
        OCIExecute($stmt);
        print OCIRowCount($stmt) . " rows inserted.<BR>";
        OCIFreeStatement($stmt);
        $stmt = OCIParse($conn,"delete from emp2");
        OCIExecute($stmt);
        print OCIRowCount($stmt) . " rows deleted.<BR>";
        OCICommit($conn);
        OCIFreeStatement($stmt);
        $stmt = OCIParse($conn,"drop table emp2");
        OCIExecute($stmt);
        OCIFreeStatement($stmt);
        OCILogOff($conn);
        print "</PRE></HTML>";
    ?> 

    OCINumCols

    OCINumCols -- ÇØ´ç statementÀÇ °á°ú¿¡ ÀÖ´Â Ä÷³ÀÇ °³¼ö¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int OCINumCols(int stmt);

    OCINumCols() returns the number of columns in a statement

    Example 1. OCINumCols

    <?php   
        print "<HTML><PRE>\n";   
        $conn = OCILogon("scott", "tiger");
        $stmt = OCIParse($conn,"select * from emp");
        OCIExecute($stmt);
        while ( OCIFetch($stmt) ) {
            print "\n";   
            $ncols = OCINumCols($stmt);
            for ( $i = 1; $i <= $ncols; $i++ ) {
                $column_name  = OCIColumnName($stmt,$i);
                $column_value = OCIResult($stmt,$i);
                print $column_name . ': ' . $column_value . "\n";
            }
            print "\n";
        }
        OCIFreeStatement($stmt);  
        OCILogoff($conn);   
        print "</PRE>";
        print "</HTML>\n"; 
    ?>   

    OCIResult

    OCIResult -- fetched row¿¡ ÀÖ´Â coulumn °ªÀ» ¹ÝȯÇÑ´Ù.

    Description

    int OCIResult(int statement, mixed column);

    OCIResult() returns the data for column column in the current row (see OCIFetch()).OCIResult() will return everything as strings except for abstract types (ROWIDs, LOBs and FILEs).

    OCIFetch

    OCIFetch -- result-buffer·Î ´ÙÀ½ row¸¦ °¡Á®¿Â´Ù.

    Description

    int OCIFetch(int statement);

    OCIFetch() fetches the next row (for SELECT statements) into the internal result-buffer.

    OCIFetchInto

    OCIFetchInto -- result-array·Î ´ÙÀ½ row¸¦ °¡Á®¿Â´Ù.

    Description

    int OCIFetchInto(int stmt, array &result, int [mode]);

    OCIFetchInto() fetches the next row (for SELECT statements) into the result array. OCIFetchInto() will overwrite the previous content of result. By default result will contain a one-based array of all columns that are not NULL.

    The mode parameter allows you to change the default behaviour. You can specify more than one flag by simply addig them up (eg OCI_ASSOC+OCI_RETURN_NULLS). The known flags are:

    OCI_ASSOC Return an associative array.

    OCI_NUM Return an numbered array starting with one. (DEFAULT)

    OCI_RETURN_NULLS Return empty columns.

    OCI_RETURN_LOBS Return the value of a LOB instead of the desxriptor.

    OCIFetchStatement

    OCIFetchStatement -- °á°ú¿¡ ÀÖ´Â ¸ðµç rowµéÀÇ µ¥ÀÌÅ͸¦ ÇϳªÀÇ ¹è¿­·Î °¡Á®¿Â´Ù.

    Description

    int OCIFetchStatement(int stmt, array &variable);

    OCIFetchStatement() fetches all the rows from a result into a user-defined array. OCIFetchStatement() returns the number of rows fetched.

    Example 1. OCIFetchStatement

    <?php
    /* OCIFetchStatement example mbritton@verinet.com (990624) */
    $conn = OCILogon("scott","tiger");
    $stmt = OCIParse($conn,"select * from emp");
    OCIExecute($stmt);
    $nrows = OCIFetchStatement($stmt,$results);
    if ( $nrows > 0 ) {
       print "<TABLE BORDER=\"1\">\n";
       print "<TR>\n";
       while ( list( $key, $val ) = each( $results ) ) {
          print "<TH>$key</TH>\n";
       }
       print "</TR>\n";
       
       for ( $i = 0; $i < $nrows; $i++ ) {
          reset($results);
          print "<TR>\n";
          while ( $column = each($results) ) {   
             $data = $column['value'];
             print "<TD>$data[$i]</TD>\n";
          }
          print "</TR>\n";
       }
       print "</TABLE>\n";
    } else {
       echo "No data found<BR>\n";
    }      
    print "$nrows Records Selected<BR>\n";
     
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>

    OCIColumnIsNULL

    OCIColumnIsNULL -- result Ä÷³ÀÌ NULLÀΰ¡ °Ë»çÇÑ´Ù.

    Description

    int OCIColumnIsNULL(int stmt, mixed column);

    OCIColumnIsNULL() returns true if the returned column col in the result from the statement stmt is NULL. You can either use the column-number (1-Based) or the column-name for the col parameter.

    OCIColumnSize

    OCIColumnSize -- result Ä÷³ Å©±â¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int OCIColumnSize(int stmt, mixed column);

    OCIColumnSize() returns the size of the column as given by Oracle. You can either use the column-number (1-Based) or the column-name for the col parameter.

    Example 1. OCIColumnSize

    <?php   
        print "<HTML><PRE>\n";   
        $conn = OCILogon("scott", "tiger");
        $stmt = OCIParse($conn,"select * from emp");
        OCIExecute($stmt);
        print "<TABLE BORDER=\"1\">";
        print "<TR>";
        print "<TH>Name</TH>";
        print "<TH>Type</TH>";
        print "<TH>Length</TH>";
        print "</TR>";
        $ncols = OCINumCols($stmt);
        for ( $i = 1; $i <= $ncols; $i++ ) {
            $column_name  = OCIColumnName($stmt,$i);
            $column_type  = OCIColumnType($stmt,$i);
            $column_size  = OCIColumnSize($stmt,$i);
            print "<TR>";
            print "<TD>$column_name</TD>";
            print "<TD>$column_type</TD>";
            print "<TD>$column_size</TD>";
            print "</TR>";
        }
        OCIFreeStatement($stmt);  
        OCILogoff($conn);   
        print "</PRE>";
        print "</HTML>\n"; 
    ?>   

    See also OCINumCols(), OCIColumnName(), and OCIColumnSize().

    OCIServerVersion

    OCIServerVersion -- ¼­¹öÀÇ ¹öÀü Á¤º¸¸¦ °¡Áö´Â ¹®ÀÚ¿­À» ¹ÝȯÇÑ´Ù.

    Description

    string OCIServerVersion(int conn);

    Example 1. OCIServerVersion

    <?php
       $conn = OCILogon("scott","tiger");
       print "Server Version: " . OCIServerVersion($conn);
       OCILogOff($conn);
    ?>

    OCIStatementType

    OCIStatementType -- OCI statementÀÇ typeÀ» ¹ÝȯÇÑ´Ù.

    Description

    string OCIStatementType(int stmt);

    OCIStatementType() returns on of the following values:

    Example 1. Code examples

    <?php
        print "<HTML><PRE>";
        $conn = OCILogon("scott","tiger");
        $sql  = "delete from emp where deptno = 10";
       
        $stmt = OCIParse($conn,$sql);
        if ( OCIStatementType($stmt) == "DELETE" ) {
            die "You are not allowed to delete from this table<BR>";
        }
       
        OCILogoff($conn);
        print "</PRE></HTML>";
    ?>

    OCINewCursor

    OCINewCursor -- »õ·Î¿î cursor(Statement-Handle)¸¦ ¹ÝȯÇÑ´Ù. ÀÌ°ÍÀº ref-cursor·Î bindÇÏ´Â µ¥ »ç¿ëÇÑ´Ù.

    Description

    int OCINewCursor(int conn);

    OCINewCursor() allocates a new statement handle on the specified connection.

    Example 1. Using a REF CURSOR from a stored procedure

    <?php   
    // suppose your stored procedure info.output returns a ref cursor in :data
    $conn = OCILogon("scott","tiger");
    $curs = OCINewCursor($conn);
    $stmt = OCIParse($conn,"begin info.output(:data); end;");
    ocibindbyname($stmt,"data",&$curs,-1,OCI_B_CURSOR);
    ociexecute($stmt);
    ociexecute($curs);
    while (OCIFetchInto($curs,&$data)) {
        var_dump($data);
    }
     
    OCIFreeCursor($stmt);
    OCIFreeStatement($curs);
    OCILogoff($conn);
    ?>

    Example 2. Using a REF CURSOR in a select statement

    <?php   
    print "<HTML><BODY>";
    $conn = OCILogon("scott","tiger");
    $count_cursor = "CURSOR(select count(empno) num_emps from emp " .
                    "where emp.deptno = dept.deptno) as EMPCNT from dept";
    $stmt = OCIParse($conn,"select deptno,dname,$count_cursor");
    ociexecute($stmt);
    print "<TABLE BORDER=\"1\">";
    print "<TR>";
    print "<TH>DEPT NAME</TH>";
    print "<TH>DEPT #</TH>";
    print "<TH># EMPLOYEES</TH>";
    print "</TR>";
    while (OCIFetchInto($stmt,&$data,OCI_ASSOC)) {
        print "<TR>";
        $dname  = $data["DNAME"];
        $deptno = $data["DEPTNO"];
        print "<TD>$dname</TD>";
        print "<TD>$deptno</TD>";
        ociexecute($data[ "EMPCNT" ]);
        while (OCIFetchInto($data[ "EMPCNT" ],&$subdata,OCI_ASSOC)) {
            $num_emps = $subdata["NUM_EMPS"];
            print  "<TD>$num_emps</TD>";
        }
        print "</TR>";
    }
    print "</TABLE>";
    print "</BODY></HTML>";
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>

    OCIFreeStatement

    OCIFreeStatement -- statement¿¡ °ü·ÃµÈ ¸ðµç ÀÚ¿øµéÀ» Ç®¾îÁØ´Ù.

    Description

    int OCIFreeStatement(int stmt);

    OCIFreeStatement() returns true if successful, or false if unsuccessful.

    OCIFreeCursor

    OCIFreeCursor -- cursor¿¡ °ü·ÃµÈ ¸ðµç ÀÚ¿øµéÀ» Ç®¾îÁØ´Ù.

    Description

    int OCIFreeCursor(int stmt);

    OCIFreeCursor() returns true if successful, or false if unsuccessful.

    OCIColumnName

    OCIColumnName -- Ä÷³ÀÇ À̸§À» ¹ÝȯÇÑ´Ù.

    Description

    string OCIColumnName(int stmt, int col);

    OCIColumnName() returns the name of the column corresponding to the column number (1-based) that is passed in.

    Example 1. OCIColumnName

    <?php   
        print "<HTML><PRE>\n";   
        $conn = OCILogon("scott", "tiger");
        $stmt = OCIParse($conn,"select * from emp");
        OCIExecute($stmt);
        print "<TABLE BORDER=\"1\">";
        print "<TR>";
        print "<TH>Name</TH>";
        print "<TH>Type</TH>";
        print "<TH>Length</TH>";
        print "</TR>";
        $ncols = OCINumCols($stmt);
        for ( $i = 1; $i <= $ncols; $i++ ) {
            $column_name  = OCIColumnName($stmt,$i);
            $column_type  = OCIColumnType($stmt,$i);
            $column_size  = OCIColumnSize($stmt,$i);
            print "<TR>";
            print "<TD>$column_name</TD>";
            print "<TD>$column_type</TD>";
            print "<TD>$column_size</TD>";
            print "</TR>";
        }
        OCIFreeStatement($stmt);  
        OCILogoff($conn);   
        print "</PRE>";
        print "</HTML>\n"; 
    ?>   

    See also OCINumCols(), OCIColumnType(), and OCIColumnSize().

    OCIColumnType

    OCIColumnType -- Ä÷³ÀÇ µ¥ÀÌÅÍ typeÀ» ¹ÝȯÇÑ´Ù.

    Description

    mixed OCIColumnName(int stmt, int col);

    OCIColumnType() returns the data type of the column corresponding to the column number (1-based) that is passed in.

    Example 1. OCIColumnType

    <?php   
        print "<HTML><PRE>\n";   
        $conn = OCILogon("scott", "tiger");
        $stmt = OCIParse($conn,"select * from emp");
        OCIExecute($stmt);
        print "<TABLE BORDER=\"1\">";
        print "<TR>";
        print "<TH>Name</TH>";
        print "<TH>Type</TH>";
        print "<TH>Length</TH>";
        print "</TR>";
        $ncols = OCINumCols($stmt);
        for ( $i = 1; $i <= $ncols; $i++ ) {
            $column_name  = OCIColumnName($stmt,$i);
            $column_type  = OCIColumnType($stmt,$i);
            $column_size  = OCIColumnSize($stmt,$i);
            print "<TR>";
            print "<TD>$column_name</TD>";
            print "<TD>$column_type</TD>";
            print "<TD>$column_size</TD>";
            print "</TR>";
        }
        OCIFreeStatement($stmt);  
        OCILogoff($conn);   
        print "</PRE>";
        print "</HTML>\n"; 
    ?>   

    See also OCINumCols(), OCIColumnName(), and OCIColumnSize().

    OCIParse

    OCIParse -- ÁúÀÇ(query)¸¦ Çؼ®(parse)ÇÏ°í statement¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int OCIParse(int conn, strint query);

    OCIParse() parses the query using conn. It returns true if the query is valid, false if not. The query can be any valid SQL statement.

    OCIError

    OCIError -- stmt|conn|globalÀÇ ÃÖ±Ù ¿¡·¯¸¦ ¹ÝȯÇÑ´Ù. ¸¸¾à ¿¡·¯°¡ ¹ß»ýÇÏÁö ¾Ê¾Ò´Ù¸é false¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int OCIError(int [stmt|conn]);

    OCIError() returns the last error found. If the optional stmt|conn is not provided, the last error encountered is returned. If no error is found, OCIError() returns false.

    OCIInternalDebug

    OCIInternalDebug -- ³»Àå µð¹ö°Å Ãâ·ÂÀ» enable½ÃÅ°°Å³ª disable½ÃŲ´Ù. ±âº»°ªÀº disableÀÌ´Ù.

    Description

    void OCIInternalDebug(int onoff);

    OCIInternalDebug() enables internal debug output. Set onoff to 0 to turn debug output off, 1 to turn it on.


    XLIV. PDF functions

    ¿©·¯ºÐÀÌ Thomas Merz°¡ Á¦°øÇÏ´Â PDF ¶óÀ̺귯¸®¸¦ °¡Áö°í ÀÖ´Ù¸é ¿©·¯ºÐÀº PHP¿¡¼­ pdf ÆÄÀÏÀ» ¸¸µé ¼ö ÀÖ´Â pdf ÇÔ¼öµéÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù. (http://www.ifconnection.de/~tm/¿¡¼­ ãÀ» ¼ö ÀÖ´Ù. ±×¸®°í, ÀÌ PDF ¶óÀ̺귯¸®¸¦ ÄÄÆÄÀÏ Çϱâ À§Çؼ­´Â the JPEG library¿Í the TIFF library°¡ ÇÊ¿äÇÒ °ÍÀÌ´Ù.±×·±µ¥, ÀÌ µÎ ¶óÀ̺귯¸®´Â php¸¦ ¼³Á¤(configure)ÇÒ ¶§ °¡²û ¹®Á¦¸¦ ¹ß»ý½ÃŲ´Ù. ¹ß»ýÇÑ ¹®Á¦¸¦ ÇØ°áÇϱâ À§Çؼ­´Â ¼³Á¤½Ã ³ª¿À´Â ¸Þ½ÃÁö¸¦ »ìÆ캸±â¹Ù¶õ´Ù. pdflib 2.01À» »ç¿ëÇÑ´Ù¸é ÀÌ ¶óÀ̺귯¸®°¡ ¾î¶»°Ô ¼³Ä¡(install)µÇ¾î Àִ°¡ Á¡°ËÇÑ´Ù. libpdf.soÀ̶ó´Â ÆÄÀÏÀ̳ª ¸µÅ©°¡ ¹Ýµå½Ã ÀÖ¾î¾ß ÇÑ´Ù. ±×·¯³ª, Version 2.01Àº libpdf2.01.soÀ̶ó´Â À̸§ÀÇ ¶óÀ̺귯¸®¸¸ ¸¸µç´Ù. ÀÌ·± °æ¿ì ¿©·¯ºÐÀº libpdf.so¶ó´Â À̸§ÀÇ symbolic link¸¦ ¸¸µé¾î libpdf2.01.so¿¡ ¿¬°áÇØ¾ß ÇÑ´Ù.)

    pdflibÀÇ 2.20 ¹öÀüÀº APIÀÇ ¸¹Àº ºÎºÐÀÌ º¯ÇÏ¿´°í, Áß±¹¾î¿Í ÀϺ»¾î ÆùÆ®¸¦ Áö¿øÇϵµ·Ï ¹Ù²î¾ú´Ù. (¿ªÀÚÁÖ: ¾ðÁ¦ºÎÅÍÀÎÁö´Â ¸ð¸£°ÚÀ¸³ª, PDFlibÀÇ ÃÖ±Ù ¹öÀüÀÎ 3.01¿¡¼­´Â Çѱ¹¾îµµ Áö¿øÇÑ´Ù.) ±×·¯³ª ºÒÇàÈ÷µµ ÀÌ·± º¯È­°¡ php4(php3´Â ¾Æ´Ï´Ù)ÀÇ pdf ¸ðµâÀ» ¹Ù²Ù°Ô ÇÏ¿´´Ù. ¸¸¾à ¿©·¯ºÐÀÌ pdflib 2.20À» »ç¿ëÇÑ´Ù¸é, ¸Þ¸ð¸® ³»¿¡ PDF documents¸¦ ¸¸µå´Â °ÍÀº ¸Å¿ì Á¶½ÉÇؼ­ ÇØ¾ß ÇÒ °ÍÀÌ´Ù. pdflib 3.0ÀÌÀü¿¡´Â ÀÌ ±â´ÉÀÌ ¸Å¿ì ºÒ¾ÈÇÏ´Ù. pdf_set_font() ÇÔ¼öÀÇ ÆĶó¸ÞÅÍ°¡ ¹®ÀÚ¿­·Î ¹Ù²î¾ú´Ù. ÀÌ°ÍÀº ¿¹¸¦µé¾î 4¶ó´Â ¼ýÀÚ ´ë½Å 'winansi'¶ó´Â ¹®ÀÚ¿­À» »ç¿ëÇÒ ¼ö ÀÖ´Ù´Â ÀǹÌÀÌ´Ù.

    ¿©·¯ºÐÀÌ pdflib 2.30À» »ç¿ëÇÏ°í ÀÖ´Ù¸é pdf_set_text_matrix() ÇÔ¼ö´Â ¾øÀ» °ÍÀÌ´Ù. ÀÌÇÔ¼ö´Â ´õ ÀÌ»ó Áö¿øµÇÁö ¾Ê´Â´Ù.

    2000³â 3¿ù 9ÀÏ ÀÌÈÄ ¹öÀüÀÇ PHP4¿¡¼­´Â pdflib 3.0 ÀÌÀüÀÇ(older than) ¹öÀüÀº Áö¿øÇÏÁö ¾Ê´Â´Ù. ±×¸®°í, PHP3¿¡¼­´Â 2.01 ÀÌÈÄÀÇ(newer than) ¹öÀüÀº »ç¿ëÇÒ ¼ö ¾ø´Ù

    pdflib¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ¼³¸íÀº pdflibÀÇ ¼Ò½º¿Í ÇÔ²² ¹èÆ÷µÇ´Â ¹®¼­¸¦ Àо¸é µÈ´Ù.(¾ÆÁÖ Àß ¾²¿©Á® ÀÖ´Ù.) ÀÌ ¹®¼­´Â pdflib°¡ ÇÒ ¼ö ÀÖ´Â ±â´É¿¡ ´ëÇÏ¿© ¸Å¿ì Àß ¼³¸íÇÏ°í ÀÖ´Ù. PHPÀÇ ¸ðµâ¿¡ ÀÖ´Â ÇÔ¼ö´Â ´ëºÎºÐ pdflib ÇÔ¼ö¿Í °°Àº À̸§À» »ç¿ëÇÑ´Ù. ¶ÇÇÑ ÆĶó¸ÞÅ͵µ µ¿ÀÏÇÏ´Ù. ¶ÇÇÑ ¿©·¯ºÐÀÌ ÀÌ ¸ðµâÀ» È¿À²ÀûÀ¸·Î »ç¿ëÇÏ·Á¸é ¿©·¯ºÐÀº ¾î´ÀÁ¤µµ PDF¿Í Postscript ÀÇ °³³ä¿¡ ´ëÇØ ÀÌÇØÇÏ°í ÀÖ¾î¾ß ÇÑ´Ù. ¸ðµç ±æÀÌ¿Í ÁÂÇ¥´Â Postscript points¸¦ ôµµÀÇ ±âÁØÀ¸·Î »ï°í ÀÖ´Ù. ÀϹÝÀûÀ¸·Î 1ÀÎÄ¡¿¡ 72 PostScript points¸¦ ±âº»À¸·Î ÇÏ°í ÀÖÁö¸¸, ÀÌ°ÍÀº Ãâ·ÂÀåÄ¡ÀÇ Çػ󵵿¡ µû¶ó ´Þ¶óÁø´Ù.

    PHP¿¡¼­ pdf ¹®¼­¸¦ ¸¸µå´Â ´Ù¸¥ ¸ðµâ·Î´Â FastIO'sÀÇ ClibPDF¸¦ ¹ÙÅÁÀ¸·Î ÇÑ °ÍÀÌ ÀÖ´Ù. ÀÌ°ÍÀº Á¶±Ý ´Ù¸¥ APIÀÌ´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº ClibPDF functions ÀåÀ» ÂüÁ¶Çϱ⠹ٶõ´Ù.

    ÇöÀç ¸ðµç ¹öÀüÀÇ pdflib¸¦ Áö¿øÇÏ°í ÀÖ´Ù. º¸Åë »õ ¹öÀüÀÌ ´õ ¸¹Àº ±â´ÉÀ» Á¦°øÇÏ°í ¿©·¯ ¹®Á¦¸¦ ÇØ°áÇÏ°í Àֱ⠶§¹®¿¡ °¡´ÉÇÏ¸é »õ ¹öÀüÀ» »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù. ÇÏÁö¸¸, ºÒÇàÈ÷µµ 2.x ¹öÀüÀÇ pdflib API´Â 0.6 ¹öÀü¿¡ ºñÇØ PHP ÇÔ¼ö¿¡ ¸î°¡Áö ¼öÁ¤À» ¿ä±¸ÇÑ´Ù. ±× ³»¿ëÀº ´ÙÀ½°ú °°´Ù.

    PHP´Â pdflibÀÇ 2.01 ¹öÀü¿¡¼­ ¸¹Àº º¯È­°¡ ÀÖ¾ú´Ù. ÀϺΠÇÔ¼ö´Â ´õ ÀÌ»ó ÇÊ¿ä°¡ ¾ø¾îÁ³´Ù.(¿¹:pdf_put_image()). ´çȲÇÏÁö ¾ÊÀ¸·Á¸é ÁÖÀÇ°¡ ÇÊ¿äÇÏ´Ù.

     

    pdf ¸ðµâÀº pdfdoc¿Í pdfinfo¶ó´Â µÎ°¡Áö »õ·Î¿î º¯¼ö typeÀ» Á¦°øÇÑ´Ù.(pdflib 2.0¿¡¼­´Â pdfdoc°¡Áö ŸÀÔ¸¸ Á¦°øµÈ´Ù.) pdfdoc Àº PDF ¹®¼­ÀÇ Æ÷ÀÎÅÍÀÌ°í °ÅÀÇ ¸ðµç ÇÔ¼ö°¡ ÀÌ ÆĶó¸ÞÅ͸¦ ÇÊ¿ä·Î ÇÑ´Ù. pdfinfo´Â PDF ¹®¼­¿¡ ´ëÇÑ meta data¸¦ °¡Áö°í ÀÖ´Ù. pdfinfoÀÇ °ªÀº pdf_open()°¡ È£ÃâµÇ±â ÀÌÀü¿¡ ¼³Á¤µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù.

    Note: ¾Æ·¡ ³»¿ëÀº pdflib 0.6¿¡¸¸ Àû¿ëµÇ´Â À̾߱âÀÌ´Ù. ±× ÀÌÈĹöÀüÀº pdflib ¸Å´º¾óÀ» Àо±â ¹Ù¶õ´Ù.

    ¿ÜºÎ text¸¦ PDF ¹®¼­·Î ¸¸µé±â À§Çؼ­´Â °¢°¢ÀÇ ÆùÆ®¿¡ ´ëÇÑ afm ÆÄÀÏÀ» Á¦°øÇØ ÁÖ¾î¾ß ÇÑ´Ù. ±âº»ÀûÀ¸·Î ÀÌ afm ÆÄÀϵéÀº PHP½ºÅ©¸³Æ®°¡ À§Ä¡ÇÑ µð·ºÅ丮³»¿¡ 'fonts' ¶ó´Â À̸§ÀÇ µð·ºÅ丮¿¡¼­ ã°Ô µÈ´Ù. (ÁÖÀÇ, ÀÌ ³»¿ëÀº pdflib 0.6¿¡¼­´Â »ç½ÇÀÌ´Ù. ±×·¯³ª »õ ¹öÀü¿¡¼­´Â ´õ ÀÌ»ó afm ÆÄÀÏÀÌ ÇÊ¿ä¾ø´Ù.)

    ´ëºÎºÐÀÇ ÇÔ¼öµéÀº »ç¿ëÇϱ⠽±´Ù. °£´ÜÇÑ pdf ¹®¼­¸¦ Çϳª ¸¸µé¾îº¸¸é º°·Î ¾î·ÆÁö ¾Ê´Ù´Â °ÍÀ» ¾Ë ¼ö ÀÖÀ» °ÍÀÌ´Ù. ´ÙÀ½ ¿¹¸¦ º¸¸é ½±°Ô ½ÃÀÛÇÒ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº ÇÑ ÀåÂ¥¸® test.pdf¶ó´Â ÆÄÀÏÀ» ¸¸µå´Â °ÍÀÌ´Ù. ÀÌ ÆäÀÌÁö¿¡´Â ¿Ü°û¼± 30ptÀÇ "Times-Roman" ÆùÆ®ÀÇ text°¡ ¾²¿©Áø´Ù. ÀÌ text´Â ¹ØÁÙÀÌ ±×¾îÁø´Ù.

    Example 1. Creating a PDF document with pdflib 0.6

      1 
      2 <?php
      3 $fp = fopen("test.pdf", "w");
      4 $info = PDF_get_info();
      5 pdf_set_info_author($info, "Uwe Steinmann");
      6 PDF_set_info_title($info, "Test for PHP wrapper of PDFlib 0.6");
      7 PDF_set_info_author($info, "Name of Author");
      8 pdf_set_info_creator($info, "See Author");
      9 pdf_set_info_subject($info, "Testing");
     10 $pdf = PDF_open($fp, $info);
     11 PDF_begin_page($pdf, 595, 842);
     12 PDF_add_outline($pdf, "Page 1");
     13 pdf_set_font($pdf, "Times-Roman", 30, 4);
     14 pdf_set_text_rendering($pdf, 1);
     15 PDF_show_xy($pdf, "Times Roman outlined", 50, 750);
     16 pdf_moveto($pdf, 50, 740);
     17 pdf_lineto($pdf, 330, 740);
     18 pdf_stroke($pdf);
     19 PDF_end_page($pdf);
     20 PDF_close($pdf);
     21 fclose($fp);
     22 echo "<A HREF=getpdf.php3>finished</A>";
     23 ?>
     24     

    ´ÙÀ½ÀÇ getpdf.php3¶ó´Â PHP ½ºÅ©¸³Æ®´Â pdf ¹®¼­¸¦ Ãâ·ÂÇÑ´Ù.

      1 
      2 <?php
      3 $fp = fopen("test.pdf", "r");
      4 header("Content-type: application/pdf");
      5 fpassthru($fp);
      6 fclose($fp);
      7 ?>
      8      

    À§ÀÇ ¿¹Á¦¸¦ pdflib 2.0 À¸·Î ÀÛ¼ºÇÏ¸é ´ÙÀ½°ú °°´Ù.

    Example 2. Creating a PDF document with pdflib 2.x

      1 
      2 <?php
      3 $fp = fopen("test.pdf", "w");
      4 $pdf = PDF_open($fp);
      5 pdf_set_info_author($pdf, "Uwe Steinmann");
      6 PDF_set_info_title($pdf, "Test for PHP wrapper of PDFlib 2.0");
      7 PDF_set_info_author($pdf, "Name of Author");
      8 pdf_set_info_creator($pdf, "See Author");
      9 pdf_set_info_subject($pdf, "Testing");
     10 PDF_begin_page($pdf, 595, 842);
     11 PDF_add_outline($pdf, "Page 1");
     12 pdf_set_font($pdf, "Times-Roman", 30, 4);
     13 pdf_set_text_rendering($pdf, 1);
     14 PDF_show_xy($pdf, "Times Roman outlined", 50, 750);
     15 pdf_moveto($pdf, 50, 740);
     16 pdf_lineto($pdf, 330, 740);
     17 pdf_stroke($pdf);
     18 PDF_end_page($pdf);
     19 PDF_close($pdf);
     20 fclose($fp);
     21 echo "<A HREF=getpdf.php3>finished</A>";
     22 ?>
     23      

    getpdf.php3 PHP ½ºÅ©¸³Æ®´Â À§¿Í µ¿ÀÏÇÏ´Ù.

    pdflib ¹èÆ÷º»¿¡ º¸¸é ¾Æ³ª·Î±× ½Ã°è°¡ Æ÷ÇÔµÈ ¿©·¯ ÆÛÀÌÁöÀÇ ¹®¼­¸¦ ¸¸µå´Â Á¶±ÝÀº º¹ÀâÇÑ ¿¹Á¦°¡ ÀÖ´Ù. ¿©±â ±× ¿¹Á¦¸¦ pdflib 2.x¸¦ »ç¿ëÇÑ PHP·Î º¯È¯ÇÑ ¿¹°¡ ÀÖ´Ù. (µ¿ÀÏÇÑ ¿¹Á¦ ¹®¼­¸¦ clibpdf module¿¡ Æ÷ÇÔµÈ ¹®¼­¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.):

    Example 3. pdfclock example from pdflib 2.x distribution

      1 
      2 <?php
      3 $pdffilename = "clock.pdf";
      4 $radius = 200;
      5 $margin = 20;
      6 $pagecount = 40;
      7 
      8 $fp = fopen($pdffilename, "w");
      9 $pdf = pdf_open($fp);
     10 pdf_set_info_creator($pdf, "pdf_clock.php3");
     11 pdf_set_info_author($pdf, "Uwe Steinmann");
     12 pdf_set_info_title($pdf, "Analog Clock");
     13 
     14 while($pagecount-- > 0) {
     15     pdf_begin_page($pdf, 2 * ($radius + $margin), 2 * ($radius + $margin));
     16 
     17     pdf_set_transition($pdf, 4);  /* wipe */ 
     18     pdf_set_duration($pdf, 0.5);
     19   
     20     pdf_translate($pdf, $radius + $margin, $radius + $margin);
     21     pdf_save($pdf);
     22     pdf_setrgbcolor($pdf, 0.0, 0.0, 1.0);
     23 
     24     /* minute strokes */
     25     pdf_setlinewidth($pdf, 2.0);
     26     for ($alpha = 0; $alpha < 360; $alpha += 6) {
     27         pdf_rotate($pdf, 6.0);
     28         pdf_moveto($pdf, $radius, 0.0);
     29         pdf_lineto($pdf, $radius-$margin/3, 0.0);
     30         pdf_stroke($pdf);
     31     }
     32 
     33     pdf_restore($pdf);
     34     pdf_save($pdf);
     35 
     36     /* 5 minute strokes */
     37     pdf_setlinewidth($pdf, 3.0);
     38     for ($alpha = 0; $alpha < 360; $alpha += 30) { 
     39         pdf_rotate($pdf, 30.0);
     40         pdf_moveto($pdf, $radius, 0.0);
     41         pdf_lineto($pdf, $radius-$margin, 0.0);
     42         pdf_stroke($pdf);
     43     }
     44 
     45     $ltime = getdate();
     46 
     47     /* draw hour hand */
     48     pdf_save($pdf);
     49     pdf_rotate($pdf,-(($ltime['minutes']/60.0)+$ltime['hours']-3.0)*30.0);
     50     pdf_moveto($pdf, -$radius/10, -$radius/20);
     51     pdf_lineto($pdf, $radius/2, 0.0);
     52     pdf_lineto($pdf, -$radius/10, $radius/20);
     53     pdf_closepath($pdf);
     54     pdf_fill($pdf);
     55     pdf_restore($pdf);
     56 
     57     /* draw minute hand */
     58     pdf_save($pdf);
     59     pdf_rotate($pdf,-(($ltime['seconds']/60.0)+$ltime['minutes']-15.0)*6.0);
     60     pdf_moveto($pdf, -$radius/10, -$radius/20);
     61     pdf_lineto($pdf, $radius * 0.8, 0.0);
     62     pdf_lineto($pdf, -$radius/10, $radius/20);
     63     pdf_closepath($pdf);
     64     pdf_fill($pdf);
     65     pdf_restore($pdf);
     66 
     67     /* draw second hand */
     68     pdf_setrgbcolor($pdf, 1.0, 0.0, 0.0);
     69     pdf_setlinewidth($pdf, 2);
     70     pdf_save($pdf);
     71     pdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0));
     72     pdf_moveto($pdf, -$radius/5, 0.0);
     73     pdf_lineto($pdf, $radius, 0.0);
     74     pdf_stroke($pdf);
     75     pdf_restore($pdf);
     76 
     77     /* draw little circle at center */
     78     pdf_circle($pdf, 0, 0, $radius/30);
     79     pdf_fill($pdf);
     80 
     81     pdf_restore($pdf);
     82 
     83     pdf_end_page($pdf);
     84 }
     85 
     86 $pdf = pdf_close($pdf);
     87 fclose($fp);
     88 echo "<A HREF=getpdf.php3?filename=".$pdffilename.">finished</A>";
     89 ?>
     90      

    ´ÙÀ½ÀÇ getpdf.php3¶ó´Â PHP ½ºÅ©¸³Æ®´Â pdf ¹®¼­¸¦ Ãâ·ÂÇÑ´Ù.

      1 
      2 <?php
      3 $fp = fopen($filename, "r");
      4 header("Content-type: application/pdf");
      5 fpassthru($fp);
      6 fclose($fp);
      7 ?>
      8       
    Table of Contents
    PDF_get_info ¡¦ Returns a default info structure for a pdf document
    PDF_set_info_creator ¡¦ Fills the creator field of the info structure
    PDF_set_info_title ¡¦ Fills the title field of the info structure
    PDF_set_info_subject ¡¦ Fills the subject field of the info structure
    PDF_set_info_keywords ¡¦ Fills the keywords field of the info structure
    PDF_set_info_author ¡¦ Fills the author field of the info structure
    PDF_open ¡¦ Opens a new pdf document
    PDF_close ¡¦ Closes the pdf document
    PDF_begin_page ¡¦ Starts page
    PDF_end_page ¡¦ Ends page
    PDF_show ¡¦ Output text at current position
    PDF_show_boxed ¡¦ Output text in a box
    PDF_show_xy ¡¦ Output text at position
    PDF_set_font ¡¦ Select the current font face and size
    PDF_set_leading ¡¦ Sets distance between text lines
    PDF_set_parameter ¡¦ Sets certain parameters
    PDF_set_text_rendering ¡¦ Determines how text is rendered
    PDF_set_horiz_scaling ¡¦ Sets horizontal scaling of text
    PDF_set_text_rise ¡¦ Sets the text rise
    PDF_set_text_matrix ¡¦ Sets the text matrix
    PDF_set_text_pos ¡¦ Sets text position
    PDF_set_char_spacing ¡¦ Sets character spacing
    PDF_set_word_spacing ¡¦ Sets spacing between words
    PDF_skew ¡¦ Skews the coordinate system
    PDF_continue_text ¡¦ Output text in next line
    PDF_stringwidth ¡¦ Returns width of text in current font
    PDF_save ¡¦ Saves current enviroment
    PDF_restore ¡¦ Restores formerly saved enviroment
    PDF_translate ¡¦ Sets origin of coordinate system
    PDF_scale ¡¦ Sets scaling
    PDF_rotate ¡¦ Sets rotation
    PDF_setflat ¡¦ Sets flatness
    PDF_setlinejoin ¡¦ Sets linejoin parameter
    PDF_setlinecap ¡¦ Sets linecap aparameter
    PDF_setmiterlimit ¡¦ Sets miter limit
    PDF_setlinewidth ¡¦ Sets line width
    PDF_setdash ¡¦ Sets dash pattern
    PDF_moveto ¡¦ Sets current point
    PDF_curveto ¡¦ Draws a curve
    PDF_lineto ¡¦ Draws a line
    PDF_circle ¡¦ Draw a circle
    PDF_arc ¡¦ Draws an arc
    PDF_rect ¡¦ Draw a rectangle
    PDF_closepath ¡¦ Close path
    PDF_stroke ¡¦ Draw line along path
    PDF_closepath_stroke ¡¦ Close path and draw line along path
    PDF_fill ¡¦ Fill current path
    PDF_fill_stroke ¡¦ Fill and stroke current path
    PDF_closepath_fill_stroke ¡¦ Close, fill and stroke current path
    PDF_endpath ¡¦ Ends current path
    PDF_clip ¡¦ Clips to current path
    PDF_setgray_fill ¡¦ Sets filling color to gray value
    PDF_setgray_stroke ¡¦ Sets drawing color to gray value
    PDF_setgray ¡¦ Sets drawing and filling color to gray value
    PDF_setrgbcolor_fill ¡¦ Sets filling color to rgb color value
    PDF_setrgbcolor_stroke ¡¦ Sets drawing color to rgb color value
    PDF_setrgbcolor ¡¦ Sets drawing and filling color to rgb color value
    PDF_add_outline ¡¦ Adds bookmark for current page
    PDF_set_transition ¡¦ Sets transition between pages
    PDF_set_duration ¡¦ Sets duration between pages
    PDF_open_gif ¡¦ Opens a GIF image
    PDF_open_png ¡¦ Opens a PNG image
    PDF_open_memory_image ¡¦ Opens an image created with PHP's image functions
    PDF_open_jpeg ¡¦ Opens a JPEG image
    PDF_close_image ¡¦ Closes an image
    PDF_place_image ¡¦ Places an image on the page
    PDF_put_image ¡¦ Stores an image in the PDF for later use
    PDF_execute_image ¡¦ Places a stored image on the page
    PDF_add_annotation ¡¦ Adds annotation

    PDF_get_info

    PDF_get_info -- pdf ¹®¼­¿¡ ´ëÇÑ ±âº» Á¤º¸(info structure)¸¦ ¹ÝȯÇÑ´Ù.

    Description

    info pdf_get_info (string filename)

    The PDF_get_info() function returns a default info structure for the pdf document. It should be filled with appropriate information like the author, subject etc. of the document.

    Note: This functions is not available if pdflib 2.x support is activated.

    See also PDF_set_info_creator(), PDF_set_info_author(), PDF_set_info_keywords(), PDF_set_info_title(), PDF_set_info_subject().

    PDF_set_info_creator

    PDF_set_info_creator -- info structureÀÇ creator Çʵ带 ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_set_info_creator (info info, string creator);

    The PDF_set_info_creator() function sets the creator of a pdf document. It has to be called after PDF_get_info() and before PDF_open(). Calling it after PDF_open() will have no effect on the document.

    Note: This function is not part of the pdf library.

    Note: This function takes a different first parameter if pdflib 2.x support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open(). Consequently, pdf_open() has to be called before this function.

    See also PDF_get_info(), PDF_set_info_keywords(), PDF_set_info_title(), PDF_set_info_subject().

    PDF_set_info_title

    PDF_set_info_title -- info structureÀÇ title Çʵ带 ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_set_info_title (info info, string title);

    The PDF_set_info_title() function sets the title of a pdf document. It has to be called after PDF_get_info() and before PDF_open(). Calling it after PDF_open() will have no effect on the document.

    Note: This function is not part of the pdf library.

    Note: This function takes a different first parameter if pdflib 2.0 support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open(). Consequently, pdf_open() has to be called before this function.

    See also PDF_get_info(), PDF_set_info_creator(), PDF_set_info_author(), PDF_set_info_keywords(), PDF_set_info_subject().

    PDF_set_info_subject

    PDF_set_info_subject -- info structureÀÇ subject Çʵ带 ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_set_info_subject (info info, string subject);

    The PDF_set_info_subject() function sets the subject of a pdf document. It has to be called after PDF_get_info() and before PDF_open(). Calling it after PDF_open() will have no effect on the document.

    Note: This function is not part of the pdf library.

    Note: This function takes a different first parameter if pdflib 2.0 support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open(). Consequently, pdf_open() has to be called before this function.

    See also PDF_get_info(), PDF_set_info_creator(), PDF_set_info_author(), PDF_set_info_title(), PDF_set_info_keywords().

    PDF_set_info_keywords

    PDF_set_info_keywords -- info structureÀÇ keyword Çʵ带 ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_set_info_keywords (info info, string keywords);

    The PDF_set_info_keywords() function sets the keywords of a pdf document. It has to be called after PDF_get_info() and before PDF_open(). Calling it after PDF_open() will have no effect on the document.

    Note: This function is not part of the pdf library.

    Note: This function takes a different first parameter if pdflib 2.0 support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open(). Consequently, pdf_open() has to be called before this function.

    See also PDF_get_info(), PDF_set_info_creator(), PDF_set_info_author(), PDF_set_info_title(), PDF_set_info_subject().

    PDF_set_info_author

    PDF_set_info_author -- info structureÀÇ author Çʵ带 ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_set_info_author (info info, string author);

    The PDF_set_info_author() function sets the author of a pdf document. It has to be called after PDF_get_info() and before PDF_open(). Calling it after PDF_open() will have no effect on the document.

    Note: This function is not part of the pdf library.

    Note: This function takes a different first parameter if pdflib 2.0 support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open(). Consequently, pdf_open() has to be called before this function.

    See also PDF_get_info(), PDF_set_info_creator(), PDF_set_info_keywords(), PDF_set_info_title(), PDF_set_info_subject().

    PDF_open

    PDF_open -- »õ pdf ¹®¼­¸¦ ¿¬´Ù.

    Description

    int pdf_open (int file, int info);

    The PDF_open() function opens a new pdf document. The corresponding file has to be opened with fopen() and the file descriptor passed as argument file. info is the info structure that has to be created with pdf_get_info(). The info structure will be deleted within this function.

    Note: The return value is needed as the first parameter in all other functions writing to the pdf document.

    Note: This function does not allow the second parameter if pdflib 2.0 support is activated.

    See also fopen(), PDF_get_info(), PDF_close().

    PDF_close

    PDF_close -- pdf ¹®¼­¸¦ ´Ý´Â´Ù.

    Description

    void pdf_close(int pdf document);

    The PDF_close() function closes the pdf document.

    Note: Due to an unclean implementation of the pdflib 0.6 the internal closing of the document also closes the file. This should not be done because pdflib did not open the file, but expects an already open file when PDF_open() is called. Consequently it shouldn't close the file. In order to fix this just take out line 190 of the file p_basic.c in the pdflib 0.6 source distribution until the next release of pdflib will fix this.

    Note: This function works properly without any patches to pdflib if pdflib 2.0 support is activated.

    See also PDF_open(), fclose().

    PDF_begin_page

    PDF_begin_page -- »õ ÆäÀÌÁö¸¦ ½ÃÀÛÇÑ´Ù.

    Description

    void pdf_begin_page (int pdf document, double height, double width);

    The PDF_begin_page() function starts a new page with height height and width width.

    See also PDF_end_page().

    PDF_end_page

    PDF_end_page -- ÆäÀÌÁö¸¦ ³¡³½´Ù.

    Description

    void pdf_end_page (int pdf document);

    The PDF_end_page() function ends a page. Once a page is ended it cannot be modified anymore.

    See also PDF_begin_page().

    PDF_show

    PDF_show -- ÇöÀç À§Ä¡¿¡ text¸¦ Ãâ·ÂÇÑ´Ù.

    Description

    void pdf_show (int pdf document, string text);

    The PDF_show() function outputs the string text at the current position using the current font.

    See also PDF_show_xy(), PDF_show_boxed(), PDF_set_text_pos(), PDF_set_font().

    PDF_show_boxed

    PDF_show_boxed -- ÁöÁ¤µÈ À§Ä¡¿¡ text¸¦ Ãâ·ÂÇÏ°í ¹Ú½º¸¦ Ä£´Ù.

    Description

    int pdf_show_boxed (int pdf document, string text, double x-coor, double y-coor, double width, double height, string mode)

    The PDF_show_boxed() function outputs the string text in a box with its lower left position at (x-coor, y-coor). The boxes dimension is height by width. The parameter mode determines how the text is type set. If width and height are zero, the mode can be "left", "right" or "center". If width or height is unequal zero it can also be "justify" and "fulljustify".

    Returns the number of characters that could not be processed because they did not fit into the box.

    See also PDF_show(), PDF_show_xy()

    PDF_show_xy

    PDF_show_xy -- ÁöÁ¤ÇÑ À§Ä¡¿¡ text¸¦ Ãâ·ÂÇÑ´Ù.

    Description

    void pdf_show_xy (int pdf document, string text, double x-koor, double y-koor);

    The PDF_show_xy() function outputs the string text at position (x-koor, y-koor).

    See also PDF_show().

    PDF_set_font

    PDF_set_font -- »ç¿ëÇÒ font ¸ð¾ç°ú Å©±â¸¦ ¼±ÅÃÇÑ´Ù.

    Description

    void pdf_set_font (int pdf document, string font name, double size, string encoding [, int embed])

    The PDF_set_font() function sets the current font face, font size and encoding. If you use pdflib 0.6 you will need to provide the Adobe Font Metrics (afm-files) for the font in the font path (default is ./fonts). If you use php3 or a version of pdflib older than 2.20 the fourth parameter encoding can take the following values: 0 = builtin, 1 = pdfdoc, 2 = macroman, 3 = macexpert, 4 = winansi. An encoding greater than 4 and less than 0 will default to winansi. winansi is often a good choice. If you use php4 and a version of pdflib >= 2.20 the encoding parameter has changed to a string. Use 'winansi', 'builtin' etc. instead. If the last parameter is set to 1 the font is embedded into the pdf document otherwise it is not. To embed a font is usually a good idea if the font is not widely spread and you cannot ensure that the person watching your document has access on fonts in the document. I font is only embedded once even if you call PDF_set_font() several times.

    Note: This function has to be called after PDF_begin_page() in order to create a valid pdf document.

    Note: If you reference a font in a .upr file make sure the name in the afm file and the font name are the same. Otherwise, the font will be embedded several times (Thanks to Paul Haddon for finding this.)

    PDF_set_leading

    PDF_set_leading -- ÁÙ °£°ÝÀ» ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_set_leading (int pdf document, double distance)

    The PDF_set_leading() function sets the distance between text lines. This will be used if text is output by PDF_continue_text().

    See also PDF_continue_text().

    PDF_set_parameter

    PDF_set_parameter -- Æ¯Á¤ ÆĶó¸ÞÅ͸¦ ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_set_parameter (int pdf document, string name, string value)

    The PDF_set_parameter() function sets several parameters of pdflib.

    PDF_set_text_rendering

    PDF_set_text_rendering -- text¸¦ Ãâ·ÂÇÒ ¹æ½ÄÀ» °áÁ¤ÇÑ´Ù.(Determines how text is rendered)

    Description

    void pdf_set_text_rendering(int pdf document, int mode);

    The PDF_set_text_rendering() function determines how text is rendered. The possible values for mode are 0=fill text, 1=stroke text, 2=fill and stroke text, 3=invisible, 4=fill text and add it to cliping path, 5=stroke text and add it to clipping path, 6=fill and stroke text and add it to cliping path, 7=add it to clipping path.

    PDF_set_horiz_scaling

    PDF_set_horiz_scaling -- textÀÇ ¼öÆò È®´ë ºñÀ²À» Á¤ÇÑ´Ù.

    Description

    void pdf_set_horiz_scaling(int pdf document, double scale);

    The PDF_set_horiz_scaling() function sets the horizontal scaling to scale percent.

    PDF_set_text_rise

    PDF_set_text_rise -- text¸¦ riseÇÏ°Ô Ç¥½ÃµÇµµ·Ï ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_set_text_rise(int pdf document, double value);

    The PDF_set_text_rise() function sets the text rising to value points.

    PDF_set_text_matrix

    PDF_set_text_matrix -- text¸¦ matrix ÇüÅ·ΠÁöÁ¤ÇÑ´Ù.

    Description

    void pdf_set_text_matrix(int pdf document, array matrix);

    The PDF_set_text_matrix() function sets a matrix which describes a transformation applied on the current text font. The matrix has to passed as an array with six elements.

    PDF_set_text_pos

    PDF_set_text_pos -- textÀÇ À§Ä¡¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_set_text_pos(int pdf document, double x-koor, double y-koor);

    The PDF_set_text_pos() function sets the position of text for the next pdf_show() function call.

    See also PDF_show(), PDF_show_xy().

    PDF_set_char_spacing

    PDF_set_char_spacing -- ±ÛÀÚ »çÀÌÀÇ °£°ÝÀ» ÁöÁ¤ÇÑ´Ù.

    Description

    void pdf_set_char_spacing(int pdf document, double space);

    The PDF_set_char_spacing() function sets the spacing between characters.

    See also PDF_set_word_spacing(), PDF_set_leading().

    PDF_set_word_spacing

    PDF_set_word_spacing -- ´Ü¾î »çÀÌÀÇ °£°ÝÀ» ÁöÁ¤ÇÑ´Ù.

    Description

    void pdf_set_word_spacing(int pdf document, double space);

    The PDF_set_word_spacing() function sets the spacing between words.

    See also PDF_set_char_spacing(), PDF_set_leading().

    PDF_skew

    PDF_skew -- ÁÂÇ¥ ½Ã½ºÅÛ ÀÚü¸¦ ±â¿ïÀδÙ.(skew)

    Description

    void pdf_skew (int pdf document, double alpha, double beta)

    The PDF_skew() function skew the coordinate system by alpha (x) and beta (y) degrees. alpha and beta may not be 90 or 270 degrees.

    PDF_continue_text

    PDF_continue_text -- »õ ÁÙ¿¡ text¸¦ Ãâ·ÂÇÑ´Ù.

    Description

    void pdf_continue_text(int pdf document, string text);

    The PDF_continue_text() function outputs the string in text in the next line. The distance between the lines can be set with PDF_set_leading().

    See also PDF_show_xy(), PDF_set_leading(), PDF_set_text_pos().

    PDF_stringwidth

    PDF_stringwidth -- ÇöÀç »ç¿ëÁßÀÎ fontÀÇ ³ÐÀ̸¦ ±¸ÇÑ´Ù.

    Description

    double pdf_stringwidth(int pdf document, string text);

    The PDF_stringwidth() function returns the width of the string in text. It requires a font to be set before.

    See also PDF_set_font().

    PDF_save

    PDF_save -- ÇöÀç ȯ°æÀ» ÀúÀåÇÑ´Ù.

    Description

    void pdf_save(int pdf document);

    The PDF_save() function saves the current environment. It works like the postscript command gsave. Very useful if you want to translate or rotate an object without effecting other objects. PDF_save() should always be followed by PDF_restore().

    See also PDF_restore().

    PDF_restore

    PDF_restore -- Àü¿¡ ÀúÀåÇØ µÎ¾ú´ø ȯ°æÀ¸·Î º¹±ÍÇÑ´Ù.

    Description

    void pdf_restore(int pdf document);

    The PDF_restore() function restores the environment saved with PDF_save(). It works like the postscript command grestore. Very useful if you want to translate or rotate an object without effecting other objects.

    Example 1. Save and Restore

    <?php PDF_save($pdf);
    // do all kinds of rotations, transformations, ...
    PDF_restore($pdf) ?>

    See also PDF_save().

    PDF_translate

    PDF_translate -- koordinate systemÀÇ ±âÁØÀ̵Ǵ ¿øÁ¡À» Á¤ÇÑ´Ù.

    Description

    void pdf_translate(int pdf document, double x-koor, double y-koor);

    The PDF_translate() function set the origin of coordinate system to the point (x-koor, y-koor). The following example draws a line from (0, 0) to (200, 200) relative to the initial coordinate system. You have to set the current point after PDF_translate() and before you start drawing more objects.

    Example 1. Translation

    <?php PDF_moveto($pdf, 0, 0);
    PDF_lineto($pdf, 100, 100);
    PDF_stroke($pdf);
    PDF_translate($pdf, 100, 100);
    PDF_moveto($pdf, 0, 0);
    PDF_lineto($pdf, 100, 100);
    PDF_stroke($pdf);
    ?>

    PDF_scale

    PDF_scale -- scalingÀ» ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_scale(int pdf document, double x-scale, double y-scale);

    The PDF_scale() function set the scaling factor in both directions. The following example scales x and y direction by 72. The following line will therefore be drawn one inch in both directions.

    Example 1. Scaling

    <?php PDF_scale($pdf, 72.0, 72.0);
    PDF_lineto($pdf, 1, 1);
    PDF_stroke($pdf);
    ?>

    PDF_rotate

    PDF_rotate -- ȸÀüÀ²À» Á¤ÇÑ´Ù.

    Description

    void pdf_rotate(int pdf document, double angle);

    The PDF_rotate() function set the rotation in degress to angle.

    PDF_setflat

    PDF_setflat -- flatness¸¦ Á¤ÇÑ´Ù.

    Description

    void pdf_setflat(int pdf document, double value);

    The PDF_setflat() function set the flatness to a value between 0 and 100.

    PDF_setlinejoin

    PDF_setlinejoin -- linejoin parameter¸¦ Á¤ÇÑ´Ù.

    Description

    void pdf_setlinejoin(int pdf document, long value);

    The PDF_setlinejoin() function set the linejoin parameter between a value of 0 and 2.

    PDF_setlinecap

    PDF_setlinecap -- linecap aparameter¸¦ Á¤ÇÑ´Ù.

    Description

    void pdf_setlinecap(int pdf document, int value);

    The PDF_setlinecap() function set the linecap parameter between a value of 0 and 2.

    PDF_setmiterlimit

    PDF_setmiterlimit -- miter limitÀ» Á¤ÇÑ´Ù.

    Description

    void pdf_setmiterlimit(int pdf document, double value);

    The PDF_setmiterlimit() function set the miter limit to a value greater of equal than 1.

    PDF_setlinewidth

    PDF_setlinewidth -- ÇÑ ¶óÀÎÀÇ ÆøÀ» Á¤ÇÑ´Ù.

    Description

    void pdf_setlinewidth(int pdf document, double width);

    The PDF_setlinewidth() function set the line width to width.

    PDF_setdash

    PDF_setdash -- Á¡¼±ÀÇ ¹«´Ì¸¦ Á¤ÇÑ´Ù.

    Description

    void pdf_setdash(int pdf document, double white, double black);

    The PDF_setdash() function set the dash pattern white white points and black black points. If both are 0 a solid line is set.

    PDF_moveto

    PDF_moveto -- ÇöÀç À§Ä¡¸¦ ¹Ù²Û´Ù.

    Description

    void pdf_moveto(int pdf document, double x-koor, double y-koor);

    The PDF_moveto() function set the current point to the coordinates x-koor and y-koor.

    PDF_curveto

    PDF_curveto -- °î¼±À» ±×¸°´Ù.

    Description

    void pdf_curveto(int pdf document, double x1, double y1, double x2, double y2, double x3, double y3);

    The PDF_curveto() function draws a Bezier curve from the current point to the point (x3, y3) using (x1, y1) and (x2, y2) as control points.

    See also PDF_moveto(), PDF_lineto(), PDF_stroke().

    PDF_lineto

    PDF_lineto -- Á÷¼±À» ±×¸°´Ù.

    Description

    void pdf_lineto(int pdf document, double x-koor, double y-koor);

    The PDF_lineto() function draws a line from the current point to the point with coordinates (x-koor, y-koor).

    See also PDF_moveto(), PDF_curveto(), PDF_stroke().

    PDF_circle

    PDF_circle -- ¿øÀ» ±×¸°´Ù.

    Description

    void pdf_circle(int pdf document, double x-koor, double y-koor, double radius);

    The PDF_circle() function draws a circle with center at point (x-koor, y-koor) and radius radius.

    See also PDF_arc(), PDF_stroke().

    PDF_arc

    PDF_arc -- ¿øÈ£¸¦ ±×¸°´Ù.

    Description

    void pdf_arc(int pdf document, double x-koor, double y-koor, double radius, double start, double end);

    The PDF_arc() function draws an arc with center at point (x-koor, y-koor) and radius radius, starting at angle start and ending at angle end.

    See also PDF_circle(), PDF_stroke().

    PDF_rect

    PDF_rect -- »ç°¢ÇüÀ» ±×¸°´Ù.

    Description

    void pdf_rect(int pdf document, double x-koor, double y-koor, double width, double height);

    The PDF_rect() function draws a rectangle with its lower left corner at point (x-koor, y-koor). This width is set to widgth. This height is set to height.

    See also PDF_stroke().

    PDF_closepath

    PDF_closepath -- path¸¦ ´Ý´Â´Ù.

    Description

    void pdf_closepath(int pdf document);

    The PDF_closepath() function closes the current path. This means, it draws a line from current point to the point where the first line was started. Many functions like PDF_moveto(), PDF_circle() and PDF_rect() start a new path.

    PDF_stroke

    PDF_stroke -- path¸¦ µû¶ó ¼±À» ±×¸°´Ù.

    Description

    void pdf_stroke(int pdf document);

    The PDF_stroke() function draws a line along current path. The current path is the sum of all line drawing. Without this function the line would not be drawn.

    See also PDF_closepath(), PDF_closepath_stroke().

    PDF_closepath_stroke

    PDF_closepath_stroke -- path¸¦ µû¶ó ¼±À» ±×¸®°í path¸¦ ´Ý´Â´Ù.

    Description

    void pdf_closepath_stroke(int pdf document);

    The PDF_closepath_stroke() function is a combination of PDF_closepath() and PDF_stroke(). Than clears the path.

    See also PDF_closepath(), PDF_stroke().

    PDF_fill

    PDF_fill -- ÇöÀç path¾ÈÀ» Ä¥ÇÑ´Ù.

    Description

    void pdf_fill(int pdf document);

    The PDF_fill() function fills the interior of the current path with the current fill color.

    See also PDF_closepath(), PDF_stroke(), PDF_setgray_fill(), PDF_setgray(), PDF_setrgbcolor_fill(), PDF_setrgbcolor().

    PDF_fill_stroke

    PDF_fill_stroke -- ÇöÀç pathÀÇ ¾ÈÂÊÀ» Ä¥ÇÏ°í, ÇöÀç path¸¦ µû¶ó ±×¸°´Ù.

    Description

    void pdf_fill_stroke(int pdf document);

    The PDF_fill_stroke() function fills the interior of the current path with the current fill color and draws current path.

    See also PDF_closepath(), PDF_stroke(), PDF_fill(), PDF_setgray_fill(), PDF_setgray(), PDF_setrgbcolor_fill(), PDF_setrgbcolor().

    PDF_closepath_fill_stroke

    PDF_closepath_fill_stroke -- ÇöÀç pathÀÇ ¾ÈÂÊÀ» Ä¥ÇÏ°í, ÇöÀç path¸¦ µû¶ó ±×¸° ÈÄ, path¸¦ ´Ý´Â´Ù.

    Description

    void pdf_closepath_fill_stroke(int pdf document);

    The PDF_closepath_fill_stroke() function closes, fills the interior of the current path with the current fill color and draws current path.

    See also PDF_closepath(), PDF_stroke(), PDF_fill(), PDF_setgray_fill(), PDF_setgray(), PDF_setrgbcolor_fill(), PDF_setrgbcolor().

    PDF_endpath

    PDF_endpath -- ÇöÀç path¸¦ Á¾·áÇÑ´Ù.

    Description

    void pdf_endpath(int pdf document);

    The PDF_endpath() function ends the current path but does not close it.

    See also PDF_closepath().

    PDF_clip

    PDF_clip -- ÇöÀç path¸¦ clipÇÑ´Ù.

    Description

    void pdf_clip(int pdf document);

    The PDF_clip() function clips all drawing to the current path.

    PDF_setgray_fill

    PDF_setgray_fill -- Ä¥ÇÏ´Â »öÀ» ȸ»öÅæÀ¸·Î ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_setgray_fill(int pdf document, double value);

    The PDF_setgray_fill() function sets the current gray value to fill a path.

    See also PDF_setrgbcolor_fill().

    PDF_setgray_stroke

    PDF_setgray_stroke -- ±×¸®´Â »öÀ» ȸ»öÅæÀ¸·Î ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_setgray_stroke(int pdf document, double gray value);

    The PDF_setgray_stroke() function sets the current drawing color to the given gray value.

    See also PDF_setrgbcolor_stroke().

    PDF_setgray

    PDF_setgray -- Ä¥ÇÏ°í ±×¸®´Â »öÀ» ȸ»öÅæÀ¸·Î ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_setgray(int pdf document, double gray value);

    The PDF_setgray_stroke() function sets the current drawing and filling color to the given gray value.

    See also PDF_setrgbcolor_stroke(), PDF_setrgbcolor_fill().

    PDF_setrgbcolor_fill

    PDF_setrgbcolor_fill -- Ä¥ÇÏ´Â »öÀ» rgb color·Î ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_setrgbcolor_fill(int pdf document, double red value, double green value, double blue value);

    The PDF_setrgbcolor_fill() function sets the current rgb color value to fill a path.

    See also PDF_setrgbcolor_fill().

    PDF_setrgbcolor_stroke

    PDF_setrgbcolor_stroke -- ±×¸®´Â »öÀ» rgb color·Î ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_setrgbcolor_stroke(int pdf document, double red value, double green value, double blue value);

    The PDF_setrgbcolor_stroke() function sets the current drawing color to the given rgb color value.

    See also PDF_setrgbcolor_stroke().

    PDF_setrgbcolor

    PDF_setrgbcolor -- Ä¥ÇÏ°í ±×¸®´Â »öÀ» rgb color·Î ¼³Á¤ÇÑ´Ù.

    Description

    void pdf_setrgbcolor(int pdf document, double red value, double green value, double blue value);

    The PDF_setrgbcolor_stroke() function sets the current drawing and filling color to the given rgb color value.

    See also PDF_setrgbcolor_stroke(), PDF_setrgbcolor_fill().

    PDF_add_outline

    PDF_add_outline -- ÇöÀç ÆäÀÌÁö¿¡ bookmark¸¦ Ãß°¡ÇÑ´Ù.

    Description

    void pdf_add_outline(int pdf document, string text);

    The PDF_add_outline() function adds a bookmark with text text that points to the current page.

    Unfortunately pdflib does not make a copy of the string, which forces PHP to allocate the memory. Currently this piece of memory is not been freed by any PDF function but it will be taken care of by the PHP memory manager.

    PDF_set_transition

    PDF_set_transition -- ÆäÀÌÁö°£ÀÇ transitionÀ» ÁöÁ¤ÇÑ´Ù.

    Description

    void pdf_set_transition(int pdf document, int transition);

    The PDF_set_transition() function set the transition between following pages. The value of transition can be

    0 for none,

    1 for two lines sweeping across the screen reveal the page,

    2 for multiple lines sweeping across the screen reveal the page,

    3 for a box reveals the page,

    4 for a single line sweeping across the screen reveals the page,

    5 for the old page dissolves to reveal the page,

    6 for the dissolve effect moves from one screen edge to another,

    7 for the old page is simply replaced by the new page (default)

    See also PDF_set_duration().

    PDF_set_duration

    PDF_set_duration -- page°£ÀÇ durationÀ» ÁöÁ¤ÇÑ´Ù.

    Description

    void pdf_set_duration(int pdf document, double duration);

    The PDF_set_duration() function set the duration between following pages in seconds.

    See also PDF_set_transition().

    PDF_open_gif

    PDF_open_gif -- GIF À̹ÌÁö¸¦ ¿¬´Ù.

    Description

    int pdf_open_gif(int pdf document, string filename);

    The PDF_open_gif() function opens an image stored in the file with the name filename. The format of the image has to be gif. The function returns a pdf image identifier.

    Example 1. Including a gif image

    <?php
    $im = PDF_open_gif($pdf, "test.gif");
    pdf_place_image($pdf, $im, 100, 100, 1);
    pdf_close_image($pdf, $im);
    ?>
          

    See also PDF_close_image(), PDF_open_jpeg(), PDF_open_png(), PDF_open_memory_image(), PDF_execute_image(), PDF_place_image(), PDF_put_image().

    PDF_open_png

    PDF_open_png --  Opens a PNG image

    Description

    int pdf_open_png (int pdf, string png_file)

    The PDF_open_png() function opens an image stored in the file with the name filename. The format of the image has to be png. The function returns a pdf image identifier.

    Example 1. Including a PNG image

      1 
      2 <?php
      3 $im = PDF_open_gif($pdf, "test.png");
      4 pdf_place_image($pdf, $im, 100, 100, 1);
      5 pdf_close_image($pdf, $im);
      6 ?>
      7           

    See also PDF_close_image(), PDF_open_jpeg(), PDF_open_gif(), PDF_open_memory_image(), PDF_execute_image(), PDF_place_image(), PDF_put_image().

    PDF_open_memory_image

    PDF_open_memory_image -- PHPÀÇ image ÇÔ¼ö·Î ¸¸µç image¸¦ ¿¬´Ù.

    Description

    int pdf_open_memory_image(int pdf document, string int image);

    The PDF_open_memory_image() function takes an image created with the PHP's image functions and makes it available for the pdf document. The function returns a pdf image identifier.

    Example 1. Including a memory image

    <?php
    $im = ImageCreate(100, 100);
    $col = ImageColorAllocate($im, 80, 45, 190);
    ImageFill($im, 10, 10, $col);
    $pim = PDF_open_memory_image($pdf, $im);
    ImageDestroy($im);
    pdf_place_image($pdf, $pim, 100, 100, 1);
    pdf_close_image($pdf, $pim);
    ?>
         

    See also PDF_close_image(), PDF_open_jpeg(), PDF_open_gif(), PDF_execute_image(), PDF_place_image(), PDF_put_image().

    PDF_open_jpeg

    PDF_open_jpeg -- JPEG image¸¦ ¿¬´Ù.

    Description

    int pdf_open_jpeg(int pdf document, string filename);

    The PDF_open_jpeg() function opens an image stored in the file with the name filename. The format of the image has to be jpeg. The function returns a pdf image identifier.

    See also PDF_close_image(), PDF_open_gif(), PDF_open_png(), PDF_open_memory_image(), PDF_execute_image(), PDF_place_image(), PDF_put_image().

    PDF_close_image

    PDF_close_image -- image¸¦ ´Ý´Â´Ù.

    Description

    void pdf_close_image(int image);

    The PDF_close_image() function closes an image which has been opened with any of the PDF_open_xxx() functions.

    See also PDF_open_jpeg(), PDF_open_gif(), PDF_open_png(), PDF_open_memory_image().

    PDF_place_image

    PDF_place_image -- image¸¦ page¿¡ À§Ä¡½ÃŲ´Ù.

    Description

    void pdf_place_image(int pdf document, int image, double x-koor, double y-koor, double scale);

    The PDF_place_image() function places an image on the page at postion (x-koor, x-koor). The image can be scaled at the same time.

    See also PDF_put_image().

    PDF_put_image

    PDF_put_image -- ³ªÁß¿¡ ¾²±â À§ÇØ image¸¦ PDF¿¡ ÀúÀåÇÑ´Ù.

    Description

    void pdf_put_image (int pdf document, int image)

    The PDF_put_image() function places an image in the PDF file without showing it. The stored image can be displayed with the PDF_execute_image() function as many times as needed. This is useful when using the same image multiple times in order to keep the file size small. Using PDF_put_image() and PDF_execute_image() is highly recommended for larger images (several kb) if they show up more than once in the document.

    Note: This function has become meaningless with version 2.01 of pdflib. It will just output a warning.

    See also PDF_put_image(), PDF_place_image(), PDF_execute_image().

    PDF_execute_image

    PDF_execute_image -- ÀúÀåµÈ image¸¦ page¿¡ À§Ä¡½ÃŲ´Ù.

    Description

    void pdf_execute_image(int pdf document, int image, double x-coor, double y-coor, double scale);

    The PDF_execute_image function displays an image that has been put in the PDF file with the PDF_put_image() function on the current page at the given coordinates.

    The image can be scaled while displaying it. A scale of 1.0 will show the image in the original size.

    Example 1. Multiple show of an image

    <?php
    $im = ImageCreate(100, 100);
    $col1 = ImageColorAllocate($im, 80, 45, 190);
    ImageFill($im, 10, 10, $col1);
    $pim = PDF_open_memory_image($pdf, $im);
    pdf_put_image($pdf, $pim);
    pdf_execute_image($pdf, $pim, 100, 100, 1);
    pdf_execute_image($pdf, $pim, 200, 200, 2);
    pdf_close_image($pdf, $pim);
    ?>
         

    PDF_add_annotation

    pdf_add_annotation -- ÁÖ¼®À» ÷°¡ÇÑ´Ù.

    Description

    void pdf_add_annotation(int pdf document, double llx, double lly, double urx, double ury, string title, string content);

    The pdf_add_annotation() adds a note with the lower left corner at (llx, lly) and the upper right corner at (urx, ury).


    XLV. Perl-compatible Regular Expression functions

    ÀÌ ÇÔ¼öµéÀº Perl Compatible Regular Expressions¿Í ÇÔ²² µ¿ÀÛÇϵµ·Ï ¸¸µé¾îÁ³´Ù.

    ÀÌ ÇÔ¼öµé¿¡¼­ »ç¿ëÇÏ´Â ÆÐÅÏÀÇ ¹®¹ýÀº Perl°ú ¸Å¿ì À¯»çÇÏ´Ù. Ç¥Çö½ÄÀº ¹Ýµå½Ã µÎ °³ÀÇ ±¸È¹¹®ÀÚ(¿¹¸¦µé¾î ½½·¡½Ã(/)°°Àº)·Î µÑ·¯½Î¿© ÀÖ¾î¾ß ÇÑ´Ù. ¾ËÆĺªÀ̳ª ¼ýÀÚ È¤Àº ¹é½½·¡½Ã(\)¸¦ Á¦¿ÜÇÑ ¾î¶² ¹®ÀÚµµ ±¸È¹¹®ÀÚ°¡ µÉ ¼ö ÀÖ´Ù. ¸¸¾à ±¸È¹¹®ÀÚ·Î »ç¿ëµÈ ¹®ÀÚ¸¦ Ç¥Çö½Ä ³»¿¡ »ç¿ëÇÏ°í ½Í´Ù¸é ¹é½½·¡½Ã·Î escapeÇØ ÁÖ¸é µÈ´Ù.(¾Õ¿¡ ¹é½½·¡½Ã¸¦ ºÙÀÌ¸é µÈ´Ù.)

    Á¾·á¸¦ ³ªÅ¸³»´Â ±¸È¹¹®ÀÚ µÚ¿¡´Â ¸ÅĪ¿¡ °ü·ÃµÈ ¿©·¯ ¿É¼ÇÀ» ºÙ¿©ÁÙ ¼ö ÀÖ´Ù. ÀÚ¼¼ÇÑ °ÍÀº Pattern Modifiers¸¦ º¸ÀÚ.

    Example 1. Examples of valid patterns

      /<\/\w+>/

      |(\d{3})-\d+|Sm

      /^(?I)php[34]/

    Example 2. Examples of invalid patterns

      /href='(.*)' - missing ending delimiter

      /\w+\s*\w+/J - unknown option 'J'

      1-\d3-\d3-\d4| - missing starting delimiter

    Table of Contents
    preg_match ¡¦ Perform a regular expression match
    preg_match_all ¡¦ Perform a global regular expression match
    preg_replace ¡¦ Perform a regular expression search and replace
    preg_split ¡¦ Split string by a regular expression
    preg_quote ¡¦ Quote regular expression characters
    preg_grep ¡¦ Return array entries that match the pattern
    Pattern Options ¡¦ describes possible options in regex patterns
    Pattern Syntax ¡¦ describes PCRE regex syntax

    preg_match

    preg_match -- Á¤±Ô Ç¥Çö½Ä °Ë»öÀ» ¼öÇàÇÑ´Ù.

    Description

    int preg_match (string pattern, string subject [, array matches])

    Searches subject for a match to the regular expression given in pattern.

    If matches is provided, then it is filled with the results of search. $matches[0] will contain the text that match the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.

    Returns true if a match for pattern was found in the subject string, or false if not match was found or an error occurred.

    Example 1. Getting the page number out of a string

      1 
      2 if (preg_match("/page\s+#(\d+)/i", "Go to page #9.", $parts))
      3     print "Next page is $parts[1]";
      4 else
      5     print "Page not found.";
      6       

    See also preg_match_all(), preg_replace(), and preg_split().

    preg_match_all

    preg_match_all -- Àü¿ªÀûÀÎ Á¤±Ô Ç¥Çö½Ä °Ë»öÀ» ¼öÇàÇÑ´Ù.

    Description

    int preg_match_all (string pattern, string subject, array matches [, int order])

    Searches subject for all matches to the regular expression given in pattern and puts them in matches in the order specified by order.

    After the first match is found, the subsequent searches are continued on from end of the last match.

    order can be one of two things:

    PREG_PATTERN_ORDER

    Orders results so that $matches[0] is an array of full pattern matches, $matches[1] is an array of strings matched by the first parenthesized subpattern, and so on.

      1 
      2 preg_match_all("|<[^>]+>(.*)</[^>]+>|U", "<b>example: </b><div align=left>a test</div>", $out, PREG_PATTERN_ORDER);
      3 print $out[0][0].", ".$out[0][1]."\n";
      4 print $out[1][0].", ".$out[1][1]."\n"
      5 	  

    This example will produce:

      1 
      2 <b>example: </b>, <div align=left>this is a test</div>
      3 example: , this is a test
      4 	  

    So, $out[0] contains array of strings that matched full pattern, and $out[1] contains array of strings enclosed by tags.

    PREG_SET_ORDER

    Orders results so that $matches[0] is an array of first set of matches, $matches[1] is an array of second set of matches, and so on.

     

      1 
      2 preg_match_all("|<[^>]+>(.*)</[^>]+>|U", "<b>example: </b><div align=left>a test</div>", $out, PREG_SET_ORDER);
      3 print $out[0][0].", ".$out[0][1]."\n";
      4 print $out[1][0].", ".$out[1][1]."\n"
      5 	  

     

    This example will produce:

     

      1 
      2 <b>example: </b>, example: 
      3 <div align=left>this is a test</div>, this is a test
      4 	  

     

    In this case, $matches[0] is the first set of matches, and $matches[0][0] has text matched by full pattern, $matches[0][1] has text matched by first subpattern and so on. Similarly, $matches[1] is the second set of matches, etc.

     

    If order is not specified, it is assumed to be PREG_PATTERN_ORDER.

    Returns the number of full pattern matches, or false if no match is found or an error occurred.

    Example 1. Getting all phone numbers out of some text.

      1 
      2 preg_match_all("/\(?  (\d{3})?  \)?  (?(1)  [\-\s] ) \d{3}-\d{4}/x",
      3                "Call 555-1212 or 1-800-555-1212", $phones);
      4       

    See also preg_match(), preg_replace(), and preg_split().

    preg_replace

    preg_replace -- Á¤±Ô Ç¥Çö½ÄÀÇ °Ë»ö°ú ¹Ù²Ù±â¸¦ ¼öÇàÇÑ´Ù.

    Description

    mixed preg_replace (mixed pattern, mixed replacement, mixed subject)

    Searches subject for matches to pattern and replaces them with replacement .

    replacement may contain references of the form \\n. Every such reference will be replaced by the text captured by the n'th parenthesized pattern. n can be from 0 to 99, and \\0 refers to the text matched by the whole pattern. Opening parentheses are counted from left to right (starting from 1) to obtain the number of the capturing subpattern.

    If no matches are found in subject, then it will be returned unchanged.

    Every parameter to preg_replace() can be an array.

    If subject is an array, then the search and replace is performed on every entry of subject, and the return value is an array as well.

    If pattern and replacement are arrays, then preg_replace() takes a value from each array and uses them to do search and replace on subject. If replacement has fewer values than pattern, then empty string is used for the rest of replacement values. If pattern is an array and replacement is a string; then this replacement string is used for every value of pattern. The converse would not make sense, though.

    /e modifier makes preg_replace() treat the replacement parameter as PHP code after the appropriate references substitution is done. Tip: make sure that replacement constitutes a valid PHP code string, otherwise PHP will complain about a parse error at the line containing preg_replace().

    Note: This modifier was added in PHP 4.0.

    Example 1. Replacing several values

      1 
      2 $patterns = array("/(19|20\d{2})-(\d{1,2})-(\d{1,2})/", "/^\s*{(\w+)}\s*=/");
      3 $replace = array("\\3/\\4/\\1", "$\\1 =");
      4 print preg_replace($patterns, $replace, "{startDate} = 1999-5-27");
      5       

    This example will produce:

      1 
      2       $startDate = 5/27/1999
      3      

    Example 2. Using /e modifier

      1 
      2 preg_replace("/(<\/?)(\w+)([^>]*>)/e", "'\\1'.strtoupper('\\2').'\\3'", $html_body);
      3       

    This would capitalize all HTML tags in the input text.

    See also preg_match(), preg_match_all(), and preg_split().

    preg_split

    preg_split -- Á¤±Ô Ç¥Çö½Ä¿¡ µû¸¥ ¹®ÀÚ¿­ ³ª´©±â¸¦ ÇÑ´Ù.

    Description

    array preg_split (string pattern, string subject [, int limit [, int flags]])

    Note: Parameter flags was added in PHP Beta 3.

    Returns an array containing substrings of subject split along boundaries matched by pattern.

    If limit is specified, then only substrings up to limit are returned.

    If flags is PREG_SPLIT_NO_EMPTY then only non-empty pieces will be by preg_split().

    Example 1. Getting parts of search string

      1 
      2 $keywords = preg_split("/[\s,]+/", "hypertext language, programming");
      3       

    See also preg_match(), preg_match_all(), and preg_replace().

    preg_quote

    preg_quote -- Á¤±Ô Ç¥Çö½Ä¿¡ »ç¿ëµÇ´Â ¹®ÀÚµéÀ» backslash°¡ ºÙÀº ¹®ÀÚ·Î Àüȯ(quote)ÇÑ´Ù.

    Description

     

    string preg_quote (string str)

    preg_quote() takes str and puts a backslash in front of every character that is part of the regular expression syntax. This is useful if you have a run-time string that you need to match in some text and the string may contain special regex characters.

    The special regular expression characters are:

    . \\ + * ? [ ^ ] $ ( ) { } = ! < > | :

    Note: This function was added in PHP 3.0.9.

    preg_grep

    preg_grep -- ¹è¿­¿¡¼­ ÆÐÅÏ¿¡ ¸Â´Â ¿ø¼ÒµéÀ» ¹ÝȯÇÑ´Ù.

    Description

    array preg_grep (string pattern, array input)

    preg_grep() returns the array consisting of the elements of the input array that match the given pattern.

    Example 1. preg_grep() example

      1 
      2 preg_grep("/^(\d+)?\.\d+$/", $array); // find all floating point numbers in the array
      3       

    Note: This function was added in PHP 4.0.

    Pattern Modifiers

    Pattern Modifiers -- regex ÆÐÅÏÀÇ °¡´ÉÇÑ º¯°æÀÚ(modifier)¸¦ ±â¼úÇÑ´Ù.

    Description

    ÇöÀç PCRE¿¡¼­ °¡´ÉÇÑ º¯°æÀÚ(modifier)µéÀº ¾Æ·¡ ³ª¿ÍÀÖ´Ù. °ýÈ£¾ÈÀÇ À̸§Àº ÇØ´ç ¿É¼Ç¿¡ ´ëÇÏ¿© PCRE ³»ºÎ¿¡¼­ »ç¿ëÇÏ´Â À̸§ÀÌ´Ù.

    i (PCRE_CASELESS)
    ÀÌ ¿É¼ÇÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é, ÆÐÅÏÀÇ ¹®ÀÚ´Â ´ë¼Ò¹®ÀÚ¸¦ °¡¸®Áö ¾Ê°í ¸ðµÎ ¸ÅĪµÈ´Ù.
     
    m (PCRE_MULTILINE)
    ±âº»ÀûÀ¸·Î, PCRE´Â (ºñ·Ï ¾È¿¡ °³Çâ ¹®ÀÚ°¡ À־) ÇØ´ç ¹®ÀÚ¿­À» ÇÑÁÙ·Î Ãë±ÞÇÑ´Ù. µû¶ó¼­, "ÁÙ ½ÃÀÛ"À» ³ªÅ¸³»´Â ¸ÞŸ ij¸¯ÅÍ(^)´Â ÇØ´ç ¹®ÀÚ¿­ÀÇ ½ÃÀÛ¿¡¸¸ ¸ÅĪµÇ°í, "ÁÙ ³¡"À» ³ªÅ¸³»´Â ¸ÞŸ ij¸¯ÅÍ($)´Â ¹®ÀÚ¿­ÀÇ ³¡À̳ª, (E optionÀÌ ¼³Á¤µÇ¾î ÀÖÁö ¾Ê´Ù¸é) newlineÀÌ ³¡³ª±â Àü¿¡ ¸ÅĪµÈ´Ù. ÀÌ°ÍÀº Perl°ú µ¿ÀÏÇÏ´Ù.
    ¸¸¾à ÀÌ ¿É¼ÇÀÌ ¼³Á¤µÇ¸é, "ÁÙ ½ÃÀÛ"°ú "ÁÙ ³¡"ÀÌ ÇØ´ç ¹®ÀÚ¿­ÀÇ ¸ðµç °³°³ÀÇ newlineÀÇ ½ÃÀÛ°ú ³¡¿¡ ¸ÅĪµÇµµ·Ï ÇÑ´Ù. ÀÌ°ÍÀº PerlÀÇ /m ¿É¼Ç°ú µ¿ÀÏÇÏ´Ù. ÇØ´çÇÏ´Â ¹®ÀÚ¿­¿¡ "\n"¹®ÀÚ°¡ ¾ø°Å³ª ÆÐÅÏ¿¡ ^³ª $°¡ ¾ø´Ù¸é ÀÌ ¿É¼ÇÀº ¾Æ¹« Àǹ̰¡ ¾ø°ÔµÈ´Ù.
     
    s (PCRE_DOTALL)
    ÀÌ ¿É¼ÇÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é, ÆÐÅÏÀÇ Á¡ ¸ÞŸ ij¸¯ÅÍ(.)´Â °³Ç๮ÀÚ¸¦ Æ÷ÇÔÇÑ ¾î¶² ¹®ÀÚ¿¡µµ ¸ÅĪµÈ´Ù. ÀÌ ¿É¼ÇÀÌ ¾ø´Ù¸é °³Ç๮ÀÚ´Â Á¦¿ÜµÈ´Ù. ÀÌ ¿É¼ÇÀº PerlÀÇ /s ¿É¼Ç°ú µ¿ÀÏÇÏ´Ù. [^a]°°Àº negative class´Â ÀÌ ¿É¼Ç¿¡ °ü°è¾øÀÌ ¾ðÁ¦³ª °³Ç๮ÀÚ¿¡ ¸ÅĪµÈ´Ù.
     
    x (PCRE_EXTENDED)
    ÀÌ ¿É¼ÇÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é, ÆÐÅÏÀÇ °ø¹é¹®ÀÚ´Â ¿ÏÀüÈ÷ ¹«½ÃµÈ´Ù. ´Ü, escapeµÇ¾î Àְųª, character class¾È¿¡ ÀÖ´Â °æ¿ì´Â À¯È¿ÇÏ´Ù. ¶ÇÇÑ character class¹Û¿¡ ÀÖ´Â unescaped # °ú ´ÙÀ½ °³Ç๮ÀÚ »çÀÌ¿¡ ÀÖ´Â ¹®Àڵ鵵 ¹«½ÃµÈ´Ù.
    ÀÌ ¿É¼ÇÀº PerlÀÇ /x ¿É¼Ç°ú µ¿ÀÏÇÏ°í, º¹ÀâÇÑ ÆÐÅÏÀÇ ¾È¿¡ ÁÖ¼®¹®À» ³Ö¾îµÎ´Â °ÍÀ» °¡´ÉÇÏ°Ô ÇÑ´Ù. ÁÖÀÇÇÒÁ¡Àº ÀÌ°ÍÀÌ ´ÜÁö µ¥ÀÌÅÍ ¹®Àڵ鿡 ´ëÇؼ­¸¸ ÀÛ¿ëÇÑ´Ù´Â °ÍÀÌ´Ù. °ø¹é ¹®ÀÚµéÀº ÆÐÅÏ¿¡¼­ÀÇ Æ¯º°ÇÑ ¹®ÀÚ sequence »çÀÌ¿¡´Â ³ªÅ¸³¯ ¼ö ¾ø´Ù. ¿¹¸¦µé¾î  conditional subpatternÀÎ (?( sequence »çÀÌ¿¡¼­´Â ³ªÅ¸³¯ ¼ö ¾ø´Ù.
    e
    ÀÌ ¿É¼ÇÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é, preg_replace()´Â ±³Ã¼ ¹®ÀÚ¿­¿¡ ÀÖ´Â \\¿¡ ´ëÇØ PHP Äڵ忡¼­ ÇÏ´Â ÀϹÝÀûÀΠġȯÀ» ¸ÕÀú ÇÏ°í, ±× °á°ú¸¦ Ž»ö ¹®ÀÚ¿­·Î »ç¿ëÇÑ´Ù. (If this option is set, preg_replace() does normal substitution of \\ references in the replacement string, evaluates it as PHP code, and uses the result for replacing the search string.)
    ÀÌ ¿É¼ÇÀº ¿ÀÁ÷ preg_replace()¿¡¼­¸¸ »ç¿ëµÈ´Ù. ´Ù¸¥ PCRE ÇÔ¼öµé¿¡¼­´Â ÀÌ ¿É¼ÇÀÌ ¹«½ÃµÈ´Ù.
     
    A (PCRE_ANCHORED)
    ÀÌ ¿É¼ÇÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é, ÆÐÅÏÀÌ "anchored"µÇ¾î ÀÖ´Ù°í °­Á¦·Î ¼³Á¤ÇÑ´Ù. ÀÌ°ÍÀº Ž»öµÇ´Â ¹®ÀÚ¿­("subject string")ÀÇ ½ÃÀÛ¿¡¼­¸¸ ¸ÅĪµÇµµ·Ï °­Á¦ÇÑ´Ù. This effect can also be achieved by appropriate constructs in the pattern itself, which is the only way to do it in Perl.
     
    E (PCRE_DOLLAR_ENDONLY)
    ÀÌ ¿É¼ÇÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é $ ¸ÞŸ ij¸¯ÅÍ´Â ÇØ´ç ¹®ÀÚ¿­ÀÇ ¸Ç ¸¶Áö¸·°ú ¸ÅĪµÈ´Ù. ÀÌ ¿É¼ÇÀÌ »ç¿ëµÇÁö ¾ÊÀ¸¸é, $´Â ¸¶Áö¸· ¹®ÀÚ°¡ newlineÀ̸é ÀÌ ¹®ÀÚ ¾Õ°ú ¸ÅĪµÈ´Ù.(¸ðµç newlineÀÇ ¾ÕÀÌ ¾Æ´Ï´Ù.) ÀÌ ¿É¼ÇÀº m ¿É¼ÇÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é ¹«½ÃµÈ´Ù. Perl¿¡¼­ µ¿ÀÏÇÑ ¿É¼ÇÀº ¾ø´Ù.
     
    S
    ÆÐÅÏÀÌ ¿©·¯¹ø »ç¿ëµÈ´Ù¸é, ¸ÅĪÀ» °Ë»çÇÏ´Â °Íº¸´Ù ´õ ¸¹Àº ½Ã°£ÀÌ ÆÐÅÏÀ» ºÐ¼®Çϴµ¥ »ç¿ëµÉ ¼ö ÀÖ´Ù. ÀÌ ¿É¼ÇÀÌ ¼³Á¤µÇ¾î ÀÖÀ¸¸é º°µµÀÇ ºÐ¼®ÀÌ ¼öÇàµÈ´Ù. ¿äÁò¿¡ ÀÌ ÆÐÅÏ studyingÀº ÇÑ °³ÀÇ °íÁ¤µÈ ½ÃÀÛ ¹®ÀÚ¸¦ °¡ÁöÁö ¾Ê´Â non-anchored ÆÐÅÏ¿¡ ´ëÇؼ­¸¸ À¯¿ëÇÏ°Ô »ç¿ëµÈ´Ù.
     
    U (PCRE_UNGREEDY)
    ÀÌ ¿É¼ÇÀº ¼ö·® ±âÈ£ÀÇ "greediness"¸¦ ¹ÝÀü½ÃŲ´Ù. µû¶ó¼­ µðÆúÆ®·Î greedy ÇÏÁö ¾Êµµ·Ï ÇÑ´Ù. ±×·¯³ª "?"´ÙÀ½¿¡ »ç¿ëµÇ´Â °æ¿ì´Â greedyÇϵµ·Ï ÇÑ´Ù. ÀÌÁ¡Àº Perl°ú ȣȯÀÌ µÇÁö ¾Ê´Â´Ù. ¶ÇÇÑ ÀÌ°ÍÀº ÆÐÅϾȿ¡ (?U) ¿É¼ÇÀ» ¼³Á¤ÇÏ¿© ¼³Á¤ÇÒ ¼öµµ ÀÖ´Ù.
     
    X (PCRE_EXTRA)
    ÀÌ ¿É¼ÇÀº PCREÀÇ Perl°ú ºñȣȯµÇ´Â Ãß°¡ÀûÀÎ ±â´ÉÀ» È°¼ºÈ­ ÇÑ´Ù. ÆÐÅÏ¿¡°Å ¹é½½·¡½Ã µÚ¿¡ ³ª¿À´Â ¹®ÀÚÁß¿¡ Ưº°ÇÑ Àǹ̰¡ ¾ø´Â °ÍÀº ¿¡·¯¸¦ ¹ß»ý½ÃŲ´Ù. ÀÌ°ÍÀº ÈÄ¿¡ È®ÀåÀ» À§Çؼ­ÀÌ´Ù. ±âº»ÀûÀ¸·Î Perl¿¡¼­´Â ¹é½½·¡½Ã µÚ¿¡ ³ª¿À´Â Àǹ̾ø´Â ¹®ÀÚµéÀº ÀÏ¹Ý ¹®ÀÚ·Î Ãë±ÞµÈ´Ù. ÀÌ ¿É¼Ç¿¡ ÀÇÇØ ¼³Á¤µÇ´Â ³»¿ëÀº ÇöÀç ÀÌ°Í »ÓÀÌ´Ù.

    Pattern Syntax

    Pattern Syntax -- describes PCRE regex syntax

    Description

         The PCRE library is a set of functions that implement regular
         expression pattern matching using the same syntax and semantics
         as Perl 5, with just a few differences (see below).  The current
         implementation corresponds to Perl 5.005.
       

    Differences From Perl

         The differences described here  are  with  respect  to  Perl
         5.005.

         1. By default, a whitespace character is any character  that
         the  C  library  function isspace() recognizes, though it is
         possible to compile PCRE  with  alternative  character  type
         tables. Normally isspace() matches space, formfeed, newline,
         carriage return, horizontal tab, and vertical tab. Perl 5 no
         longer  includes vertical tab in its set of whitespace char-
         acters. The \v escape that was in the Perl documentation for
         a long time was never in fact recognized. However, the char-
         acter itself was treated as whitespace at least up to 5.002.
         In 5.004 and 5.005 it does not match \s.

         2. PCRE does  not  allow  repeat  quantifiers  on  lookahead
         assertions. Perl permits them, but they do not mean what you
         might think. For example, (?!a){3} does not assert that  the
         next  three characters are not "a". It just asserts that the
         next character is not "a" three times.

         3. Capturing subpatterns that occur inside  negative  looka-
         head  assertions  are  counted,  but  their  entries  in the
         offsets vector are never set. Perl sets its numerical  vari-
         ables  from  any  such  patterns that are matched before the
         assertion fails to match something (thereby succeeding), but
         only  if  the negative lookahead assertion contains just one
         branch.

         4. Though binary zero characters are supported in  the  sub-
         ject  string,  they  are  not  allowed  in  a pattern string
         because it is passed as a normal  C  string,  terminated  by
         zero. The escape sequence "\0" can be used in the pattern to
         represent a binary zero.

         5. The following Perl escape sequences  are  not  supported:
         \l,  \u,  \L,  \U,  \E, \Q. In fact these are implemented by
         Perl's general string-handling and are not part of its  pat-
         tern matching engine.

         6. The Perl \G assertion is  not  supported  as  it  is  not
         relevant to single pattern matches.

         7. Fairly obviously, PCRE does  not  support  the  (?{code})
         construction.

         8. There are at the time of writing some  oddities  in  Perl
         5.005_02  concerned  with  the  settings of captured strings
         when part of a pattern is repeated.  For  example,  matching
         "aba"  against the pattern /^(a(b)?)+$/ sets $2 to the value
         "b", but matching "aabbaa" against /^(aa(bb)?)+$/ leaves  $2
         unset.    However,    if   the   pattern   is   changed   to
         /^(aa(b(b))?)+$/ then $2 (and $3) get set.

         In Perl 5.004 $2 is set in both cases, and that is also true
         of PCRE. If in the future Perl changes to a consistent state
         that is different, PCRE may change to follow.

         9. Another as yet unresolved discrepancy  is  that  in  Perl
         5.005_02  the  pattern /^(a)?(?(1)a|b)+$/ matches the string
         "a", whereas in PCRE it does not.  However, in both Perl and
         PCRE /^(a)?a/ matched against "a" leaves $1 unset.

         10. PCRE  provides  some  extensions  to  the  Perl  regular
         expression facilities:

         (a) Although lookbehind assertions must match  fixed  length
         strings,  each  alternative branch of a lookbehind assertion
         can match a different length of string. Perl 5.005  requires
         them all to have the same length.

         (b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is  not
         set,  the  $ meta- character matches only at the very end of
         the string.

         (c) If PCRE_EXTRA is set, a backslash followed by  a  letter
         with no special meaning is faulted.

         (d) If PCRE_UNGREEDY is set, the greediness of  the  repeti-
         tion  quantifiers  is inverted, that is, by default they are
         not greedy, but if followed by a question mark they are.
        

    Regular Expression Details

         The syntax and semantics of  the  regular  expressions  sup-
         ported  by PCRE are described below. Regular expressions are
         also described in the Perl documentation and in a number  of
         other  books,  some  of which have copious examples. Jeffrey
         Friedl's  "Mastering  Regular  Expressions",  published   by
         O'Reilly  (ISBN 1-56592-257-3), covers them in great detail.
         The description here is intended as reference documentation.

         A regular expression is a pattern that is matched against  a
         subject string from left to right. Most characters stand for
         themselves in a pattern, and match the corresponding charac-
         ters in the subject. As a trivial example, the pattern

           The quick brown fox

         matches a portion of a subject string that is  identical  to
         itself.  The  power  of  regular  expressions comes from the
         ability to include alternatives and repetitions in the  pat-
         tern.  These  are encoded in the pattern by the use of meta-
         characters, which do not stand for  themselves  but  instead
         are interpreted in some special way.

         There are two different sets of meta-characters: those  that
         are  recognized anywhere in the pattern except within square
         brackets, and those that are recognized in square  brackets.
         Outside square brackets, the meta-characters are as follows:

           \      general escape character with several uses
           ^      assert start of  subject  (or  line,  in  multiline
         mode)
           $      assert end of subject (or line, in multiline mode)
           .      match any character except newline (by default)
           [      start character class definition
           |      start of alternative branch
           (      start subpattern
           )      end subpattern
           ?      extends the meaning of (
                  also 0 or 1 quantifier
                  also quantifier minimizer
           *      0 or more quantifier
           +      1 or more quantifier
           {      start min/max quantifier

         Part of a pattern that is in square  brackets  is  called  a
         "character  class".  In  a  character  class  the only meta-
         characters are:

           \      general escape character
           ^      negate the class, but only if the first character
           -      indicates character range
           ]      terminates the character class

         The following sections describe  the  use  of  each  of  the
         meta-characters.

    BACKSLASH
         The backslash character has several uses. Firstly, if it  is
         followed  by  a  non-alphameric character, it takes away any
         special  meaning  that  character  may  have.  This  use  of
         backslash  as  an  escape  character applies both inside and
         outside character classes.

         For example, if you want to match a "*" character, you write
         "\*" in the pattern. This applies whether or not the follow-
         ing character would otherwise  be  interpreted  as  a  meta-
         character,  so it is always safe to precede a non-alphameric
         with "\" to specify that it stands for itself.  In  particu-
         lar, if you want to match a backslash, you write "\\".

         If a pattern is compiled with the PCRE_EXTENDED option, whi-
         tespace in the pattern (other than in a character class) and
         characters between a "#" outside a character class  and  the
         next  newline  character  are ignored. An escaping backslash
         can be used to include a whitespace or "#" character as part
         of the pattern.

         A second use of backslash provides a way  of  encoding  non-
         printing  characters  in patterns in a visible manner. There
         is no restriction on the appearance of non-printing  charac-
         ters,  apart from the binary zero that terminates a pattern,
         but when a pattern is being prepared by text editing, it  is
         usually  easier to use one of the following escape sequences
         than the binary character it represents:

           \a     alarm, that is, the BEL character (hex 07)
           \cx    "control-x", where x is any character
           \e     escape (hex 1B)
           \f     formfeed (hex 0C)
           \n     newline (hex 0A)
           \r     carriage return (hex 0D)
           \t     tab (hex 09)
           \xhh   character with hex code hh
           \ddd   character with octal code ddd, or backreference

         The precise effect of "\cx" is as follows: if "x" is a lower
         case  letter,  it  is converted to upper case. Then bit 6 of
         the character (hex 40) is inverted.  Thus "\cz" becomes  hex
         1A, but "\c{" becomes hex 3B, while "\c;" becomes hex 7B.

         After "\x", up to two hexadecimal digits are  read  (letters
         can be in upper or lower case).

         After "\0" up to two further octal digits are read. In  both
         cases,  if  there are fewer than two digits, just those that
         are present are used. Thus the sequence "\0\x\07"  specifies
         two binary zeros followed by a BEL character.  Make sure you
         supply two digits after the initial zero  if  the  character
         that follows is itself an octal digit.

         The handling of a backslash followed by a digit other than 0
         is  complicated.   Outside  a character class, PCRE reads it
         and any following digits as a decimal number. If the  number
         is  less  than  10, or if there have been at least that many
         previous capturing left parentheses in the  expression,  the
         entire  sequence is taken as a back reference. A description
         of how this works is given later, following  the  discussion
         of parenthesized subpatterns.

         Inside a character  class,  or  if  the  decimal  number  is
         greater  than  9 and there have not been that many capturing
         subpatterns, PCRE re-reads up to three octal digits  follow-
         ing  the  backslash,  and  generates  a single byte from the
         least significant 8 bits of the value. Any subsequent digits
         stand for themselves.  For example:

           \040   is another way of writing a space
           \40    is the same, provided there are fewer than 40
                     previous capturing subpatterns
           \7     is always a back reference
           \11    might be a back reference, or another way of
                     writing a tab
           \011   is always a tab
           \0113  is a tab followed by the character "3"
           \113   is the character with octal code 113 (since there
                     can be no more than 99 back references)
           \377   is a byte consisting entirely of 1 bits
           \81    is either a back reference, or a binary zero
                     followed by the two characters "8" and "1"

         Note that octal values of 100 or greater must not be  intro-
         duced  by  a  leading zero, because no more than three octal
         digits are ever read.

         All the sequences that define a single  byte  value  can  be
         used both inside and outside character classes. In addition,
         inside a character class, the sequence "\b"  is  interpreted
         as  the  backspace  character  (hex 08). Outside a character
         class it has a different meaning (see below).

         The third use of backslash is for specifying generic charac-
         ter types:

           \d     any decimal digit
           \D     any character that is not a decimal digit
           \s     any whitespace character
           \S     any character that is not a whitespace character
           \w     any "word" character
           \W     any "non-word" character

         Each pair of escape sequences partitions the complete set of
         characters  into  two  disjoint  sets.  Any  given character
         matches one, and only one, of each pair.

         A "word" character is any letter or digit or the  underscore
         character,  that  is,  any  character which can be part of a
         Perl "word". The definition of letters and  digits  is  con-
         trolled  by PCRE's character tables, and may vary if locale-
         specific matching is  taking  place  (see  "Locale  support"
         above). For example, in the "fr" (French) locale, some char-
         acter codes greater than 128 are used for accented  letters,
         and these are matched by \w.

         These character type sequences can appear  both  inside  and
         outside  character classes. They each match one character of
         the appropriate type. If the current matching  point  is  at
         the end of the subject string, all of them fail, since there
         is no character to match.

         The fourth use of backslash is  for  certain  simple  asser-
         tions. An assertion specifies a condition that has to be met
         at a particular point in  a  match,  without  consuming  any
         characters  from  the subject string. The use of subpatterns
         for more complicated  assertions  is  described  below.  The
         backslashed assertions are

           \b     word boundary
           \B     not a word boundary
           \A     start of subject (independent of multiline mode)
           \Z     end of subject or newline at  end  (independent  of
         multiline mode)
           \z     end of subject (independent of multiline mode)

         These assertions may not appear in  character  classes  (but
         note that "\b" has a different meaning, namely the backspace
         character, inside a character class).

         A word boundary is a position in the  subject  string  where
         the current character and the previous character do not both
         match \w or \W (i.e. one matches \w and  the  other  matches
         \W),  or the start or end of the string if the first or last
         character matches \w, respectively.

         The \A, \Z, and \z assertions differ  from  the  traditional
         circumflex  and  dollar  (described below) in that they only
         ever match at the very start and end of the subject  string,
         whatever  options  are  set.  They  are  not affected by the
         PCRE_NOTBOL or PCRE_NOTEOL options. The  difference  between
         \Z  and  \z  is that \Z matches before a newline that is the
         last character of the string as well as at the  end  of  the
         string, whereas \z matches only at the end.

    CIRCUMFLEX AND DOLLAR
         Outside a character class, in the default matching mode, the
         circumflex  character  is an assertion which is true only if
         the current matching point is at the start  of  the  subject
         string. Inside a character class, circumflex has an entirely
         different meaning (see below).

         Circumflex need not be the first character of the pattern if
         a  number of alternatives are involved, but it should be the
         first thing in each alternative in which it appears  if  the
         pattern is ever to match that branch. If all possible alter-
         natives start with a circumflex, that is, if the pattern  is
         constrained to match only at the start of the subject, it is
         said to be an "anchored" pattern. (There are also other con-
         structs that can cause a pattern to be anchored.)

         A dollar character is an assertion which is true only if the
         current  matching point is at the end of the subject string,
         or immediately before a newline character that is  the  last
         character in the string (by default). Dollar need not be the
         last character of the pattern if a  number  of  alternatives
         are  involved,  but it should be the last item in any branch
         in which it appears.  Dollar has no  special  meaning  in  a
         character class.

         The meaning of dollar can be changed so that it matches only
         at   the   very   end   of   the   string,  by  setting  the
         PCRE_DOLLAR_ENDONLY option at compile or matching time. This
         does not affect the \Z assertion.

         The meanings of the circumflex  and  dollar  characters  are
         changed  if  the  PCRE_MULTILINE option is set. When this is
         the case,  they  match  immediately  after  and  immediately
         before an internal "\n" character, respectively, in addition
         to matching at the start and end of the subject string.  For
         example,  the  pattern  /^abc$/  matches  the subject string
         "def\nabc" in multiline  mode,  but  not  otherwise.  Conse-
         quently,  patterns  that  are  anchored  in single line mode
         because all branches start with "^" are not anchored in mul-
         tiline  mode.  The  PCRE_DOLLAR_ENDONLY option is ignored if
         PCRE_MULTILINE is set.

         Note that the sequences \A, \Z, and \z can be used to  match
         the  start  and end of the subject in both modes, and if all
         branches of a pattern start with \A is it  always  anchored,
         whether PCRE_MULTILINE is set or not.



    FULL STOP (PERIOD, DOT)
         Outside a character class, a dot in the pattern matches  any
         one  character  in  the  subject,  including  a non-printing
         character, but not (by default) newline.  If the PCRE_DOTALL
         option  is  set,  then dots match newlines as well. The han-
         dling of dot is entirely independent of the handling of cir-
         cumflex  and  dollar,  the only relationship being that they
         both involve newline characters.  Dot has no special meaning
         in a character class.



    SQUARE BRACKETS
         An opening square bracket introduces a character class, ter-
         minated  by  a  closing  square  bracket.  A  closing square
         bracket on its own is  not  special.  If  a  closing  square
         bracket  is  required as a member of the class, it should be
         the first data character in the class (after an initial cir-
         cumflex, if present) or escaped with a backslash.

         A character class matches a single character in the subject;
         the  character  must  be in the set of characters defined by
         the class, unless the first character in the class is a cir-
         cumflex,  in which case the subject character must not be in
         the set defined by the class. If a  circumflex  is  actually
         required  as  a  member  of  the class, ensure it is not the
         first character, or escape it with a backslash.

         For example, the character class [aeiou] matches  any  lower
         case vowel, while [^aeiou] matches any character that is not
         a lower case vowel. Note that a circumflex is  just  a  con-
         venient  notation for specifying the characters which are in
         the class by enumerating those that are not. It  is  not  an
         assertion:  it  still  consumes a character from the subject
         string, and fails if the current pointer is at  the  end  of
         the string.

         When caseless matching  is  set,  any  letters  in  a  class
         represent  both their upper case and lower case versions, so
         for example, a caseless [aeiou] matches "A" as well as  "a",
         and  a caseless [^aeiou] does not match "A", whereas a case-
         ful version would.

         The newline character is never treated in any special way in
         character  classes,  whatever the setting of the PCRE_DOTALL
         or PCRE_MULTILINE options is. A  class  such  as  [^a]  will
         always match a newline.

         The minus (hyphen) character can be used to specify a  range
         of  characters  in  a  character  class.  For example, [d-m]
         matches any letter between d and m, inclusive.  If  a  minus
         character  is required in a class, it must be escaped with a
         backslash or appear in a position where it cannot be  inter-
         preted as indicating a range, typically as the first or last
         character in the class.
         It is not possible to have the literal character "]" as  the
         end  character  of  a  range.  A  pattern such as [W-]46] is
         interpreted as a class of two characters ("W" and "-")  fol-
         lowed by a literal string "46]", so it would match "W46]" or
         "-46]". However, if the "]" is escaped with a  backslash  it
         is  interpreted  as  the end of range, so [W-\]46] is inter-
         preted as a single class containing a range followed by  two
         separate characters. The octal or hexadecimal representation
         of "]" can also be used to end a range.

         Ranges operate in ASCII collating sequence. They can also be
         used  for  characters  specified  numerically,  for  example
         [\000-\037]. If a range that includes letters is  used  when
         caseless  matching  is set, it matches the letters in either
         case. For example, [W-c] is equivalent  to  [][\^_`wxyzabc],
         matched  caselessly,  and  if  character tables for the "fr"
         locale are in use, [\xc8-\xcb] matches accented E characters
         in both cases.

         The character types \d, \D, \s, \S,  \w,  and  \W  may  also
         appear  in  a  character  class, and add the characters that
         they match to the class. For example, [\dABCDEF] matches any
         hexadecimal  digit.  A  circumflex  can conveniently be used
         with the upper case character types to specify a  more  res-
         tricted set of characters than the matching lower case type.
         For example, the class [^\W_] matches any letter  or  digit,
         but not underscore.

         All non-alphameric characters other than \,  -,  ^  (at  the
         start)  and  the  terminating ] are non-special in character
         classes, but it does no harm if they are escaped.



    VERTICAL BAR
         Vertical bar characters are  used  to  separate  alternative
         patterns. For example, the pattern

           gilbert|sullivan

         matches either "gilbert" or "sullivan". Any number of alter-
         natives  may  appear,  and an empty alternative is permitted
         (matching the empty string).   The  matching  process  tries
         each  alternative in turn, from left to right, and the first
         one that succeeds is used. If the alternatives are within  a
         subpattern  (defined  below),  "succeeds" means matching the
         rest of the main pattern as well as the alternative  in  the
         subpattern.




    INTERNAL OPTION SETTING
         The settings of PCRE_CASELESS, PCRE_MULTILINE,  PCRE_DOTALL,
         and  PCRE_EXTENDED can be changed from within the pattern by
         a sequence of Perl option letters enclosed between "(?"  and
         ")". The option letters are

           i  for PCRE_CASELESS
           m  for PCRE_MULTILINE
           s  for PCRE_DOTALL
           x  for PCRE_EXTENDED

         For example, (?im) sets caseless, multiline matching. It  is
         also possible to unset these options by preceding the letter
         with a hyphen, and a combined setting and unsetting such  as
         (?im-sx),  which sets PCRE_CASELESS and PCRE_MULTILINE while
         unsetting PCRE_DOTALL and PCRE_EXTENDED, is also  permitted.
         If  a  letter  appears both before and after the hyphen, the
         option is unset.

         The scope of these option changes depends on  where  in  the
         pattern  the  setting  occurs. For settings that are outside
         any subpattern (defined below), the effect is the same as if
         the  options were set or unset at the start of matching. The
         following patterns all behave in exactly the same way:

           (?i)abc
           a(?i)bc
           ab(?i)c
           abc(?i)

         which in turn is the same as compiling the pattern abc  with
         PCRE_CASELESS  set.   In  other words, such "top level" set-
         tings apply to the whole pattern  (unless  there  are  other
         changes  inside subpatterns). If there is more than one set-
         ting of the same option at top level, the rightmost  setting
         is used.

         If an option change occurs inside a subpattern,  the  effect
         is  different.  This is a change of behaviour in Perl 5.005.
         An option change inside a subpattern affects only that  part
         of the subpattern that follows it, so

           (a(?i)b)c

         matches  abc  and  aBc  and  no  other   strings   (assuming
         PCRE_CASELESS  is  not used).  By this means, options can be
         made to have different settings in different  parts  of  the
         pattern.  Any  changes  made  in one alternative do carry on
         into subsequent branches within  the  same  subpattern.  For
         example,

           (a(?i)b|c)

         matches "ab", "aB", "c", and "C", even though when  matching
         "C" the first branch is abandoned before the option setting.
         This is because the effects of  option  settings  happen  at
         compile  time. There would be some very weird behaviour oth-
         erwise.

         The PCRE-specific options PCRE_UNGREEDY and  PCRE_EXTRA  can
         be changed in the same way as the Perl-compatible options by
         using the characters U and X  respectively.  The  (?X)  flag
         setting  is  special in that it must always occur earlier in
         the pattern than any of the additional features it turns on,
         even when it is at top level. It is best put at the start.



    SUBPATTERNS
         Subpatterns are delimited by parentheses  (round  brackets),
         which can be nested.  Marking part of a pattern as a subpat-
         tern does two things:

         1. It localizes a set of alternatives. For example, the pat-
         tern

           cat(aract|erpillar|)

         matches one of the words "cat",  "cataract",  or  "caterpil-
         lar".  Without  the  parentheses, it would match "cataract",
         "erpillar" or the empty string.

         2. It sets up the subpattern as a capturing  subpattern  (as
         defined  above).   When the whole pattern matches, that por-
         tion of the subject string that matched  the  subpattern  is
         passed  back  to  the  caller  via  the  ovector argument of
         pcre_exec(). Opening parentheses are counted  from  left  to
         right (starting from 1) to obtain the numbers of the captur-
         ing subpatterns.

         For example, if the string "the red king" is matched against
         the pattern

           the ((red|white) (king|queen))

         the captured substrings are "red king", "red",  and  "king",
         and are numbered 1, 2, and 3.

         The fact that plain parentheses fulfil two functions is  not
         always  helpful.  There are often times when a grouping sub-
         pattern is required without a capturing requirement.  If  an
         opening parenthesis is followed by "?:", the subpattern does
         not do any capturing, and is not counted when computing  the
         number of any subsequent capturing subpatterns. For example,
         if the string "the  white  queen"  is  matched  against  the
         pattern

           the ((?:red|white) (king|queen))

         the captured substrings are "white queen" and  "queen",  and
         are  numbered  1  and 2. The maximum number of captured sub-
         strings is 99, and the maximum number  of  all  subpatterns,
         both capturing and non-capturing, is 200.

         As a  convenient  shorthand,  if  any  option  settings  are
         required  at  the  start  of a non-capturing subpattern, the
         option letters may appear between the "?" and the ":".  Thus
         the two patterns

           (?i:saturday|sunday)
           (?:(?i)saturday|sunday)

         match exactly the same set of strings.  Because  alternative
         branches  are  tried from left to right, and options are not
         reset until the end of the subpattern is reached, an  option
         setting  in  one  branch does affect subsequent branches, so
         the above patterns match "SUNDAY" as well as "Saturday".



    REPETITION
         Repetition is specified by quantifiers, which can follow any
         of the following items:

           a single character, possibly escaped
           the . metacharacter
           a character class
           a back reference (see next section)
           a parenthesized subpattern (unless it is  an  assertion  -
         see below)

         The general repetition quantifier specifies  a  minimum  and
         maximum  number  of  permitted  matches,  by  giving the two
         numbers in curly brackets (braces), separated  by  a  comma.
         The  numbers  must be less than 65536, and the first must be
         less than or equal to the second. For example:

           z{2,4}

         matches "zz", "zzz", or "zzzz". A closing brace on  its  own
         is not a special character. If the second number is omitted,
         but the comma is present, there is no upper  limit;  if  the
         second number and the comma are both omitted, the quantifier
         specifies an exact number of required matches. Thus

           [aeiou]{3,}

         matches at least 3 successive vowels,  but  may  match  many
         more, while

           \d{8}

         matches exactly 8 digits.  An  opening  curly  bracket  that
         appears  in a position where a quantifier is not allowed, or
         one that does not match the syntax of a quantifier, is taken
         as  a literal character. For example, {,6} is not a quantif-
         ier, but a literal string of four characters.

         The quantifier {0} is permitted, causing the  expression  to
         behave  as  if the previous item and the quantifier were not
         present.

         For convenience (and  historical  compatibility)  the  three
         most common quantifiers have single-character abbreviations:

           *    is equivalent to {0,}
           +    is equivalent to {1,}
           ?    is equivalent to {0,1}

         It is possible to construct infinite loops  by  following  a
         subpattern  that  can  match no characters with a quantifier
         that has no upper limit, for example:

           (a?)*

         Earlier versions of Perl and PCRE used to give an  error  at
         compile  time  for such patterns. However, because there are
         cases where this  can  be  useful,  such  patterns  are  now
         accepted,  but  if  any repetition of the subpattern does in
         fact match no characters, the loop is forcibly broken.

         By default, the quantifiers  are  "greedy",  that  is,  they
         match  as much as possible (up to the maximum number of per-
         mitted times), without causing the rest of  the  pattern  to
         fail. The classic example of where this gives problems is in
         trying to match comments in C programs. These appear between
         the  sequences /* and */ and within the sequence, individual
         * and / characters may appear. An attempt to  match  C  com-
         ments by applying the pattern

           /\*.*\*/

         to the string

           /* first command */  not comment  /* second comment */

         fails, because it matches  the  entire  string  due  to  the
         greediness of the .*  item.

         However, if a quantifier is followed  by  a  question  mark,
         then it ceases to be greedy, and instead matches the minimum
         number of times possible, so the pattern

           /\*.*?\*/

         does the right thing with the C comments. The meaning of the
         various  quantifiers is not otherwise changed, just the pre-
         ferred number of matches.  Do not confuse this use of  ques-
         tion  mark  with  its  use as a quantifier in its own right.
         Because it has two uses, it can sometimes appear doubled, as
         in

           \d??\d

         which matches one digit by preference, but can match two  if
         that is the only way the rest of the pattern matches.

         If the PCRE_UNGREEDY option is set (an option which  is  not
         available  in  Perl)  then the quantifiers are not greedy by
         default, but individual ones can be made greedy by following
         them  with  a  question mark. In other words, it inverts the
         default behaviour.

         When a parenthesized subpattern is quantified with a minimum
         repeat  count  that is greater than 1 or with a limited max-
         imum, more store is required for the  compiled  pattern,  in
         proportion to the size of the minimum or maximum.

         If a pattern starts with .* or  .{0,}  and  the  PCRE_DOTALL
         option (equivalent to Perl's /s) is set, thus allowing the .
         to match newlines, then the pattern is implicitly  anchored,
         because whatever follows will be tried against every charac-
         ter position in the subject string, so there is no point  in
         retrying  the overall match at any position after the first.
         PCRE treats such a pattern as though it were preceded by \A.
         In  cases where it is known that the subject string contains
         no newlines, it is worth setting PCRE_DOTALL when  the  pat-
         tern begins with .* in order to obtain this optimization, or
         alternatively using ^ to indicate anchoring explicitly.

         When a capturing subpattern is repeated, the value  captured
         is the substring that matched the final iteration. For exam-
         ple, after

           (tweedle[dume]{3}\s*)+

         has matched "tweedledum tweedledee" the value  of  the  cap-
         tured  substring  is  "tweedledee".  However,  if  there are
         nested capturing  subpatterns,  the  corresponding  captured
         values  may  have been set in previous iterations. For exam-
         ple, after
           /(a|(b))+/

         matches "aba" the value of the second captured substring  is
         "b".



    BACK REFERENCES
         Outside a character class, a backslash followed by  a  digit
         greater  than  0  (and  possibly  further  digits) is a back
         reference to a capturing subpattern  earlier  (i.e.  to  its
         left)  in  the  pattern,  provided there have been that many
         previous capturing left parentheses.

         However, if the decimal number following  the  backslash  is
         less  than  10,  it is always taken as a back reference, and
         causes an error only if there are not  that  many  capturing
         left  parentheses in the entire pattern. In other words, the
         parentheses that are referenced need not be to the  left  of
         the  reference  for  numbers  less  than 10. See the section
         entitled "Backslash" above for further details of  the  han-
         dling of digits following a backslash.

         A back reference matches whatever actually matched the  cap-
         turing subpattern in the current subject string, rather than
         anything matching the subpattern itself. So the pattern

           (sens|respons)e and \1ibility

         matches "sense and sensibility" and "response and  responsi-
         bility",  but  not  "sense  and  responsibility". If caseful
         matching is in force at the time of the back reference, then
         the case of letters is relevant. For example,

           ((?i)rah)\s+\1

         matches "rah rah" and "RAH RAH", but  not  "RAH  rah",  even
         though  the  original  capturing subpattern is matched case-
         lessly.

         There may be more than one back reference to the  same  sub-
         pattern.  If  a  subpattern  has not actually been used in a
         particular match, then any  back  references  to  it  always
         fail. For example, the pattern

           (a|(bc))\2

         always fails if it starts to match  "a"  rather  than  "bc".
         Because  there  may  be up to 99 back references, all digits
         following the backslash are taken as  part  of  a  potential
         back reference number. If the pattern continues with a digit
         character, then some delimiter must be used to terminate the
         back reference. If the PCRE_EXTENDED option is set, this can
         be whitespace.  Otherwise an empty comment can be used.

         A back reference that occurs inside the parentheses to which
         it  refers  fails when the subpattern is first used, so, for
         example, (a\1) never matches.  However, such references  can
         be useful inside repeated subpatterns. For example, the pat-
         tern

           (a|b\1)+

         matches any number of "a"s and also "aba", "ababaa" etc.  At
         each iteration of the subpattern, the back reference matches
         the character string corresponding to  the  previous  itera-
         tion.  In  order  for this to work, the pattern must be such
         that the first iteration does not need  to  match  the  back
         reference.  This  can  be  done using alternation, as in the
         example above, or by a quantifier with a minimum of zero.



    ASSERTIONS
         An assertion is  a  test  on  the  characters  following  or
         preceding  the current matching point that does not actually
         consume any characters. The simple assertions coded  as  \b,
         \B,  \A,  \Z,  \z, ^ and $ are described above. More compli-
         cated assertions are coded as  subpatterns.  There  are  two
         kinds:  those that look ahead of the current position in the
         subject string, and those that look behind it.

         An assertion subpattern is matched in the normal way, except
         that  it  does not cause the current matching position to be
         changed. Lookahead assertions start with  (?=  for  positive
         assertions and (?! for negative assertions. For example,

           \w+(?=;)

         matches a word followed by a semicolon, but does not include
         the semicolon in the match, and

           foo(?!bar)

         matches any occurrence of "foo"  that  is  not  followed  by
         "bar". Note that the apparently similar pattern

           (?!foo)bar

         does not find an occurrence of "bar"  that  is  preceded  by
         something other than "foo"; it finds any occurrence of "bar"
         whatsoever, because the assertion  (?!foo)  is  always  true
         when  the  next  three  characters  are  "bar". A lookbehind
         assertion is needed to achieve this effect.
         Lookbehind assertions start with (?<=  for  positive  asser-
         tions and (?<! for negative assertions. For example,

           (?<!foo)bar

         does find an occurrence of "bar" that  is  not  preceded  by
         "foo". The contents of a lookbehind assertion are restricted
         such that all the strings  it  matches  must  have  a  fixed
         length.  However, if there are several alternatives, they do
         not all have to have the same fixed length. Thus

           (?<=bullock|donkey)

         is permitted, but

           (?<!dogs?|cats?)

         causes an error at compile time. Branches  that  match  dif-
         ferent length strings are permitted only at the top level of
         a lookbehind assertion. This is an extension  compared  with
         Perl  5.005,  which  requires all branches to match the same
         length of string. An assertion such as

           (?<=ab(c|de))

         is not permitted, because its single  top-level  branch  can
         match two different lengths, but it is acceptable if rewrit-
         ten to use two top-level branches:

           (?<=abc|abde)

         The implementation of lookbehind  assertions  is,  for  each
         alternative,  to  temporarily move the current position back
         by the fixed width and then  try  to  match.  If  there  are
         insufficient  characters  before  the  current position, the
         match is deemed to fail.  Lookbehinds  in  conjunction  with
         once-only  subpatterns can be particularly useful for match-
         ing at the ends of strings; an example is given at  the  end
         of the section on once-only subpatterns.

         Several assertions (of any sort) may  occur  in  succession.
         For example,

           (?<=\d{3})(?<!999)foo

         matches "foo" preceded by three digits that are  not  "999".
         Furthermore,  assertions  can  be nested in any combination.
         For example,

           (?<=(?<!foo)bar)baz

         matches an occurrence of "baz" that  is  preceded  by  "bar"
         which in turn is not preceded by "foo".

         Assertion subpatterns are not capturing subpatterns, and may
         not  be  repeated,  because  it makes no sense to assert the
         same thing several times. If an assertion contains capturing
         subpatterns within it, these are always counted for the pur-
         poses of numbering the capturing subpatterns  in  the  whole
         pattern.   Substring  capturing  is carried out for positive
         assertions, but it does not make sense for  negative  asser-
         tions.

         Assertions count towards the maximum  of  200  parenthesized
         subpatterns.



    ONCE-ONLY SUBPATTERNS
         With both maximizing and minimizing repetition,  failure  of
         what  follows  normally  causes  the repeated item to be re-
         evaluated to see if a different number of repeats allows the
         rest  of  the  pattern  to  match. Sometimes it is useful to
         prevent this, either to change the nature of the  match,  or
         to  cause  it fail earlier than it otherwise might, when the
         author of the pattern knows there is no  point  in  carrying
         on.

         Consider, for example, the pattern \d+foo  when  applied  to
         the subject line

           123456bar

         After matching all 6 digits and then failing to match "foo",
         the normal action of the matcher is to try again with only 5
         digits matching the \d+ item, and then with 4,  and  so  on,
         before ultimately failing. Once-only subpatterns provide the
         means for specifying that once a portion of the pattern  has
         matched,  it  is  not to be re-evaluated in this way, so the
         matcher would give up immediately on failing to match  "foo"
         the  first  time.  The  notation  is another kind of special
         parenthesis, starting with (?> as in this example:

           (?>\d+)bar

         This kind of parenthesis "locks up" the  part of the pattern
         it  contains once it has matched, and a failure further into
         the pattern is prevented from backtracking  into  it.  Back-
         tracking  past  it to previous items, however, works as nor-
         mal.

         An alternative description is that a subpattern of this type
         matches  the  string  of  characters that an identical stan-
         dalone pattern would match, if anchored at the current point
         in the subject string.

         Once-only subpatterns are not capturing subpatterns.  Simple
         cases  such as the above example can be thought of as a max-
         imizing repeat that must  swallow  everything  it  can.  So,
         while both \d+ and \d+? are prepared to adjust the number of
         digits they match in order to make the rest of  the  pattern
         match, (?>\d+) can only match an entire sequence of digits.

         This construction can of course contain arbitrarily  compli-
         cated subpatterns, and it can be nested.

         Once-only subpatterns can be used in conjunction with  look-
         behind  assertions  to specify efficient matching at the end
         of the subject string. Consider a simple pattern such as

           abcd$

         when applied to a long  string  which  does  not  match  it.
         Because matching proceeds from left to right, PCRE will look
         for each "a" in the subject and then  see  if  what  follows
         matches the rest of the pattern. If the pattern is specified
         as

           ^.*abcd$

         then the initial .* matches the entire string at first,  but
         when  this  fails,  it  backtracks to match all but the last
         character, then all but the last two characters, and so  on.
         Once again the search for "a" covers the entire string, from
         right to left, so we are no better off. However, if the pat-
         tern is written as

           ^(?>.*)(?<=abcd)

         then there can be no backtracking for the .*  item;  it  can
         match  only  the  entire  string.  The subsequent lookbehind
         assertion does a single test on the last four characters. If
         it  fails,  the  match  fails immediately. For long strings,
         this approach makes a significant difference to the process-
         ing time.



    CONDITIONAL SUBPATTERNS
         It is possible to cause the matching process to obey a  sub-
         pattern  conditionally  or to choose between two alternative
         subpatterns, depending on the result  of  an  assertion,  or
         whether  a previous capturing subpattern matched or not. The
         two possible forms of conditional subpattern are

           (?(condition)yes-pattern)
           (?(condition)yes-pattern|no-pattern)

         If the condition is satisfied, the yes-pattern is used; oth-
         erwise  the  no-pattern  (if  present) is used. If there are
         more than two alternatives in the subpattern, a compile-time
         error occurs.

         There are two kinds of condition. If the  text  between  the
         parentheses  consists of a sequence of digits, then the con-
         dition is satisfied if  the  capturing  subpattern  of  that
         number  has  previously matched. Consider the following pat-
         tern, which contains non-significant white space to make  it
         more  readable  (assume  the  PCRE_EXTENDED  option)  and to
         divide it into three parts for ease of discussion:

           ( \( )?    [^()]+    (?(1) \) )

         The first part matches an optional opening parenthesis,  and
         if  that character is present, sets it as the first captured
         substring. The second part matches one  or  more  characters
         that  are  not  parentheses. The third part is a conditional
         subpattern that tests whether the first set  of  parentheses
         matched  or  not.  If  they did, that is, if subject started
         with an opening parenthesis, the condition is true,  and  so
         the  yes-pattern  is  executed  and a closing parenthesis is
         required. Otherwise, since no-pattern is  not  present,  the
         subpattern  matches  nothing.  In  other words, this pattern
         matches a sequence of non-parentheses,  optionally  enclosed
         in parentheses.

         If the condition is not a sequence of digits, it must be  an
         assertion.  This  may be a positive or negative lookahead or
         lookbehind assertion. Consider this pattern, again  contain-
         ing  non-significant  white space, and with the two alterna-
         tives on the second line:

           (?(?=[^a-z]*[a-z])
           \d{2}[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} )

         The condition is a positive lookahead assertion that matches
         an optional sequence of non-letters followed by a letter. In
         other words, it tests for  the  presence  of  at  least  one
         letter  in the subject. If a letter is found, the subject is
         matched against  the  first  alternative;  otherwise  it  is
         matched  against the second. This pattern matches strings in
         one of the two forms dd-aaa-dd or dd-dd-dd,  where  aaa  are
         letters and dd are digits.



    COMMENTS
         The  sequence  (?#  marks  the  start  of  a  comment  which
         continues   up  to  the  next  closing  parenthesis.  Nested
         parentheses are not permitted. The characters that make up a
         comment play no part in the pattern matching at all.

         If the PCRE_EXTENDED option is set, an unescaped # character
         outside  a character class introduces a comment that contin-
         ues up to the next newline character in the pattern.



    PERFORMANCE
         Certain items that may appear in patterns are more efficient
         than  others.  It is more efficient to use a character class
         like [aeiou] than a set of alternatives such as (a|e|i|o|u).
         In  general,  the  simplest  construction  that provides the
         required behaviour is usually the  most  efficient.  Jeffrey
         Friedl's  book contains a lot of discussion about optimizing
         regular expressions for efficient performance.

         When a pattern begins with .* and the PCRE_DOTALL option  is
         set,  the  pattern  is implicitly anchored by PCRE, since it
         can match only at the start of a subject string. However, if
         PCRE_DOTALL  is not set, PCRE cannot make this optimization,
         because the . metacharacter does not then match  a  newline,
         and if the subject string contains newlines, the pattern may
         match from the character immediately following one  of  them
         instead of from the very start. For example, the pattern

            (.*) second

         matches the subject "first\nand second" (where \n stands for
         a newline character) with the first captured substring being
         "and". In order to do this, PCRE  has  to  retry  the  match
         starting after every newline in the subject.

         If you are using such a pattern with subject strings that do
         not  contain  newlines,  the best performance is obtained by
         setting PCRE_DOTALL, or starting the  pattern  with  ^.*  to
         indicate  explicit anchoring. That saves PCRE from having to
         scan along the subject looking for a newline to restart at.


    XLVI. PHP options & information

    Table of Contents
    error_log ¡¦ send an error message somewhere
    error_reporting ¡¦ set which PHP errors are reported
    extension_loaded ¡¦ find out whether an extension is loaded
    getenv ¡¦ Get the value of an environment variable.
    get_cfg_var ¡¦ Get the value of a PHP configuration option.
    get_current_user ¡¦ Get the name of the owner of the current PHP script.
    get_magic_quotes_gpc ¡¦ Get the current active configuration setting of magic quotes gpc.
    get_magic_quotes_runtime ¡¦ Get the current active configuration setting of magic_quotes_runtime.
    getlastmod ¡¦ Get time of last page modification.
    getmyinode ¡¦ Get the inode of the current script.
    getmypid ¡¦ Get PHP's process ID.
    getmyuid ¡¦ Get PHP script owner's UID.
    getrusage ¡¦ Get the current resource usages.
    phpinfo ¡¦ Output lots of PHP information.
    phpversion ¡¦ Get the current PHP version.
    php_logo_guid ¡¦ Get the logo guid
    putenv ¡¦ Set the value of an environment variable.
    set_magic_quotes_runtime ¡¦ Set the current active configuration setting of magic_quotes_runtime.
    set_time_limit ¡¦ limit the maximum execution time
    zend_logo_guid ¡¦ Get the zend guid

    error_log

    error_log -- ¿¡·¯ ¸Þ¼¼Áö¸¦ ÁöÁ¤ÇÑ °÷¿¡ º¸³½´Ù.

    Description

    int error_log(string message, int message_type, string [destination], string [extra_headers]);

    Sends an error message to the web server's error log, a TCP port or to a file. The first parameter, message, is the error message that should be logged. The second parameter, message_type says where the message should go:

    Table 1. error_log() log types

    0

    message is sent to PHP's system logger, using the Operating System's system logging mechanism or a file, depending on what the error_log configuration directive is set to.

    1

    message is sent by email to the address in the destination parameter. This is the only message type where the fourth parameter, extra_headers is used. This message type uses the same internal function as Mail() does.

    2

    message is sent through the PHP debugging connection. This option is only available if remote debugging has been enabled. In this case, the destination parameter specifies the host name or IP address and optionally, port number, of the socket receiving the debug information.

    3

    message is appended to the file destination.

    Example 1. error_log() examples

    // Send notification through the server log if we can not
    // connect to the database.
    if (!Ora_Logon($username, $password)) {
        error_log("Oracle database not available!", 0);
    }
    // Notify administrator by email if we run out of FOO
    if (!($foo = allocate_new_foo()) {
        error_log("Big trouble, we're all out of FOOs!", 1,
                  "operator@mydomain.com");
    }
    // other ways of calling error_log():
    error_log("You messed up!", 2, "127.0.0.1:7000");
    error_log("You messed up!", 2, "loghost");
    error_log("You messed up!", 3, "/var/tmp/my-errors.log");

    error_reporting

    error_reporting -- report µÉ PHP ¿¡·¯µéÀ» Á¤ÇÑ´Ù.

    Description

    int error_reporting(int [level]);

    Sets PHP's error reporting level and returns the old level. The error reporting level is a bitmask of the following values (follow the links for the internal values to get their meanings):

    Table 1. error_reporting() bit values

    value

    internal name

    1

    E_ERROR

    2

    E_WARNING

    4

    E_PARSE

    8

    E_NOTICE

    16

    E_CORE_ERROR

    32

    E_CORE_WARNING

    extension_loaded

    extension_loaded -- ¾î¶² extensionÀÌ loadµÇ¾î ÀÖ´ÂÁö ¾Ë·ÁÁØ´Ù.

    Description

    bool extension_loaded(string name);

    Returns true if the extension identified by name is loaded. You can see the names of various extensions by using phpinfo().

    See also phpinfo().

    Note: This function was added in 3.0.10.

    getenv

    getenv -- ȯ°æ º¯¼ö(environment variable)ÀÇ °ªÀ» ±¸ÇÑ´Ù.

    Description

    string getenv(string varname);

    Returns the value of the environment variable varname, or false on an error.

    $ip = getenv("REMOTE_ADDR"); // get the ip number from the user 

    get_cfg_var

    get_cfg_var -- PHP ¼³Á¤ ¿É¼Ç(configuration option)ÀÇ °ªÀ» ±¸ÇÑ´Ù.

    Description

    string get_cfg_var(string varname);

    Returns the current value of the PHP configuration variable specified by varname, or false if an error occurs.

    It will not return configuration information set when the PHP was compiled, or read from an Apache configuration file (using the php3_configuration_option directives).

    To check whether the system is using a php3.ini file, try retrieving the value of the cfg_file_path configuration setting. If this is available, a php3.ini file is being used.

    get_current_user

    get_current_user -- Çö PHP scriptÀÇ owner À̸§À» ±¸ÇÑ´Ù.

    Description

    string get_current_user(void);

    Returns the name of the owner of the current PHP script.

    See also getmyuid(), getmypid(), getmyinode(), and getlastmod().

    get_magic_quotes_gpc

    get_magic_quotes_gpc -- magic quotes gpcÀÇ ÇöÀç ¼³Á¤ »óŸ¦ ¾ò´Â´Ù.

    Description

    long get_magic_quotes_gpc(void);

    Returns the current active configuration setting of magic_quotes_gpc. (0 for off, 1 for on)

    See also get_magic_quotes_runtime(), set_magic_quotes_runtime().

    get_magic_quotes_runtime

    get_magic_quotes_runtime -- magic_quotes_runtimeÀÇ ÇöÀç ¼³Á¤ »óŸ¦ ¾ò´Â´Ù.

    Description

    long get_magic_quotes_runtime(void);

    Returns the current active configuration setting of magic_quotes_runtime. (0 for off, 1 for on)

    See also get_magic_quotes_gpc(), set_magic_quotes_runtime().

    getlastmod

    getlastmod -- Çö ¹®¼­¸¦ ¸¶Áö¸·À¸·Î ¼öÁ¤ÇÑ ½Ã°£À» ±¸ÇÑ´Ù.

    Description

    int getlastmod(void);

    Returns the time of the last modification of the current page. The value returned is a Unix timestamp, suitable for feeding to date(). Returns false on error.

    Example 1. getlastmod() example

    // outputs e.g. 'Last modified: March 04 1998 20:43:59.'
    echo "Last modified: ".date( "F d Y H:i:s.", getlastmod() );
          

    See alse date(), getmyuid(), get_current_user(), getmyinode(), and getmypid().

    getmyinode

    getmyinode -- Çö scriptÀÇ inode¸¦ ±¸ÇÑ´Ù.

    Description

    int getmyinode(void);

    Returns the current script's inode, or false on error.

    See also getmyuid(), get_current_user(), getmypid(), and getlastmod().

    getmypid

    getmypid -- PHPÀÇ process ID¸¦ ±¸ÇÑ´Ù.

    Description

    int getmypid(void);

    Returns the current PHP process ID, or false on error.

    Note that when running as a server module, separate invocations of the script are not guaranteed to have distinct pids.

    See also getmyuid(), get_current_user(), getmyinode(), and getlastmod().

    getmyuid

    getmyuid -- PHP scriptÀÇ ownerÀÇ UID °ªÀ» ±¸ÇÑ´Ù..

    Description

    int getmyuid(void);

    Returns the user ID of the current script, or false on error.

    See also getmypid(), get_current_user(), getmyinode(), and getlastmod().

    getrusage

    getrusage -- ÇöÀç ÀÚ¿øÀÇ »ç¿ë ÇöȲÀ» ¾ò´Â´Ù.

    Description

    array getrusage(int [who]);

    This is an interface to getrusage(2). It returns an associative array containing the data returned from the system call. If who is 1, getrusage will be called with RUSAGE_CHILDREN. All entries are accessible by using their documented field names.

    Example 1. Getrusage Example

    $dat = getrusage();
    echo $dat["ru_nswap"];         # number of swaps
    echo $dat["ru_majflt"];        # number of page faults
    echo $dat["ru_utime.tv_sec"];  # user time used (seconds)
    echo $dat["ru_utime.tv_usec"]; # user time used (microseconds)

    See your system's man page for more details.

    phpinfo

    phpinfo -- ¿©·¯°¡ÁöÀÇ PHP informationÀ» Ãâ·ÂÇÑ´Ù.

    Description

    int phpinfo(void);

    Outputs a large amount of information about the current state of PHP. This includes information about PHP compilation options and extensions, the PHP version, server information and environment (if compiled as a module), the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the GNU Public License.

    See also phpversion().

    phpversion

    phpversion -- Çö PHP versionÀ» ±¸ÇÑ´Ù.

    Description

    string phpversion(void);

    Returns a string containing the version of the currently running PHP parser.

    Example 1. phpversion() example

    // prints e.g. 'Current PHP version: 3.0rel-dev'
    echo "Current PHP version: ".phpversion();
          

    See also phpinfo().

    php_logo_guid

    (PHP4 >= 4.0b4)

    php_logo_guid -- logo guid¸¦ ¾ò´Â´Ù.

    Description

    string php_logo_guid (void)

    Note: This funcionality was added in PHP4 Beta 4.

    putenv

    putenv -- ȯ°æ º¯¼ö(environment variable)ÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù.

    Description

    void putenv (string setting)

    Adds setting to the environment.

    Example 1. Setting an Environment Variable

      1 
      2 putenv("UNIQID=$uniqid");
      3       

    set_magic_quotes_runtime

    set_magic_quotes_runtime -- Set the current active configuration setting of magic_quotes_runtime.

    Description

    long set_magic_quotes_runtime(int new_setting);

    Set the current active configuration setting of magic_quotes_runtime. (0 for off, 1 for on)

    See also get_magic_quotes_gpc(), get_magic_quotes_runtime().

    set_time_limit

    set_time_limit -- ½ÇÇà¿¡ °É¸®´Â ½Ã°£À» ÇÑÁ¤½ÃŲ´Ù. (limit the maximum execution time)

    Description

    void set_time_limit(int seconds);

    Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in php3.ini. If seconds is set to zero, no time limit is imposed.

    When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit( 20 ) is made, the script will run for a total of 45 seconds before timing out.

    zend_logo_guid

    (PHP4 >= 4.0b4)

    zend_logo_guid -- zend guid¸¦ ¾ò´Â´Ù.

    Description

    string zend_logo_guid (void)

    Note: This funcionality was added in PHP4 Beta 4.


    XLVII. POSIX functions

    ÀÌ ¸ðµâÀº IEEE 1003.1 (POSIX.1) Ç¥ÁØ ¹®¼­¿¡ Á¤ÀǵǾî ÀÖ´Â ÇÔ¼öÁß¿¡ ´Ù¸¥ ¹æ¹ýÀ¸·Î´Â Áö¿øµÇÁö ¾Ê´Â ÇÔ¼ö¿¡ ´ëÇÑ ÀÎÅÍÆäÀ̽º¸¦ Æ÷ÇÔÇÑ´Ù. ¿¹¸¦µé¾î POSIX.1¿¡´Â open(), read(), write(), close() µîÀÇ ÇÔ¼ö°¡ Æ÷ÇԵǾî ÀÖ´À³ª ÀÌ ÇÔ¼öµéÀº PHP3¿¡¼­ ÀÌÀüºÎÅÍ Áö¿øÇÏ´ø °ÍÀ̹ǷΠÀÌ ¸ðµâ¿¡ Æ÷ÇÔµÇÁö ¾Ê´Â´Ù. ÀÌÀü¿¡´Â ½Ã½ºÅÛ¿¡ °ü·ÃµÈ ¸¹Àº ÇÔ¼ö¸¦ »ç¿ëÇÏÁö ¸øÇÏ¿´À¸³ª, ÀÌ ¸ðµâÀº ÀÌ ÇÔ¼öµéÀ» ½±°Ô »ç¿ëÇÒ ¼ö ÀÖµµ·Ï µµ¿ÍÁÙ °ÍÀÌ´Ù.

    Table of Contents
    posix_kill ¡¦ Send a signal to a process
    posix_getpid ¡¦ Return the current process identifier
    posix_getppid ¡¦ Return the parent process identifier
    posix_getuid ¡¦ Return the real user ID of the current process
    posix_geteuid ¡¦ Return the effective user ID of the current process
    posix_getgid ¡¦ Return the real group ID of the current process
    posix_getegid ¡¦ Return the effective group ID of the current process
    posix_setuid ¡¦ Set the effective UID of the current process
    posix_setgid ¡¦ Set the effective GID of the current process
    posix_getgroups ¡¦ Return the group set of the current process
    posix_getlogin ¡¦ Return login name
    posix_getpgrp ¡¦ Return the current process group identifier
    posix_setsid ¡¦ Make the current process a session leader
    posix_setpgid ¡¦ set process group id for job control
    posix_getpgid ¡¦ Get process group id for job control
    posix_getsid ¡¦ Get the current sid of the process
    posix_uname ¡¦ Get system name
    posix_times ¡¦ Get process times
    posix_ctermid ¡¦ Get path name of controlling terminal
    posix_ttyname ¡¦ Determine terminal device name
    posix_isatty ¡¦ Determine if a file descriptor is an interactive terminal
    posix_getcwd ¡¦ Pathname of current directory
    posix_mkfifo ¡¦ Create a fifo special file (a named pipe)
    posix_getgrnam ¡¦ Return info about a group by name
    posix_getgrgid ¡¦ Return info about a group by group id
    posix_getpwnam ¡¦ Return info about a user by username
    posix_getpwuid ¡¦ Return info about a user by user id
    posix_getrlimit ¡¦ Return info about system ressource limits

    posix_kill

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_kill -- ƯÁ¤ ÇÁ·Î¼¼½º¿¡ ½ÅÈ£(signal)À» ÁØ´Ù.

    Description

    bool posix_kill(int pid, int sig);

    Send the signal sig to the process with the process identifier pid. Returns FALSE, if unable to send the signal, TRUE otherwise.

    See also the kill(2) manual page of your POSIX system, which contains additional information about negative process identifiers, the special pid 0, the special pid -1, and the signal number 0.

    posix_getpid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getpid -- ÇöÀç ÇÁ·Î¼¼½ºÀÇ ID¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int posix_getpid(void );

    Return the process identifier of the current process.

    posix_getppid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getppid -- ºÎ¸ð ÇÁ·Î¼¼½ºÀÇ ID¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int posix_getppid(void );

    Return the process identifier of the parent process of the current process.

    posix_getuid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getuid -- ÇöÀç ÇÁ·Î¼¼½ºÀÇ real user ID¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int posix_getuid(void );

    Return the numeric real user ID of the current process. See also posix_getpwuid() for information on how to convert this into a useable username.

    posix_geteuid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_geteuid -- ÇöÀç ÇÁ·Î¼¼½ºÀÇ effective user ID¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int posix_geteuid(void );

    Return the numeric effective user ID of the current process. See also posix_getpwuid() for information on how to convert this into a useable username.

    posix_getgid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getgid -- ÇöÀç ÇÁ·Î¼¼½ºÀÇ real group ID¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int posix_getgid(void );

    Return the numeric real group ID of the current process. See also posix_getgrgid() for information on how to convert this into a useable group name.

    posix_getegid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getegid -- ÇöÀç ÇÁ·Î¼¼½ºÀÇ effective group ID¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int posix_getegid(void );

    Return the numeric effective group ID of the current process. See also posix_getgrgid() for information on how to convert this into a useable group name.

    posix_setuid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_setuid -- ÇöÀç ÇÁ·Î¼¼½ºÀÇ effective UID¸¦ »õ·Î ¼³Á¤ÇÑ´Ù.

    Description

    bool posix_setuid(int uid);

    Set the real user ID of the current process. This is a privileged function and you need appropriate privileges (usually root) on your system to be able to perform this function.

    Returns TRUE on success, FALSE otherwise. See also posix_setgid().

    posix_setgid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_setgid -- ÇöÀç ÇÁ·Î¼¼½ºÀÇ effective GID¸¦ »õ·Î ¼³Á¤ÇÑ´Ù.

    Description

    bool posix_setgid(int gid);

    Set the real group ID of the current process. This is a privileged function and you need appropriate privileges (usually root) on your system to be able to perform this function. The appropriate order of function calls is posix_setgid() first, posix_setuid() last.

    Returns TRUE on success, FALSE otherwise.

    posix_getgroups

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getgroups -- ÇöÀç ÇÁ·Î¼¼½ºÀÇ group setÀ» ¹ÝȯÇÑ´Ù.

    Description

    array posix_getgroups(void );

    Returns an array of integers containing the numeric group ids of the group set of the current process. See also posix_getgrgid() for information on how to convert this into useable group names.

    posix_getlogin

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getlogin -- login nameÀ» ¹ÝȯÇÑ´Ù.

    Description

    string posix_getlogin(void );

    Returns the login name of the user owning the current process. See posix_getpwnam() for information how to get more information about this user.

    posix_getpgrp

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getpgrp -- ÇöÀç ÇÁ·Î¼¼½ºÀÇ group ID¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int posix_getpgrp(void );

    Return the process group identifier of the current process. See POSIX.1 and the getpgrp(2) manual page on your POSIX system for more information on process groups.

    posix_setsid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_setsid -- ÇöÀç ÇÁ·Î¼¼½º¸¦ session leader·Î ¸¸µç´Ù.

    Description

    int posix_setsid(void );

    Make the current process a session leader. See POSIX.1 and the setsid(2) manual page on your POSIX system for more informations on process groups and job control. Returns the session id.

    posix_setpgid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_setpgid -- ƯÁ¤ ÇÁ·Î¼¼½º¿¡ ÇÁ·Î¼¼½º group ID¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int posix_setpgid(int pid, int pgid);

    Let the process pid join the process group pgid. See POSIX.1 and the setsid(2) manual page on your POSIX system for more informations on process groups and job control. Returns TRUE on success, FALSE

    posix_getpgid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getpgid -- ƯÁ¤ ÇÁ·Î¼¼½ºÀÇ ÇÁ·Î¼¼½º group ID¸¦ ¾ò´Â´Ù.

    Description

    int posix_getpgid(int pid);

    Returns the process group identifier of the process pid.

    This is not a POSIX function, but is common on BSD and System V systems. If your system does not support this function at system level, this PHP function will always return FALSE.

    posix_getsid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getsid -- ƯÁ¤ÇÁ·Î¼¼½ºÀÇ ÇöÀç sid¸¦ ¾ò´Â´Ù.

    Description

    int posix_getsid(int pid);

    Return the sid of the process pid. If pid is 0, the sid of the current process is returned.

    This is not a POSIX function, but is common on System V systems. If your system does not support this function at system level, this PHP function will always return FALSE.

    posix_uname

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_uname -- system nameÀ» ¾ò´Â´Ù.

    Description

    array posix_uname(void );

    Returns a hash of strings with information about the system. The indices of the hash are

    Posix requires that you must not make any assumptions about the format of the values, e.g. you cannot rely on three digit version numbers or anything else returned by this function.

    posix_times

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_times -- process timesÀ» ¾ò´Â´Ù.

    Description

    array posix_times(void );

    Returns a hash of strings with information about the current process CPU usage. The indices of the hash are

    posix_ctermid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_ctermid -- controlling terminalÀÇ path À̸§À» ¾ò´Â´Ù.

    Description

    string posix_ctermid(void );

    Needs to be written.

    posix_ttyname

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_ttyname -- ÁöÁ¤µÈ ÆÄÀÏ descriptorÀÇ terminal ÀåÄ¡(device) À̸§À» °áÁ¤ÇÑ´Ù.

    Description

    string posix_ttyname(int fd);

    Needs to be written.

    posix_isatty

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_isatty -- ÁöÁ¤µÈ ÆÄÀÏ descriptor°¡ interactive terminal Àΰ¡ °áÁ¤ÇÑ´Ù.

    Description

    bool posix_isatty(int fd);

    Needs to be written.

    posix_getcwd

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getcwd -- ÇöÀç µð·ºÅ丮ÀÇ Pathname

    Description

    string posix_getcwd(void );

    Needs to be written ASAP

    posix_mkfifo

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_mkfifo -- fifo special file (a named pipe)À» ¸¸µç´Ù.

    Description

    bool posix_getcwd(string pathname, int mode);

    Needs to be written ASAP..

    posix_getgrnam

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getgrnam -- ±×·ì¸íÀ» »ç¿ëÇÏ¿© ±×·ì¿¡ ´ëÇÑ Á¤º¸¸¦ °¡Á®¿Â´Ù.

    Description

    array posix_getgrnam(string name);

    Needs to be written.

    posix_getgrgid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getgrgid -- ±×·ì ID¸¦ »ç¿ëÇÏ¿© ±×·ì¿¡ ´ëÇÑ Á¤º¸¸¦ °¡Á®¿Â´Ù.

    Description

    array posix_getgrgid (int gid)

    Needs to be written.

    posix_getpwnam

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getpwnam -- »ç¿ëÀÚ¸íÀ» »ç¿ëÇÏ¿© »ç¿ëÀÚ¿¡ ´ëÇÑ Á¤º¸¸¦ °¡Á®¿Â´Ù.

    Description

    array posix_getpwnam(string username);

    Returns an associative array containing information about a user referenced by an alphanumeric username, passed in the username parameter.

    The array elements returned are:

    Table 1. The user information array

    Element Description
    name The name element contains the username of the user. This is a short, usually less than 16 character "handle" of the user, not her real, full name. This should be the same as the username parameter used when calling the function, and hence redundant.
    passwd The passwd element contains the user's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.
    uid User ID of the user in numeric form.
    gid The group ID of the user. Use the function posix_getgrgid() to resolve the group name and a list of its members.
    gecos GECOS is an obsolete term that refers to the finger information field on a Honeywell batch processing system. The field, however, lives on, and its contents have been formalized by POSIX. The field contains a comma separated list containing the user's full name, office phone, office number, and home phone number. On most systems, only the user's full name is available.
    dir This element contains the absolute path to the home directory of the user.
    shell The shell element contains the absolute path to the executable of the user's default shell.

    posix_getpwuid

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getpwuid -- »ç¿ëÀÚ ID¸¦ »ç¿ëÇÏ¿© »ç¿ëÀÚ¿¡ ´ëÇÑ Á¤º¸¸¦ °¡Á®¿Â´Ù.

    Description

    array posix_getpwuid(int uid);

    Returns an associative array containing information about a user referenced by a numeric user ID, passed in the uid parameter.

    The array elements returned are:

    Table 1. The user information array

    Element Description
    name The name element contains the username of the user. This is a short, usually less than 16 character "handle" of the user, not her real, full name.
    passwd The passwd element contains the user's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.
    uid User ID, should be the same as the uid parameter used when calling the function, and hence redundant.
    gid The group ID of the user. Use the function posix_getgrgid() to resolve the group name and a list of its members.
    gecos GECOS is an obsolete term that refers to the finger information field on a Honeywell batch processing system. The field, however, lives on, and its contents have been formalized by POSIX. The field contains a comma separated list containing the user's full name, office phone, office number, and home phone number. On most systems, only the user's full name is available.
    dir This element contains the absolute path to the home directory of the user.
    shell The shell element contains the absolute path to the executable of the user's default shell.

    posix_getrlimit

    (PHP3 >= 3.0.13, PHP4 >= 4.0b4)

    posix_getrlimit -- system ÀÚ¿øÀÇ limit¿¡ ´ëÇÑ Á¤º¸¸¦ ¹ÝȯÇÑ´Ù.

    Description

    array posix_getrlimit(void );

    Needs to be written ASAP.

    XLVIII. PostgreSQL functions

    UC Berkeley Computer Science Department¿¡¼­ óÀ½ °³¹ßµÈ Postgres´Â ÀÌÁ¦´Â ÀϺΠ»ó¿ë database¿¡¼­ °¡´ÉÇÑ object-relational °³³äÀÇ ¸¹Àº °ÍÀ» °³Ã´ÇÏ¿´´Ù. ÀÌ°ÍÀº SQL92/SQL3 ¾ð¾î¸¦ Áö¿øÇÏ°í, transaction integrity¿Í type È®Àå°¡´É¼ºÀ» Á¦°øÇÑ´Ù. PostgreSQLÀº public-domainÀÌ°í, original Berkeley codeÀÇ ¹ßÀüµÈ ¼Ò½º¸¦ Á¦°øÇÑ´Ù.

    PostgreSQLÀº ¹«·á·Î »ç¿ë°¡´ÉÇÏ´Ù. ÇöÀç ¹öÁ¯Àº 6.3.3±îÁö ³ª¿ÍÀÖ°í, www.postgreSQL.org¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.

    version 6.3 (03/02/1998)ÀÌÈÄ·Î PostgreSQLÀº unix domain socketÀ» »ç¿ëÇÏ°í, ÀÌ ±â´ÉÀ» À§ÇØ tableÀÌ ÁÖ¾îÁø´Ù. ÀÌ ¼ÒÄÏÀº /tmp/.s.PGSQL.5432¿¡¼­ ãÀ» ¼ö ÀÖ´Ù. ÀÌ ¿É¼ÇÀº postmaster¿¡ '-i' flag¸¦ Á־ enable½Ãų ¼ö Àִµ¥, ÀÌ°ÍÀº "TCP/IP sockets»Ó ¾Æ´Ï¶ó Unix domain socketÀÇ ¿äûµµ ¹Þ¾Æµé¿©¶ó."´Â ÀǹÌÀÌ´Ù.

    Table 1. Postmaster and PHP

    Postmaster

    PHP

    Status

    postmaster &

    pg_connect("", "", "", "", "dbname");

    OK

    postmaster -i &

    pg_connect("", "", "", "", "dbname");

    OK

    postmaster &

    pg_connect("localhost", "", "", "", "dbname");

    PostgreSQL server¿¡ ¿¬°áÇÒ ¼ö ¾øÀ½: connectDB() failed: Is the postmaster running and accepting TCP/IP (with -i) connection at 'localhost' on port '5432'? in /path/to/file.php3 on line 20.

    postmaster -i &

    pg_connect("localhost", "", "", "", "dbname");

    OK

    ´ÙÀ½°ú °°Àº ÇϳªÀÇ ÆĶó¸ÞÅ͸¸À¸·Îµµ ¿¬°áÀ» ¼³Á¤ÇÒ ¼ö ÀÖ´Ù. : $conn = pg_Connect("host=localhost port=5432 dbname=chris");

    large object (lo) interface¸¦ »ç¿ëÇÏ·Á¸é transaction blockÀ¸·Î µÑ·¯ ½Î´Â °ÍÀÌ ÇÊ¿äÇÏ´Ù. transaction blockÀº beginÀ¸·Î ½ÃÀÛÇÏ°í, transactionÀÌÈ®½ÇÇÏ´Ù¸é commitÀ̳ª end·Î ³¡³½´Ù. ¸¸¾à transactionÀÌ ¿À·ù°¡Àְųª ½ÇÆÐÇϸé transaction blockÀº abort³ª rollbackÀ¸·Î ³¡³»¾ß ÇÒ °ÍÀÌ´Ù.

    Example 1. Using Large Objects

      1 
      2 <?php
      3     $database = pg_Connect ("", "", "", "", "jacarta");
      4     pg_exec ($database, "begin");
      5     $oid = pg_locreate ($database);
      6     echo ("$oid\n");
      7     $handle = pg_loopen ($database, $oid, "w");
      8     echo ("$handle\n");
      9     pg_lowrite ($handle, "gaga");
     10     pg_loclose ($handle);
     11     pg_exec ($database, "commit");
     12 ?>
     13      

    Table of Contents

    pg_Close ¡¦ closes a PostgreSQL connection
    pg_cmdTuples ¡¦ returns number of affected tuples
    pg_Connect ¡¦ opens a connection
    pg_DBname ¡¦ database name
    pg_ErrorMessage ¡¦ error message
    pg_Exec ¡¦ execute a query
    pg_Fetch_Array ¡¦ fetch row as array
    pg_Fetch_Object ¡¦ fetch row as object
    pg_Fetch_Row ¡¦ get row as enumerated array
    pg_FieldIsNull ¡¦ Test if a field is NULL
    pg_FieldName ¡¦ Returns the name of a field
    pg_FieldNum ¡¦ Returns the number of a column
    pg_FieldPrtLen ¡¦ Returns the printed length
    pg_FieldSize ¡¦ Returns the internal storage size of the named field
    pg_FieldType ¡¦ Returns the type name for the corresponding field number
    pg_FreeResult ¡¦ Frees up memory
    pg_GetLastOid ¡¦ Returns the last object identifier
    pg_Host ¡¦ Returns the host name
    pg_loclose ¡¦ close a large object
    pg_locreate ¡¦ create a large object
    pg_loexport ¡¦export a large object to file
    pg_loimport ¡¦ import a large object from file
    pg_loopen ¡¦ open a large object
    pg_loread ¡¦ read a large object
    pg_loreadall ¡¦ read a entire large object
    pg_lounlink ¡¦ delete a large object
    pg_lowrite ¡¦ write a large object
    pg_NumFields ¡¦ Returns the number of fields
    pg_NumRows ¡¦ Returns the number of rows
    pg_Options ¡¦ Returns options
    pg_pConnect ¡¦ make a persistent database connection
    pg_Port ¡¦ Returns the port number
    pg_Result ¡¦ Returns values from a result identifier
    pg_trace ¡¦ Trace a connection to PostgreSQL server
    pg_tty ¡¦ Returns the tty name
    pg_untrace ¡¦ Stop tracing a connection to PostgreSQL server

    pg_Close

    pg_Close -- PostgreSQL connectionÀ» ´Ý´Â´Ù.

    Description

    void pg_close(int connection);

    Returns false if connection is not a valid connection index, true otherwise. Closes down the connection to a PostgreSQL database associated with the given connection index.

    pg_cmdTuples

    pg_cmdTuples -- ÇØ´çÇÏ´Â tupleÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int pg_cmdtuples(int result_id);

    pg_cmdTuples() returns the number of tuples (instances) affected by INSERT, UPDATE, and DELETE queries. If no tuple is affected the function will return 0.

    Example 1. pg_cmdtuples

    <?php
    $result = pg_exec($conn, "INSERT INTO verlag VALUES ('Autor')");
    $cmdtuples = pg_cmdtuples($result);
    echo $cmdtuples . " <- cmdtuples affected.";
    ?>

    pg_Connect

    pg_Connect -- connectionÀ» ¿¬´Ù.

    Description

    int pg_connect(string host, string port, string options, string tty, string dbname);

    Returns a connection index on success, or false if the connection could not be made. Opens a connection to a PostgreSQL database. Each of the arguments should be a quoted string, including the port number. The options and tty arguments are optional and can be left out. This function returns a connection index that is needed by other PostgreSQL functions. You can have multiple connections open at once.

    A connection can also established with the following command: $conn = pg_connect("dbname=marliese port=5432"); Other parameters besides dbname and port are host, tty and options.

    See also pg_pConnect().

    pg_DBname

    pg_DBname -- database À̸§

    Description

    string pg_dbname(int connection);

    Returns the name of the database that the given PostgreSQL connection index is connected to, or false if connection is not a valid connection index.

    pg_ErrorMessage

    pg_ErrorMessage -- ¿¡·¯ ¸Þ¼¼Áö

    Description

    string pg_errormessage(int connection);

    Returns a string containing the error message, false on failure. Details about the error probably cannot be retrieved using the pg_errormessage() function if an error occured on the last database action for which a valid connection exists, this function will return a string containing the error message generated by the backend server.

    pg_Exec

    pg_Exec -- ÁúÀǸ¦ ½ÇÇàÇÑ´Ù.

    Description

    int pg_exec(int connection, string query);

    Returns a result index if query could be executed, false on failure or if connection is not a valid connection index. Details about the error can be retrieved using the pg_ErrorMessage() function if connection is valid. Sends an SQL statement to the PostgreSQL database specified by the connection index. The connection must be a valid index that was returned by pg_Connect(). The return value of this function is an index to be used to access the results from other PostgreSQL functions.

    Note: PHP/FI returned 1 if the query was not expected to return data (inserts or updates, for example) and greater than 1 even on selects that did not return anything. No such assumption can be made in PHP.

    pg_Fetch_Array

    pg_Fetch_Array -- row¸¦ ¹è¿­·Î °¡Á®¿Â´Ù.

    Description

    array pg_fetch_array(int result, int row, int [result_type] );

    Returns: An array that corresponds to the fetched row, or false if there are no more rows.

    pg_fetch_array() is an extended version of pg_fetch_row(). In addition to storing the data in the numeric indices of the result array, it also stores the data in associative indices, using the field names as keys.

    The third optional argument result_type in pg_fetch_array() is a constant and can take the following values: PGSQL_ASSOC, PGSQL_NUM, and PGSQL_BOTH.

    Note: Result_type was added in PHP 4.0.

    An important thing to note is that using pg_fetch_array() is NOT significantly slower than using pg_fetch_row(), while it provides a significant added value.

    For further details, also see pg_fetch_row()

    Example 1. PostgreSQL fetch array

    <?php 
    $conn = pg_pconnect("","","","","publisher");
    if (!$conn) {
        echo "An error occured.\n";
        exit;
    }
    $result = pg_Exec ($conn, "SELECT * FROM authors");
    if (!$result) {
        echo "An error occured.\n";
        exit;
    }
    $arr = pg_fetch_array ($result, 0);
    echo $arr[0] . " <- array\n";
    $arr = pg_fetch_array ($result, 1);
    echo $arr["author"] . " <- array\n";
    ?>

    pg_Fetch_Object

    pg_Fetch_Object -- row¸¦ object·Î °¡Á®¿Â´Ù.

    Description

    object pg_fetch_object(int result, int row, int [result_type] );

    Returns: An object with properties that correspond to the fetched row, or false if there are no more rows.

    pg_fetch_object() is similar to pg_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

    The third optional argument result_type in pg_fetch_object() is a constant and can take the following values: PGSQL_ASSOC, PGSQL_NUM, and PGSQL_BOTH.

    Note: Result_type was added in PHP 4.0.

    Speed-wise, the function is identical to pg_fetch_array(), and almost as quick as pg_fetch_row() (the difference is insignificant).

    See also: pg_fetch_array() and pg_fetch_row().

    Example 1. Postgres fetch object

    <?php 
    $database = "verlag";
    $db_conn = pg_connect ("localhost", "5432", "", "", $database);
    if (!$db_conn): ?>
        <H1>Failed connecting to postgres database <? echo $database ?></H1> <?
        exit;
    endif;
    $qu = pg_exec ($db_conn, "SELECT * FROM verlag ORDER BY autor");
    $row = 0; // postgres needs a row counter other dbs might not 
    while ($data = pg_fetch_object ($qu, $row)):
        echo $data->autor." (";
        echo $data->jahr ."): ";
        echo $data->titel."<BR>";
        $row++;
    endwhile; ?>
    <PRE><?php
    $fields[] = Array ("autor", "Author");
    $fields[] = Array ("jahr",  "  Year");
    $fields[] = Array ("titel", " Title");
    $row= 0; // postgres needs a row counter other dbs might not
    while ($data = pg_fetch_object ($qu, $row)):
        echo "----------\n";
        reset ($fields);
        while (list (,$item) = each ($fields)):
            echo $item[1].": ".$data->$item[0]."\n";
        endwhile;
        $row++;
    endwhile;
    echo "----------\n"; ?>
    </PRE> <?php
    pg_freeResult ($qu);
    pg_close ($db_conn);
    ?>

    pg_Fetch_Row

    pg_Fetch_Row -- row¸¦ ¹è¿­(enumerated array)·Î °¡Á®¿Â´Ù.

    Description

    array pg_fetch_row(int result, int row);

    Returns: An array that corresponds to the fetched row, or false if there are no more rows.

    pg_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

    Subsequent call to pg_fetch_row() would return the next row in the result set, or false if there are no more rows.

    See also: pg_fetch_array(), pg_fetch_object(), pg_result().

    Example 1. Postgres fetch row

    <?php 
    $conn = pg_pconnect("","","","","publisher");
    if (!$conn) {
        echo "An error occured.\n";
        exit;
    }
    $result = pg_Exec ($conn, "SELECT * FROM authors");
    if (!$result) {
        echo "An error occured.\n";
        exit;
    }
    $row = pg_fetch_row ($result, 0);
    echo $row[0] . " <- row\n";
    $row = pg_fetch_row ($result, 1);
    echo $row[0] . " <- row\n";
    $row = pg_fetch_row ($result, 2);
    echo $row[1] . " <- row\n";
    ?>

    pg_FieldIsNull

    pg_FieldIsNull -- field°¡ NULLÀΰ¡ °Ë»çÇÑ´Ù.

    Description

    int pg_fieldisnull(int result_id, int row, mixed field);

    Test if a field is NULL or not. Returns 0 if the field in the given row is not NULL. Returns 1 if the field in the given row is NULL. Field can be specified as number or fieldname. Row numbering starts at 0.

    pg_FieldName

    pg_FieldName -- fieldÀÇ À̸§À» ¹ÝȯÇÑ´Ù.

    Description

    string pg_fieldname(int result_id, int field_number);

    pg_FieldName() will return the name of the field occupying the given column number in the given PostgreSQL result identifier. Field numbering starts from 0.

    pg_FieldNum

    pg_FieldNum -- columnÀÇ °³¼ö¸¦ ¹ÝȯÇÑ´Ù.

    Description

    string pg_fieldnum(int result_id, int field_name);

    pg_FieldNum() will return the number of the column slot that corresponds to the named field in the given PosgreSQL result identifier. Field numbering starts at 0. This function will return -1 on error.

    pg_FieldPrtLen

    pg_FieldPrtLen -- ÇÁ¸°µåµÉ ±æÀÌ(¹®ÀÚ °³¼ö)¸¦ ±¸ÇÑ´Ù.

    Description

    int pg_fieldprtlen(int result_id, int row_number, string field_name);

    pg_FieldPrtLen() will return the actual printed length (number of characters) of a specific value in a PostgreSQL result. Row numbering starts at 0. This function will return -1 on an error.

    pg_FieldSize

    pg_FieldSize -- ÁöÁ¤µÈ fieldÀÇ ÀúÀåÀ» À§ÇØ ÇÒ´çµÈ °ø°£(internal storage)ÀÇ Å©±â

    Description

    int pg_fieldsize(int result_id, string field_name);

    pg_FieldSize() will return the internal storage size (in bytes) of the named field in the given PostgreSQL result. A field size of -1 indicates a variable length field. This function will return false on error.

    pg_FieldType

    pg_FieldType -- ÇØ´ç ÇÊµå ¹øÈ£¿¡ ´ëÀÀÇÏ´Â typeÀ̸§À» ¹ÝȯÇÑ´Ù.

    Description

    int pg_fieldtype(int result_id, int field_number);

    pg_FieldType() will return a string containing the type name of the given field in the given PostgreSQL result identifier. Field numbering starts at 0.

    pg_FreeResult

    pg_FreeResult -- result memory¸¦ ÇØÁ¦ÇÑ´Ù.

    Description

    int pg_freeresult(int result_id);

    pg_FreeResult() only needs to be called if you are worried about using too much memory while your script is running. All result memory will automatically be freed when the script is finished. But, if you are sure you are not going to need the result data anymore in a script, you may call pg_FreeResult() with the result identifier as an argument and the associated result memory will be freed.

    pg_GetLastOid

    pg_GetLastOid -- ÃÖ±ÙÀÇ object identifier¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int pg_getlastoid(int result_id);

    pg_GetLastOid() can be used to retrieve the Oid assigned to an inserted tuple if the result identifier is used from the last command sent via pg_Exec() and was an SQL INSERT. This function will return a positive integer if there was a valid Oid. It will return -1 if an error occured or the last command sent via pg_Exec() was not an INSERT.

    pg_Host

    pg_Host -- host À̸§À» ¹ÝȯÇÑ´Ù.

    Description

    string pg_host(int connection_id);

    pg_Host() will return the host name of the given PostgreSQL connection identifier is connected to.

    pg_loclose

    pg_loclose -- large object¸¦ ´Ý´Â´Ù.

    Description

    void pg_loclose(int fd);

    pg_loclose() closes an Inversion Large Object. fd is a file descriptor for the large object from pg_loopen().

    pg_locreate

    pg_locreate -- large object¸¦ »ý¼ºÇÑ´Ù.

    Description

    int pg_locreate(int conn);

    pg_locreate() creates an Inversion Large Object and returns the oid of the large object. conn specifies a valid database connection. PostgreSQL access modes INV_READ, INV_WRITE, and INV_ARCHIVE are not supported, the object is created always with both read and write access. INV_ARCHIVE has been removed from PostgreSQL itself (version 6.3 and above).

    pg_loexport

    pg_loexport -- large object¸¦ ÆÄÀÏ·Î ³»º¸³½´Ù.

    Description

    void pg_loexport (int oid, int file [, int connection_id])

    The oid argument specifies the object id of the large object to export and the filename argument specifies the pathname of the file. Returns FALSE if an error occurred, TRUE otherwise. Remember that handling large objects in PostgreSQL must happen inside a transaction.

    pg_loimport

    pg_loimport -- large object¸¦ ÆÄÀϷκÎÅÍ ²ø¾î¿Â´Ù.

    Description

    void pg_loimport (int file [, int connection_id])

    The filename argument specifies the pathname of the file to be imported as a large object. Returns FALSE if an error occurred, object id of the just created large object otherwise. Remember that handling large objects in PostgreSQL must happen inside a transaction.

    pg_loopen

    pg_loopen -- large object¸¦ ¿¬´Ù.

    Description

    int pg_loopen(int conn, int objoid, string mode);

    pg_loopen() open an Inversion Large Object and returns file descriptor of the large object. The file descriptor encapsulates information about the connection. Do not close the connection before closing the large object file descriptor. objoid specifies a valid large object oid and mode can be either "r", "w", or "rw".

    pg_loread

    pg_loread -- large object¸¦ Àд´Ù.

    Description

    string pg_loread(int fd, int len);

    pg_loread() reads at most len bytes from a large object and returns it as a string. fd specifies a valid large object file descriptor andlen specifies the maximum allowable size of the large object segment.

    pg_loreadall

    pg_loreadall -- large object Àüü¸¦ Àд´Ù.

    Description

    void pg_loreadall(int fd);

    pg_loreadall() reads a large object and passes it straight through to the browser after sending all pending headers. Mainly intended for sending binary data like images or sound.

    pg_lounlink

    pg_lounlink -- large object¸¦ Áö¿î´Ù.

    Description

    void pg_lounlink(int conn, int lobjid);

    pg_lounlink() deletes a large object with the lobjid identifier for that large object.

    pg_lowrite

    pg_lowrite -- large object¿¡ ¾´´Ù.

    Description

    int pg_lowrite(int fd, string buf);

    pg_lowrite() writes at most to a large object from a variable buf and returns the number of bytes actually written, or false in the case of an error. fd is a file descriptor for the large object from pg_loopen().

    pg_NumFields

    pg_NumFields -- fieldÀÇ °³¼ö¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int pg_numfields(int result_id);

    pg_NumFields() will return the number of fields (columns) in a PostgreSQL result. The argument is a valid result identifier returned by pg_Exec(). This function will return -1 on error.

    pg_NumRows

    pg_NumRows -- rowÀÇ °³¼ö¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int pg_numrows(int result_id);

    pg_NumRows() will return the number of rows in a PostgreSQL result. The argument is a valid result identifier returned by pg_Exec(). This function will return -1 on error.

    pg_Options

    pg_Options -- optionµéÀ» ¹ÝȯÇÑ´Ù.

    Description

    string pg_options(int connection_id);

    pg_Options() will return a string containing the options specified on the given PostgreSQL connection identifier.

    pg_pConnect

    pg_pConnect -- ¿µ±¸ÀûÀÎ database connectionÀ» ¸¸µç´Ù.

    Description

    int pg_pconnect(string host, string port, string options, string tty, string dbname);

    Returns a connection index on success, or false if the connection could not be made. Opens a persistent connection to a PostgreSQL database. Each of the arguments should be a quoted string, including the port number. The options and tty arguments are optional and can be left out. This function returns a connection index that is needed by other PostgreSQL functions. You can have multiple persistent connections open at once. See also pg_Connect().

    A connection can also established with the following command: $conn = pg_pconnect("dbname=marliese port=5432"); Other parameters besides dbname and port are host, tty and options.

    pg_Port

    pg_Port -- port ¹øÈ£¸¦ ¹ÝȯÇÑ´Ù.

    Description

    int pg_port(int connection_id);

    pg_Port() will return the port number that the given PostgreSQL connection identifier is connected to.

    pg_Result

    pg_Result -- result identifier·Î ºÎÅÍ °ªµéÀ» ±¸ÇÑ´Ù.

    Description

    mixed pg_result(int result_id, int row_number, mixed fieldname);

    pg_Result() will return values from a result identifier produced by pg_Exec(). The row_number and fieldname sepcify what cell in the table of results to return. Row numbering starts from 0. Instead of naming the field, you may use the field index as an unquoted number. Field indices start from 0.

    PostgreSQL has many built in types and only the basic ones are directly supported here. All forms of integer, boolean and oid types are returned as integer values. All forms of float, and real types are returned as double values. All other types, including arrays are returned as strings formatted in the same default PostgreSQL manner that you would see in the psql program.

    pg_trace

    pg_trace -- PostgreSQL ¼­¹ö¿ÍÀÇ ¿¬°áÀ» ÃßÀûÇÑ´Ù.

    Description

    bool pg_trace (string filename [, string mode [, int connection]])

    Enables tracing of the PostgreSQL frontend/backend communication to a debugging file. To fully understand the results one needs to be familiar with the internals of PostgreSQL communication protocol. For those who are not, it can still be useful for tracing errors in queries sent to the server, you could do for example 'grep '^To backend' trace.log' and see what queriew actually were sent to the PostgreSQL server.

    filename and mode are the same as in fopen() (mode defaults to 'w'), connection specifies the connection to trace and defaults to the last one opened.

    Returns TRUE if filename could be opened for logging, FALSE otherwise.

    See also fopen() and pg_untrace().

    pg_tty

    pg_tty -- tty À̸§À» ¹ÝȯÇÑ´Ù.

    Description

    string pg_tty(int connection_id);

    pg_tty() will return the tty name that server side debugging output is sent to on the given PostgreSQL connection identifier.

    pg_untrace

    pg_untrace -- PostgreSQL ¼­¹ö¿ÍÀÇ ¿¬°áÀ» ÃßÀûÇÏ´Â °ÍÀ» Áß´ÜÇÑ´Ù.

    Description

    bool pg_untrace ([int connection])

    Stop tracing started by pg_trace(). connection specifies the connection that was traced and defaults to the last one opened.

    Returns always TRUE.

    See also pg_trace().


    XLIX. Program Execution functions

    Table of Contents
    escapeshellcmd ¡¦ escape shell metacharacters
    exec ¡¦ Execute an external program
    passthru ¡¦ Execute an external program and display raw output
    system ¡¦ Execute an external program and display output

    escapeshellcmd

    escapeshellcmd -- shellÀÇ metacharacterµéÀ» escapeÇÑ ´Ù.

    Description

    string escapeshellcmd (string command)

    EscapeShellCmd() escapes any characters in a string that might be used to trick a shell command into executing arbitrary commands. This function should be used to make sure that any data coming from user input is escaped before this data is passed to the exec() or system() functions. A standard use would be:

      1 
      2 system(EscapeShellCmd($cmd))
      3       

    See also exec(), popen(), system(), and the backtick operator.

    exec

    exec -- ¿ÜºÎ programÀ» ½ÇÇàÇÑ´Ù.

    Description

    string exec (string command [, string array [, int return_var]])

    Exec executes the given command, however it does not output anything. It simply returns the last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the PassThru() function.

    If the array argument is present, then the specified array will be filled with every line of output from the command. Note that if the array already contains some elements, exec() will append to the end of the array. If you do not want the function to append elements, call unset() on the array before passing it to exec().

    If the return_var argument is present along with the array argument, then the return status of the executed command will be written to this variable.

    Note that if you are going to allow data coming from user input to be passed to this function, then you should be using EscapeShellCmd() to make sure that users cannot trick the system into executing arbitrary commands.

    Note also that if you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends.

    See also system(), PassThru(), popen(), EscapeShellCmd(), and the backtick operator.

    passthru

    passthru -- ¿ÜºÎ ÇÁ·Î±×·¥À» ½ÇÇàÇÏ°í ±× °á°ú¸¦ Á÷Á¢ (Áöü¾øÀÌ) Ãâ·ÂÇÑ´Ù.

    Description

    void passthru (string command [, int return_var])

    The passthru() function is similar to the Exec() function in that it executes a command. If the return_var argument is present, the return status of the Unix command will be placed here. This function should be used in place of Exec() or System() when the output from the Unix command is binary data which needs to be passed directly back to the browser. A common use for this is to execute something like the pbmplus utilities that can output an image stream directly. By setting the content-type to image/gif and then calling a pbmplus program to output a gif, you can create PHP scripts that output images directly.

    Note that if you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends.

    See also exec(), system(), popen(), EscapeShellCmd(), and the backtick operator.

    system

    system -- ¿ÜºÎ programÀ» ½ÇÇàÇÏ°í ±× °á°ú¸¦ Ãâ·ÂÇÑ´Ù.

    Description

    string system (string command [, int return_var])

    System() is just like the C version of the function in that it executes the given command and outputs the result. If a variable is provided as the second argument, then the return status code of the executed command will be written to this variable.

    Note, that if you are going to allow data coming from user input to be passed to this function, then you should be using the EscapeShellCmd() function to make sure that users cannot trick the system into executing arbitrary commands.

    Note also that if you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends.

    The System() call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module.

    Returns the last line of the command output on success, and false on failure.

    If you need to execute a command and have all the data from the command passed directly back without any interference, use the PassThru() function.

    See also exec(), PassThru(), popen(), EscapeShellCmd(), and the backtick operator.


    L. GNU Recode functions

    ÀÌ ¸ðµâÀº GNU Recode ¶óÀ̺귯¸®(version 3.5)ÀÇ ÀÎÅÍÆäÀ̽º¸¦ Æ÷ÇÔÇÑ´Ù. ÀÌ ¸ðµâ¿¡ ÀÖ´Â ÇÔ¼ö¸¦ »ç¿ëÇÏ°íÀÚ ÇÑ´Ù¸é, PHP¸¦ ÄÄÆÄÀÏ ÇÒ ¶§ --with-recode ¿É¼ÇÀ» ÁÖ°í ÄÄÆÄÀÏÇÏ¿©¾ß ÇÑ´Ù. À̸¦ À§Çؼ­´Â ´ç¿¬È÷ ½Ã½ºÅÛ¿¡ GNU Recode 3.5 ÀÌ»óÀÌ ¼³Ä¡µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù.

    GNU Recode ¶óÀ̺귯¸®´Â ÆÄÀÏÀ» ¿©·¯ °¡Áö ´Ù¸¥ character sets °ú surface encodings·Î º¯È¯ÇÑ´Ù. ¸¸¾à ÀÌ º¯È¯ÀÌ Á¤È®ÇÏ°Ô ÀÌ·ç¾îÁú ¼ö ¾ø°Ô µÇ¸é, ¿À·ù°¡ ÀÖ´Â ¹®ÀÚ·ÎÀÇ º¯È¯À» ÇÏÁö ¾Ê°í, ÃÖ´ëÇÑ ºñ½ÁÇÑ °ÍÀ¸·Î ´ëüÇϰԵȴÙ.ÀÌ ¶óÀ̺귯¸®´Â ¾à 150°¡ÁöÀÇ ¼­·Î ´Ù¸¥ character setsÀ» ÀνÄÇÏ°í ¸¸µé¾î ³¾ ¼ö ÀÖ°í, À̵鰣ÀÇ ´ëºÎºÐÀÇ Á¶ÇÕÀ» »ç¿ëÇÏ¿© º¯È¯ÀÌ °¡´ÉÇÏ´Ù. RFC 1345 character sets °ÅÀÇ ÀüºÎ¸¦ Áö¿øÇÑ´Ù.

    Table of Contents
    recode_string ¡¦ Recode a string according to a recode request
    recode ¡¦ Recode a string according to a recode request
    recode_file ¡¦ Recode from file to file according to recode request

    recode_string

    (PHP3 >= 3.0.13, PHP4 >= 4.0RC1)

    recode_string -- recode ¿ä±¸¿¡ µû¶ó ¹®ÀÚ¿­À» RecodeÇÑ´Ù.

    Description

    string recode_string (string request, string string)

    Recode the string string according to the recode request request. Returns FALSE, if unable to comply, TRUE otherwise.

    A simple recode request may be "lat1..iso646-de". See also the GNU Recode documentation of your installation for detailed instructions about recode requests.

    recode

    (PHP4 >= 4.0RC1)

    recode -- recode ¿ä±¸¿¡ µû¶ó ¹®ÀÚ¿­À» RecodeÇÑ´Ù.

    Description

    string recode_string (string request, string string)

    Note: This is an alias for recode_string(). It has been added in PHP4.

    recode_file

    (PHP3 >= 3.0.13, PHP4 >= 4.0RC1)

    recode_file --  recode ¿ä±¸¿¡ µû¶ó ÆÄÀÏÀ» RecodeÇÑ´Ù.

    Description

    bool recode_file (int input, int output)

    Recode the file referenced by file handle input into the file referenced by file handle output according to the recode request. Returns FALSE, if unable to comply, TRUE otherwise.

    This function does not currently process filehandles referencing remote files (URLs). Both filehandles must refer to local files.


    LI. Regular expression functions

    Regular expressionÀº PHP¿¡¼­ º¹ÀâÇÑ ¹®ÀÚ¿­ Á¶ÀÛÀ» À§ÇØ »ç¿ëÇÑ´Ù. regular expressionÀ» Áö¿øÇϱâ À§ÇØ ´ÙÀ½ÀÇ ÇÔ¼ö°¡ »ç¿ëµÈ´Ù. :

    À§ÀÇ ÇÔ¼öµéÀº regular expression ¹®ÀÚ¿­À» ù Àμö(argument)·Î °¡Áø´Ù. PHP´Â Posix 1003.2¿¡¼­ Á¤ÀÇµÈ Posix È®Àå regular expressionÀ» »ç¿ëÇÑ´Ù. Posix regular expressions¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ¼³¸íÀº PHP distributionÀÇ regexµð·ºÅ丮¿¡ ÀÖ´Â regex man page¸¦ ÂüÁ¶Çϱ⠹ٶõ´Ù. ÀÌ°ÍÀº manpage ÇüŸ¦ ÇÏ°í ÀÖÀ¸¹Ç·Î man /usr/local/src/regex/regex.7 °ú °°Àº ¸í·ÉÀ» »ç¿ëÇÏ¿© ÀÐÀ» ¼ö ÀÖ´Ù.

    Example 1. Regular expression examples

      1 
      2 ereg("abc",$string);            
      3 /* Returns true if "abc"
      4    is found anywhere in $string. */
      5 
      6 ereg("^abc",$string);
      7 /* Returns true if "abc"
      8    is found at the beginning of $string. */
      9 
     10 ereg("abc$",$string);
     11 /* Returns true if "abc"
     12    is found at the end of $string. */
     13 
     14 eregi("(ozilla.[23]|MSIE.3)",$HTTP_USER_AGENT);  
     15 /* Returns true if client browser
     16    is Netscape 2, 3 or MSIE 3. */
     17 
     18 ereg("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)",
     19      $string,$regs); 
     20 /* Places three space separated words
     21    into $regs[1], $regs[2] and $regs[3]. */
     22 
     23 $string = ereg_replace("^","<BR>",$string); 
     24 /* Put a <BR> tag at the beginning of $string. */
     25  
     26 $string = ereg_replace("$","<BR>",$string); 
     27 /* Put a <BR> tag at the end of $string. */
     28 
     29 $string = ereg_replace("\n","",$string);
     30 /* Get rid of any newline
     31    characters in $string. */
     32      
    Table of Contents
    ereg ¡¦ regular expression match
    ereg_replace ¡¦ replace regular expression
    eregi ¡¦ case insensitive regular expression match
    eregi_replace ¡¦ replace regular expression case insensitive
    split ¡¦ split string into array by regular expression
    sql_regcase ¡¦ make regular expression for case insensitive match

    ereg

    ereg -- regular expression ÀÌ ÁÖ¾îÁø ÆÐÅÏ¿¡ ¸Â´ÂÁö °Ë»çÇÑ´Ù.

    Description

    int ereg(string pattern, string string, array [regs]);

    Searchs string for matches to the regular expression given in pattern.

    If matches are found for parenthesized substrings of pattern and the function is called with the third argument regs, the matches will be stored in the elements of regs. $regs[1] will contain the substring which starts at the first left parenthesis; $regs[2] will contain the substring starting at the second, and so on. $regs[0] will contain a copy of string.

    Searching is case sensitive.

    Returns true if a match for pattern was found in string, or false if no matches were found or an error occurred.

    The following code snippet takes a date in ISO format (YYYY-MM-DD) and prints it in DD.MM.YYYY format:

    Example 1. ereg() example

    if ( ereg( "([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs ) ) {
        echo "$regs[3].$regs[2].$regs[1]";
    } else {
        echo "Invalid date format: $date";
    }

    See also eregi(), ereg_replace(), and eregi_replace().

    ereg_replace

    ereg_replace -- regular expressionÀÇ ¹®ÀåÀ» ´ëÄ¡ÇÑ´Ù.

    Description

    string ereg_replace(string pattern, string replacement, string string);

    This function scans string for matches to pattern, then replaces the matched text with replacement.

    The modified string is returned. (Which may mean that the original string is returned if there are no matches to be replaced.)

    If pattern contains parenthesized substrings, replacement may contain substrings of the form \\digit, which will be replaced by the text matching the digit'th parenthesized substring; \\0 will produce the entire contents of string. Up to nine substrings may be used. Parentheses may be nested, in which case they are counted by the opening parenthesis.

    If no matches are found in string, then string will be returned unchanged.

    For example, the following code snippet prints "This was a test" three times:

    Example 1. ereg_replace() example

    $string = "This is a test";
    echo ereg_replace( " is", " was", $string );
    echo ereg_replace( "( )is", "\\1was", $string );
    echo ereg_replace( "(( )is)", "\\2was", $string );
          

    See also ereg(), eregi(), and eregi_replace().

    eregi

    eregi -- regular expression ÀÌ ÁÖ¾îÁø ÆÐÅÏ¿¡ ¸Â´ÂÁö ´ë,¼Ò¹®ÀÚ °¡¸®Áö ¾Ê°í °Ë»çÇÑ´Ù.

    Description

    int eregi(string pattern, string string, array [regs]);

    This function is identical to ereg() save that this ignores case distinction when matching alphabetic characters.

    See also ereg(), ereg_replace(), and eregi_replace().

    eregi_replace

    eregi_replace -- regular expressionÀÇ ¹®ÀåÀ» ´ë,¼Ò¹®ÀÚ °¡¸®Áö ¾Ê°í ´ëÄ¡ÇÑ´Ù.

    Description

    string eregi_replace(string pattern, string replacement, string string);

    This function is identical to ereg_replace() save that this ignores case distinction when matching alphabetic characters.

    See also ereg(), eregi(), and ereg_replace().

    split

    split -- ¹®ÀÚ¿­À» regular expression¿¡ ÀÇÇØ ³ª´«´Ù.

    Description

    array split(string pattern, string string, int [limit]);

    Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by pattern. If an error occurs, returns false.

    To get the first five fields from a line from /etc/passwd:

    Example 1. split() example

    $passwd_list = split( ":", $passwd_line, 5 );

    Note that pattern is case-sensitive.

    See also explode() and implode().

    sql_regcase

    sql_regcase -- ´ë,¼Ò¹®ÀÚ °¡¸®Áö ¾Ê´Â °Ë»ç¸¦ À§ÇÑ regular expressionÀ» ¸¸µç´Ù.

    Description

    string sql_regcase (string string)

    Returns a valid regular expression which will match string, ignoring case. This expression is string with each character converted to a bracket expression; this bracket expression contains that character's uppercase and lowercase form if applicable, otherwise it contains the original character twice.

    Example 1. sql_regcase() example

      1 
      2 echo sql_regcase( "Foo bar" );
      3 

    prints

    [Ff][Oo][Oo][  ][Bb][Aa][Rr]
    .

    This can be used to achieve case insensitive pattern matching in products which support only case sensitive regular expressions.


    LII. Semaphore and Shared Memory functions

    ÀÌ ¸ðµâÀº System V ¼¼¸¶Æ÷¾î¸¦ »ç¿ëÇÏ´Â ¼¼¸¶Æ÷¾î ÇÔ¼ö¸¦ Á¦°øÇÑ´Ù. ¼¼¸¶Æ÷¾î´Â º¸Åë ÇöÀç ÄÄÇ»ÅÍÀÇ ÀÚ¿ø(resources)¿¡ ´ëÇØ ¹èŸÀûÀ¸·Î Á¢±ÙÇϰųª, ÇÑ ÀÚ¿ø¿¡ µ¿½Ã¿¡ »ç¿ë °¡´ÉÇÑ ÇÁ·Î¼¼½ºÀÇ ¼ö¸¦ Á¦ÇÑ ÇÒ ¶§ »ç¿ëÇÑ´Ù.

    ¶ÇÇÑ À̸ðµâÀº System V °øÀ¯ ¸Þ¸ð¸®¸¦ »ç¿ëÇÏ´Â °øÀ¯ ¸Þ¸ð¸® ÇÔ¼ö¸¦ Á¦°øÇÑ´Ù. °øÀ¯ ¸Þ¸ð¸®(Shared memory)´Â Àü¿ª º¯¼ö¿¡ Á¢±ÙÇϱâÀ§ÇØ »ç¿ëµÈ´Ù. ´Ù¸¥Á¡Àº httpd-daemonÀ̳ª ½ÉÁö¾î PerlÀ̳ª C·Î ÀÛ¼ºµÈ ´Ù¸¥ ÇÁ·Î±×·¥¿¡¼­µµ ÀÌ º¯¼ö¿¡ Á¢±ÙÇÒ ¼ö ÀÖÀ¸¹Ç·Î ±¤¹üÀ§ÇÑ µ¥ÀÌÅÍ ±³È¯ÀÌ °¡´ÉÇÏ´Ù. ÁÖÀÇÇÒ Á¡Àº °øÀ¯ ¸Þ¸ð¸®´Â µ¿½Ã¿¡ µÎ±ºµ¥¼­ Á¢±ÙÇÏ´Â °Í¿¡ ´ëÇØ Àý´ë·Î ¾ÈÀüÇÏÁö ¾Ê´Ù. µû¶ó¼­ À̸¦ ¹æÁöÇϱâÀ§ÇØ ¼¼¸¶Æ÷¾î¸¦ »ç¿ëÇÏ¿© µ¿±âÈ­(synchronize)ÇÏ¿©¾ß ÇÑ´Ù.

    Table 1. Limits of shared memory by the Unix OS

    SHMMAX

    max size of shared memory, normally 131072 bytes

    SHMMIN

    minimum size of shared memory, normally 1 byte

    SHMMNI

    max amount of shared memory segments, normally 100

    SHMSEG

    max amount of shared memory per process, normally 6

    Table of Contents
    sem_get ¡¦ get a semaphore id
    sem_acquire ¡¦ acquire a semaphore
    sem_release ¡¦ release a semaphore
    shm_attach ¡¦ Creates or open a shared memory segment
    shm_detach ¡¦ Disconnects from shared memory segment
    shm_remove ¡¦ Removes shared memory from Unix systems
    shm_put_var ¡¦ Inserts or updates a variable in shared memory
    shm_get_var ¡¦ Returns a variable from shared memory
    shm_remove_var ¡¦ Removes a variable from shared memory

    sem_get

    (PHP3 >= 3.0.6, PHP4 )

    sem_get -- semaphore id¸¦ ¾ò´Â´Ù.

    Description

    int sem_get (int key [, int max_acquire [, int perm]])

    Returns: A positive semaphore identifier on success, or false on error.

    Sem_get() returns an id that can be used to access the System V semaphore with the given key. The semaphore is created if necessary using the permission bits specified in perm (defaults to 0666). The number of processes that can acquire the semaphore simultaneously is set to max_acquire (defaults to 1). Actually this value is set only if the process finds it is the only process currently attached to the semaphore.

    A second call to sem_get() for the same key will return a different semaphore identifier, but both identifiers access the same underlying semaphore.

    See also: sem_acquire() and sem_release().

    sem_acquire

    (PHP3 >= 3.0.6, PHP4 )

    sem_acquire -- semaphore¸¦ ¾ò´Â´Ù.

    Description

    int sem_acquire (int sem_identifier)

    Returns: true on success, false on error.

    Sem_acquire() blocks (if necessary) until the semaphore can be acquired. A process attempting to acquire a semaphore which it has already acquired will block forever if acquiring the semaphore would cause its max_acquire value to be exceeded.

    After processing a request, any semaphores acquired by the process but not explicitly released will be released automatically and a warning will be generated.

    See also: sem_get() and sem_release().

    sem_release

    (PHP3 >= 3.0.6, PHP4 )

    sem_release -- semaphore¸¦ Ç®¾îÁØ´Ù.

    Description

    int sem_release (int sem_identifier)

    Returns: true on success, false on error

    sem_release() releases the semaphore if it is currently acquired by the calling process, otherwise a warning is generated.

    After releasing the semaphore, sem_acquire() may be called to re-acquire it.

    See also: sem_get() and sem_acquire().

    shm_attach

    (PHP3 >= 3.0.6, PHP4 )

    shm_attach -- °øÀ¯ ¸Þ¸ð¸®ÀÇ segment¸¦ ¸¸µé°Å³ª ¿¬´Ù.

    Description

    int shm_attach (int key [, int memsize [, int perm]])

    Shm_attach() returns an id that that can be used to access the System V shared memory with the given key, the first call creates the shared memory segment with mem_size (default: sysvshm.init_mem in the configuration file, otherwise 10000 bytes) and the optional perm-bits (default: 0666).

    A second call to shm_attach() for the same key will return a different shared memory identifier, but both identifiers access the same underlying shared memory. Memsize and perm will be ignored.

    shm_detach

    (PHP3 >= 3.0.6, PHP4 )

    shm_detach -- °øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®¿ÍÀÇ ¿¬°áÀ» ²÷´Â´Ù.

    Description

    int shm_detach (int shm_identifier)

    shm_detach() disconnects from the shared memory given by the shm_identifier created by shm_attach(). Remember, that shared memory still exist in the Unix system and the data is still present.

    shm_remove

    (PHP3 >= 3.0.6, PHP4 )

    shm_remove -- Unix ½Ã½ºÅÛ¿¡¼­ °øÀ¯ ¸Þ¸ð¸®¸¦ Á¦°ÅÇÑ´Ù.

    Description

    int shm_remove (int shm_identifier);

    Removes shared memory from Unix systems. All data will be destroyed.

    shm_put_var

    (PHP3 >= 3.0.6, PHP4 )

    shm_put_var -- °øÀ¯ ¸Þ¸ð¸®¾È¿¡ º¯¼ö¸¦ »ðÀÔÇϰųª º¯¼ö °ªÀ» º¯°æÇÑ´Ù.

    Description

    int shm_put_var (int shm_identifier, int variable_key, mixed variable)

    Inserts or updates a variable with a given variable_key. All variable-types (double, int, string, array) are supported.

    shm_get_var

    (PHP3 >= 3.0.6, PHP4 )

    shm_get_var -- °øÀ¯ ¸Þ¸ð¸®ÀÇ º¯¼ö¸¦ ¹ÝȯÇÑ´Ù.

    Description

    mixed shm_get_var (int id, int variable_key)

    Shm_get_var() returns the variable with a given variable_key. The variable is still present in the shared memory.

    shm_remove_var

    (PHP3 >= 3.0.6, PHP4 )

    shm_remove_var -- °øÀ¯ ¸Þ¸ð¸®·ÎºÎÅÍ º¯¼ö¸¦ Á¦°ÅÇÑ´Ù.

    Description

    int shm_remove_var (int id, int variable_key)

    Removes a variable with a given variable_key and frees the occupied memory.


    LIII. Session handling functions

    PHP¿¡¼­ Áö¿øÇÏ´Â ¼¼¼ÇÀº ƯÁ¤ µ¥ÀÌÅ͸¦ ¿¬ÀÌÀº Á¢¼Ó¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖµµ·Ï ÀúÀåÇÏ´Â ¹æ¹ýÀ» Á¦°øÇÑ´Ù. ÀÌ°ÍÀº ¿©·¯ºÐ¿¡°Ô Á»´õ »ç¿ëÀÚ¿¡°Ô Ä£±ÙÇÑ ¾îÇø®ÄÉÀ̼ÇÀ» ¸¸µé ¼ö ÀÖµµ·Ï ÇØ ÁÖ°í, ¿©·¯ºÐÀÇ À¥ »çÀÌÆ®¸¦ ´õ¿í Èï¹Ì·Ó°Ô ¸¸µé ¼ö ÀÖ°Ô ÇØ ÁØ´Ù.

    ¸¸¾à ¿©·¯ºÐÀÌ PHPLIBÀÇ ¼¼¼Ç °ü¸®¿¡ ´ëÇØ Àß ¾Ë°í ÀÖ´Ù¸é, ÀÌ°ÍÀÇ ¸¹Àº °³³äµéÀÌ PHPÀÇ ¼¼¼Ç Áö¿ø°ú ºñ½ÁÇÏ´Ù´Â °ÍÀ» ¾Ë °Ô µÉ °ÍÀÌ´Ù.

    ¿©·¯ºÐÀÇ À¥»çÀÌÆ®¸¦ ¹æ¹®ÇÑ ¹æ¹®ÀÚ´Â À¯ÀÏÇÑ ID Çϳª¸¦ ¹èÁ¤¹Þ°Ô µÇ´Âµ¥, ÀÌ°ÍÀÌ ¼¼¼Ç IDÀÌ´Ù. ÀÌ ¼¼¼Ç ID´Â »ç¿ëÀÚÃø¿¡ ÄíÅ°·Î ÀúÀåµÉ ¼öµµ ÀÖ°í, URLÀÇ ÀϺηΠºÙ¾î´Ù´Ò ¼öµµ ÀÖ´Ù.

    ¼¼¼ÇÀº ¼­¹ö¿¡ ´ëÇÑ ¿ä±¸(request)µé¿¡ °øÅëÀûÀ¸·Î ÀúÀåµÇ°í »ç¿ëµÉ ¿©·¯°³ÀÇ º¯¼ö¸¦ µî·ÏÇÒ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù. ¹æ¹®ÀÚ°¡ ¿©·¯ºÐÀÇ »çÀÌÆ®¸¦ Á¢±ÙÇϸé, PHP´Â ÀÚµ¿ÀûÀ¸·Î(session.auto_start °¡ 1·Î ¼³Á¤µÇ¾î ÀÖ´Â °æ¿ì), ȤÀº ¿©·¯ºÐÀÇ ¿ä±¸°¡ ÀÖ´Â °æ¿ì(À̰͸¸À» ÇÏ´Â session_start() ÇÔ¼ö³ª, ÀÌ ±â´Éµµ Æ÷ÇÔÇÏ´Â session_register() ÇÔ¼ö¸¦ »ç¿ë) ÇØ´ç ¿ä±¸(request)¿Í ÇÔ²² ƯÁ¤ ¼¼¼Ç ID°¡ Àü¼ÛµÇ¾ú´Â°¡ ¿©ºÎ¸¦ ÆÇ´ÜÇÑ´Ù. ÀÌ·± ÀÌÀ¯¶ó¸é ÀÌÀü¿¡ ÀúÀåµÇ¾ú´ø ȯ°æÀ¸·Î ´Ù½Ã º¹±¸µÈ´Ù.

    ÀÌ ¿ä±¸(request) µ¿ÀÛÀÌ ³¡³ª¸é ¸ðµç µî·ÏÇÑ º¯¼öµéÀÌ ¼ø¼­´ë·Î ³ª¿­µÈ´Ù. Á¤ÀǵǾî(defined) ÀÖÁö ¾ÊÀº µî·ÏÇÑ(registered) º¯¼ö´Â ÇöÀç µî·ÏµÇÁö ¾Ê¾Ò´Ù°í Ç¥½ÃµÈ´Ù. ¿¬ÀÌÀº Á¢¼Ó¿¡¼­, ÀÌ·± º¯¼öµéÀº »ç¿ëÀÚ°¡ ³ªÁß¿¡ Á¤ÀÇÇÏÁö ¾Ê´Â ÇÑ ¼¼¼Ç ¸ðµâ¿¡ ÀÇÇØ Á¤ÀǵÇÁö´Â ¾Ê´Â´Ù.

    track_vars ¿Í gpc_globals ¼³Á¤Àº ¼¼¼Ç º¯¼öµéÀÌ ¾î¶»°Ô º¹±¸µÇ´Â°¡¿¡ ¿µÇâÀ» ÁØ´Ù. track_varsÀÌ enable µÇ¾îÀÖÀ¸¸é, ÀúÀåµÈ ¼¼¼Ç º¯¼öµéÀ» $HTTP_STATE_VARS¶ó´Â Àü¿ª associative ¹è¿­À» »ç¿ëÇÏ¿© Á¢±ÙÇÒ ¼ö ÀÖ´Ù. gpc_globals°¡ enable µÇ¾î ÀÖÀ¸¸é, ¼¼¼Ç º¯¼öµéÀº °¢°¢ÀÇ Àü¿ª º¯¼ö·Î º¹¿øµÈ´Ù. µÎ°¡Áö ¸ðµÎ ¼³Á¤µÇ¾î ÀÖÀ¸¸é, Àü¿ªº¯¼ö¿Í $HTTP_STATE_VARS ¸ðµÎ¿¡ °°Àº °ªÀ¸·Î º¹¿øµÈ´Ù.

    ¼¼¼Ç ID¸¦ Àü´ÞÇÏ´Â ¹æ¹ýÀº ´ÙÀ½ µÎ°¡Áö°¡ ÀÖ´Ù. :

    ¼¼¼Ç ¸ðµâÀº µÎ°¡Áö ¹æ¹ý ¸ðµÎ¸¦ Áö¿øÇÑ´Ù. ÄíÅ°°¡ Á»´õ ÀÌ»óÀûÀÎ ¹æ¹ýÀ̱â´Â Çصµ, »ç¿ëÀÚÀÇ ºê¶ó¿ìÀú°¡ ÄíÅ°¸¦ Áö¿øÇÏÁö ¾ÊÀ» ¼öµµ ÀÖ°í, ÄíÅ° µ¥ÀÌÅ͸¦ ¹Þ¾ÆµéÀδٴ º¸ÀåÀÌ ¾ø±â ¶§¹®¿¡ ½Å·Ú¼ºÀÌ ¶³¾îÁø´Ù. µÎ ¹ø° ¹æ¹ýÀº ¼¼¼Ç ID¸¦ URL¿¡ Á÷Á¢ Æ÷ÇÔ½ÃÅ°´Â ¹æ¹ýÀÌ´Ù.

    PHP´Â --enable-trans-sid ¿É¼ÇÀ» ÁÖ¾î ÄÄÆÄÀÏ Çϸé ÀÌ ±â´ÉÀ» ÀÚµ¿À¸·Î ÇØ ÁØ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ÀÌ ¿É¼ÇÀ» ¼³Á¤Çϸé, »ó´ëÀû(relative) URIµéÀº ¸ðµÎ ÀÚµ¿ÀûÀ¸·Î ¼¼¼Ç ID¸¦ Æ÷ÇÔÇϵµ·Ï ¹Ù²ï´Ù. ´Ù¸¥ ´ë¾ÈÀ¸·Î, »ç¿ëÀÚÀÇ ºê¶ó¿ìÀú°¡ ÀûÀýÇÑ ÄíÅ°¸¦ º¸³»Áö ¸øÇÑ´Ù¸é, ¹Ì¸® Á¤ÀÇµÈ SID¶ó´Â »ó¼ö¸¦ »ç¿ëÇÒ ¼öµµ ÀÖ´Ù. SID ´Â session_name=session_idÀÇ Çüųª, ºó ¹®ÀÚ¿­ÀÌ µÈ´Ù.

    ´ÙÀ½ ¿¹Á¦´Â º¯¼ö¸¦ µî·ÏÇÏ°í, SID¸¦ »ç¿ëÇÏ¿© ´Ù¸¥ ÆäÀÌÁö·Î ¿¬°áÇÏ´Â ¿¹¸¦ º¸¿©ÁØ´Ù.

    Example 1. Counting the number of hits of a single user

      1 
      2 <?php
      3 session_register("count");
      4 $count++;
      5 ?>
      6 
      7 Hello visitor, you have seen this page <? echo $count; ?> times.<p>
      8 
      9 <php?
     10 # the <?=SID?> is necessary to preserve the session id
     11 # in the case that the user has disabled cookies
     12 ?>
     13 
     14 To continue, <A HREF="nextpage.php?<?=SID?>">click here</A>
     15      

    µ¥ÀÌÅͺ£À̽º °ø°£À» »ç¿ëÇϱâ À§Çؼ­´Â, ¾à°£ÀÇ PHP ÄÚµå¿Í session_set_save_handler() À̶ó´Â »ç¿ëÀÚ ·¹º§ ÇÔ¼ö°¡ ÇÊ¿äÇÏ´Ù. MySQL À̳ª ´Ù¸¥ µ¥ÀÌÅͺ£À̽º¸¦ ÀÌ¿ëÇϱâ À§Çؼ­´Â ¾Æ¸¶µµ ´ÙÀ½ ÇÔ¼öµéÀ» Àß È°¿ëÇØ¾ß ÇÒ °ÍÀÌ´Ù.

    Example 2. Usage of session_set_save_handler()

      1 
      2 <?php
      3 
      4 function open ($save_path, $session_name) {
      5     echo "open ($save_path, $session_name)\n";
      6     return true;
      7 }
      8 
      9 function close() {
     10     echo "close\n";
     11     return true;
     12 }
     13 
     14 function read ($key) {
     15     echo "write ($key, $val)\n";
     16     return "foo|i:1;";
     17 }
     18 
     19 function write ($key, $val) {
     20     echo "write ($key, $val)\n";
     21     return true;
     22 }
     23 
     24 function destroy ($key) {
     25     return true;
     26 }
     27 
     28 function gc ($maxlifetime) {
     29     return true;
     30 }
     31 
     32 session_set_save_handler ("open", "close", "read", "write", "destroy", "gc");
     33 
     34 session_start();
     35 
     36 $foo++;
     37 
     38 ?>
     39      

    À§ÀÇ ¿¹Á¦´Â ´ÙÀ½°ú °°Àº °á°ú¸¦ ¸¸µé¾î ³½´Ù. :

      1 
      2 $ ./php save_handler.php
      3 Content-Type: text/html
      4 Set-cookie: PHPSESSID=f08b925af0ecb52bdd2de97d95cdbe6b
      5 
      6 open (/tmp, PHPSESSID)
      7 read (f08b925af0ecb52bdd2de97d95cdbe6b)
      8 write (f08b925af0ecb52bdd2de97d95cdbe6b, foo|i:2;)
      9 close
     10     

    --enable-trans-sid ·Î ÄÄÆÄÀÏµÈ PHP¿¡¼­´Â, <?=SID?> °¡ ÇÊ¿ä ¾ø´Ù.

    ¼¼¼Ç °ü¸® ½Ã½ºÅÛÀº php.ini ÆÄÀÏ¿¡¼­ ¼³Á¤°¡´ÉÇÑ ¸¹Àº ¼³Á¤ ¿É¼ÇÀ» Áö¿øÇÑ´Ù. À̰͵鿡 ´ëÇØ °£´ÜÈ÷ »ìÆ캸ÀÚ.

    Note: Session handlingÀº PHP 4.0¿¡¼­ Ãß°¡µÇ¾ú´Ù.

    Table of Contents
    session_start ¡¦ Initialize session data
    session_destroy ¡¦ Destroys all data registered to a session
    session_name ¡¦ Get and/or set the current session name
    session_module_name ¡¦ Get and/or set the current session module
    session_save_path ¡¦ Get and/or set the current session save path
    session_id ¡¦ Get and/or set the current session id
    session_register ¡¦ Register a variable with the current session
    session_unregister ¡¦ Unregister a variable from the current session
    session_unset ¡¦ Free all session variables
    session_is_registered ¡¦ Find out if a variable is registered in a session
    session_get_cookie_params ¡¦ Get the session cookie parameters
    session_set_cookie_params ¡¦ Set the session cookie parameters
    session_decode ¡¦ Decodes session data from a string
    session_encode ¡¦ Encodes the current session data as a string

    session_start

    session_start -- session µ¥ÀÌŸ¸¦ ÃʱâÈ­ÇÑ´Ù.

    Description

    bool session_start(void);

    session_start() creates a session (or resumes the current one based on the session id being passed via a GET variable or a cookie).

    This function always returns true.

    Note: This function was added in PHP 4.0.

    session_destroy

    session_destroy -- session¿¡ µî·ÏµÈ ¸ðµç µ¥ÀÌŸ¸¦ Á¦°ÅÇÑ´Ù.

    Description

    bool session_destroy(void);

    session_destroy() destroys all of the data associated with the current session.

    This function always returns true.

    Note: This function was added in PHP 4.0.

    session_name

    session_name -- ÇöÀç sessionÀÇ À̸§À» ¾ò°Å³ª, ¼³Á¤ÇÑ´Ù.

    Description

    string session_name ([string name])

    session_name() returns the name of the current session. If name is specified, the name of the current session is changed to its value.

    The session name references the session id in cookies and URLs. It should contain only alphanumeric characters; it should be short and descriptive (i.e. for users with enabled cookie warnings). The session name is resetted to the default value stored in session.name at request startup time. Thus, you need to call session_name() for every request (and before session_start() or session_register() are called).

    Example 1. session_name() examples

      1 
      2 <?php
      3 
      4 # set the session name to WebsiteID
      5 
      6 $previous_name = session_name ("WebsiteID");
      7 
      8 echo "The previous session name was $previous_name<p>";
      9 ?>
     10      

    Note: This function was added in PHP 4.0.

    session_module_name

    session_module_name -- ÇöÀç session ¸ðµâÀÇ À̸§À» ¾ò°Å³ª, ¼³Á¤ÇÑ´Ù.

    Description

    string session_module_name ([string module])

    session_module_name() returns the name of the current session module. If module is specified, that module will be used instead.

    Note: This function was added in PHP 4.0.

    session_save_path

    session_save_path -- ÇöÀç session µ¥ÀÌŸ°¡ ÀúÀåµÈ path¸¦ ¾ò°Å³ª, ¼³Á¤ÇÑ´Ù.

    Description

    string session_save_path ([string path])

    session_save_path() returns the path of the current directory used to save session data. If path is specified, the path to which data is saved will be changed.

    Note: On some operating systems, you may want to specify a path on a filesystem that handles lots of small files efficiently. For example, on Linux, reiserfs may provide better performance than ext2fs.

    Note: This function was added in PHP 4.0.

    session_id

    session_id -- ÇöÀç sessionÀÇ ID¸¦ ¾ò°Å³ª, ¼³Á¤ÇÑ´Ù.

    Description

    string session_id ([string id])

    session_id() returns the session id for the current session. If id is specified, it will replace the current session id.

    directory used to save session data. If path is specified, the path to which data is saved will be changed.

    The constant SID can also be used to retrieve the current name and session id as a string suitable for adding to URLs.

    Note: This function was added in PHP 4.0.

    session_register

    session_register -- ÇöÀç session¿¡ º¯¼ö¸¦ µî·ÏÇÑ´Ù.

    Description

    bool session_register (mixed name [, mixed ...])

    session_register() variable number of arguments, any of which can be either a string holding the variable name or an array consisting of such variable names or other arrays. For each encountered variable name, session_register() registers the global variable named by it with the current session.

    This function returns true when the variable is successfully registered with the session.

    Note: This function was added in PHP 4.0.

    session_unregister

    session_unregister -- ÇöÀç session¿¡ µî·ÏµÈ º¯¼ö¸¦ »èÁ¦ÇÑ´Ù.

    Description

    bool session_unregister (string name)

    session_unregister() unregisters (forgets) the global variable named name from the current session.

    This function returns true when the variable is successfully unregistered from the session.

    Note: This function was added in PHP 4.0.

    session_unset

    (PHP4 >= 4.0b4)

    session_unset --  ¸ðµç session º¯¼öµéÀ» ÇØÁ¦ÇÑ´Ù.

    Description

    void session_unset (void);

    The session_unset() function free's all session variables currently registered.

    session_is_registered

    session_is_registered -- ÇØ´ç º¯¼ö°¡ session¿¡ µî·ÏµÇ¾î Àִ°¡ È®ÀÎÇÑ´Ù.

    Description

    bool session_is_registered (string name)

    session_is_registered() returns true if there is a variable with the name name registered in the current session.

    Note: This function was added in PHP 4.0.

    session_get_cookie_params

    (PHP4 >= 4.0RC2)

    session_get_cookie_params --  session cookie ÆĶó¸ÞÅ͸¦ ±¸ÇÑ´Ù.

    Description

    array session_get_cookie_params (void);

    The session_get_cookie_params() function returns an array with the current session cookie information, the array contains the following items:

    session_set_cookie_params

    (PHP4 >= 4.0b4)

    session_set_cookie_params --  session cookie ÆĶó¸ÞÅ͸¦ ¼³Á¤ÇÑ´Ù.

    Description

    void session_set_cookie_params (int lifetime [, string path [, string domain]])

    Set cookie parameters defined in the php.ini file. The effect of this function only lasts for the duration of the script.

    session_decode

    session_decode -- ¹®ÀÚ¿­¿¡¼­ session µ¥ÀÌŸ·Î decodeÇÑ´Ù.

    Description

    bool session_decode (string data)

    session_decode() decodes the session data in data, setting variables stored in the session.

    Note: This function was added in PHP 4.0.

    session_encode

    session_encode -- ÇöÀç sessionÀÇ µ¥ÀÌŸ¸¦ ¹®ÀÚ¿­·Î encodeÇÑ´Ù.

    Description

    bool session_encode(void);

    session_encode() returns a string with the contents of the current session encoded within.

    Note: This function was added in PHP 4.0.


    LIV. SNMP functions

    ÀÌ SNMP ÇÔ¼öµéÀ» »ç¿ëÇÏ·Á¸é ucd-snmp package¸¦ ¼³Ä¡ÇÏ¿©¾ß ÇÑ´Ù. ÃֽŹöÀüÀÌ ÀÖ´Â °÷¿¡ ´ëÇؼ­´Â PHP FAQ¸¦ ÂüÁ¶Çϵµ·ÏÇÑ´Ù. Windows¿¡¼­ ÀÌ ÇÔ¼öµéÀº NTȯ°æ¿¡¼­¸¸ µ¿ÀÛÇϸç Win95/98¿¡¼­´Â µ¿ÀÛÇÏÁö ¾Ê´Â´Ù.

    ÁÖÀÇ»çÇ× : UCD SNMP ÆÐÅ°Áö¸¦ »ç¿ëÇÏ·Á¸é, ÀÌ ÆÐÅ°Áö¸¦ ÄÄÆÄÀÏ Çϱâ Àü¿¡ NO_ZEROLENGTH_COMMUNITY¸¦ 1·Î ¼³Á¤ÇØ¾ß ÇÑ´Ù. UCD SNMP¸¦ configure ÇÑ ÈÄ¿¡ config.hÀÇ NO_ZEROLENGTH_COMMUNITY °ªÀ» ¼ÕÀ¸·Î Á÷Á¢ °íÃÄ ÁÖ¾î¾ß ÇÑ´Ù. #define ¶óÀÎÀÇ comment¸¦ ¾ø¾ÖÁÖ¸é µÈ´Ù. Áï, ´ÙÀ½°ú °°ÀÌ ¸¸µé¸é µÇ´Â °ÍÀÌ´Ù.

      1 
      2 #define NO_ZEROLENGTH_COMMUNITY 1
      3     

    ¸¸¾à SNMP ¸í·É »ç¿ëÁß¿¡ ÀÌ»óÇÑ segmentation faults¸¦ ¸¸³ª¸é, À§ÀÇ ÀÛ¾÷À» ¾ÈÇÑ °ÍÀÌ´Ù. ¸¸¾à UCD SNMP¸¦ ´Ù½Ã ÄÄÆÄÀÏÇÏ°í ½ÍÁö ¾Ê´Ù¸é PHP¸¦ ÄÄÆÄÀÏÇÒ ¶§ --enable-ucd-snmp-hack ½ºÀ§Ä¡¸¦ ÁÖ°í ÄÄÆÄÀÏÇÏ¸é µÇ±â´Â ÇÏÁö¸¸ ¹®Á¦°¡ ÀÖÀ» ¼öµµ ÀÖ´Ù.

    Table of Contents
    snmpget ¡¦ Fetch an SNMP object
    snmpset ¡¦ Set an SNMP object
    snmpwalk ¡¦ Fetch all the SNMP objects from an agent
    snmpwalkoid ¡¦ Query for a tree of information about a network entity
    snmp_get_quick_print ¡¦ Fetch the current value of the UCD library's quick_print setting
    snmp_set_quick_print ¡¦ Set the value of quick_print within the UCD SNMP library.

    snmpget

    snmpget -- SNMP object¸¦ °¡Á®¿Â´Ù.

    Description

    string snmpget (string hostname, string community, string object_id [, int timeout [, int retries]])

    Returns SNMP object value on success and false on error.

    The snmpget() function is used to read the value of an SNMP object specified by the object_id. SNMP agent is specified by the hostname and the read community is specified by the community parameter.

      1 
      2 $syscontact = snmpget("127.0.0.1", "public", "system.SysContact.0");
      3       

    snmpset

    (PHP3 >= 3.0.12, PHP4 >= 4.0b2)

    snmpset -- SNMP object¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    bool snmpset (string hostname, string community, string object_id, string type, mixed value [, int timeout [, int retries]])

    Sets the specified SNMP object value, returning true on success and false on error.

    The snmpset() function is used to set the value of an SNMP object specified by the object_id. SNMP agent is specified by the hostname and the read community is specified by the community parameter.

    snmpwalk

    snmpwalk -- agent·Î ºÎÅÍ ¸ðµç SNMP objectµéÀ» °¡Á®¿Â´Ù.

    Description

    array snmpwalk (string hostname, string community, string object_id [, int timeout [, int retries]])

    Returns an array of SNMP object values starting from the object_id() as root and false on error.

    snmpwalk() function is used to read all the values from an SNMP agent specified by the hostname. Community specifies the read community for that agent. A null object_id is taken as the root of the SNMP objects tree and all objects under that tree are returned as an array. If object_id is specified, all the SNMP objects below that object_id are returned.

      1  
      2 $a = snmpwalk("127.0.0.1", "public", ""); 
      3       

    Above function call would return all the SNMP objects from the SNMP agent running on localhost. One can step through the values with a loop

      1 
      2 for ($i=0; $i<count($a); $i++) {
      3     echo $a[$i];
      4 }
      5       

    snmpwalkoid

    snmpwalkoid -- ³×Æ®¿÷ entity¿¡ ´ëÇÑ Á¤º¸ tree¸¦ ÁúÀÇÇÑ´Ù.

    Description

    array snmpwalkoid (string hostname, string community, string object_id [, int timeout [, int retries]])

    Returns an associative array with object ids and their respective object value starting from the object_id as root and false on error.

    snmpwalkoid() function is used to read all object ids and their respective values from an SNMP agent specified by the hostname. Community specifies the read community for that agent. A null object_id is taken as the root of the SNMP objects tree and all objects under that tree are returned as an array. If object_id is specified, all the SNMP objects below that object_id are returned.

    The existence of snmpwalkoid() and snmpwalk() has historical reasons. Both functions are provided for backward compatibility.

      1  
      2 $a = snmpwalkoid("127.0.0.1", "public", ""); 
      3       

    Above function call would return all the SNMP objects from the SNMP agent running on localhost. One can step through the values with a loop

      1 
      2 for (reset($a); $i = key($a); next($a)) {
      3     echo "$i: $a[$i]<br>\n";
      4 }
      5       

    snmp_get_quick_print

    snmp_get_quick_print -- UCD SNMP libraryÀÇ ÇöÀç quick_print setting °ªÀ» °¡Á®¿Â´Ù.

    Description

    boolean snmp_get_quick_print (void )

    Returns the current value stored in the UCD Library for quick_print. quick_print is off by default.

      1  
      2 $quickprint = snmp_get_quick_print();
      3       

    Above function call would return false if quick_print is on, and true if quick_print is on.

    snmp_get_quick_print() is only available when using the UCD SNMP library. This function is not available when using the Windows SNMP library.

    See: snmp_set_quick_print() for a full description of what quick_print does.

    snmp_set_quick_print

    snmp_set_quick_print -- UCD SNMP libraryÀÇ quick_printÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù.

    Description

    void snmp_set_quick_print (boolean quick_print)

    Sets the value of quick_print within the UCD SNMP library. When this is set (1), the SNMP library will return 'quick printed' values. This means that just the value will be printed. When quick_print is not enabled (default) the UCD SNMP library prints extra information including the type of the value (i.e. IpAddress or OID). Additionally, if quick_print is not enabled, the library prints additional hex values for all strings of three characters or less.

    Setting quick_print is often used when using the information returned rather then displaying it.

      1  
      2 snmp_set_quick_print(0);
      3 $a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1");
      4 echo "$a<BR>\n";
      5 snmp_set_quick_print(1);
      6 $a = snmpget("127.0.0.1", "public", ".1.3.6.1.2.1.2.2.1.9.1");
      7 echo "$a<BR>\n";
      8       

    The first value printed might be: 'Timeticks: (0) 0:00:00.00', whereas with quick_print enabled, just '0:00:00.00' would be printed.

    By default the UCD SNMP library returns verbose values, quick_print is used to return only the value.

    Currently strings are still returned with extra quotes, this will be corrected in a later release.

    snmp_set_quick_print() is only available when using the UCD SNMP library. This function is not available when using the Windows SNMP library.


    LV. String functions

    ÀÌ ÇÔ¼öµéÀº ¹®ÀÚ¿­À» ´Ù·ç´Â ÇÔ¼öµéÀÌ´Ù. ´õ ÀÚ¼¼ÇÑ »çÇ×Àº regular expression À̳ª URL handling Àý¿¡ ¼³¸íµÈ ºÎºÐÀ» ÂüÁ¶Ç϶ó.

    Table of Contents
    AddCSlashes ¡¦ Quote string with slashes in a C style.
    AddSlashes ¡¦ quote string with slashes
    bin2hex ¡¦ convert binary data into hexadecimal representation
    Chop ¡¦ remove trailing whitespace
    Chr ¡¦ return a specific character
    chunk_split ¡¦ Split a string into smaller chunks
    convert_cyr_string ¡¦ Convert from one Cyrillic character set to another
    count_chars ¡¦ Return information abouts characters used in a string.
    crypt ¡¦ DES-encrypt a string
    echo ¡¦ output one or more strings
    explode ¡¦ split a string by string
    flush ¡¦ flush the output buffer
    get_html_translation_table ¡¦ Returns the translation table used by htmlspecialchars() and htmlentities().
    get_meta_tags ¡¦ Extracts all meta tag content attributes from a file and returns an array
    htmlentities ¡¦ Convert all applicable characters to HTML entities.
    htmlspecialchars ¡¦ Convert special characters to HTML entities.
    implode ¡¦ join array elements with a string
    join ¡¦ join array elements with a string
    levenshtein ¡¦ Calculate Levenshtein distance between two strings
    ltrim ¡¦ Strip whitespace from the beginning of a string.
    md5 ¡¦ calculate the md5 hash of a string
    Metaphone ¡¦ Calculate the metaphone key of a string.
    nl2br ¡¦ Converts newlines to HTML line breaks.
    Ord ¡¦ return ASCII value of character
    parse_str ¡¦ parses the string into variables
    print ¡¦ output a string
    printf ¡¦ output a formatted string
    quoted_printable_decode ¡¦ Convert a quoted-printable string to an 8 bit string
    QuoteMeta ¡¦ quote meta characters
    rawurldecode ¡¦ decode URL-encoded strings
    rawurlencode ¡¦ URL-encode according to RFC1738
    setlocale ¡¦ set locale information
    similar_text ¡¦ calculate the similarity between two strings
    soundex ¡¦ calculate the soundex key of a string
    sprintf ¡¦ return a formatted string
    strcasecmp ¡¦ Binary safe case-insensitive string comparison.
    strchr ¡¦ Find the first occurrence of a character.
    strcmp ¡¦ binary safe string comparison
    strcspn ¡¦ find length of initial segment not matching mask
    strip_tags ¡¦ Strip HTML and PHP tags from a string
    StripCSlashes ¡¦ un-quote string quoted with addcslashes
    StripSlashes ¡¦ un-quote string quoted with addslashes
    stristr ¡¦ Case-insensitive strstr().
    strlen ¡¦ get string length
    strpos ¡¦ Find position of first occurrence of a string.
    strrchr ¡¦ Find the last occurrence of a character in a string.
    str_repeat ¡¦ Repeat a string.
    strrev ¡¦ Reverse a string.
    strrpos ¡¦ Find position of last occurrence of a char in a string.
    strspn ¡¦ find length of initial segment matching mask
    strstr ¡¦ Find first occurrence of a string.
    strtok ¡¦ tokenize string
    strtolower ¡¦ Make a string lowercase.
    strtoupper ¡¦ Make a string uppercase.
    str_replace ¡¦ Replace all occurrences of needle in haystack with str
    strtr ¡¦ Translate certain characters.
    substr ¡¦ Return part of a string.
    substr_replace ¡¦ Replace text within a portion of a string.
    trim ¡¦ Strip whitespace from the beginning and end of a string.
    ucfirst ¡¦ Make a string's first character uppercase
    ucwords ¡¦ Uppercase the first character of each word in a string

    AddCSlashes

    AddCSlashes -- C style·Î ÇÊ¿äÇÑ °÷À» backslash·Î °¨½Ñ´Ù.

    Description

    string addcslashes (string str, string charlist)

    Returns a string with backslashes before characters that are listed in charlist parameter. It escapes \n, \r etc. in C-like style, characters with ASCII code lower than 32 and higher than 126 are converted to octal representation. Be carefull when escaping alphanumeric characters. You can specify a range in charlist like "\0..\37", which would escape all characters with ASCII code between 0 and 31.

    Example 1. Addcslashes() example

      1 
      2 $escaped = addcslashes ($not_escaped, "\0..\37!@\177..\377");
      3       

    Note: Added in PHP4b3-dev.

    See also stripcslashes(), stripslashes(), htmlspecialchars() and quotemeta().

    AddSlashes

    AddSlashes -- ÇÊ¿äÇÑ °÷À» backslash·Î °¨½Ñ´Ù.

    Description

    string addslashes(string str);

    Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the null byte).

    See also stripcslashes(), stripslashes(), htmlspecialchars() and quotemeta().

    bin2hex

    bin2hex -- ÀÌÁø µ¥ÀÌÅ͸¦ 16Áø¼ö Ç¥½Ã·Î ¹Ù²Û´Ù.

    Description

    string bin2hex(string str);

    Returns an ASCII string containing the hexadecimal representation of str. The conversion is done byte-wise with the high-nibble first.

    Chop

    Chop -- µÚÂÊÀÇ ¿©¹é¸¦ »èÁ¦ÇÑ´Ù.

    Description

    string chop (string str)

    Returns the argument string without trailing whitespace, including newlines.

    Example 1. Chop() example

      1 
      2 $trimmed = chop ($line);
      3       

    See also trim().

    Chr

    Chr -- ÁöÁ¤µÈ ¹®ÀÚ¸¦ ¹ÝȯÇÑ´Ù.

    Description

    string chr (int ascii)

    Returns a one-character string containing the character specified by ascii.

    Example 1. Chr() example

      1 
      2 $str .= chr (27); /* add an escape character at the end of $str */
      3 
      4 /* Often this is more useful */
      5 
      6 $str = sprintf ("The string ends in escape: %c", 27);
      7       

    This function complements ord(). See also sprintf() with a format string of %c.

    chunk_split

    chunk_split -- ¹®ÀÚ¿­À» ºñ½ÁÇÑ Å©±â·Î ³ª´«´Ù.

    Description

    string chunk_split (string string [, int chunklen [, string end]])

    Can be used to split a string into smaller chunks which is useful for e.g. converting base64_encode output to match RFC 2045 semantics. It inserts every chunklen (defaults to 76) chars the string end (defaults to "\r\n"). It returns the new string leaving the original string untouched.

    Example 1. Chunk_split() example

      1 
      2 # format $data using RFC 2045 semantics
      3 
      4 $new_string = chunk_split (base64_encode($data));
      5       

    This function is significantly faster than ereg_replace().

    convert_cyr_string

    convert_cyr_string -- ¹®ÀÚ¿­À» ƯÁ¤ Cyrillic ¹®ÀÚ¿¡¼­ ´Ù¸¥ °ÍÀ¸·Î ¹Ù²Û´Ù.

    Description

    string convert_cyr_string (string str, string from, string to);

    This function converts the given string from one Cyrillic character set to another. The from and to arguments are single characters that represent the source and target Cyrillic character sets. The supported types are:

    count_chars

    (PHP4 >= 4.0b4)

    count_chars -- ¹®ÀÚ¿­¿¡ »ç¿ëµÈ ¹®Àڵ鿡 ´ëÇÑ Á¤º¸¸¦ ¹ÝȯÇÑ´Ù.

    Description

    mixed count_chars (string string [, mode])

    Counts the number of occurances of every byte-value (0..255) in string and returns it in various ways. The optional parameter Mode default to 0. Depending on mode count_chars() returns one of the following:

    Note: This function was added in PHP 4.0.

     

    crypt

    crypt -- ¹®ÀÚ¿­À» DES encryption¹æ¹ýÀ¸·Î º¯È¯(encrypt)ÇÑ´Ù.

    Description

    string crypt (string str [, string salt])

    crypt() will encrypt a string using the standard Unix DES encryption method. Arguments are a string to be encrypted and an optional two-character salt string to base the encryption on. See the Unix man page for your crypt function for more information.

    If the salt argument is not provided, it will be randomly generated by PHP.

    Some operating systems support more than one type of encryption. In fact, sometimes the standard DES encryption is replaced by an MD5 based encryption algorithm. The encryption type is triggered by the salt argument. At install time, PHP determines the capabilities of the crypt function and will accept salts for other encryption types. If no salt is provided, PHP will auto-generate a standard 2-character DES salt by default unless the default encryption type on the system is MD5 in which case a random MD5-compatible salt is generated. PHP sets a constant named CRYPT_SALT_LENGTH which tells you whether a regular 2-character salt applies to your system or the longer 12-char MD5 salt is applicable.

    The standard DES encryption crypt() contains the salt as the first two characters of the output.

    On systems where the crypt() function supports multiple encryption types, the following constants are set to 0 or 1 depending on whether the given type is available:

    There is no decrypt function, since crypt() uses a one-way algorithm.

    echo

    echo -- Çϳª ÀÌ»óÀÇ ¹®ÀÚ¿­À» Ãâ·ÂÇÑ´Ù.

    Description

    echo (string arg1, string [argn]...)

    Outputs all parameters.

    Echo() is not actually a function (it is a language construct) so you are not required to use parantheses with it.

    Example 1. Echo() example

      1 
      2 echo "Hello World";
      3 
      4 echo "This spans
      5 multiple lines. The newlines will be 
      6 output as well";
      7 
      8 echo "This spans\nmultiple lines. The newlines will be\noutput as well.";
      9       

    Note: In fact, if you want to pass more than one parameter to echo, you must not enclose the parameters within parentheses.

    See also: print(), printf(), and flush()

    explode

    explode -- ¹®ÀÚ¿­À» ¹®ÀÚ¿­ ±âÁØÀ¸·Î ³ª´«´Ù.

    Description

    array explode (string separator, string string [, int limit])

    Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delim. If limit is set, the returned array will contaion a maximum of limit elements with the last element containing the whole rest of string.

    Example 1. Explode() example

      1 
      2 $pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
      3 $pieces = explode (" ", $pizza);
      4       

    See also split() and implode().

    flush

    flush -- output buffer¸¦ FlushÇÑ´Ù.

    Description

    void flush(void);

    Flushes the output buffers of PHP and whatever backend PHP is using (CGI, a web server, etc.) This effectively tries to push all the output so far to the user's browser.

    get_html_translation_table

    (PHP4 >= 4.0b4)

    get_html_translation_table -- htmlspecialchars()¿Í htmlentities() ÇÔ¼ö¿¡¼­ »ç¿ëÇÏ´Â º¯È¯ Å×À̺íÀ» ¹ÝȯÇÑ´Ù.

    Description

    string get_html_translation_table (int table)

    get_html_translation_table() will return the translation table that is used internally for htmlspecialchars() and htmlentities(). Ther are two new defines (HTML_ENTITIES, HTML_SPECIALCHARS) that allow you to specify the table you want.

    Example 1. Translation Table Example

      1 
      2 $trans = get_html_translation_table (HTML_ENTITIES);
      3 $str = "Hallo & <Frau> & Krämer";
      4 $encoded = strtr ($str, $trans);
      5       

    The $encoded variable will now contain: "Hallo &amp; &lt;Frau&gt; &amp; Kr&auml;mer".

    The cool thing is using array_flip() to change the direction of the translation.

      1 
      2 $trans = array_flip ($trans);
      3 $original = strtr ($str, $trans);
      4       

    The content of $original would be: "Hallo & <Frau> & Krämer".

    Note: This function was added in PHP 4.0.

    See also: htmlspecialchars(), htmlentities(), strtr(), and array_flip().

    get_meta_tags

    get_meta_tags -- ÆÄÀÏ¿¡¼­ ¸ðµç meta tagÀÇ content ¼Ó¼ºÀ» ÃßÃâÇÏ¿© ¹è¿­¿¡ ÀúÀåÇÑ´Ù.

    Description

    array get_meta_tags (string filename [, int use_include_path])

    Opens filename and parses it line by line for <meta> tags of the form

    Example 1. Meta Tags Example

      1 
      2 <meta name="author" content="name">
      3 <meta name="tags" content="php3 documentation">
      4 </head> <!-- parsing stops here -->
      5       

    (pay attention to line endings - PHP uses a native function to parse the input, so a Mac file won't work on Unix).

    The value of the name property becomes the key, the value of the content property becomes the value of the returned array, so you can easily use standard array functions to traverse it or access single values. Special characters in the value of the name property are substituted with '_', the rest is converted to lower case.

    Setting use_include_path to 1 will result in PHP trying to open the file along the standard include path.

    htmlentities

    htmlentities -- ¸ðµç °¡´ÉÇÑ ¹®ÀÚµéÀ» HTML entity·Î ¹Ù²Û´Ù.

    Description

    string htmlentities (string string)

    This function is identical to htmlspecialchars() in all ways, except that all characters which have HTML entity equivalents are translated into these entities.

    At present, the ISO-8859-1 character set is used.

    See also htmlspecialchars() and nl2br().

    htmlspecialchars

    htmlspecialchars -- Ư¼ö¹®ÀÚµéÀ» HTML entity·Î º¯È¯ÇÑ´Ù.

    Description

    string htmlspecialchars (string string)

    Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with these conversions made.

    This function is useful in preventing user-supplied text from containing HTML markup, such as in a message board or guest book application.

    At present, the translations that are done are:

    Note that this functions does not translate anything beyond what is listed above. For full entity translation, see htmlentities().

    See also htmlentities() and nl2br().

    implode

    implode -- ¹è¿­ÀÇ ¿ø¼ÒµéÀ» ¹®ÀÚ¿­À» »ç¿ëÇØ ¿¬°áÇÑ´Ù.

    Description

    string implode (string glue, array pieces)

    Returns a string containing a string representation of all the array elements in the same order, with the glue string between each element.

    Example 1. Implode() example

      1 
      2 $colon_separated = implode (":", $array);
      3       

    See also explode(), join(), and split().

    join

    join -- ¹è¿­ÀÇ ¿ø¼ÒµéÀ» ¹®ÀÚ¿­À» »ç¿ëÇØ ¿¬°áÇÑ´Ù

    Description

    string join (string glue, array pieces)

    join() is an alias to implode(), and is identical in every way.

    See also explode(), implode(), and split().

    levenshtein

    (PHP3 CVS only, PHP4 CVS only)

    levenshtein -- µÎ ¹®ÀÚ¿­°£ÀÇ Levenshtein °Å¸®¸¦ °è»êÇÑ´Ù.

    Description

    int levenshtein (string str1, string str2)

    This function return the Levenshtein-Distance between the two argument strings or -1, if one of the argument strings is longer than the limit of 255 characters.

    The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform str1 into str2. The complexity of the algorithm is O(m*n), where n and m are the length of str1 and str2 (rather good when compared to similar_text(), which is O(max(n,m)**3), but still expensive).

    See also soundex(), similar_text() and metaphone().

    ltrim

    ltrim -- ¹®ÀÚ¿­ÀÇ ¾Õ ¿©¹éÀ» Á¦°ÅÇÑ´Ù.

    Description

    string ltrim (string str)

    This function strips whitespace from the start of a string and returns the stripped string. The whitespace characters it currently strips are: "\n", "\r", "\t", "\v", "\0", and a plain space.

    See also chop() and trim().

    md5

    md5 -- ¹®ÀÚ¿­ÀÇ md5 hash °ªÀ» °è»êÇÑ´Ù.

    Description

    string md5 (string str)

    Calculates the MD5 hash of str using the RSA Data Security, Inc. MD5 Message-Digest Algorithm.

    ( ¿ªÀÚÁÖ : MD5 algorithm¿¡ °üÇÑÀÚ¼¼ÇÑ ¼³¸íÀº RFC 1321À» º¸¼¼¿ä.)

    Metaphone

    Metaphone -- ¹®ÀÚ¿­ÀÇ metaphone key¸¦ °è»êÇÑ´Ù.

    Description

    string metaphone (string str)

    Calculates the metaphone key of str.

    Similar to soundex() metaphone creates the same key for similar sounding words. It's more accurate than soundex() as it knows the basic rules of English pronunciation. The metaphone generated keys are of variable length.

    Metaphone was developed by Lawrence Philips <lphilips@verity.com>. It is described in ["Practical Algorithms for Programmers", Binstock & Rex, Addison Wesley, 1995].

    Note: This function was added in PHP 4.0.

    nl2br

    nl2br -- newlineÀ» HTML line break·Î º¯È¯ÇÑ´Ù.

    Description

    string nl2br (string string)

    Returns string with '<BR>' inserted before all newlines.

    See also htmlspecialchars() and htmlentities().

    Ord

    Ord -- ¹®ÀÚÀÇ ASCII °ªÀ» ±¸ÇÑ´Ù.

    Description

    int ord (string string)

    Returns the ASCII value of the first character of string. This function complements chr().

    Example 1. Ord() example

      1 
      2 if (ord ($str) == 10) {
      3     echo "The first character of \$str is a line feed.\n";
      4 }
      5       

    See also chr().

    parse_str

    parse_str -- ¹®ÀÚ¿­À» º¯¼ö·Î Çؼ®(parse)ÇÑ´Ù.

    Description

    void parse_str (string str)

    Parses str as if it were the query string passed via an URL and sets variables in the current scope.

    Example 1. Using parse_str()

      1 
      2 $str = "first=value&second[]=this+works&second[]=another";
      3 parse_str($str);
      4 echo $first;     /* prints "value" */
      5 echo $second[0]; /* prints "this works" */
      6 echo $second[1]; /* prints "another" */
      7       

    print

    print -- ¹®ÀÚ¿­À» Ãâ·ÂÇÑ´Ù.

    Description

    print (string arg)

    Outputs arg.

    See also: echo(), printf() and flush()

    printf

    printf -- ¹®ÀÚ¿­À» formatÇÏ¿© Ãâ·ÂÇÑ´Ù.

    Description

    int printf (string format [, mixed args...])

    Produces output according to format, which is described in the documentation for sprintf().

    See also: print(), sprintf(), and flush().

    quoted_printable_decode

    quoted_printable_decode -- quoted-printable ¹®ÀÚ¿­À» 8 bit ¹®ÀÚ¿­·Î ¹Ù²Û´Ù.

    Description

    string quoted_printable_decode (string str)

    This function returns an 8-bit binary string corresponding to the decoded quoted printable string. This function is similar to imap_qprint(), except this one does not require the IMAP module to work.

    QuoteMeta

    QuoteMeta -- meta characterµéÀ» backslash°¡ ºÙÀº ¹®ÀÚ·Î ÀüȯÇÑ´Ù.

    Description

    string quotemeta (string str)

    Returns a version of str with a backslash character (\) before every character that is among these:
    . \\ + * ? [ ^ ] ( $ )

    See also addslashes(), htmlentities(), htmlspecialchars(), nl2br(), and stripslashes().

    rawurldecode

    rawurldecode -- URL-encoded ¹®ÀÚ¿­À» decodeÇÑ´Ù.

    Description

    string rawurldecode (string str)

    Returns a string in which the sequences with percent (%) signs followed by two hex digits have been replaced with literal characters. For example, the string

    foo%20bar%40baz

    decodes into

    foo
         bar@baz
    .

    See also rawurlencode().

    rawurlencode

    rawurlencode -- RFC1738À» µû¶ó URL-encodeÇÑ´Ù.

    Description

    string rawurlencode (string str)

    Returns a string in which all non-alphanumeric characters except

    -_.

    have been replaced with a percent (%) sign followed by two hex digits. This is the encoding described in RFC1738 for protecting literal characters from being interpreted as special URL delimiters, and for protecting URL's from being mangled by transmission media with character conversions (like some email systems). For example, if you want to include a password in an ftp url:

    Example 1. Rawurlencode() example 1

      1 
      2 echo '<A HREF="ftp://user:', rawurlencode ('foo @+%/'),
      3      '@ftp.my.com/x.txt">';
      4       

    Or, if you pass information in a path info component of the url:

    Example 2. Rawurlencode() example 2

      1 
      2 echo '<A HREF="http://x.com/department_list_script/',
      3     rawurlencode ('sales and marketing/Miami'), '">';
      4       

    See also rawurldecode().

    setlocale

    setlocale -- locale informationÀ» ¼³Á¤ÇÑ´Ù.

    Description

    string setlocale (string category, string locale)

    category is a string specifying the category of the functions affected by the locale setting:

    If locale is the empty string "", the locale names will be set from the values of environment variables with the same names as the above categories, or from "LANG".

    If locale is zero or "0", the locale setting is not affected, only the current setting is returned.

    Setlocale returns the new current locale, or false if the locale functionality is not implemented in the plattform, the specified locale does not exist or the category name is invalid. An invalid category name also causes a warning message.

    similar_text

    similar_text -- µÎ ¹®ÀÚ¿­ °£ÀÇ ºñ½ÁÇÑ Á¤µµ¸¦ °è»êÇÑ´Ù.

    Description

    int similar_text (string first, string second [, double percent])

    This calculates the similarity between two strings as described in Oliver [1993]. Note that this implementation does not use a stack as in Oliver's pseudo code, but recursive calls which may or may not speed up the whole process. Note also that the complexity of this algorithm is O(N**3) where N is the length of the longest string.

    By passing a reference as third argument, similar_text() will calculate the similarity in percent for you. It returns the number of matching chars in both strings.

    soundex

    soundex -- ¹®ÀÚ¿­ÀÇ soundex key¸¦ ±¸ÇÑ´Ù.(¿ªÀÚÁÖ: ºñ½ÁÇÑ ¹ßÀ½À» ã±â À§ÇØ »ç¿ë, ¿µ¾î¸¸ °¡´É)

    Description

    string soundex (string str)

    Calculates the soundex key of str.

    Soundex keys have the property that words pronounced similarly produce the same soundex key, and can thus be used to simplify searches in databases where you know the pronunciation but not the spelling. This soundex function returns a string 4 characters long, starting with a letter.

    This particular soundex function is one described by Donald Knuth in "The Art Of Computer Programming, vol. 3: Sorting And Searching", Addison-Wesley (1973), pp. 391-392.

    Example 1. Soundex Examples

      1 
      2 soundex ("Euler") == soundex ("Ellery") == 'E460';
      3 soundex ("Gauss") == soundex ("Ghosh") == 'G200';
      4 soundex ("Knuth") == soundex ("Kant") == 'H416';
      5 soundex ("Lloyd") == soundex ("Ladd") == 'L300';
      6 soundex ("Lukasiewicz") == soundex ("Lissajous") == 'L222';
      7       

    sprintf

    sprintf -- formatµÈ ¹®ÀÚ¿­À» ¹ÝȯÇÑ´Ù.

    Description

    string sprintf (string format [, mixed args...])

    Returns a string produced according to the formatting string format.

    The format string is composed by zero or more directives: ordinary characters (excluding %) that are copied directly to the result, and conversion specifications, each of which results in fetching its own parameter. This applies to both sprintf() and printf().

    Each conversion specification consists of these elements, in order:

    1. An optional padding specifier that says what character will be used for padding the results to the right string size. This may be a space character or a 0 (zero character). The default is to pad with spaces. An alternate padding character can be specified by prefixing it with a single quote ('). See the examples below.
    2. An optional alignment specifier that says if the result should be left-justified or right-justified. The default is right-justified; a - character here will make it left-justified.
    3. An optional number, a width specifier that says how many characters (minimum) this conversion should result in.
    4. An optional precision specifier that says how many decimal digits should be displayed for floating-point numbers. This option has no effect for other types than double. (Another function useful for formatting numbers is number_format().)
    5. A type specifier that says what type the argument data should be treated as. Possible types:
    6. % - a literal percent character. No argument is required.

      b - the argument is treated as an integer, and presented as a binary number.
      c - the argument is treated as an integer, and presented as the character with that ASCII value.
      d - the argument is treated as an integer, and presented as a decimal number.
      f - the argument is treated as a double, and presented as a floating-point number.
      o - the argument is treated as an integer, and presented as an octal number.
      s - the argument is treated as and presented as a string.
      x - the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters).
      X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).

    See also: printf(), number_format()

    Examples

    Example 1. Sprintf(): zero-padded integers

      1 
      2 $isodate = sprintf ("%04d-%02d-%02d", $year, $month, $day);
      3       

    Example 2. Sprintf(): formatting currency

      1 
      2 $money1 = 68.75;
      3 $money2 = 54.35;
      4 $money = $money1 + $money2;
      5 // echo $money will output "123.1";
      6 $formatted = sprintf ("%01.2f", $money);
      7 // echo $formatted will output "123.10"
      8       

    strcasecmp

    (PHP3 >= 3.0.2, PHP4 )

    strcasecmp -- binary ¹æ½Ä(safe)ÀÇ ´ë,¼Ò¹®ÀÚ ±¸º° ¾ø´Â ¹®ÀÚ¿­ ºñ±³

    Description

    int strcasecmp (string str1, string str2)

    Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.

    Example 1. strcasecmp() example

      1 
      2 $var1 = "Hello";
      3 $var2 = "hello";
      4 if ( !strcasecmp($var1,$var2) ) {
      5     echo '$var1 is equal to $var2 in a case-insensitive string comparison';
      6 }
      7       

    See also ereg(), strcmp(), substr(), stristr(), and strstr().

    strchr

    strchr -- ÇØ´ç ¹®ÀÚ°¡ óÀ½ ³ªÅ¸³ª´Â °÷À» ã´Â´Ù.

    Description

    string strchr (string haystack, string needle)

    This function is an alias for strstr(), and is identical in every way.

    strcmp

    strcmp -- binary ¹æ½Ä(safe)ÀÇ ¹®ÀÚ¿­ ºñ±³

    Description

    int strcmp (string str1, string str2)

    Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.

    Note that this comparison is case sensitive.

    See also ereg(), substr(), and strstr().

    strcspn

    strcspn -- mask¿¡ ¸ÂÁö ¾Ê´Â initial segmentÀÇ ±æÀ̸¦ ±¸ÇÑ´Ù.

    Description

    int strcspn (string str1, string str2)

    Returns the length of the initial segment of str1 which does not contain any of the characters in str2.

    See also strspn().

    strip_tags

    (PHP3 >= 3.0.8, PHP4 >= 4.0b2)

    strip_tags -- ¹®ÀÚ¿­¿¡¼­ HTML°ú PHP Å×±×µéÀ» Á¦°ÅÇÑ´Ù.

    Description

    string strip_tags (string str [, string allowable_tags])

    This function tries to strip all HTML and PHP tags from the given string. It errors on the side of caution in case of incomplete or bogus tags. It uses the same tag stripping state machine as the fgetss() function.

    You can use the optional second parameter to specify tags which should not be stripped.

    Note: Allowable_tags was added in PHP 3.0.13, PHP4B3.

    StripCSlashes

    StripCSlashes -- addcslashes·Î quoteµÈ ¹®ÀÚ¿­À» un-quoteÇÑ´Ù.

    Description

    string stripcslashes (string str)

    Returns a string with backslashes stripped off. Recognizes C-like \n, \r ..., octal and hexadecimal representation.

    Note: Added in PHP4b3-dev.

    See also addcslashes().

    StripSlashes

    StripSlashes -- addslashes·Î quoteµÈ ¹®ÀÚ¿­À» un-quoteÇÑ´Ù.

    Description

    string stripslashes (string str)

    Returns a string with backslashes stripped off. (\' becomes ' and so on.) Double backslashes are made into a single backslash.

    See also addslashes().

    stristr

    (PHP3 >= 3.0.6, PHP4 )

    stristr -- ´ë,¼Ò¹®ÀÚ¸¦ ±¸ºÐÇÏÁö ¾Ê´Â strstr()

    Description

    string stristr (string haystack, string needle)

    Returns all of haystack from the first occurrence of needle to the end. needle and haystack are examined in a case-insensitive manner.

    If needle is not found, returns false.

    If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.

    See also strchr(), strrchr(), substr(), and ereg().

    strlen

    strlen -- ¹®ÀÚ¿­ÀÇ ±æÀ̸¦ ±¸ÇÑ´Ù.

    Description

    int strlen (string str)

    Returns the length of string.

    strpos

    strpos -- ÇØ´ç ¹®ÀÚ¿­ÀÌ ³ªÅ¸³ª´Â ù À§Ä¡¸¦ ±¸ÇÑ´Ù.

    Description

    int strpos (string haystack, string needle [, int offset])

    Returns the numeric position of the first occurrence of needle in the haystack string. Unlike the strrpos(), this function can take a full string as the needle parameter and the entire string will be used.

    If needle is not found, returns false.

    Note: It is easy to mistake the return values for "character found at position 0" and "character not found". Here's how to detect the difference:

      1 
      2 // in PHP 4.0b3 and newer:
      3 $pos = strpos ("b", $mystring);
      4 if ($pos === false) { // note: three equal signs
      5     // not found...
      6 }
      7 
      8 // in versions older than 4.0b3:
      9 $pos = strpos ("b", $mystring);
     10 if (is_string ($pos) && !$pos) {
     11     // not found...
     12 }
     13 	

    If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.

    The optional offset parameter allows you to specify which character in haystack to start searching. The position returned is still relative to the the beginning of haystack.

    See also strrpos(), strrchr(), substr(), and strstr().

    strrchr

    strrchr -- ¹®ÀÚ°¡ ¸¶Áö¸·À¸·Î ³ªÅ¸³ª´Â À§Ä¡¸¦ ±¸ÇÑ´Ù.

    Description

    string strrchr (string haystack, string needle)

    This function returns the portion of haystack which starts at the last occurrence of needle and goes until the end of haystack.

    Returns false if needle is not found.

    If needle contains more than one character, the first is used.

    If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.

    Example 1. Strrchr() example

      1 
      2 // get last directory in $PATH
      3 $dir = substr (strrchr ($PATH, ":"), 1);
      4 
      5 // get everything after last newline
      6 $text = "Line 1\nLine 2\nLine 3";
      7 $last = substr (strrchr ($text, 10), 1 );
      8       

    See also substr() and strstr().

    str_repeat

    (PHP4 >= 4.0b4)

    str_repeat -- ¹®ÀÚ¿­À» ¹Ýº¹ÇÑ´Ù.

    Description

    string str_repeat (string input, int multiplier)

    Returns input_str repeated multiplier times. multiplier has to be greater than 0.

    Example 1. Str_repeat() example

      1 
      2 echo str_repeat ("-=", 10);
      3      

    This will output "-=-=-=-=-=-=-=-=-=-=".

    Note: This function was added in PHP 4.0.

    strrev

    strrev -- ¹®ÀÚ¿­À» ReverseÇÑ´Ù.

    Description

    string strrev (string string)

    Returns string, reversed.

    strrpos

    strrpos -- ¹®ÀÚ¿­¿¡¼­ ÇØ´ç ¹®ÀÚ°¡ ³ªÅ¸³ª´Â Á¦ÀÏ ¸¶Áö¸· À§Ä¡¸¦ ±¸ÇÑ´Ù.

    Description

    int strrpos (string haystack, char needle)

    Returns the numeric position of the last occurrence of needle in the haystack string. Note that the needle in this case can only be a single character. If a string is passed as the needle, then only the first character of that string will be used.

    If needle is not found, returns false.

    If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.

    See also strpos(), strrchr(), substr(), stristr() and strstr().

    strspn

    strspn -- mask¿¡ ¸Â´Â initial segmentÀÇ ±æÀ̸¦ ±¸ÇÑ´Ù.

    Description

    int strspn (string str1, string str2)

    Returns the length of the initial segment of str1 which consists entirely of characters in str2

    See also strcspn().

    strstr

    strstr -- ¹®ÀÚ¿­ÀÌ Ã³À½ ³ªÅ¸³ª´Â À§Ä¡ÀÇ ¹®ÀÚ¿­À» ¹ÝȯÇÑ´Ù.

    Description

    string strstr (string haystack, string needle)

    Returns all of haystack from the first occurrence of needle to the end.

    If needle is not found, returns false.

    If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.

    Example 1. Strstr() example

      1 
      2 $email = 'sterling@designmultimedia.com';
      3 $domain = strstr ($email, '@');
      4 print $domain; // prints designmultimedia.com
      5       

    See also stristr(), strrchr(), substr(), and ereg().

    strtok

    strtok -- ¹®ÀÚ¿­À» tokenÈ­ ÇÑ´Ù.

    Description

    string strtok (string arg1, string arg2)

    strtok() is used to tokenize a string. That is, if you have a string like "This is an example string" you could tokenize this string into its individual words by using the space character as the token.

    Example 1. Strtok() example

      1 
      2 $string = "This is an example string";
      3 $tok = strtok ($string," ");
      4 while ($tok) {
      5     echo "Word=$tok<br>";
      6     $tok = strtok (" ");
      7 }
      8       

    Note that only the first call to strtok uses the string argument. Every subsequent call to strtok only needs the token to use, as it keeps track of where it is in the current string. To start over, or to tokenize a new string you simply call strtok with the string argument again to initialize it. Note that you may put multiple tokens in the token parameter. The string will be tokenized when any one of the characters in the argument are found.

    Also be careful that your tokens may be equal to "0". This evaluates to false in conditional expressions.

    See also split() and explode().

    strtolower

    strtolower -- ¼Ò¹®ÀÚ·Î ¸¸µç´Ù.

    Description

    string strtolower (string str)

    Returns string with all alphabetic characters converted to lowercase.

    Note that 'alphabetic' is determined by the current locale. This means that in i.e. the default "C" locale, characters such as umlaut-A (Ä) will not be converted.

    Example 1. Strtolower() example

      1 
      2 $str = "Mary Had A Little Lamb and She LOVED It So";
      3 $str = strtolower($str);	
      4 print $str; # Prints mary had a little lamb and she loved it so
      5      

    See also strtoupper() and ucfirst().

    strtoupper

    strtoupper -- ´ë¹®ÀÚ·Î ¸¸µç´Ù.

    Description

    string strtoupper (string string)

    Returns string with all alphabetic characters converted to uppercase.

    Note that 'alphabetic' is determined by the current locale. For instance, in the default "C" locale characters such as umlaut-a (ä) will not be converted.

    Example 1. Strtoupper() example

      1 
      2 $str = "Mary Had A Little Lamb and She LOVED It So";
      3 $str = strtoupper ($str);	
      4 print $str; # Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
      5      

    See also strtolower() and ucfirst().

    str_replace

    str_replace -- Replace all occurrences of needle in haystack with str

    Description

    string str_replace (string needle, string str, string haystack)

    This function replaces all occurences of needle in haystack with the given str. If you don't need fancy replacing rules, you should always use this function instead of ereg_replace().

    Example 1. Str_replace() example

      1 
      2 $bodytag = str_replace ("%body%", "black", "<body text=%body%>");
      3       

    This function is binary safe.

    Note: Str_replace() was added in PHP 3.0.6, but was buggy up until PHP 3.0.8.

    See also ereg_replace() and strtr()

    strtr

    strtr -- ƯÁ¤ ¹®ÀÚ¿­À» ´ëÄ¡(translate)ÇÑ´Ù.

    Description

    string strtr (string str, string from, string to)

    This function operates on str, translating all occurrences of each character in from to the corresponding character in to and returning the result.

    If from and to are different lengths, the extra characters in the longer of the two are ignored.

    Example 1. Strtr() example

      1 
      2 $addr = strtr($addr, "äåö", "aao");
      3       

    strtr() can be called with only two arguments. If called with two arguments it behaves in a new way: from then has to be an array that contains string -> string pairs that will be replaced in the source string. strtr() will always look for the longest possible match first and will *NOT* try to replace stuff that it has already worked on.

    Examples:

      1 
      2 $trans = array ("hello" => "hi", "hi" => "hello");
      3 echo strtr("hi all, I said hello", $trans) . "\n";
      4       

    This will show: "hello all, I said hi",

    Note: This feature (two arguments) was added in PHP 4.0.

    See also : ereg_replace().

    substr

    substr -- ¹®ÀÚ¿­ÀÇ ÀϺκÐÀ» ¹ÝȯÇÑ´Ù.

    Description

    string substr (string string, int start [, int length])

    Substr returns the portion of string specified by the start and length parameters.

    If start is positive, the returned string will start at the start'th character of string.

    Examples:

      1 
      2 $rest = substr ("abcdef", 1);    // returns "bcdef"
      3 $rest = substr ("abcdef", 1, 3); // returns "bcd"
      4       

    If start is negative, the returned string will start at the start'th character from the end of string.

    Examples:

      1 
      2 $rest = substr ("abcdef", -1);    // returns "f"
      3 $rest = substr ("abcdef", -2);    // returns "ef"
      4 $rest = substr ("abcdef", -3, 1); // returns "d"
      5       

    If length is given and is positive, the string returned will end length characters from start. If this would result in a string with negative length (because the start is past the end of the string), then the returned string will contain the single character at start.

    If length is given and is negative, the string returned will end length characters from the end of string. If this would result in a string with negative length, then the returned string will contain the single character at start.

    Examples:

      1 
      2 $rest = substr ("abcdef", 1, -1); // returns "bcde"
      3       

    See also strrchr() and ereg().

    substr_replace

    (PHP4 >= 4.0b4)

    substr_replace -- ¹®ÀÚ¿­ÀÇ Æ¯Á¤ À§Ä¡ÀÇ text¸¦ ġȯÇÑ´Ù.

    Description

    string substr_replace (string string, string replacement, int start [, int length])

    substr_replace() replaces the part of string delimited by the start and (optionally) length parameters with the string given in replacement. The result is returned.

    If start is positive, the replacing will begin at the start'th offset into string.

    If start is negative, the replacing will begin at the start'th character from the end of string.

    If length is given and is positive, it represents the length of the portion of string which is to be replaced. If it is negative, it represents the number of characters from the end of string at which to stop replacing. If it is not given, then it will default to strlen( string ); i.e. end the replacing at the end of string.

    Example 1. Substr_replace() example

      1 
      2 <?php
      3 $var = 'ABCDEFGH:/MNRPQR/';
      4 echo "Original: $var<hr>\n";
      5 
      6 /* These two examples replace all of $var with 'bob'. */
      7 echo substr_replace ($var, 'bob', 0) . "<br>\n";
      8 echo substr_replace ($var, 'bob', 0, strlen ($var)) . "<br>\n";
      9 
     10 /* Insert 'bob' right at the beginning of $var. */
     11 echo substr_replace ($var, 'bob', 0, 0) . "<br>\n";
     12 
     13 /* These next two replace 'MNRPQR' in $var with 'bob'. */
     14 echo substr_replace ($var, 'bob', 10, -1) . "<br>\n";
     15 echo substr_replace ($var, 'bob', -7, -1) . "<br>\n";
     16 
     17 /* Delete 'MNRPQR' from $var. */
     18 echo substr_replace ($var, '', 10, -1) . "<br>\n";
     19 ?>
     20       

    See also str_replace() and substr().

    Note: Substr_replace() was added in PHP 4.0.

    trim

    trim -- ¹®ÀÚ¿­ÀÇ ¾Õ,µÚ ¿©¹é ¸ðµÎ¸¦ Á¦°ÅÇÑ´Ù.

    Description

    string trim (string str)

    This function strips whitespace from the start and the end of a string and returns the stripped string. The whitespace characters it currently strips are: "\n", "\r", "\t", "\v", "\0", and a plain space

    See also chop() and ltrim().

    ucfirst

    ucfirst -- ¹®ÀÚ¿­ÀÇ Ã³À½ ¹®ÀÚ¸¦ ´ë¹®ÀÚ·Î ¸¸µç´Ù.

    Description

    string ucfirst (string str)

    Capitalizes the first character of str if that character is alphabetic.

    Note that 'alphabetic' is determined by the current locale. For instance, in the default "C" locale characters such as umlaut-a (ä) will not be converted.

    Example 1. ucfirst() example

      1     
      2 $text = 'mary had a little lamb and she loved it so.';
      3 $text = ucfirst($text); // $text is now Mary had a little lamb and she loved it so.
      4         

    See also strtoupper() and strtolower().

    ucwords

    ucwords -- ¹®ÀÚ¿­³»ÀÇ °¢ ´Ü¾îÀÇ Ã¹ ¹ø° ¹®ÀÚ¸¦ ´ë¹®ÀÚ·Î ¸¸µç´Ù.

    Description

    string ucwords (string str)

    Capitalizes the first character of each word in str if that character is alphabetic.

    Example 1. ucwords() example

      1 
      2 $text = "mary had a little lamb and she loved it so.";
      3 $text = ucwords($text); // $text is now: Mary Had A Little Lamb And She Loved It So.
      4        

    See also strtoupper(), strtolower() and ucfirst().


    LVI. Shockwave Flash functions

    PHP´Â Paul HaeberliÀÇ libswf ¸ðµâÀ» ÅëÇØ Shockwave Flash ÆÄÀÏÀ» ¸¸µå´Â ±â´ÉÀ» Á¦°øÇÑ´Ù. libswf´Â http://reality.sgi.com/grafica/flash/¿¡¼­ ¾òÀ» ¼ö ÀÖ´Ù. libswf °¡ ÀÖ´Ù¸é PHP ¼³Á¤½Ã¿¡ --with-swf[=DIR] ¿É¼ÇÀ» ÁÖ°í ¼³Á¤ÇÏ¿©¾ß ÇÑ´Ù. (DIRÀº include¿Í lib µð·ºÅ丮¸¦ Æ÷ÇÔÇÏ°í ÀÖ´Â µð·ºÅ丮ÀÌ´Ù.) include µð·ºÅ丮¿¡´Â swf.h ÆÄÀÏÀÌ ÀÖ¾î¾ß ÇÏ°í, lib µð·ºÅ丮¿¡´Â libswf.a ÆÄÀÏÀÌ ÀÖ¾î¾ß ÇÑ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ libswf ¹èÆ÷º»À» Ç®¾ú´Âµ¥ ÀÌ µÎ ÆÄÀÏÀÌ °°Àº µð·ºÅ丮¿¡ ÀÖ´Ù¸é, include¿Í lib µð·ºÅ丮¸¦ Á÷Á¢ ¸¸µé¾î ÀÌ µÎ ÆÄÀÏÀ» ÀûÇÕÇÑ À§Ä¡¿¡ ¿Å°Ü µÎ¾î¾ß ÇÑ´Ù.

    PHP¸¦ Shockwave Flash Áö¿øÀ¸·Î ¼³Ä¡ÇÏ¿´´Ù¸é, ÀÌÁ¦ PHP¿¡¼­ Shockwave ÆÄÀÏÀ» ¸¸µé ¼ö ÀÖ´Ù. ÀÌÁ¦ ¹«¾ùÀ» ÇÒ ¼ö ÀÖ´ÂÁö ³î¶ö °ÍÀÌ´Ù. ´ÙÀ½ÀÇ Äڵ带 »ìÆ캸ÀÚ. :

    Example 1. SWF example

      1 
      2 <php
      3 swf_openfile ("test.swf", 256, 256, 30, 1, 1, 1);
      4 swf_ortho2 (-100, 100, -100, 100);
      5 swf_defineline (1, -70, 0, 70, 0, .2);
      6 swf_definerect (4, 60, -10, 70, 0, 0);
      7 swf_definerect (5, -60, 0, -70, 10, 0);
      8 swf_addcolor (0, 0, 0, 0);
      9 
     10 swf_definefont (10, "Mod");
     11 swf_fontsize (5);
     12 swf_fontslant (10);
     13 swf_definetext (11, "This be Flash wit PHP!", 1);
     14 
     15 swf_pushmatrix ();
     16 swf_translate (-50, 80, 0);
     17 swf_placeobject (11, 60);
     18 swf_popmatrix ();
     19 
     20 for ($i = 0; $i < 30; $i++) {
     21     $p = $i/(30-1);
     22     swf_pushmatrix ();
     23     swf_scale (1-($p*.9), 1, 1);
     24     swf_rotate (60*$p,  'z');
     25     swf_translate (20+20*$p, $p/1.5, 0);
     26     swf_rotate (270*$p,  'z');
     27     swf_addcolor ($p, 0, $p/1.2, -$p);
     28     swf_placeobject (1, 50);
     29     swf_placeobject (4, 50);
     30     swf_placeobject (5, 50);
     31     swf_popmatrix ();
     32     swf_showframe ();
     33 }
     34 
     35 for ($i = 0; $i < 30; $i++) {
     36     swf_removeobject (50);
     37     if (($i%4) == 0) {
     38         swf_showframe ();
     39     }
     40 }
     41 
     42 swf_startdoaction ();
     43 swf_actionstop ();
     44 swf_enddoaction ();
     45 
     46 swf_closefile ();
     47 ?>
     48      

    À§ÀÇ ¿¹Á¦´Â ÀÌ url¿¡¼­ º¼ ¼ö ÀÖ´Â µ¿¿µ»óÀ» ¸¸µé¾î ³½´Ù.

    Note: SWF Áö¿øÀº PHP4 RC2¿¡¼­ Ãß°¡µÇ¾ú´Ù.

    Table of Contents
    swf_openfile ¡¦ Open a new Shockwave Flash file
    swf_closefile ¡¦ Close the current Shockwave Flash file
    swf_labelframe ¡¦ Label the current frame
    swf_showframe ¡¦ Display the current frame
    swf_setframe ¡¦ Switch to a specified frame
    swf_getframe ¡¦ Get the frame number of the current frame
    swf_mulcolor ¡¦ Sets the global multiply color to the rgba value specified
    swf_addcolor ¡¦ Set the global add color to the rgba value specified
    swf_placeobject ¡¦ Place an object onto the screen
    swf_modifyobject ¡¦ Modify an object
    swf_removeobject ¡¦ Remove an object
    swf_nextid ¡¦ Returns the next free object id
    swf_startdoaction ¡¦ Start a description of an action list for the current frame
    swf_actiongotoframe ¡¦ Play a frame and then stop
    swf_actiongeturl ¡¦ Get a URL from a Shockwave Flash movie
    swf_actionnextframe ¡¦ Go foward one frame
    swf_actionprevframe ¡¦ Go backwards one frame
    swf_actionplay ¡¦ Start playing the flash movie from the current frame
    swf_actionstop ¡¦ Stop playing the flash movie at the current frame
    swf_actiontogglequality ¡¦ Toggle between low and high quality
    swf_actionwaitforframe ¡¦ Skip actions if a frame has not been loaded
    swf_actionsettarget ¡¦ Set the context for actions
    swf_actiongotolabel ¡¦ Display a frame with the specified label
    swf_enddoaction ¡¦ End the current action
    swf_defineline ¡¦ Define a line
    swf_definerect ¡¦ Define a rectangle
    swf_definepoly ¡¦ Define a polygon
    swf_startshape ¡¦ Start a complex shape
    swf_shapelinesolid ¡¦ Set the current line style
    swf_shapefilloff ¡¦ Turns off filling
    swf_shapefillsolid ¡¦ Set the current fill style to the specified color
    swf_shapefillbitmaptile ¡¦ Set current fill mode to clipped bitmap
    swf_shapefillbitmaptile ¡¦ Set current fill mode to tiled bitmap
    swf_shapemoveto ¡¦ Move the current position
    swf_shapelineto ¡¦ Draw a line
    swf_shapecurveto ¡¦ Draw a quadratic bezier curve between two points
    swf_shapecurveto3 ¡¦ Draw a cubic bezier curve
    swf_shapearc ¡¦ Draw a circular arc
    swf_endshape ¡¦ Completes the definition of the current shape
    swf_definefont ¡¦ Defines a font
    swf_setfont ¡¦ Change the current font
    swf_fontsize ¡¦ Change the font size
    swf_fontslant ¡¦ Set the font slant
    swf_fonttracking ¡¦ Set the current font tracking
    swf_getfontinfo ¡¦ The height in pixels of a capital A and a lowercase x
    swf_definetext ¡¦ Define a text string
    swf_textwidth ¡¦ Get the width of a string
    swf_definebitmap ¡¦ Define a bitmap
    swf_getbitmapinfo ¡¦ Get information about a bitmap
    swf_startsymbol ¡¦ Define a symbol
    swf_endsymbol ¡¦ End the definition of a symbol
    swf_startbutton ¡¦ Start the definition of a button
    swf_addbuttonrecord ¡¦ Controls location, appearance and active area of the current button
    swf_oncondition ¡¦ Describe a transition used to trigger an action list
    swf_endbutton ¡¦ End the definition of the current button
    swf_viewport ¡¦ Select an area for future drawing
    swf_ortho ¡¦ Defines an orthographic mapping of user coordinates onto the current viewport
    swf_ortho2 ¡¦ Defines 2D orthographic mapping of user coordinates onto the current viewport
    swf_perspective ¡¦ Define a perspective projection transformation
    swf_polarview ¡¦ Define the viewer's position with polar coordinates
    swf_lookat ¡¦ Define a viewing transformation
    swf_pushmatrix ¡¦ Push the current transformation matrix back unto the stack
    swf_popmatrix ¡¦ Restore a previous transformation matrix
    swf_scale ¡¦ Scale the current transformation
    swf_translate ¡¦ Translate the current transformations
    swf_rotate ¡¦ Rotate the current transformation
    swf_posround ¡¦ Enables or Disables the rounding of the translation when objects are placed or moved

    swf_openfile

    (PHP4 >= 4.0RC2)

    swf_openfile -- Open a new Shockwave Flash file

    Description

    void swf_openfile (string filename, float width, float height, float framerate, float r, float g, float b)

    The swf_openfile() function opens a new file named filename with a width of width and a height of height a frame rate of framerate and background with a red color of r a green color of g and a blue color of b.

    The swf_openfile() must be the first function you call, otherwise your script will cause a segfault. If you want to send your output to the screen make the filename: "php://stdout" (support for this is in 4.0.1 and up).

    swf_closefile

    (PHP4 >= 4.0RC2)

    swf_closefile -- Close the current Shockwave Flash file

    Description

    void swf_closefile (void);

    Close a file that was opened by the swf_openfile() function.

    swf_labelframe

    (PHP4 >= 4.0RC2)

    swf_labelframe -- Label the current frame

    Description

    void swf_labelframe (string name)

    Label the current frame with the name given by the name parameter.

    swf_showframe

    (PHP4 >= 4.0RC2)

    swf_showframe -- Display the current frame

    Description

    void swf_showframe (void);

    The swf_showframe function will output the current frame.

    swf_setframe

    (PHP4 >= 4.0RC2)

    swf_setframe -- Switch to a specified frame

    Description

    void swf_setframe (int framenumber)

    The swf_setframe() changes the active frame to the frame specified by framenumber.

    swf_getframe

    (PHP4 >= 4.0RC2)

    swf_getframe -- Get the frame number of the current frame

    Description

    int swf_getframe (void);

    The swf_getframe() function gets the number of the current frame.

    swf_mulcolor

    (PHP4 >= 4.0RC2)

    swf_mulcolor --  Sets the global multiply color to the rgba value specified

    Description

    void swf_mulcolor (float r, float g, float b, float a)

    The swf_mulcolor() function sets the global multiply color to the rgba color specified. This color is then used (implicitly) by the swf_placeobject(), swf_modifyobject() and the swf_addbuttonrecord() functions. The color of the object will be multiplied by the rgba values when the object is written to the screen.

    Note: The rgba values can be either positive or negative.

    swf_addcolor

    (PHP4 >= 4.0RC2)

    swf_addcolor --  Set the global add color to the rgba value specified

    Description

    void swf_addcolor (float r, float g, float b, float a)

    The swf_addcolor() function sets the global add color to the rgba color specified. This color is then used (implicitly) by the swf_placeobject(), swf_modifyobject() and the swf_addbuttonrecord() functions. The color of the object will be add by the rgba values when the object is written to the screen.

    Note: The rgba values can be either positive or negative.

    swf_placeobject

    (PHP4 >= 4.0RC2)

    swf_placeobject -- Place an object onto the screen

    Description

    void swf_placeobject (int objid, int depth)

    Places the object specified by objid in the current frame at a depth of depth. The objid parameter and the depth must be between 1 and 65535.

    This uses the current mulcolor (specified by swf_mulcolor()) and the current addcolor (specified by swf_addcolor()) to color the object and it uses the current matrix to position the object.

    Note: Full RGBA colors are supported.

    swf_modifyobject

    (PHP4 >= 4.0RC2)

    swf_modifyobject -- Modify an object

    Description

    void swf_modifyobject (int depth, int how)

    Updates the position and/or color of the object at the specified depth, depth. The parameter how determines what is updated. how can either be the constant MOD_MATRIX or MOD_COLOR or it can be a combination of both (MOD_MATRIX|MOD_COLOR).

    MOD_COLOR uses the current mulcolor (specified by the function swf_mulcolor()) and addcolor (specified by the function swf_addcolor()) to color the object. MOD_MATRIX uses the current matrix to position the object.

    swf_removeobject

    (PHP4 >= 4.0RC2)

    swf_removeobject -- Remove an object

    Description

    void swf_removeobject (int depth)

    Removes the object at the depth specified by depth.

    swf_nextid

    (PHP4 >= 4.0RC2)

    swf_nextid -- Returns the next free object id

    Description

    int swf_nextid (void);

    The swf_nextid() function returns the next available object id.

    swf_startdoaction

    (PHP4 >= 4.0RC2)

    swf_startdoaction --  Start a description of an action list for the current frame

    Description

    void swf_startdoaction (void);

    The swf_startdoaction() function starts the description of an action list for the current frame. This must be called before actions are defined for the current frame.

    swf_actiongotoframe

    (PHP4 >= 4.0RC2)

    swf_actiongotoframe -- Play a frame and then stop

    Description

    void swf_actiongotoframe (int framenumber)

    The swf_actionGotoFrame() function will go to the frame specified by framenumber, play it, and then stop.

    swf_actiongeturl

    (PHP4 >= 4.0RC2)

    swf_actiongeturl -- Get a URL from a Shockwave Flash movie

    Description

    void swf_actiongeturl (string url, string target)

    The swf_actionGetUrl() function gets the URL specified by the parameter url with the target target.

    swf_actionnextframe

    (PHP4 >= 4.0RC2)

    swf_actionnextframe -- Go foward one frame

    Description

    void swf_actionnextframe (void);

    Go foward one frame.

    swf_actionprevframe

    (PHP4 >= 4.0RC2)

    swf_actionprevframe -- Go backwards one frame

    Description

    void swf_actionprevframe (void);

    swf_actionplay

    (PHP4 >= 4.0RC2)

    swf_actionplay --  Start playing the flash movie from the current frame

    Description

    void swf_actionplay (void);

    Start playing the flash movie from the current frame.

    swf_actionstop

    (PHP4 >= 4.0RC2)

    swf_actionstop --  Stop playing the flash movie at the current frame

    Description

    void swf_actionstop (void);

    Stop playing the flash movie at the current frame.

    swf_actiontogglequality

    (PHP4 >= 4.0RC2)

    swf_actiontogglequality --  Toggle between low and high quality

    Description

    void swf_actiontogglequality (void);

    Toggle the flash movie between high and low quality.

    swf_actionwaitforframe

    (PHP4 >= 4.0RC2)

    swf_actionwaitforframe --  Skip actions if a frame has not been loaded

    Description

    void swf_actionwaitforframe (int framenumber, int skipcount)

    The swf_actionWaitForFrame() function will check to see if the frame, specified by the framenumber parameter has been loaded, if not it will skip the number of actions specified by the skipcount parameter. This can be useful for "Loading..." type animations.

    swf_actionsettarget

    (PHP4 >= 4.0RC2)

    swf_actionsettarget -- Set the context for actions

    Description

    void swf_actionsettarget (string target)

    The swf_actionSetTarget() function sets the context for all actions. You can use this to control other flash movies that are currently playing.

    swf_actiongotolabel

    (PHP4 >= 4.0RC2)

    swf_actiongotolabel --  Display a frame with the specified label

    Description

    void swf_actiongotolabel (string label)

    The swf_actionGotoLabel() function displays the frame with the label given by the label parameter and then stops.

    swf_enddoaction

    (PHP4 >= 4.0RC2)

    swf_enddoaction -- End the current action

    Description

    void swf_enddoaction (void);

    Ends the current action started by the swf_startdoaction() function.

    swf_defineline

    (PHP4 >= 4.0RC2)

    swf_defineline -- Define a line

    Description

    void swf_defineline (int objid, float x1, float y1, float x2, float y2, float width)

    The swf_defineline() defines a line starting from the x coordinate given by x1 and the y coordinate given by y1 parameter. Up to the x coordinate given by the x2 parameter and the y coordinate given by the y2 parameter. It will have a width defined by the width parameter.

    swf_definerect

    (PHP4 >= 4.0RC2)

    swf_definerect -- Define a rectangle

    Description

    void swf_definerect (int objid, float x1, float y1, float x2, float y2, float width)

    The swf_definerect() defines a rectangle with an upper left hand coordinate given by the x, x1, and the y, y1. And a lower right hand coordinate given by the x coordinate, x2, and the y coordinate, y2 . Width of the rectangles border is given by the width parameter, if the width is 0.0 then the rectangle is filled.

    swf_definepoly

    (PHP4 >= 4.0.0)

    swf_definepoly --  Define a polygon

    Description

    void swf_definepoly (int objid, array coords, int npoints, float width)

    The swf_definepoly() function defines a polygon given an array of x, y coordinates (the coordinates are defined in the parameter coords). The parameter npoints is the number of overall points that are contained in the array given by coords. The width is the width of the polygon's border, if set to 0.0 the polygon is filled.

    swf_startshape

    (PHP4 >= 4.0RC2)

    swf_startshape -- Start a complex shape

    Description

    void swf_startshape (int objid)

    The swf_startshape() function starts a complex shape, with an object id given by the objid parameter.

    swf_shapelinesolid

    (PHP4 >= 4.0RC2)

    swf_shapelinesolid -- Set the current line style

    Description

    void swf_shapelinesolid (float r, float g, float b, float a, float width)

    The swf_shapeLineSolid() function sets the current line style to the color of the rgba parameters and width to the width parameter. If 0.0 is given as a width then no lines are drawn.

    swf_shapefilloff

    (PHP4 >= 4.0RC2)

    swf_shapefilloff -- Turns off filling

    Description

    void swf_shapefilloff (void);

    The swf_shapeFillOff() function turns off filling for the current shape.

    swf_shapefillsolid

    (PHP4 >= 4.0RC2)

    swf_shapefillsolid --  Set the current fill style to the specified color

    Description

    void swf_shapefillsolid (float r, float g, float b, float a)

    The swf_shapeFillSolid() function sets the current fill style to solid, and then sets the fill color to the values of the rgba parameters.

    swf_shapefillbitmaptile

    (PHP4 >= 4.0RC2)

    swf_shapefillbitmaptile --  Set current fill mode to clipped bitmap

    Description

    void swf_shapefillbitmapclip (int bitmapid)

    Sets the fill to bitmap clipped, empty spaces will be filled by the bitmap given by the bitmapid parameter

    swf_shapefillbitmaptile

    (PHP4 >= 4.0RC2)

    swf_shapefillbitmaptile --  Set current fill mode to tiled bitmap

    Description

    void swf_shapefillbitmaptile (int bitmapid)

    Sets the fill to bitmap tile, empty spaces will be filled by the bitmap given by the bitmapid parameter (tiled).

    swf_shapemoveto

    (PHP4 >= 4.0RC2)

    swf_shapemoveto -- Move the current position

    Description

    void swf_shapemoveto (float x, float y)

    The swf_shapeMoveTo() function moves the current position to the x coordinate given by the x parameter and the y position given by the y parameter.

    swf_shapelineto

    (PHP4 >= 4.0RC2)

    swf_shapelineto -- Draw a line

    Description

    void swf_shapelineto (float x, float y)

    The swf_shapeLineTo() draws a line to the x,y coordinates given by the x parameter & the y parameter. The current position is then set to the x,y parameters.

    swf_shapecurveto

    (PHP4 >= 4.0RC2)

    swf_shapecurveto --  Draw a quadratic bezier curve between two points

    Description

    void swf_shapecurveto (float x1, float y1, float x2, float y2)

    The swf_shapecurveto() function draws a quadratic bezier curve from the x coordinate given by x1 and the y coordinate given by y1 to the x coordinate given by x2 and the y coordinate given by y2. The current position is then set to the x,y coordinates given by the x2 and y2 parameters

    swf_shapecurveto3

    (PHP4 >= 4.0RC2)

    swf_shapecurveto3 -- Draw a cubic bezier curve

    Description

    void swf_shapecurveto3 (float x1, float y1, float x2, float y2, float x3, float y3)

    Draw a cubic bezier curve using the x,y coordinate pairs x1, y1 and x2,y2 as off curve control points and the x,y coordinate x3, y3 as an endpoint. The current position is then set to the x,y coordinate pair given by x3,y3.

    swf_shapearc

    (PHP4 >= 4.0RC2)

    swf_shapearc -- Draw a circular arc

    Description

    void swf_shapearc (float x, float y, float r, float ang1, float ang2)

    The swf_shapeArc() function draws a circular arc from angle A given by the ang1 parameter to angle B given by the ang2 parameter. The center of the circle has an x coordinate given by the x parameter and a y coordinate given by the y, the radius of the circle is given by the r parameter.

    swf_endshape

    (PHP4 >= 4.0RC2)

    swf_endshape --  Completes the definition of the current shape

    Description

    void swf_endshape (void);

    The swf_endshape() completes the definition of the current shape.

    swf_definefont

    (PHP4 >= 4.0RC2)

    swf_definefont --  Defines a font

    Description

    void swf_definefont (int fontid, string fontname)

    The swf_definefont() function defines a font given by the fontname parameter and gives it the id specified by the fontid parameter. It then sets the font given by fontname to the current font.

    swf_setfont

    (PHP4 >= 4.0RC2)

    swf_setfont -- Change the current font

    Description

    void swf_setfont (int fontid)

    The swf_setfont() sets the current font to the value given by the fontid parameter.

    swf_fontsize

    (PHP4 >= 4.0RC2)

    swf_fontsize -- Change the font size

    Description

    void swf_fontsize (float size)

    The swf_fontsize() function changes the font size to the value given by the size parameter.

    swf_fontslant

    (PHP4 >= 4.0RC2)

    swf_fontslant -- Set the font slant

    Description

    void swf_fontslant (float slant)

    Set the current font slant to the angle indicated by the slant parameter. Positive values create a foward slant, negative values create a negative slant.

    swf_fonttracking

    (PHP4 >= 4.0RC2)

    swf_fonttracking -- Set the current font tracking

    Description

    void swf_fonttracking (float tracking)

    Set the font tracking to the value specified by the tracking parameter. This function is used to increase the spacing between letters and text, positive values increase the space and negative values decrease the space between letters.

    swf_getfontinfo

    (PHP4 >= 4.0RC2)

    swf_getfontinfo --  The height in pixels of a capital A and a lowercase x

    Description

    array swf_getfontinfo (void);

    The swf_getfontinfo() function returns an associative array with the following parameters:

    swf_definetext

    (PHP4 >= 4.0RC2)

    swf_definetext -- Define a text string

    Description

    void swf_definetext (int objid, string str, int docenter)

    Define a text string (the str parameter) using the current font and font size. The docenter is where the word is centered, if docenter is 1, then the word is centered in x.

    swf_textwidth

    (PHP4 >= 4.0RC2)

    swf_textwidth -- Get the width of a string

    Description

    float swf_textwidth (string str)

    The swf_textwidth() function gives the width of the string, str, in pixels, using the current font and font size.

    swf_definebitmap

    (PHP4 >= 4.0RC2)

    swf_definebitmap -- Define a bitmap

    Description

    void swf_definebitmap (int objid, string image_name)

    The swf_definebitmap() function defines a bitmap given a GIF, JPEG, RGB or FI image. The image will be converted into a Flash JPEG or Flash color map format.

    swf_getbitmapinfo

    (PHP4 >= 4.0RC2)

    swf_getbitmapinfo -- Get information about a bitmap

    Description

    array swf_getbitmapinfo (int bitmapid)

    The swf_getbitmapinfo() function returns an array of information about a bitmap given by the bitmapid parameter. The returned array has the following elements:

    swf_startsymbol

    (PHP4 >= 4.0RC2)

    swf_startsymbol -- Define a symbol

    Description

    void swf_startsymbol (int objid)

    Define an object id as a symbol. Symbols are tiny flash movies that can be played simultaneously. The objid parameter is the object id you want to define as a symbol.

    swf_endsymbol

    (PHP4 >= 4.0RC2)

    swf_endsymbol -- End the definition of a symbol

    Description

    void swf_endsymbol (void);

    The swf_endsymbol() function ends the definition of a symbol that was started by the swf_startsymbol() function.

    swf_startbutton

    (PHP4 >= 4.0RC2)

    swf_startbutton -- Start the definition of a button

    Description

    void swf_startbutton (int objid, int type)

    The swf_startbutton() function starts off the definition of a button. The type parameter can either be TYPE_MENUBUTTON or TYPE_PUSHBUTTON. The TYPE_MENUBUTTON constant allows the focus to travel from the button when the mouse is down, TYPE_PUSHBUTTON does not allow the focus to travel when the mouse is down.

    swf_addbuttonrecord

    (PHP4 >= 4.0RC2)

    swf_addbuttonrecord --  Controls location, appearance and active area of the current button

    Description

    void swf_addbuttonrecord (int states, int shapeid, int depth)

    The swf_addbuttonrecord() function allows you to define the specifics of using a button. The first parameter, states, defines what states the button can have, these can be any or all of the following constants: BSHitTest, BSDown, BSOver or BSUp. The second parameter, the shapeid is the look of the button, this is usually the object id of the shape of the button. The depth parameter is the placement of the button in the current frame.

    Example 1. Swf_addbuttonrecord() function example

      1 
      2 swf_startButton ($objid, TYPE_MENUBUTTON);
      3     swf_addButtonRecord (BSDown|BSOver, $buttonImageId, 340);
      4     swf_onCondition (MenuEnter);
      5         swf_actionGetUrl ("http://www.designmultimedia.com", "_level1");
      6     swf_onCondition (MenuExit);
      7         swf_actionGetUrl ("", "_level1");
      8 swf_endButton ();
      9       

    swf_oncondition

    (PHP4 >= 4.0RC2)

    swf_oncondition --  Describe a transition used to trigger an action list

    Description

    void swf_oncondition (int transition)

    The swf_onCondition() function describes a transition that will trigger an action list. There are several types of possible transitions, the following are for buttons defined as TYPE_MENUBUTTON:

    For TYPE_PUSHBUTTON there are the following options:

    swf_endbutton

    (PHP4 >= 4.0RC2)

    swf_endbutton --  End the definition of the current button

    Description

    void swf_endbutton (void);

    The swf_endButton() function ends the definition of the current button.

    swf_viewport

    (PHP4 >= 4.0RC2)

    swf_viewport -- Select an area for future drawing

    Description

    void swf_viewport (double xmin, double xmax, double ymin, double ymax)

    The swf_viewport() function selects an area for future drawing for xmin to xmax and ymin to ymax, if this function is not called the area defaults to the size of the screen.

    swf_ortho

    (PHP4 CVS only)

    swf_ortho --  Defines an orthographic mapping of user coordinates onto the current viewport

    Description

    void swf_ortho (double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)

    The swf_ortho() funcion defines a orthographic mapping of user coordinates onto the current viewport.

    swf_ortho2

    (PHP4 >= 4.0RC2)

    swf_ortho2 --  Defines 2D orthographic mapping of user coordinates onto the current viewport

    Description

    void swf_ortho2 (double xmin, double xmax, double ymin, double ymax)

    The swf_ortho2() function defines a two dimensional orthographic mapping of user coordinates onto the current viewport, this defaults to one to one mapping of the area of the Flash movie. If a perspective transformation is desired, the swf_perspective () function can be used.

    swf_perspective

    (PHP4 >= 4.0RC2)

    swf_perspective --  Define a perspective projection transformation

    Description

    void swf_perspective (double fovy, double aspect, double near, double far)

    The swf_perspective() function defines a perspective projection transformation. The fovy parameter is field-of-view angle in the y direction. The aspect parameter should be set to the aspect ratio of the viewport that is being drawn onto. The near parameter is the near clipping plane and the far parameter is the far clipping plane.

    Note: Various distortion artifacts may appear when performing a perspective projection, this is because Flash players only have a two dimensional matrix. Some are not to pretty.

    swf_polarview

    (PHP4 >= 4.0RC2)

    swf_polarview --  Define the viewer's position with polar coordinates

    Description

    void swf_polarview (double dist, double azimuth, double incidence, double twist)

    The swf_polarview() function defines the viewer's position in polar coordinates. The dist parameter gives the distance between the viewpoint to the world space origin. The azimuth parameter defines the azimuthal angle in the x,y coordinate plane, measured in distance from the y axis. The incidence parameter defines the angle of incidence in the y,z plane, measured in distance from the z axis. The incidence angle is defined as the angle of the viewport relative to the z axis. Finally the twist specifies the amount that the viewpoint is to be rotated about the line of sight using the right hand rule.

    swf_lookat

    (PHP4 >= 4.0RC2)

    swf_lookat -- Define a viewing transformation

    Description

    void swf_lookat (double view_x, double view_y, double view_z, double reference_x, double reference_y, double reference_z, double twist)

    The swf_lookat() function defines a viewing transformation by giving the viewing position (the parameters view_x, view_y, and view_z) and the coordinates of a reference point in the scene, the reference point is defined by the reference_x, reference_y , and reference_z parameters. The twist controls the rotation along with viewer's z axis.

    swf_pushmatrix

    (PHP4 >= 4.0RC2)

    swf_pushmatrix --  Push the current transformation matrix back unto the stack

    Description

    void swf_pushmatrix (void);

    The swf_pushmatrix() function pushes the current transformation matrix back onto the stack.

    swf_popmatrix

    (PHP4 >= 4.0RC2)

    swf_popmatrix --  Restore a previous transformation matrix

    Description

    void swf_popmatrix (void);

    The swf_popmatrix() function pushes the current transformation matrix back onto the stack.

    swf_scale

    (PHP4 >= 4.0RC2)

    swf_scale -- Scale the current transformation

    Description

    void swf_scale (double x, double y, double z)

    The swf_scale() scales the x coordinate of the curve by the value of the x parameter, the y coordinate of the curve by the value of the y parameter, and the z coordinate of the curve by the value of the z parameter.

    swf_translate

    (PHP4 >= 4.0RC2)

    swf_translate -- Translate the current transformations

    Description

    void swf_translate (double x, double y, double z)

    The swf_translate() function translates the current transformation by the x, y, and z values given.

    swf_rotate

    (PHP4 >= 4.0RC2)

    swf_rotate -- Rotate the current transformation

    Description

    void swf_rotate (double angle, string axis)

    The swf_rotate() rotates the current transformation by the angle given by the angle parameter around the axis given by the axis parameter. Valid values for the axis are 'x' (the x axis), 'y' (the y axis) or 'z' (the z axis).

    swf_posround

    (PHP4 >= 4.0RC2)

    swf_posround --  Enables or Disables the rounding of the translation when objects are placed or moved

    Description

    void swf_posround (int round)

    The swf_posround() function enables or disables the rounding of the translation when objects are placed or moved, there are times when text becomes more readable because rounding has been enabled. The round is whether to enable rounding or not, if set to the value of 1, then rounding is enabled, if set to 0 then rounding is disabled.


    LVII. Sybase functions

    Table of Contents
    sybase_affected_rows ¡¦ get number of affected rows in last query
    sybase_close ¡¦ close Sybase connection
    sybase_connect ¡¦ open Sybase server connection
    sybase_data_seek ¡¦ move internal row pointer
    sybase_fetch_array ¡¦ fetch row as array
    sybase_fetch_field ¡¦ get field information
    sybase_fetch_object ¡¦ fetch row as object
    sybase_fetch_row ¡¦ get row as enumerated array
    sybase_field_seek ¡¦ set field offset
    sybase_free_result ¡¦ free result memory
    sybase_num_fields ¡¦ get number of fields in result
    sybase_num_rows ¡¦ get number of rows in result
    sybase_pconnect ¡¦ open persistent Sybase connection
    sybase_query ¡¦ send Sybase query
    sybase_result ¡¦ get result data
    sybase_select_db ¡¦ select Sybase database

    sybase_affected_rows

    sybase_affected_rows -- ÃÖ±Ù ÁúÀÇ¿¡ ¿µÇâÀ» ¹Þ´Â rowÀÇ °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int sybase_affected_rows(int [link_identifier] );

    Returns: The number of affected rows by the last query.

    sybase_affected_rows() returns the number of rows affected by the last INSERT, UPDATE or DELETE query on the server associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed.

    This command is not effective for SELECT statements, only on statements which modify records. To retrieve the number of rows returned from a SELECT, use sybase_num_rows().

    Note: This function is only available using the CT library interface to Sybase, and not the DB library.

    sybase_close

    sybase_close -- Sybase connectionÀ» ´Ý´Â´Ù.

    Description

    int sybase_close(int link_identifier);

    Returns: true on success, false on error

    sybase_close() closes the link to a Sybase database that's associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed.

    Note that this isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.

    sybase_close() will not close persistent links generated by sybase_pconnect().

    See also: sybase_connect(), sybase_pconnect().

    sybase_connect

    sybase_connect -- Sybase server connectionÀ» ¿¬´Ù.

    Description

    int sybase_connect(string servername, string username, string password);

    Returns: A positive Sybase link identifier on success, or false on error.

    sybase_connect() establishes a connection to a Sybase server. The servername argument has to be a valid servername that is defined in the 'interfaces' file.

    In case a second call is made to sybase_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned.

    The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling sybase_close().

    See also sybase_pconnect(), sybase_close().

    sybase_data_seek

    sybase_data_seek -- internal row pointer¸¦ ¿Å±ä´Ù.

    Description

    int sybase_data_seek(int result_identifier, int row_number);

    Returns: true on success, false on failure

    sybase_data_seek() moves the internal row pointer of the Sybase result associated with the specified result identifier to pointer to the specifyed row number. The next call to sybase_fetch_row() would return that row.

    See also: sybase_data_seek().

    sybase_fetch_array

    sybase_fetch_array -- row¸¦ ¹è¿­·Î °¡Á®¿Â´Ù.

    Description

    int sybase_fetch_array(int result);

    Returns: An array that corresponds to the fetched row, or false if there are no more rows.

    sybase_fetch_array() is an extended version of sybase_fetch_row(). In addition to storing the data in the numeric indices of the result array, it also stores the data in associative indices, using the field names as keys.

    An important thing to note is that using sybase_fetch_array() is NOT significantly slower than using sybase_fetch_row(), while it provides a significant added value.

    For further details, also see sybase_fetch_row()

    sybase_fetch_field

    sybase_fetch_field -- Çʵå Á¤º¸¸¦ ±¸ÇÑ´Ù.

    Description

    object sybase_fetch_field(int result, int field_offset);

    Returns an object containing field information.

    sybase_fetch_field() can be used in order to obtain information about fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retreived by sybase_fetch_field() is retreived.

    The properties of the object are:

    See also sybase_field_seek()

    sybase_fetch_object

    sybase_fetch_object -- row¸¦ °´Ã¼(Object)·Î °¡Á®¿Â´Ù.

    Description

    int sybase_fetch_object(int result);

    Returns: An object with properties that correspond to the fetched row, or false if there are no more rows.

    sybase_fetch_object() is similar to sybase_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

    Speed-wise, the function is identical to sybase_fetch_array(), and almost as quick as sybase_fetch_row() (the difference is insignificant).

    See also: sybase_fetch-array() and sybase_fetch-row().

    sybase_fetch_row

    sybase_fetch_row -- row¸¦ ¹è¿­(enumerated array)·Î °¡Á®¿Â´Ù.

    Description

    array sybase_fetch_row(int result);

    Returns: An array that corresponds to the fetched row, or false if there are no more rows.

    sybase_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

    Subsequent call to sybase_fetch_rows() would return the next row in the result set, or false if there are no more rows.

    See also: sybase_fetch_array(), sybase_fetch_object(), sybase_data_seek(), sybase_fetch_lengths(), and sybase_result().

    sybase_field_seek

    sybase_field_seek -- ÇʵåÀÇ offsetÀ» ¼³Á¤ÇÑ´Ù.

    Description

    int sybase_field_seek(int result, int field_offset);

    Seeks to the specified field offset. If the next call to sybase_fetch_field() won't include a field offset, this field would be returned.

    See also: sybase_fetch_field().

    sybase_free_result

    sybase_free_result -- result memory¸¦ Ç®¾îÁØ´Ù.

    Description

    int sybase_free_result(int result);

    sybase_free_result() only needs to be called if you are worried about using too much memory while your script is running. All result memory will automatically be freed when the script, you may call sybase_free_result() with the result identifier as an argument and the associated result memory will be freed.

    sybase_num_fields

    sybase_num_fields -- resultÀÇ field °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int sybase_num_fields(int result);

    sybase_num_fields() returns the number of fields in a result set.

    See also: sybase_db_query(), sybase_query(), sybase_fetch_field(), sybase_num_rows().

    sybase_num_rows

    sybase_num_rows -- resultÀÇ row °³¼ö¸¦ ±¸ÇÑ´Ù.

    Description

    int sybase_num_rows(string result);

    sybase_num_rows() returns the number of rows in a result set.

    See also: sybase_db_query(), sybase_query() and, sybase_fetch_row().

    sybase_pconnect

    sybase_pconnect -- ¿µ±¸ÀûÀÎ Sybase Á¢¼ÓÀ» ¿¬´Ù.

    Description

    int sybase_pconnect(string servername, string username, string password);

    Returns: A positive Sybase persistent link identifier on success, or false on error

    sybase_pconnect() acts very much like sybase_connect() with two major differences.

    First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

    Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (sybase_close() will not close links established by sybase_pconnect()).

    This type of links is therefore called 'persistent'.

    sybase_query

    sybase_query -- Sybase ÁúÀǸ¦ Àü¼ÛÇÑ´Ù.

    Description

    int sybase_query(string query, int link_identifier);

    Returns: A positive Sybase result identifier on success, or false on error.

    sybase_query() sends a query to the currently active database on the server that's associated with the specified link identifier. If the link identifier isn't specified, the last opened link is assumed. If no link is open, the function tries to establish a link as if sybase_connect() was called, and use it.

    See also: sybase_db_query(), sybase_select_db(), and sybase_connect().

    sybase_result

    sybase_result -- result data¸¦ ±¸ÇÑ´Ù.

    Description

    int sybase_result(int result, int i, mixed field);

    Returns: The contents of the cell at the row and offset in the specified Sybase result set.

    sybase_result() returns the contents of one cell from a Sybase result set. The field argument can be the field's offset, or the field's name, or the field's table dot field's name (fieldname.tablename). If the column name has been aliased ('select foo as bar from...'), use the alias instead of the column name.

    When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than sybase_result(). Also, note that specifying a numeric offset for the field argument is much quicker than specifying a fieldname or tablename.fieldname argument.

    Recommended high-performance alternatives: sybase_fetch_row(), sybase_fetch_array(), and sybase_fetch_object().

    sybase_select_db

    sybase_select_db -- Sybase database¸¦ ¼±ÅÃÇÑ´Ù.

    Description

    int sybase_select_db(string database_name, int link_identifier);

    Returns: true on success, false on error

    sybase_select_db() sets the current active database on the server that's associated with the specified link identifier. If no link identifier is specified, the last opened link is assumed. If no link is open, the function will try to establish a link as if sybase_connect() was called, and use it.

    Every subsequent call to sybase_query() will be made on the active database.

    See also: sybase_connect(), sybase_pconnect(), and sybase_query()


    LVIII. URL functions

    Table of Contents
    base64_decode ¡¦ decodes data encoded with MIME base64
    base64_encode ¡¦ encodes data with MIME base64
    parse_url ¡¦ parse a URL and return its components
    urldecode ¡¦ decodes URL-encoded string
    urlencode ¡¦ URL-encodes string

    base64_decode

    base64_decode -- MIME base64·Î encodeµÈ ¹®ÀÚ¿­À» decode ÇÑ´Ù.

    Description

    string base64_decode (string encoded_data)

    base64_decode() decodes encoded_data and returns the original data. The returned data may be binary.

    See also: base64_encode(), RFC-2045 section 6.8.

    base64_encode

    base64_encode -- MIME base64 ¹æ½ÄÀ¸·Î encodeÇÑ´Ù.

    Description

    string base64_encode (string data)

    base64_encode() returns data encoded with base64. This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.

    Base64-encoded data takes about 33% more space than the original data.

    See also: base64_decode(), chunk_split(), RFC-2045 section 6.8.

    parse_url

    parse_url -- PHP°¡ form data¸¦ Çؼ®ÇϵíÀÌ query stringÀ» Çؼ®(parse)ÇÑ´Ù.

    Description

    array parse_url (string url)

    This function returns an associative array returning any of the various components of the URL that are present. This includes the "scheme", "host", "port", "user", "pass", "path", "query", and "fragment".

    urldecode

    urldecode -- URL-encodeµÈ ¹®ÀÚ¿­À» decodeÇÑ´Ù.

    Description

    string urldecode (string str)

    Decodes any %## encoding in the given string. The decoded string is returned.

    Example 1. Urldecode() example

      1 
      2 $a = split ('&', $querystring);
      3 $i = 0;
      4 while ($i < count ($a)) {
      5     $b = split ('=', $a [$i]);
      6     echo 'Value for parameter ', htmlspecialchars (urldecode ($b [0])),
      7          ' is ', htmlspecialchars (urldecode ($b [1])), "<BR>";
      8     $i++;
      9 }
     10       

    See also urlencode()

    urlencode

    urlencode -- ¹®ÀÚ¿­À» URL-encodeÇÑ´Ù.

    Description

    string urlencode (string str)

    Returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. It is encoded the same way that the posted data from a WWW form is encoded, that is the same way as in application/x-www-form-urlencoded media type. This differs from the RFC1738 encoding (see rawurlencode()) in that for historical reasons, spaces are encoded as plus (+) signs. This function is convenient when encoding a string to be used in a query part of an URL, as a convenient way to pass variables to the next page:

    Example 1. Urlencode() example

      1 
      2 echo '<A HREF="mycgi?foo=', urlencode ($userinput), '">';
      3       

    See also urldecode()


    LIX. Variable functions

    Table of Contents
    call_user_func ¡¦ Call a user function given by the first parameter
    doubleval ¡¦ Get double value of a variable.
    empty ¡¦ determine whether a variable is set
    gettype ¡¦ Get the type of a variable.
    intval ¡¦ Get integer value of a variable.
    is_array ¡¦ Finds whether a variable is an array.
    is_bool ¡¦ Finds out whether a variable is a boolean
    is_double ¡¦ Finds whether a variable is a double.
    is_float ¡¦ Finds whether a variable is a float.
    is_int ¡¦ Find whether a variable is an integer.
    is_integer ¡¦ Find whether a variable is an integer.
    is_long ¡¦ Finds whether a variable is an integer.
    is_numeric ¡¦ Finds whether a variable is a number or a numeric string
    is_object ¡¦ Finds whether a variable is an object.
    is_real ¡¦ Finds whether a variable is a real.
    is_resource ¡¦ Finds whether a variable is a resource
    is_string ¡¦ Finds whether a variable is a string.
    isset ¡¦ determine whether a variable is set
    settype ¡¦ Set the type of a variable.
    strval ¡¦ Get string value of a variable.
    unset ¡¦ Unset a given variable
    var_dump ¡¦ Dumps information about a variable

    call_user_func

    (PHP3 >= 3.0.3, PHP4 )

    call_user_func -- Ã¹ ¹ø° ÆĶó¸ÞÅÍ·Î ÁÖ¾îÁø »ç¿ëÀÚ ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù.

    Description

    mixed call_user_func (string function_name [, mixed parameters*])

    Call a user defined function given by the function_name parameter. Take the following:

      1 
      2 function barber ($type) {
      3   print "You wanted a $type haircut, no problem";
      4 }
      5 call_user_func('barber', "mushroom");
      6 call_user_func('barber', "shave");
      7           

    doubleval

    doubleval -- º¯¼öÀÇ ½Ç¼ö(double)°ªÀ» ±¸ÇÑ´Ù.

    Description

    double doubleval (mixed var)

    Returns the double (floating point) value of var.

    Var may be any scalar type. You cannot use doubleval() on arrays or objects.

      1 
      2 $var = '122.34343The';
      3 $double_value_of_var = doubleval ($var);
      4 print $double_value_of_var; // prints 122.34343
      5       

    See also intval(), strval(), settype() and Type juggling.

    empty

    empty -- º¯¼ö°¡ °ªÀÌ ºñ¾î Àִ°¡ °Ë»çÇÑ´Ù.

    Description

    int empty (mixed var)

    Returns false if var is set and has a non-empty or non-zero value; true otherwise.

      1 
      2 $var = 0;
      3 if (empty($var)) { #evaluates true 
      4     print '$var is either 0 or not at all set';
      5 }
      6 if (!isset($var)) { // evaluates false
      7     print 'The $var is not set at all';
      8 }
      9       

    Note that this is meaningless when used on anything which isn't a variable; i.e. empty (addslashes ($name)) has no meaning since it would be checking whether something which isn't a variable is a variable with a false value.

    See also isset() and unset().

    gettype

    gettype -- º¯¼öÀÇ typeÀ» ±¸ÇÑ´Ù.

    Description

    string gettype (mixed var)

    Returns the type of the PHP variable var.

    Possibles values for the returned string are:

    See also settype().

    intval

    intval -- º¯¼öÀÇ Á¤¼ö°ªÀ» ±¸ÇÑ´Ù.

    Description

    int intval (mixed var [, int base])

    Returns the integer value of var, using the specified base for the conversion (the default is base 10).

    Var may be any scalar type. You cannot use intval() on arrays or objects.

    See also doubleval(), strval(), settype() and Type juggling.

    is_array

    is_array -- º¯¼ö°¡ ¹è¿­Àΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_array (mixed var)

    Returns true if var is an array, false otherwise.

    See also is_bool(), is_double(), is_float(), is_int(), is_integer(), is_real(), is_string(), is_long(), and is_object().

    is_bool

    (PHP4 >= 4.0b4)

    is_bool -- º¯¼ö°¡ ºÒ¸°ÇüÀΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_bool (mixed var)

    Returns true if the var parameter is a boolean.

    See also is_array(), is_double(), is_float(), is_int(), is_integer(), is_real(), is_string(), is_long(), and is_object().

    is_double

    is_double -- º¯¼ö°¡ ½Ç¼öÀΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_double (mixed var);

    Returns true if var is a double, false otherwise.

    See also is_array(), is_bool(), is_float(), is_int(), is_integer(), is_real(), is_string(), is_long(), and is_object().

    is_float

    is_float -- º¯¼ö°¡ ½Ç¼öÀΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_float (mixed var);

    This function is an alias for is_double().

    See also is_bool(), is_double(), is_real(), is_int(), is_integer(), is_string(), is_object(), is_array(), and is_long().

    is_int

    is_int -- º¯¼ö°¡ Á¤¼öÀΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_int (mixed var);

    This function is an alias for is_long().

    See also is_bool(), is_double(), is_float(), is_integer(), is_string(), is_real(), is_object(), is_array(), and is_long().

    is_integer

    is_integer -- º¯¼ö°¡ Á¤¼öÀΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_integer (mixed var);

    This function is an alias for is_long().

    See also is_bool(), is_double(), is_float(), is_int(), is_string(), is_real(), is_object(), is_array(), and is_long().

    is_long

    is_long -- º¯¼ö°¡ Á¤¼öÀΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_long (mixed var);

    Returns true if var is an integer (long), false otherwise.

    See also is_bool(), is_double(), is_float(), is_int(), is_real(), is_string(), is_object(), is_array(), and is_integer().

    is_numeric

    (PHP4 >= 4.0RC1)

    is_numeric -- º¯¼ö°¡ ¼ýÀÚ È¤Àº ¼ýÀÚ¸¦ Ç¥ÇöÇÏ´Â ¹®ÀÚ¿­Àΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_numeric (mixed var)

    Returns true if var is a number or a numeric string, false otherwise.

    See also is_bool(), is_double(), is_float(), is_int(), is_real(), is_string(), is_object(), is_array(), and is_integer().

    is_object

    is_object -- º¯¼ö°¡ °´Ã¼(object)Àΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_object (mixed var)

    Returns true if var is an object, false otherwise.

    See also is_bool(), is_long(), is_int(), is_integer(), is_float(), is_double(), is_real(), is_string(), and is_array().

    is_real

    is_real -- º¯¼ö°¡ ½Ç¼öÀΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_real (mixed var)

    This function is an alias for is_double().

    See also is_bool(), is_long(), is_int(), is_integer(), is_float(), is_double(), is_object(), is_string(), and is_array().

    is_resource

    (PHP4 >= 4.0b4)

    is_resource -- º¯¼ö°¡ ÀÚ¿ø(resource)À» °¡Áö°í Àִ°¡ °Ë»çÇÑ´Ù.

    Description

    int is_resource (mixed var)

    is_resource() returns true if the variable given by the var parameter is a resource, otherwise it returns false.

    Resources are things like file or database result handles that are allocated and freed by internal PHP functions and that may need some cleanup when they are no longer in use but haven't been freed by user code.

    is_string

    is_string -- º¯¼ö°¡ ¹®ÀÚ¿­Àΰ¡ °Ë»çÇÑ´Ù.

    Description

    int is_string (mixed var)

    Returns true if var is a string, false otherwise.

    See also is_bool(), is_long(), is_int(), is_integer(), is_float(), is_double(), is_real(), is_object(), and is_array().

    isset

    isset -- º¯¼ö¿¡ °ªÀÌ Àִ°¡ °Ë»çÇÑ´Ù.

    Description

    int isset (mixed var)

    Returns true if var exists; false otherwise.

    If a variable has been unset with unset(), it will no longer be isset().

      1 
      2 $a = "test";
      3 echo isset ($a); // true
      4 unset ($a);
      5 echo isset ($a); // false
      6       

    See also empty() and unset().

    print_r

    (PHP4 )

    print_r -- º¯¼ö°ªÀ» »ç¶÷ÀÌ ÀÐÀ» ¼ö ÀÖ´Â ÇüÅ·Π¹Ù²Ù¾î Ãâ·ÂÇÑ´Ù.

    Description

    void print_r (mixed expression)

    This function displays information about the values of variables in a way that's readable by humans. If given a string, integer or double, the value itself will be printed. If given an array, values will be presented in a format that shows keys and elements. Similar notation is used for objects.

    Compare print_r() to var_dump().

      1 
      2 <?php
      3 $a = array (1, 2, array ("a", "b", "c"));
      4 print_r ($a);
      5 ?>
      6       
    Warning

    This function will continue forever if given an array or object that contains a direct or indirect reference to itself or that contains an array or object on a deepre level that does so. This is especially true for print_r($GLOBALS), as $GLOBALS is itself a global variable and contains a reference to itself as such.

    settype

    settype -- º¯¼öÀÇ typeÀ» ¼³Á¤ÇÑ´Ù.

    Description

    int settype (string var, string type)

    Set the type of variable var to type.

    Possibles values of type are:

    Returns true if successful; otherwise returns false.

    See also gettype().

    strval

    strval -- º¯¼öÀÇ °ªÀ» ¹®ÀÚ¿­·Î ¸¸µç´Ù.

    Description

    string strval (mixed var)

    Returns the string value of var.

    var may be any scalar type. You cannot use strval() on arrays or objects.

    See also doubleval(), intval(), settype() and Type juggling.

    unset

    unset -- º¯¼ö¸¦ UnsetÇÑ´Ù.

    Description

    int unset (mixed var)

    unset() destroys the specified variable and returns true.

    Example 1. Unset() example

      1 
      2 unset ($foo);
      3 unset ($bar['quux']);
      4       

    See also isset() and empty().

    var_dump

    (PHP3 >= 3.0.5, PHP4 )

    var_dump -- Dumps information about a variable

    Description

    void var_dump (mixed expression)

    This function returns structured information about an expression that includes its type and value. Arrays are explored recursively with values indented to show structure.

    Compare var_dump() to print_r().

      1 
      2 <pre>
      3 <?php
      4     $a = array (1, 2, array ("a", "b", "c"));
      5     var_dump ($a);
      6 ?>
      7 </pre>
      8       

    LX. Vmailmgr functions

    ÀÌ ÇÔ¼öµéÀº QMAIL (www.qmail.org) °ú vmailmgr ÆÐÅ°Áö¸¦ ÇÊ¿ä·Î ÇÑ´Ù. ÀÌ ÆÐÅ°Áö´Â Bruce Guenter¿¡ ÀÇÇØ Á¦°øµÇ°í ÀÖ°í http://www.qcc.sk.ca/~bguenter/distrib/vmailmgr/ ¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.

    ¾Æ·¡ÀÇ ÇÔ¼öµé¿¡¼­´Â µÎ °³ÀÇ º¯¼ö°¡ Á¤ÀǵǾî ÀÖ´Ù : ¿©·¯ºÐÀÇ °¡»ó domain (vdomain.com)ÀÇ µµ¸ÞÀÎ À̸§À» °ªÀ¸·Î °¡Áö´Â vdomainÀ̶ó´Â string º¯¼ö¿Í, °¡»ó userµéÀ» °¡Áö°í ÀÖ´Â 'ÁøÂ¥(real)' userÀÇ password¸¦ °ªÀ¸·Î °¡Áö´Â basepwd¶ó´Â string º¯¼öÀÌ´Ù.

    °¡»ó userµéÀÇ password´Â 8ÀÚ±îÁö¸¸ ÀÎ½ÄµÇ°í ±× ÀÌÈÄ´Â ¹«½ÃµÈ´Ù.

    ¸ðµç ÇÔ¼öµéÀÇ return »óÅ´ response.h ¿¡ ´ÙÀ½°ú °°ÀÌ Á¤ÀǵǾî ÀÖ´Ù.

    O ok

    1 bad

    2 error

    3 error connecting

    ¾Ë·ÁÁø ¹®Á¦µé: vm_deluser()´Â »ç¿ëÀÚÀÇ directory¸¦ Áö¿ìÁö ¾Ê´Â´Ù. vm_addalias()´Â ÇöÀç Á¦´ë·Î µ¿ÀÛÇÏÁö ¾Ê´Â´Ù.

      1 
      2 <?php
      3 dl("php3_vmailmgr.so"); //load the shared library
      4 $vdomain="vdomain.com";
      5 $basepwd="password";
      6 ?>
      7       
    Table of Contents
    vm_adduser ¡¦ Add a new virtual user with a password
    vm_addalias ¡¦ Add an alias to a virtual user
    vm_passwd ¡¦ Changes a virtual users password
    vm_delalias ¡¦ Removes an alias
    vm_deluser ¡¦ Removes a virtual user

    vm_adduser

    vm_adduser -- ÁÖ¾îÁø password·Î »õ virtual user¸¦ ¸¸µç´Ù.

    Description

    int vm_adduser (string vdomain, string basepwd, string newusername, string newuserpassword)

    Add a new virtual user with a password. newusername is the email login name and newuserpassword the password for this user.

    vm_addalias

    vm_addalias -- virtual user¿¡ alias¸¦ Ãß°¡ÇÑ´Ù.

    Description

    int vm_addalias (string vdomain, string basepwd, string username, string alias);

    Add an alias to a virtual user. username is the email login name and alias is an alias for this vuser.

    vm_passwd

    vm_passwd -- virtual userÀÇ password¸¦ º¯°æÇÑ´Ù.

    Description

    int vm_passwd (string vdomain, string username, string password, string newpassword)

    Changes a virtual users password. username is the email login name, password the old password for the vuser, and newpassword the new password.

    vm_delalias

    vm_delalias -- alias¸¦ Áö¿î´Ù.

    Description

    int vm_delalias (string vdomain, string basepwd, string alias)

    Removes an alias.

    vm_deluser

    vm_deluser -- virtual user¸¦ »èÁ¦ÇÑ´Ù.

    Description

    int vm_deluser (string vdomain, string username)

    Removes a virtual user.


    LXI. WDDX functions

    ÀÌ ÇÔ¼öµéÀº WDDX¿Í ÇÔ²² µ¿ÀÛÇϵµ·Ï µÇ¾îÀÖ´Ù.

    º¯¼ö¸¦ ³ª¿­(serialize)ÇÏ´Â ¸ðµç ÇÔ¼öµéÀº, ¹è¿­ÀÇ Ã¹ ¹ø° ¿ø¼Ò·Î ÇØ´ç ¹è¿­ÀÌ ´Ù¸¥ ¹è¿­·Î ³ª¿­(serialize)µÉ °ÍÀÎÁö, ±¸Á¶Ã¼(structure)·Î ³ª¿­µÉ °ÍÀΰ¡¸¦ °áÁ¤ÇÑ´Ù. ù¹ø° ¿ø¼Ò°¡ ¹®ÀÚ¿­ Å°¸¦ °¡Áö°í ÀÖÀ¸¸é ±¸Á¶Ã¼·Î ³ª¿­µÇ°í, ±×·¸Áö ¾Ê´Ù¸é ¹è¿­·Î ³ª¿­µÈ´Ù.

    Note that all the functions that serialize variables use the first element of an array to determine whether the array is to be serialized into an array or structure. If the first element has string key, then it is serialized into a structure, otherwise, into an array.

    Example 1. Serializing a single value

      1 
      2 <?php
      3 print wddx_serialize_value("PHP to WDDX packet example", "PHP packet");
      4 ?>
      5      

    À§ÀÇ ¿¹Á¦´Â ´ÙÀ½°ú °°Àº ³»¿ëÀ» Ãâ·ÂÇÑ´Ù.:

      1 
      2 <wddxPacket version='0.9'><header comment='PHP packet'/><data>
      3 <string>PHP to WDDX packet example</string></data></wddxPacket>
      4      

     

    Example 2. Using incremental packets

      1 
      2 <?php
      3 $pi = 3.1415926;
      4 $packet_id = wddx_packet_start("PHP");
      5 wddx_add_vars($packet_id, "pi");
      6 
      7 /* Suppose $cities came from database */
      8 $cities = array("Austin", "Novato", "Seattle");
      9 wddx_add_vars($packet_id, "cities");
     10 
     11 $packet = wddx_packet_end($packet_id);
     12 print $packet;
     13 ?>
     14      

    À§ÀÇ ¿¹Á¦´Â ´ÙÀ½°ú °°Àº ³»¿ëÀ» Ãâ·ÂÇÑ´Ù.:

      1 
      2 <wddxPacket version='0.9'><header comment='PHP'/><data><struct>
      3 <var name='pi'><number>3.1415926</number></var><var name='cities'>
      4 <array length='3'><string>Austin</string><string>Novato</string>
      5 <string>Seattle</string></array></var></struct></data></wddxPacket>
      6      
    Table of Contents
    wddx_serialize_value ¡¦ Serialize a single value into a WDDX packet
    wddx_serialize_vars ¡¦ Serialize variables into a WDDX packet
    wddx_packet_start ¡¦ Starts a new WDDX packet with structure inside it
    wddx_packet_end ¡¦ Ends a WDDX packet with the specified ID
    wddx_add_vars ¡¦ Ends a WDDX packet with the specified ID
    wddx_deserialize ¡¦ Deserializes a WDDX packet

    wddx_serialize_value

    wddx_serialize_value -- WDDX  ÆÐÄÏ¿¡ ´ÜÀÏ °ªÀ» serialize ÇÑ´Ù.

    Description

    string wddx_serialize_value (mixed var, string [comment]);

    wddx_serialize_value() is used to create a WDDX packet from a single given value. It takes the value contained in var, and an optional comment string that appears in the packet header, and returns the WDDX packet.

    wddx_serialize_vars

    wddx_serialize_vars -- WDDX  ÆÐÄÏ¿¡ ¿©·¯ º¯¼ö¸¦ serialize ÇÑ´Ù.

    Description

    string wddx_serialize_vars (mixed var_name [, mixed ...])

    wddx_serialize_vars() is used to create a WDDX packet with a structure that contains the serialized representation of the passed variables.

    wddx_serialize_vars() takes a variable number of arguments, each of which can be either a string naming a variable or an array containing strings naming the variables or another array, etc.

    Example 1. wddx_serialize_vars example

      1 
      2 <?php
      3 $a = 1;
      4 $b = 5.5;
      5 $c = array("blue", "orange", "violet");
      6 $d = "colors";
      7 
      8 $clvars = array("c", "d");
      9 print wddx_serialize_vars("a", "b", $clvars);
     10 ?>
     11       

    The above example will produce:

      1 
      2 <wddxPacket version='0.9'><header/><data><struct><var name='a'><number>1</number></var>
      3 <var name='b'><number>5.5</number></var><var name='c'><array length='3'>
      4 <string>blue</string><string>orange</string><string>violet</string></array></var>
      5 <var name='d'><string>colors</string></var></struct></data></wddxPacket>
      6      

    wddx_packet_start

    wddx_packet_start -- ³»ºÎ¿¡ ÀÖ´Â ±¸Á¶´ë·Î »õ·Î¿î WDDX ÆÐÄÏÀ» ¸¸µç´Ù.

    Description

    int wddx_packet_start (string [comment]);

    Use wddx_packet_start() to start a new WDDX packet for incremental addition of variables. It takes an optional comment string and returns a packet ID for use in later functions. It automatically creates a structure definition inside the packet to contain the variables.

    wddx_packet_end

    wddx_packet_end -- ÁöÁ¤µÈ IDÀÇ WDDX ÆÐÄÏÀ» Á¾·áÇÑ´Ù.

    Description

    int wddx_packet_end (int packet_id);

    wddx_packet_end() ends the WDDX packet specified by the packet_id and returns the string with the packet.

    wddx_add_vars

    wddx_add_vars -- ÇØ´çÇÏ´Â ÆÐÄÏ¿¡ Ãß°¡·Î º¯¼öµéÀ» serializeÇÑ´Ù.

    Description

    wddx_add_vars (int packet_id, ...);

    wddx_add_vars() is used to serialize passed variables and add the result to the packet specified by the packet_id. The variables to be serialized are specified in exactly the same way as wddx_serialize_vars().

    wddx_deserialize

    wddx_deserialize -- WDDX ÆÐÄÏÀ» deserialize ÇÑ´Ù.

    Description

    mixed wddx_deserialize (string packet);

    wddx_deserialized() takes a packet string and deserializes it. It returns the result which can be string, number, or array. Note that structures are deserialized into associative arrays.


    LXII. XML Parser functions

    ¼Ò°³ (Introduction)

    XML¿¡ ´ëÇÏ¿© (About XML)

    XML(eXtensible Markup Language)À̶õ À¥¿¡¼­ ±³È¯µÇ´Â ¹®¼­¸¦ À§ÇÑ µ¥ÀÌÅÍ Æ÷¸ËÀÇ ÇϳªÀÌ´Ù. ÀÌ°ÍÀº W3C(World Wide Web consortium)¿¡ ÀÇÇØ ±ÔÁ¤µÈ Ç¥ÁØÀÌ´Ù. XML¿¡ ´ëÇÑ Á¤º¸¿Í ±×¿¡ °ü·ÃµÈ ±â¼úµéÀº http://www.w3.org/XML/¿¡¼­ ã¾Æº¼ ¼ö ÀÖÀ» °ÍÀÌ´Ù.


    ¼³Ä¡ (Installation)

    ÀÌ È®ÀåÀº http://www.jclark.com/xml/¿¡¼­ ãÀ» ¼ö ÀÖ´Â expat¶ó´Â °ÍÀ» »ç¿ëÇÏ°í ÀÖ´Ù. expact¿Í ÇÔ²² µû¶ó¿À´Â MakefileÀº ±×´ë·Î´Â ¶óÀ̺귯¸®¸¦ ¸¸µé¾î ³»Áö ¸øÇÑ´Ù. ´ÙÀ½°ú °°Àº make ruleÀ» »ç¿ëÇØ¾ß °¡´ÉÇØ Áø´Ù. :

      1 
      2 libexpat.a: $(OBJS)
      3 	ar -rc $@ $(OBJS)
      4 	ranlib $@
      5       

    expactÀÇ ¼Ò½º RPM ÆÐÅ°Áö´Â http://www.guardian.no/~ssb/phpxml.html¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.

    À¯´Ð½º¿¡¼­´Â configure¸¦ --with-xml ¿É¼ÇÀ» ÁÖ¾î ½ÇÇàÇÑ´Ù. expat ¶óÀ̺귯¸®´Â ¿©·¯ºÐÀÇ ÄÄÆÄÀÏ·¯°¡ ±âº»ÀûÀ¸·Î ãÀ» ¼ö ÀÖ´Â °÷¿¡ ¼³Ä¡µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù. ¸¸¾à ¼³Ä¡ÇÑ expact°¡ ÄÄÆÄÀÏ·¯°¡ ãÀ» ¼ö ¾ø´Â °÷¿¡ ÀÖ´Ù¸é configure¸¦ ½ÇÇàÇϱâ Àü¿¡ ȯ°æº¯¼ö CPPFLAGS¿Í LDFLAGS¸¦ ¿©·¯ºÐÀÇ È¯°æ¿¡¼­ ÇØ´ç °ªÀ¸·Î ¼³Á¤ÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.

    ÀÌÁ¦ PHP¸¦ ÄÄÆÄÀÏÇÏ¸é µÈ´Ù.


    ÀÌ È®Àå¿¡ ´ëÇÏ¿© (About This Extension)

    ÀÌ È®ÀåÀº PHP¿¡¼­ James ClarkÀÇ expat¸¦ Áö¿øÇϵµ·Ï ÇØ ÁØ´Ù. ÀÌ ToolkitÀº ¿©·¯ºÐÀÌ XMLÀ» Çؼ®(parse)Çϵµ·Ï ÇÏÁö¸¸, À¯È¿ÇÑ°¡(validate)´Â È®ÀÎÇÏÁö ¾Ê´Â´Ù. ÀÌ È®ÀåÀº PHP°¡ Á¦°øÇÏ´Â ¼¼°¡Áö ¹®ÀÚ ÇüÅÂ(character encodings)¸¦ Áö¿øÇÑ´Ù. US-ASCII¿Í ISO-8859-1, UTF-8ÀÌ °¡´ÉÇÏ´Ù. UTF-16Àº Áö¿øÇÏÁö ¾Ê´Â´Ù.

    ÀÌ È®ÀåÀ¸·Î ¿©·¯ºÐÀº XML Æļ­¸¦ ¸¸µé°í(create XML parsers), ¼­·Î´Ù¸¥ XML event¿¡ ´ëÇØ handlers¸¦ Á¤ÀÇÇÑ´Ù. °¢°¢ÀÇ XML Æļ­´Â ¿©·¯ºÐÀÌ Á¶Á¤°¡´ÉÇÑ ¸î °³ÀÇ parameters¸¦ °¡Áö°í ÀÖ´Ù.

    Á¦°øµÇ´Â XML event handlers´Â ´ÙÀ½°ú °°´Ù. :

    Table 1. Supported XML handlers

    PHP function to set handler

    Event description

    xml_set_element_handler()

    Element events are issued whenever the XML parser encounters start or end tags. There are separate handlers for start tags and end tags.

    xml_set_character_data_handler()

    Character data is roughly all the non-markup contents of XML documents, including whitespace between tags. Note that the XML parser does not add or remove any whitespace, it is up to the application (you) to decide whether whitespace is significant.

    xml_set_processing_instruction_handler()

    PHP programmers should be familiar with processing instructions (PIs) already. <?php ?> is a processing instruction, where php is called the "PI target". The handling of these are application-specific, except that all PI targets starting with "XML" are reserved.

    xml_set_default_handler()

    What goes not to another handler goes to the default handler. You will get things like the XML and document type declarations in the default handler.

    xml_set_unparsed_entity_decl_handler()

    This handler will be called for declaration of an unparsed (NDATA) entity.

    xml_set_notation_decl_handler()

    This handler is called for declaration of a notation.

    xml_set_external_entity_ref_handler()

    This handler is called when the XML parser finds a reference to an external parsed general entity. This can be a reference to a file or URL, for example. See the external entity example for a demonstration.


    Case °ãÄ¡±â (Case Folding)

    element handler ÇÔ¼öµéÀº ±×µéÀÇ ¿ä¼Ò¸¦ case-foldedÇÏ°Ô ¾ò´Â´Ù. Case-foldingÀº XML Ç¥ÁØ¿¡ ´ÙÀ½°ú °°ÀÌ Á¤ÀǵǾî ÀÖ´Ù. : "a process applied to a sequence of characters, in which those identified as non-uppercase are replaced by their uppercase equivalents" (ÀÏ·ÃÀÇ ¹®Àڵ鿡¼­ ´ë¹®ÀÚ°¡ ¾Æ´Ñ ±ÛÀÚµéÀ» ´ë¹®ÀÚ¿Í µ¿ÀÏÇÏ°Ô ´Ù·ç´Â ¹æ¹ý). ´Ù¸¥ ¸»·Î Çϸé case-foldingÀ̶õ ´Ü¼øÈ÷ uppercasingÀ» ÀǹÌÇÑ´Ù.

    ±âº»ÀûÀ¸·Î, handler ÇÔ¼ö¿¡ Àü´ÞµÇ´Â ¸ðµç ¿ä¼ÒµéÀÇ À̸§Àº case-foldedÇÏ´Ù. case-folded ¼³Á¤Àº xml_parser_get_option()°ú xml_parser_set_option() ÇÔ¼ö·Î XML Æļ­¿¡ ´ëÇØ ÁúÀÇÇϰųª ¿øÇÏ´Â ´ë·Î ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.


    Error Codes

    ´ÙÀ½ÀÇ »ó¼öµéÀÌ XML ¿¡·¯ ÄÚµå·Î Á¤ÀǵǾî ÀÖ´Ù. (xml_parse()ÀÇ ¹Ýȯ°ªÀÌ´Ù.)

    XML_ERROR_NONE

    XML_ERROR_NO_MEMORY

    XML_ERROR_SYNTAX

    XML_ERROR_NO_ELEMENTS

    XML_ERROR_INVALID_TOKEN

    XML_ERROR_UNCLOSED_TOKEN

    XML_ERROR_PARTIAL_CHAR

    XML_ERROR_TAG_MISMATCH

    XML_ERROR_DUPLICATE_ATTRIBUTE

    XML_ERROR_JUNK_AFTER_DOC_ELEMENT

    XML_ERROR_PARAM_ENTITY_REF

    XML_ERROR_UNDEFINED_ENTITY

    XML_ERROR_RECURSIVE_ENTITY_REF

    XML_ERROR_ASYNC_ENTITY

    XML_ERROR_BAD_CHAR_REF

    XML_ERROR_BINARY_ENTITY_REF

    XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF

    XML_ERROR_MISPLACED_XML_PI

    XML_ERROR_UNKNOWN_ENCODING

    XML_ERROR_INCORRECT_ENCODING

    XML_ERROR_UNCLOSED_CDATA_SECTION

    XML_ERROR_EXTERNAL_ENTITY_HANDLING


    Character Encoding

    PHPÀÇ XML È®ÀåÀº ¼­·Î ´Ù¸¥ character encodingµéÀ» À§ÇØ Unicode character setÀ» Áö¿øÇÑ´Ù. character encoding¿¡´Â source encoding°ú target encodingÀÇ µÎ°¡Áö À¯ÇüÀÌ ÀÖ´Ù. Âü°í·Î PHP´Â ³»ºÎÀûÀ¸·Î ¸ðµç ¹®¼­¸¦ UTF-8À¸·Î encodeÇÏ°í ÀÖ´Ù.

    Source encodingÀº XML ¹®¼­°¡ Çؼ®(parse)µÉ ¶§ ÀϾ´Ù. XML Æļ­¸¦ ¸¸µé ¶§(Upon creating an XML parser), source encodingÀº ÁöÁ¤µÉ ¼ö ÀÖ´Ù. (ÀÌ encodingÀº ÇØ´ç XML Æļ­°¡ ¾ø¾îÁú ¶§ ±îÁö º¯°æµÉ ¼ö ¾ø´Ù.) Áö¿øµÇ´Â source encodingÀº ISO-8859-1¿Í US-ASCII, UTF-8ÀÇ ¼¼°¡Áö ÀÌ´Ù. ¾ÕÀÇ µÎ°¡Áö´Â single-byte encodingÀÌ´Ù. ÀÌ°ÍÀº °¢°¢ÀÇ ¹®ÀÚ°¡ 1°³ÀÇ byte·Î Ç¥ÇöµÈ´Ù´Â ÀǹÌÀÌ´Ù. UTF-8Àº 1 ¹ÙÀÌÆ®¿¡¼­ 4 ¹ÙÀÌÆ®(21ºñÆ®)±îÁö º¯°æ°¡´ÉÇÑ ¼öÀÇ ºñÆ®¼ö·Î ±¸¼ºµÈ ¹®ÀÚ·Î encodeÇÑ´Ù. PHP¿¡¼­ ±âº» source encodingÀº ISO-8859-1ÀÌ´Ù.

    Target encodingÀº PHP°¡ XML handler ÇÔ¼ö·Î µ¥ÀÌÅ͸¦ ³Ñ°ÜÁÙ ¶§ ÀϾ´Ù. XML Æļ­°¡ »ý¼ºµÉ ¶§ target encodingÀº source encoding°ú °°Àº °ªÀ¸·Î ¼³Á¤µÇÁö¸¸, ±× °ªÀº ³ªÁß¿¡ ¾ðÁ¦¶óµµ ¹Ù²Ü ¼ö ÀÖ´Ù. target encodingÀº ¹®ÀÚ µ¥ÀÌÅÍ»Ó ¾Æ´Ï¶ó, tag À̸§À̳ª processing instruction targets¿¡µµ Àû¿ëµÈ´Ù.

    ¸¸¾à XML Æļ­°¡ ±×°ÍÀÇ source encodingÀÌ Ç¥ÇöÇÒ ¼ö ¾ø´Â ¹üÀ§¿¡ ÀÖ´Â ¹®ÀÚ¸¦ ¸¸³­´Ù¸é, Æļ­´Â ¿¡·¯¸¦ ¹ÝȯÇÑ´Ù.

    PHP°¡ Çؼ®µÈ(parsed) ¹®¼­Áß¿¡¼­ ¼±ÅÃµÈ target encoding¾È¿¡¼­ Ç¥ÇöÀÌ ºÒ°¡´ÉÇÑ ¹®ÀÚ¸¦ ¸¸³µ´Ù¸é, ÀÌ ¹®Á¦°¡ µÈ ¹®ÀÚ¸¦ "demoted"ÇÑ´Ù. ÇöÀç ±×·± ¹®ÀÚµéÀº ¹°À½Ç¥(?)·Î ´ëÄ¡µÈ´Ù.


    Some Examples

    ¿©±â¿¡ XML ¹®¼­¸¦ Çؼ®ÇÏ´Â PHP ½ºÅ©¸³Æ® ¿¹Á¦°¡ ÀÖ´Ù.

    XML Element Structure Example

    ¹®¼­¿¡¼­ ½ÃÀÛ ¿ä¼ÒµéÀÇ ±¸Á¶¸¦ indentationÇÏ¿© Ç¥½ÃÇÏ´Â ¿¹Á¦. :

    Example 1. Show XML Element Structure

      1 
      2 $file = "data.xml";
      3 $depth = array();
      4 
      5 function startElement($parser, $name, $attrs) {
      6     global $depth;
      7     for ($i = 0; $i < $depth[$parser]; $i++) {
      8         print "  ";
      9     }
     10     print "$name\n";
     11     $depth[$parser]++;
     12 }
     13 
     14 function endElement($parser, $name) {
     15     global $depth;
     16     $depth[$parser]--;
     17 }
     18 
     19 $xml_parser = xml_parser_create();
     20 xml_set_element_handler($xml_parser, "startElement", "endElement");
     21 if (!($fp = fopen($file, "r"))) {
     22     die("could not open XML input");
     23 }
     24 
     25 while ($data = fread($fp, 4096)) {
     26     if (!xml_parse($xml_parser, $data, feof($fp))) {
     27         die(sprintf("XML error: %s at line %d",
     28                     xml_error_string(xml_get_error_code($xml_parser)),
     29                     xml_get_current_line_number($xml_parser)));
     30     }
     31 }
     32 xml_parser_free($xml_parser);
     33        

    XML Tag Mapping Example

    Example 2. Map XML to HTML

    ÀÌ ¿¹Á¦´Â XML¹®¼­ÀÇ ÅÃÀ» Á÷Á¢ÀûÀ¸·Î HTML ÅÃÀ¸·Î mapÇÑ´Ù. "map array"¿¡¼­ ãÀ» ¼ö ¾ø´Â ¿ä¼Ò´Â ¹«½ÃµÈ´Ù. ¹°·Ð, ÀÌ ¿¹Á¦´Â ƯÁ¤ÇÑ ¹®¼­ ŸÀÔ¿¡¼­¸¸ µ¿ÀÛÇÑ´Ù.

      1 
      2 $file = "data.xml";
      3 $map_array = array(
      4     "BOLD"     => "B",
      5     "EMPHASIS" => "I",
      6     "LITERAL"  => "TT"
      7 );
      8 
      9 function startElement($parser, $name, $attrs) {
     10     global $map_array;
     11     if ($htmltag = $map_array[$name]) {
     12         print "<$htmltag>";
     13     }
     14 }
     15 
     16 function endElement($parser, $name) {
     17     global $map_array;
     18     if ($htmltag = $map_array[$name]) {
     19         print "</$htmltag>";
     20     }
     21 }
     22 
     23 function characterData($parser, $data) {
     24     print $data;
     25 }
     26 
     27 $xml_parser = xml_parser_create();
     28 // use case-folding so we are sure to find the tag in $map_array
     29 xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
     30 xml_set_element_handler($xml_parser, "startElement", "endElement");
     31 xml_set_character_data_handler($xml_parser, "characterData");
     32 if (!($fp = fopen($file, "r"))) {
     33     die("could not open XML input");
     34 }
     35 
     36 while ($data = fread($fp, 4096)) {
     37     if (!xml_parse($xml_parser, $data, feof($fp))) {
     38         die(sprintf("XML error: %s at line %d",
     39                     xml_error_string(xml_get_error_code($xml_parser)),
     40                     xml_get_current_line_number($xml_parser)));
     41     }
     42 }
     43 xml_parser_free($xml_parser);
     44 	

    XML External Entity Example

    ÀÌ ¿¹Á¦´Â XML ÄÚµåÀÇ ÇÏÀ̶óÀÌÆ®ÀÌ´Ù. ÀÌ°ÍÀº ´Ù¸¥ ¹®¼­¸¦ Æ÷ÇÔ(include)ÇÏ°í Çؼ®(parse)Çϱâ À§ÇØ external entity reference handler¸¦ ¾î¶»°Ô »ç¿ëÇϴ°¡ º¸¿©ÁÖ°í, ¾î¶»°Ô PI(processing instruction)°¡ ¼öÇàµÇ°í, PI°¡ ´ã°í ÀÖ´Â ÄÚµåÀÇ "½Å·Ú(trust)"¸¦ °áÁ¤ÇÏ´Â °¡¿¡ ´ëÇÑ ¹æ¹ýÀ» º¸¿©ÁØ´Ù.

    ÀÌ ¿¹Á¦¸¦ »ç¿ëÇϱâ À§ÇÑ XML ¹®¼­´Â ¾Æ·¡ ¿¹Á¦¿¡¼­ ãÀ» ¼ö ÀÖ´Ù. (xmltest.xml¿Í xmltest2.xml.)

    Example 3. External Entity Example

      1 
      2 $file = "xmltest.xml";
      3 
      4 function trustedFile($file) {
      5     // only trust local files owned by ourselves
      6     if (!eregi("^([a-z]+)://", $file) 
      7         && fileowner($file) == getmyuid()) {
      8             return true;
      9     }
     10     return false;
     11 }
     12 
     13 function startElement($parser, $name, $attribs) {
     14     print "&lt;<font color=\"#0000cc\">$name</font>";
     15     if (sizeof($attribs)) {
     16         while (list($k, $v) = each($attribs)) {
     17             print " <font color=\"#009900\">$k</font>=\"<font 
     18                    color=\"#990000\">$v</font>\"";
     19         }
     20     }
     21     print "&gt;";
     22 }
     23 
     24 function endElement($parser, $name) {
     25     print "&lt;/<font color=\"#0000cc\">$name</font>&gt;";
     26 }
     27 
     28 function characterData($parser, $data) {
     29     print "<b>$data</b>";
     30 }
     31 
     32 function PIHandler($parser, $target, $data) {
     33     switch (strtolower($target)) {
     34         case "php":
     35             global $parser_file;
     36             // If the parsed document is "trusted", we say it is safe
     37             // to execute PHP code inside it.  If not, display the code
     38             // instead.
     39             if (trustedFile($parser_file[$parser])) {
     40                 eval($data);
     41             } else {
     42                 printf("Untrusted PHP code: <i>%s</i>", 
     43                         htmlspecialchars($data));
     44             }
     45             break;
     46     }
     47 }
     48 
     49 function defaultHandler($parser, $data) {
     50     if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") {
     51         printf('<font color="#aa00aa">%s</font>', 
     52                 htmlspecialchars($data));
     53     } else {
     54         printf('<font size="-1">%s</font>', 
     55                 htmlspecialchars($data));
     56     }
     57 }
     58 
     59 function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId,
     60                                   $publicId) {
     61     if ($systemId) {
     62         if (!list($parser, $fp) = new_xml_parser($systemId)) {
     63             printf("Could not open entity %s at %s\n", $openEntityNames,
     64                    $systemId);
     65             return false;
     66         }
     67         while ($data = fread($fp, 4096)) {
     68             if (!xml_parse($parser, $data, feof($fp))) {
     69                 printf("XML error: %s at line %d while parsing entity %s\n",
     70                        xml_error_string(xml_get_error_code($parser)),
     71                        xml_get_current_line_number($parser), $openEntityNames);
     72                 xml_parser_free($parser);
     73                 return false;
     74             }
     75         }
     76         xml_parser_free($parser);
     77         return true;
     78     }
     79     return false;
     80 }
     81 
     82 
     83 function new_xml_parser($file) {
     84     global $parser_file;
     85 
     86     $xml_parser = xml_parser_create();
     87     xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1);
     88     xml_set_element_handler($xml_parser, "startElement", "endElement");
     89     xml_set_character_data_handler($xml_parser, "characterData");
     90     xml_set_processing_instruction_handler($xml_parser, "PIHandler");
     91     xml_set_default_handler($xml_parser, "defaultHandler");
     92     xml_set_external_entity_ref_handler($xml_parser, "externalEntityRefHandler");
     93     
     94     if (!($fp = @fopen($file, "r"))) {
     95         return false;
     96     }
     97     if (!is_array($parser_file)) {
     98         settype($parser_file, "array");
     99     }
    100     $parser_file[$xml_parser] = $file;
    101     return array($xml_parser, $fp);
    102 }
    103 
    104 if (!(list($xml_parser, $fp) = new_xml_parser($file))) {
    105     die("could not open XML input");
    106 }
    107 
    108 print "<pre>";
    109 while ($data = fread($fp, 4096)) {
    110     if (!xml_parse($xml_parser, $data, feof($fp))) {
    111         die(sprintf("XML error: %s at line %d\n",
    112                     xml_error_string(xml_get_error_code($xml_parser)),
    113                     xml_get_current_line_number($xml_parser)));
    114     }
    115 }
    116 print "</pre>";
    117 print "parse complete\n";
    118 xml_parser_free($xml_parser);
    119 
    120 ?>
    121        

    Example 4. xmltest.xml

      1 
      2 <?xml version='1.0'?>
      3 <!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [
      4 <!ENTITY plainEntity "FOO entity">
      5 <!ENTITY systemEntity SYSTEM "xmltest2.xml">
      6 ]>
      7 <chapter>
      8  <TITLE>Title &plainEntity;</TITLE>
      9  <para>
     10   <informaltable>
     11    <tgroup cols="3">
     12     <tbody>
     13      <row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row>
     14      <row><entry>a2</entry><entry>c2</entry></row>
     15      <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
     16     </tbody>
     17    </tgroup>
     18   </informaltable>
     19  </para>
     20  &systemEntity;
     21  <sect1 id="about">
     22   <title>About this Document</title>
     23   <para>
     24    <!-- this is a comment -->
     25    <?php print 'Hi!  This is PHP version '.phpversion(); ?>
     26   </para>
     27  </sect1>
     28 </chapter>
     29        

    ÀÌ ÆÄÀÏÀº xmltest.xml¿¡ Æ÷ÇÔ(include)µÈ´Ù.

    Example 5. xmltest2.xml

      1 
      2 <?xml version="1.0"?>
      3 <!DOCTYPE foo [
      4 <!ENTITY testEnt "test entity">
      5 ]>
      6 <foo>
      7    <element attrib="value"/>
      8    &testEnt;
      9    <?php print "This is some more PHP code being executed."; ?>
     10 </foo>
     11        

    Table of Contents
    xml_parser_create ¡¦ create an XML parser
    xml_set_object ¡¦ Use XML Parser withing an object
    xml_set_element_handler ¡¦ set up start and end element handlers
    xml_set_character_data_handler ¡¦ set up character data handler
    xml_set_processing_instruction_handler ¡¦ set up processing instruction (PI) handler
    xml_set_default_handler ¡¦ set up default handler
    xml_set_unparsed_entity_decl_handler ¡¦ set up unparsed entity declaration handler
    xml_set_notation_decl_handler ¡¦ set up notation declaration handler
    xml_set_external_entity_ref_handler ¡¦ set up external entity reference handler
    xml_parse ¡¦ start parsing an XML document
    xml_get_error_code ¡¦ get XML parser error code
    xml_error_string ¡¦ get XML parser error string
    xml_get_current_line_number ¡¦ get current line number for an XML parser
    xml_get_current_column_number ¡¦ get current column number for an XML parser
    xml_get_current_byte_index ¡¦ get current byte index for an XML parser
    xml_parser_free ¡¦ free an XML parser
    xml_parser_set_option ¡¦ set options in an XML parser
    xml_parser_get_option ¡¦ get options from an XML parser
    utf8_decode ¡¦ Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1.
    utf8_encode ¡¦ encodes an ISO-8859-1 string to UTF-8

    xml_parser_create

    xml_parser_create -- XML parser¸¦ ¸¸µç´Ù.

    Description

    int xml_parser_create ([string encoding])

    encoding (optional)

    Which character encoding the parser should use. The following character encodings are supported:

    ISO-8859-1 (default)

    US-ASCII

    UTF-8

    This function creates an XML parser and returns a handle for use by other XML functions. Returns false on failure.

    xml_set_object

    (PHP4 >= 4.0b4)

    xml_set_object -- object¿¡ ´ëÇÑ XML Parser¸¦ »ç¿ëÇÑ´Ù. (Use XML Parser within an object)

    Description

    void xml_set_object (int parser, object &object)

    This function makes parser useable from within object. All callback functions settet via xml_set_element_handler() etc are assumed to be methods of object.

      1 
      2 <?php
      3 class xml  {
      4 var $parser;
      5 
      6 function xml() {
      7     $this->parser = xml_parser_create();
      8     xml_set_object($this->parser,&$this);
      9     xml_set_element_handler($this->parser,"tag_open","tag_close");
     10     xml_set_character_data_handler($this->parser,"cdata");
     11 }
     12 
     13 function parse($data) { 
     14     xml_parse($this->parser,$data);
     15 }
     16 
     17 function tag_open($parser,$tag,$attributes) { 
     18     var_dump($parser,$tag,$attributes); 
     19 }
     20 
     21 function cdata($parser,$cdata) { 
     22     var_dump($parser,$cdata);
     23 }
     24 
     25 function tag_close($parser,$tag) { 
     26     var_dump($parser,$tag); 
     27 }
     28 
     29 } // end of class xml
     30 
     31 $xml_parser = new xml();
     32 $xml_parser->parse("<A ID=\"hallo\">PHP</A>");
     33 ?>
     34    

    Note: xml_set_object() handling was added in PHP 4.0.

    xml_set_element_handler

    xml_set_element_handler -- ½ÃÀÛ element handlers¿Í ³¡ element handlers¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int xml_set_element_handler(int parser, string startElementHandler, string endElementHandler);

    Sets the element handler functions for the XML parser parser. startElementHandler and endElementHandler are strings containing the names of functions that must exist when xml_parse() is called for parser.

    The function named by startElementHandler must accept three parameters:

    startElementHandler(int parser, string name, string attribs);

    parser
    The first parameter, parser, is a reference to the XML parser calling the handler.
    name
    The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters.
    attribs
    The third parameter, attribs, contains an associative array with the element's attributes (if any). The keys of this array are the attribute names, the values are the attribute values. Attribute names are case-folded on the same criteria as element names. Attribute values are not case-folded.
    The original order of the attributes can be retrieved by walking through attribs the normal way, using each(). The first key in the array was the first attribute, and so on.

    The function named by endElementHandler must accept two parameters:

    endElementHandler(int parser, string name);

    parser
    The first parameter, parser, is a reference to the XML parser calling the handler.
    name
    The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters.

    If a handler function is set to an empty string, or false, the handler in question is disabled.

    True is returned if the handlers are set up, false if parser is not a parser.

    There is currently no support for object/method handlers.

    xml_set_character_data_handler

    xml_set_character_data_handler -- character data handler¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int xml_set_character_data_handler(int parser, string handler);

    Sets the character data handler function for the XML parser parser. handler is a string containing the name of a function that must exist when xml_parse() is called for parser.

    The function named by handler must accept two parameters:

    handler(int parser, string data);

    parser
    The first parameter, parser, is a reference to the XML parser calling the handler.
    data
    The second parameter, data, contains the character data as a string.

    If a handler function is set to an empty string, or false, the handler in question is disabled.

    True is returned if the handler is set up, false if parser is not a parser.

    There is currently no support for object/method handlers.

    xml_set_processing_instruction_handler

    xml_set_processing_instruction_handler -- processing instruction (PI) handler¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int xml_set_processing_instruction_handler(int parser, string handler);

    Sets the processing instruction (PI) handler function for the XML parser parser. handler is a string containing the name of a function that must exist when xml_parse() is called for parser.

    A processing instruction has the following format:

    <?target data?>

    You can put PHP code into such a tag, but be aware of one limitation: in an XML PI, the PI end tag (?>) can not be quoted, so this character sequence should not appear in the PHP code you embed with PIs in XML documents. If it does, the rest of the PHP code, as well as the "real" PI end tag, will be treated as character data.

    The function named by handler must accept three parameters:

    handler(int parser, string target, string data);

    parser
    The first parameter, parser, is a reference to the XML parser calling the handler.
    target
    The second parameter, target, contains the PI target.
    data
    The third parameter, data, contains the PI data.

    If a handler function is set to an empty string, or false, the handler in question is disabled.

    True is returned if the handler is set up, false if parser is not a parser.

    There is currently no support for object/method handlers.

    xml_set_default_handler

    xml_set_default_handler -- ±âº» handler¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int xml_set_default_handler(int parser, string handler);

    Sets the default handler function for the XML parser parser. handler is a string containing the name of a function that must exist when xml_parse() is called for parser.

    The function named by handler must accept two parameters:

    handler(int parser, string data);

    parser
    The first parameter, parser, is a reference to the XML parser calling the handler.
    data
    The second parameter, data, contains the character data. This may be the XML declaration, document type declaration, entities or other data for which no other handler exists.

    If a handler function is set to an empty string, or false, the handler in question is disabled.

    True is returned if the handler is set up, false if parser is not a parser.

    There is currently no support for object/method handlers.

    xml_set_unparsed_entity_decl_handler

    xml_set_unparsed_entity_decl_handler -- unparsed entity declaration handler¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int xml_set_unparsed_entity_decl_handler(int parser, string handler);

    Sets the unparsed entity declaration handler function for the XML parser parser. handler is a string containing the name of a function that must exist when xml_parse() is called for parser.

    This handler will be called if the XML parser encounters an external entity declaration with an NDATA declaration, like the following:

    <!ENTITY name {publicId | systemId} NDATA notationName>

    See section 4.2.2 of the XML 1.0 spec for the definition of notation declared external entities.

    The function named by handler must accept six parameters:

    handler(int parser, string entityName, string base, string systemId, string publicId, string notationName);

    parser
    The first parameter, parser, is a reference to the XML parser calling the handler.
    entityName
    The name of the entity that is about to be defined.
    base
    This is the base for resolving the system identifier (systemId) of the external entity. Currently this parameter will always be set to an empty string.
    systemId
    System identifier for the external entity.
    publicId
    Public identifier for the external entity.
    notationName
    Name of the notation of this entity (see xml_set_notation_decl_handler()).

    If a handler function is set to an empty string, or false, the handler in question is disabled.

    True is returned if the handler is set up, false if parser is not a parser.

    There is currently no support for object/method handlers.

    xml_set_notation_decl_handler

    xml_set_notation_decl_handler -- notation declaration handler¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int xml_set_notation_decl_handler(int parser, string handler);

    Sets the notation declaration handler function for the XML parser parser. handler is a string containing the name of a function that must exist when xml_parse() is called for parser.

    A notation declaration is part of the document's DTD and has the following format:

    <!NOTATION name {systemId | publicId}>

    See section 4.7 of the XML 1.0 spec for the definition of notation declarations.

    The function named by handler must accept five parameters:

    handler(int parser, string notationName, string base, string systemId, string publicId);

    parser
    The first parameter, parser, is a reference to the XML parser calling the handler.
    notationName
    This is the notation's name, as per the notation format described above.
    base
    This is the base for resolving the system identifier (systemId) of the notation declaration. Currently this parameter will always be set to an empty string.
    systemId
    System identifier of the external notation declaration.
    publicId
    Public identifier of the external notation declaration.

    If a handler function is set to an empty string, or false, the handler in question is disabled.

    True is returned if the handler is set up, false if parser is not a parser.

    There is currently no support for object/method handlers.

    xml_set_external_entity_ref_handler

    xml_set_external_entity_ref_handler -- external entity reference handler¸¦ ¼³Á¤ÇÑ´Ù.

    Description

    int xml_set_external_entity_ref_handler(int parser, string handler);

    Sets the notation declaration handler function for the XML parser parser. handler is a string containing the name of a function that must exist when xml_parse() is called for parser.

    The function named by handler must accept five parameters, and should return an integer value. If the value returned from the handler is false (which it will be if no value is returned), the XML parser will stop parsing and xml_get_error_code() will return XML_ERROR_EXTERNAL_ENTITY_HANDLING.

    int handler(int parser, string openEntityNames, string base, string systemId, string publicId);

    parser
    The first parameter, parser, is a reference to the XML parser calling the handler.
    openEntityNames
    The second parameter, openEntityNames, is a space-separated list of the names of the entities that are open for the parse of this entity (including the name of the referenced entity).
    base
    This is the base for resolving the system identifier (systemid) of the external entity. Currently this parameter will always be set to an empty string.
    systemId
    The fourth parameter, systemId, is the system identifier as specified in the entity declaration.
    publicId
    The fifth parameter, publicId, is the public identifier as specified in the entity declaration, or an empty string if none was specified; the whitespace in the public identifier will have been normalized as required by the XML spec.

    If a handler function is set to an empty string, or false, the handler in question is disabled.

    True is returned if the handler is set up, false if parser is not a parser.

    There is currently no support for object/method handlers.

    xml_parse

    xml_parse -- XML documentÀÇ Çؼ®(parsing)À» ½ÃÀÛÇÑ´Ù.

    Description

    int xml_parse(int parser, string data, int [isFinal]);

    parser
    A reference to the XML parser to use.
    data
    Chunk of data to parse. A document may be parsed piece-wise by calling xml_parse() several times with new data, as long as the isFinal parameter is set and true when the last data is parsed.
    isFinal (optional)
    If set and true, data is the last piece of data sent in this parse.

    When the XML document is parsed, the handlers for the configured events are called as many times as necessary, after which this function returns true or false.

    True is returned if the parse was successful, false if it was not successful, or if parser does not refer to a valid parser. For unsuccessful parses, error information can be retrieved with xml_get_error_code(), xml_error_string(), xml_get_current_line_number(), xml_get_current_column_number() and xml_get_current_byte_index().

    xml_get_error_code

    xml_get_error_code -- XML parser error code¸¦ ¾ò´Â´Ù.

    Description

    int xml_get_error_code(int parser);

    parser
    A reference to the XML parser to get error code from.

    This function returns false if parser does not refer to a valid parser, or else it returns one of the error codes listed in the error codes section.

    xml_error_string

    xml_error_string -- XML parser error ¹®ÀÚ¿­À» ¾ò´Â´Ù.

    Description

    string xml_error_string(int code);

    code
    An error code from xml_get_error_code().

    Returns a string with a textual description of the error code code, or false if no description was found.

    xml_get_current_line_number

    xml_get_current_line_number -- XML parserÀÇ ÇöÀç line number¸¦ ¾ò´Â´Ù.

    Description

    int xml_get_current_line_number(int parser);

    parser
    A reference to the XML parser to get line number from.

    This function returns false if parser does not refer to a valid parser, or else it returns which line the parser is currently at in its data buffer.

    xml_get_current_column_number

    xml_get_current_column_number -- XML parserÀÇ ÇöÀç column number¸¦ ¾ò´Â´Ù.

    Description

    int xml_get_current_column_number(int parser);

    parser
    A reference to the XML parser to get column number from.

    This function returns false if parser does not refer to a valid parser, or else it returns which column on the current line (as given by xml_get_current_line_number()) the parser is currently at.

    xml_get_current_byte_index

    xml_get_current_byte_index -- XML parserÀÇ ÇöÀç byte index¸¦ ¾ò´Â´Ù.

    Description

    int xml_get_current_byte_index(int parser);

    parser
    A reference to the XML parser to get byte index from.

    This function returns false if parser does not refer to a valid parser, or else it returns which byte index the parser is currently at in its data buffer (starting at 0).

    xml_parser_free

    xml_parser_free -- XML parser¸¦ ÇØÁ¦(free)ÇÑ´Ù.

    Description

    string xml_parser_free(int parser);

    parser
    A reference to the XML parser to free.

    This function returns false if parser does not refer to a valid parser, or else it frees the parser and returns true.

    xml_parser_set_option

    xml_parser_set_option -- XML parserÀÇ ¿É¼ÇÀ» ¼³Á¤ÇÑ´Ù.

    Description

    int xml_parser_set_option(int parser, int option, mixed value);

    parser
    A reference to the XML parser to set an option in.
    option
    Which option to set. See below.
    value
    The option's new value.

    This function returns false if parser does not refer to a valid parser, or if the option could not be set. Else the option is set and true is returned.

    The following options are available:

    Table 1. XML parser options

    Option constant

    Data type

    Description

    XML_OPTION_CASE_FOLDING

    integer

    Controls whether case-folding is enabled for this XML parser. Enabled by default.

    XML_OPTION_TARGET_ENCODING

    string

    Sets which target encoding to use in this XML parser. By default, it is set to the same as the source encoding used by xml_parser_create(). Supported target encodings are ISO-8859-1, US-ASCII and UTF-8.

    xml_parser_get_option

    xml_parser_get_option -- XML parserÀÇ ¿É¼ÇÀ» ±¸ÇÑ´Ù.

    Description

    mixed xml_parser_get_option(int parser, int option);

    parser
    A reference to the XML parser to get an option from.
    option
    Which option to fetch. See xml_parser_set_option() for a list of options.

    This function returns false if parser does not refer to a valid parser, or if the option could not be set. Else the option's value is returned.

    See xml_parser_set_option() for the list of options.

    utf8_decode

    utf8_decode -- UTF-8À¸·Î encodeµÈ ISO-8859-1 ¹®ÀÚ¿­À» 1¹ÙÀÌÆ®ÀÇ ISO-8859-1·Î º¯È¯ÇÑ´Ù.

    Description

    string utf8_decode(string data);

    This function decodes data, assumed to be UTF-8 encoded, to ISO-8859-1.

    See utf8_encode() for an explaination of UTF-8 encoding.

    utf8_encode

    utf8_encode -- ISO-8859-1·Î encodeµÈ ¹®ÀÚ¿­À» UTF-8À¸·Î º¯È¯ÇÑ´Ù.

    Description

    string utf8_encode(string data);

    This function encodes the string data to UTF-8, and returns the encoded version. UTF-8 is a standard mechanism used by Unicodefor encoding wide character values into a byte stream. UTF-8 is transparent to plain ASCII characters, is self-synchronized (meaning it is possible for a program to figure out where in the bytestream characters start) and can be used with normal string comparison functions for sorting and such. PHP encodes UTF-8 characters in up to four bytes, like this:

    Table 1. UTF-8 encoding

    bytes

    bits

    representation

    1

    7

    0bbbbbbb

    2

    11

    110bbbbb 10bbbbbb

    3

    16

    1110bbbb 10bbbbbb 10bbbbbb

    4

    21

    11110bbb 10bbbbbb 10bbbbbb 10bbbbbb

    Each b represents a bit that can be used to store character data.

     


    V. ºÎ·Ï (Appendixes)

    Table of Contents
    A. Migrating from PHP/FI 2.0 to PHP 3.0
    B. PHP development
    C. The PHP Debugger

     


    Appendix A. Migrating from PHP/FI 2.0 to PHP 3.0

     


    (¿ªÀÚÁÖ: À̺κÐÀº º°·Î ÀÌ¿ëµÇÁö ¾ÊÀ» °ÍÀ¸·Î »ý°¢µÇ¹Ç·Î ¹ø¿ªÀ» »ý·«ÇÑ´Ù.)

    About the incompatbilities in 3.0

    PHP 3.0 is rewritten from the ground up. It has a proper parser that is much more robust and consistent than 2.0's. 3.0 is also significantly faster, and uses less memory. However, some of these improvements have not been possible without compatibility changes, both in syntax and functionality.

    In addition, PHP's developers have tried to clean up both PHP's syntax and semantics in version 3.0, and this has also caused some incompatibilities. In the long run, we believe that these changes are for the better.

    This chapter will try to guide you through the incompatibilities you might run into when going from PHP/FI 2.0 to PHP 3.0 and help you resolve them. New features are not mentioned here unless necessary.

    A conversion program that can automatically convert your old PHP/FI 2.0 scripts exists. It can be found in the convertor subdirectory of the PHP 3.0 distribution. This program only catches the syntax changes though, so you should read this chapter carefully anyway.

     


    Start/end tags

    The first thing you probably will notice is that PHP's start and end tags have changed. The old <? > form has been replaced by three new possible forms:

    Example 0-1. Migration: old start/end tags

    <? echo "This is PHP/FI 2.0 code.\n"; >

    As of version 2.0, PHP/FI also supports this variation:

    Example 0-2. Migration: first new start/end tags

    <? echo "This is PHP 3.0 code!\n"; ?>

    Notice that the end tag now consists of a question mark and a greater-than character instead of just greater-than. However, if you plan on using XML on your server, you will get problems with the first new variant, because PHP may try to execute the XML markup in XML documents as PHP code. Because of this, the following variation was introduced:

    Example 0-3. Migration: second new start/end tags

    <?php echo "This is PHP 3.0 code!\n"; ?>

    Some people have had problems with editors that don't understand the processing instruction tags at all. Microsoft FrontPage is one such editor, and as a workaround for these, the following variation was introduced as well:

    Example 0-4. Migration: third new start/end tags

    <script language="php">
      echo "This is PHP 3.0 code!\n";
    </script>

     


    if..endif syntax

    The `alternative' way to write if/elseif/else statements, using if(); elseif(); else; endif; cannot be efficiently implemented without adding a large amount of complexity to the 3.0 parser. Because of this, the syntax has been changed:

    Example 0-5. Migration: old if..endif syntax

    if ($foo);
        echo "yep\n";
    elseif ($bar);
        echo "almost\n";
    else;
        echo "nope\n";
    endif;

    Example 0-6. Migration: new if..endif syntax

    if ($foo):
        echo "yep\n";
    elseif ($bar):
        echo "almost\n";
    else:
        echo "nope\n";
    endif;

    Notice that the semicolons have been replaced by colons in all statements but the one terminating the expression (endif).

     


    while syntax

    Just like with if..endif, the syntax of while..endwhile has changed as well:

    Example 0-7. Migration: old while..endwhile syntax

    while ($more_to_come);
        ...
    endwhile;

    Example 0-8. Migration: new while..endwhile syntax

    while ($more_to_come):
        ...
    endwhile;

    Warning

    If you use the old while..endwhile syntax in PHP 3.0, you will get a never-ending loop.

     


    Expression types

    PHP/FI 2.0 used the left side of expressions to determine what type the result should be. PHP 3.0 takes both sides into account when determining result types, and this may cause 2.0 scripts to behave unexpectedly in 3.0.

    Consider this example:

    $a[0]=5;
    $a[1]=7;
    $key = key($a);
    while ("" != $key) {
        echo "$keyn";
        next($a);
    }

    In PHP/FI 2.0, this would display both of $a's indices. In PHP 3.0, it wouldn't display anything. The reason is that in PHP 2.0, because the left argument's type was string, a string comparison was made, and indeed "" does not equal "0", and the loop went through. In PHP 3.0, when a string is compared with an integer, an integer comparison is made (the string is converted to an integer). This results in comparing atoi("") which is 0, and variablelist which is also 0, and since 0==0, the loop doesn't go through even once.

    The fix for this is simple. Replace the while statement with:

    while ((string)$key != "") {

     


    Error messages have changed

    PHP 3.0's error messages are usually more accurate than 2.0's were, but you no longer get to see the code fragment causing the error. You will be supplied with a file name and a line number for the error, though.

     


    Short-circuited boolean evaluation

    In PHP 3.0 boolean evaluation is short-circuited. This means that in an expression like (1 || test_me()), the function test_me() would not be executed since nothing can change the result of the expression after the 1.

    This is a minor compatibility issue, but may cause unexpected side-effects.

     


    Function true/false return values

    Most internal functions have been rewritten so they return TRUE when successful and FALSE when failing, as opposed to 0 and -1 in PHP/FI 2.0, respectively. The new behaviour allows for more logical code, like $fp = fopen("/your/file") or fail("darn!");. Because PHP/FI 2.0 had no clear rules for what functions should return when they failed, most such scripts will probably have to be checked manually after using the 2.0 to 3.0 convertor.

    Example 0-9. Migration from 2.0: return values, old code

    $fp = fopen($file, "r");
    if ($fp == -1);
        echo("Could not open $file for reading<br>\n");
    endif;

    Example 0-10. Migration from 2.0: return values, new code

    $fp = @fopen($file, "r") or print("Could not open $file for reading<br>\n");

     


    Other incompatibilities

    Example 0-11. Migration from 2.0: concatenation for strings

    echo "1" + "1";

    In PHP 2.0 this would echo 11, in PHP 3.0 it would echo 2. Instead use:

    echo "1"."1";
    $a = 1;
    $b = 1;
    echo $a + $b;

    This would echo 2 in both PHP 2.0 and 3.0.

    $a = 1;
    $b = 1;
    echo $a.$b;

    This will echo 11 in PHP 3.0.

     

     


    Appendix B. PHP development

     


    Adding functions to PHP3

     


    Function Prototype

    ¸ðµç ÇÔ¼ö´Â ´ÙÀ½°ú °°Àº ¸ð¾çÀ» ÃëÇÑ´Ù. :

    void php3_foo(INTERNAL_FUNCTION_PARAMETERS) {
         
    }

    ºñ·Ï ÇÔ¼ö°¡ ¾î¶² Àμö(argument)µµ °¡Áö°í ÀÖÁö ¾Ê¾Æµµ, ÀÌ·± ¹æ½ÄÀ¸·Î È£ÃâµÈ´Ù.

     


    Function Arguments

    Àμö(Argument)´Â ÇÑ»ó pval typeÀÌ´Ù. ÀÌ typeÀº argumentÀÇ actual typeÀ» °¡Áø unionÀ» Æ÷ÇÔÇÏ°í ÀÖ´Ù. µû¶ó¼­, ¸¸¾à ÇÔ¼ö°¡ µÎ °³ÀÇ argument¸¦ °¡Áø´Ù¸é, ÇÔ¼öÀÇ ¸Ç óÀ½¿¡¼­ ´ÙÀ½°ú °°Àº µ¿ÀÛÀ» ÃëÇÑ´Ù. :

    Example 0-1. Fetching function arguments

    pval *arg1, *arg2;
    if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&arg1,&arg2)==FAILURE) {
       WRONG_PARAM_COUNT;
    }

    NOTE: argument´Â by value¿Í by referenceÀÇ ¹æ½ÄÁß¿¡ Çϳª·Î Àü´ÞµÈ´Ù. µÎ ¹æ½Ä ¸ðµÎ getParameters¿¡ &(pval *)À» Àü´ÞÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. ¸¸¿ª ¿©·¯ºÐÀÌ n¹ø° parameter°¡ by reference·Î Àü´ÞµÇ¾ú´Â°¡¸¦ °Ë»çÇÏ·Á¸é, ParameterPassedByReference(ht,n) ÇÔ¼ö¸¦ »ç¿ëÇÑ´Ù. ÀÌ ÇÔ¼ö´Â 1À̳ª 0À» ¹ÝȯÇÑ´Ù.

    When you change any of the passed parameters, whether they are sent by reference or by value, you can either start over with the parameter by calling pval_destructor on it, or if it's an ARRAY you want to add to, you can use functions similar to the ones in internal_functions.h which manipulate return_value as an ARRAY.

    Also if you change a parameter to IS_STRING make sure you first assign the new estrdup()'ed string and the string length, and only later change the type to IS_STRING. If you change the string of a parameter which already IS_STRING or IS_ARRAY you should run pval_destructor on it first.

     


    Variable Function Arguments

    A function can take a variable number of arguments. If your function can take either 2 or 3 arguments, use the following:

    Example 0-2. Variable function arguments

    pval *arg1, *arg2, *arg3;
    int arg_count = ARG_COUNT(ht);
    if (arg_count < 2 || arg_count > 3 ||
        getParameters(ht,arg_count,&arg1,&arg2,&arg3)==FAILURE) {
        WRONG_PARAM_COUNT;
    }

     


    Using the Function Arguments

    °³º° argumentÀÇ typeÀº pval type Çʵ忡 ÀúÀåµÈ´Ù. ÀÌ typeÀº ´ÙÀ½Áß ÇÑ °³´Ù. :

    Table 0-1. PHP Internal Types

    IS_STRING

    String

    IS_DOUBLE

    Double-precision floating point

    IS_LONG

    Long integer

    IS_ARRAY

    Array

    IS_EMPTY

    None

    IS_USER_FUNCTION

    ??

    IS_INTERNAL_FUNCTION

    ?? (if some of these cannot be passed to a function - delete)

    IS_CLASS

    ??

    IS_OBJECT

    ??

    If you get an argument of one type and would like to use it as another, or if you just want to force the argument to be of a certain type, you can use one of the following conversion functions:

    convert_to_long(arg1);
    convert_to_double(arg1);
    convert_to_string(arg1); 
    convert_to_boolean_long(arg1); /* If the string is "" or "0" it becomes 0, 1 otherwise */
    convert_string_to_number(arg1);  /* Converts string to either LONG or DOUBLE depending on string */

    These function all do in-place conversion. They do not return anything.

    The actual argument is stored in a union; the members are:

     


    Memory Management in Functions

    ÇÔ¼ö°¡ ÇÊ¿äÇÑ ¸ðµç ¸Þ¸ð¸®´Â emalloc()À̳ª estrdup()À» »ç¿ëÇؼ­ È®º¸ÇÑ´Ù. ÀÌ ÇÔ¼öµéÀº ÀϹÝÀûÀÎ malloc(), strdup()°ú ºñ½ÁÇÏ°Ô ´À²¸Áö´Â Ãß»óÀûÀÎ ¸Þ¸ð¸® °ü¸® ÇÔ¼öÀÌ´Ù. ÀÌ ¸Þ¸ð¸®´Â efree()ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ÇØÁ¦(free)µÈ´Ù.

    ÇÁ·Î±×·¥¿¡¼­´Â ´ÙÀ½°ú °°Àº µÎ Á¾·ùÀÇ Á¾·ùÀÇ ¸Þ¸ð¸®°¡ »ç¿ëµÈ´Ù. : º¯¼ö¿¡¼­ »ç¿ëÇÏ¿© Æļ­¿¡ µ¹·ÁÁö´Â ¸Þ¸ð¸®¿Í, ¿©·¯ºÐÀÇ ³»ºÎ ÇÔ¼ö(internal function)¿¡¼­ Àӽà ÀúÀå °ø°£À¸·Î ÇÊ¿äÇÑ ¸Þ¸ð¸®. ¸¸¾à ¿©·¯ºÐÀÌ ¹®ÀÚ¿­À» Æļ­¿¡ µ¹·ÁÁÙ º¯¼ö¿¡ ÀúÀåÇÏ·Á ÇÑ´Ù¸é, ÀÌ º¯¼ö´Â ¿ì¼± emalloc()À̳ª estrdup()ÀÇ ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ¸Þ¸ð¸®ÀÇ °ø°£À» È®º¸ÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. ÀÌ ¸Þ¸ð¸®´Â Àý´ë ¿©·¯ºÐÀÌ Ç®¾îÁÙ ¼ö ¾ø´Ù. ´ÜÁö, ÈÄ¿¡ °°Àº ÇÔ¼ö³»¿¡¼­ ¿ø·¡ÀÇ ´ëÀÔµÈ °ªÀ» ¹Ù²Ù¾î ÁÙ ¼ö ÀÖÀ» »ÓÀÌ´Ù.

    ¿©·¯ºÐÀÌ ÇÔ¼ö³ª ¶óÀ̺귯¸®¿¡¼­ ÇÊ¿äÇÑ ¾î¶°ÇÑ ÀÓ½Ã/¿µ±¸ÀûÀÎ ¸Þ¸ð¸®¿¡ ´ëÇؼ­µµ, ¿©·¯ºÐÀº emalloc()°ú estrdup(), efree()ÀÇ 3°³ÀÇ ÇÔ¼ö¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù. ÀÌ ÇÔ¼öµéÀº ¹Ýµå½Ã ±×°Í¿¡ ´ëÀÀµÇ´Â ÇÔ¼öµé°ú ÇÔ²² ÀÛµ¿ÇØ¾ß ÇÑ´Ù. emalloc()À̳ª estrdup()À» »ç¿ëÇÑ ¸Þ¸ð¸®¿¡´Â, ÀÌ ¸Þ¸ð¸®°¡ ÇÁ·Î±×·¥ÀÌ Á¾·áµÉ ¶§±îÁö ÇÊ¿äÇÑ °ÍÀÌ ¾Æ´Ñ ÇÑ, ¹Ýµå½Ã efree()°¡ ÇÊ¿äÇÏ´Ù. ¸¸¾à ±×·¸°Ô ÇÏÁö ¾ÊÀ¸¸é ¸Þ¸ð¸® ´©¼³(leak)ÀÌ ¹ß»ýÇÑ´Ù. "±× ÇÔ¼ö°¡ ±×°Í¿¡ ´ëÀÀµÇ´Â ÇÔ¼ö¿Í ÇÔ²² ÀÛµ¿ÇØ¾ß ÇÑ´Ù"´Â °ÍÀÇ Àǹ̴Â, emalloc()À̳ª estrdup()¾øÀÌ efree()¸¦ »ç¿ëÇÑ´Ù¸é ¿©·¯ºÐÀº segment fault ¿À·ù¸¦ ¸¸³ª°Ô µÉ °ÍÀÌ´Ù. ±×·¯¹Ç·Î ÇÊ¿ä¾ø´Â ¸Þ¸ð¸®¿¡ ´ëÇÑ ÇØÁ¦´Â ÃæºÐÇÑ ÁÖÀǸ¦ ±â¿ï¿©¾ß ÇÒ °ÍÀÌ´Ù.

    PHPÀ» "-DDEBUG"¸¦ ÁÖ°í ÄÄÆÄÀÏÇÏ¿´´Ù¸é, PHP´Â emalloc()À̳ª estrdup()¿¡ ÀÇÇØ È®º¸µÈ ¸ðµç ¸Þ¸ð¸®ÀÇ list¸¦ Ç¥½ÃÇÒ °ÍÀÌ´Ù. ±×·¯³ª, efree()ÇÔ¼ö¸¦ »ç¿ëÇصµ ÇØÁ¦µÇÁö ¾Ê°í, ÇØ´ç ÇÁ·Î±×·¥ÀÌ Á¾·áµÉ ¶§ ÇØÁ¦µÈ´Ù.

     


    Setting Variables in the Symbol Table

    symbol table¿¡ º¯¼ö¸¦ ¼³Á¤Çϱ⠽±°ÔÇϱâ À§ÇØ ´ÙÀ½°ú °°Àº ¸î °³ÀÇ macro°¡ ÀÖ´Ù. :

    [1]

    PHP 3.0ÀÇ Symbol tablesÀº hash tableÀÇ ÇüÅ·ΠµÇ¾î ÀÖ´Ù. ¾ðÁ¦³ª &symbol_tableÀº 'main' symbol tableÀ» °¡¸®Å°°í ÀÖ°í, active_symbol_tableÀº ÇöÀç activeµÈ symbol tableÀ» °¡¸®Å°°í ÀÖ´Ù. (ÀÌ µÎ°¡Áö´Â ½ÃÀÛ(startup)½Ã´Â °°Áö¸¸, ÇÔ¼ö¾È¿¡¼­´Â ´Þ¶óÁø´Ù.)

    The following examples use 'active_symbol_table'. You should replace it with &symbol_table if you specifically want to work with the 'main' symbol table. Also, the same functions may be applied to arrays, as explained below.

    Example 0-3. Checking whether $foo exists in a symbol table

    if (hash_exists(active_symbol_table,"foo",sizeof("foo"))) { exists... }
    else { doesn't exist }

    Example 0-4. Finding a variable's size in a symbol table

    hash_find(active_symbol_table,"foo",sizeof("foo"),&pvalue);
    check(pvalue.type);

    Arrays in PHP 3.0 are implemented using the same hashtables as symbol tables. This means the two above functions can also be used to check variables inside arrays.

    If you want to define a new array in a symbol table, you should do the following.

    First, you may want to check whether it exists and abort appropiately, using hash_exists() or hash_find().

    Next, initialize the array:

    Example 0-5. Initializing a new array

    pval arr;
    if (array_init(&arr) == FAILURE) { failed... };
    hash_update(active_symbol_table,"foo",sizeof("foo"),&arr,sizeof(pval),NULL);

    This code declares a new array, named $foo, in the active symbol table. This array is empty.

    Here's how to add new entries to it:

    Example 0-6. Adding entries to a new array

    pval entry;
    entry.type = IS_LONG;
    entry.value.lval = 5;
      
    /* defines $foo["bar"] = 5 */
    hash_update(arr.value.ht,"bar",sizeof("bar"),&entry,sizeof(pval),NULL); 
    /* defines $foo[7] = 5 */
    hash_index_update(arr.value.ht,7,&entry,sizeof(pval),NULL); 
    /* defines the next free place in $foo[],
     * $foo[8], to be 5 (works like php2)
     */
    hash_next_index_insert(arr.value.ht,&entry,sizeof(pval),NULL); 

    If you'd like to modify a value that you inserted to a hash, you must first retrieve it from the hash. To prevent that overhead, you can supply a pval ** to the hash add function, and it'll be updated with the pval * address of the inserted element inside the hash. If that value is NULL (like in all of the above examples) - that parameter is ignored.

    hash_next_index_insert() uses more or less the same logic as "$foo[] = bar;" in PHP 2.0.

    If you are building an array to return from a function, you can initialize the array just like above by doing:

    if (array_init(return_value) == FAILURE) { failed...; }

    ...and then adding values with the helper functions:

    add_next_index_long(return_value,long_value);
    add_next_index_double(return_value,double_value);
    add_next_index_string(return_value,estrdup(string_value));

    Of course, if the adding isn't done right after the array initialization, you'd probably have to look for the array first:

    pval *arr;
    if (hash_find(active_symbol_table,"foo",sizeof("foo"),(void **)&arr)==FAILURE) { can't find... }
    else { use arr->value.ht... }

    Note that hash_find receives a pointer to a pval pointer, and not a pval pointer.

    Just about any hash function returns SUCCESS or FAILURE (except for hash_exists(), which returns a boolean truth value).


    Returning simple values

    ÇÔ¼ö¿¡¼­ ½±°Ô °ªÀ» ¹ÝȯÇϱâ À§ÇØ ´ÙÀ½°ú °°Àº ¸î °³ÀÇ ¸ÅÅ©·Î°¡ ÀÖ´Ù. :

    ¸ðµç RETURN_* ¸ÅÅ©·ÎµéÀº return°ªÀ» ¼³Á¤ÇÏ°í, ÇØ´ç ÇÔ¼ö·ÎºÎÅÍ º¹±ÍÇÑ´Ù. :

    ¸ðµç RETVAL_* ¸ÅÅ©·ÎµéÀº return°ªÀ» ¼³Á¤ÇÏÁö¸¸, ÇØ´ç ÇÔ¼ö·ÎºÎÅÍ º¹±ÍÇÏÁö´Â ¾Ê´Â´Ù. :

    The string macros above will all estrdup() the passed 's' argument, so you can safely free the argument after calling the macro, or alternatively use statically allocated memory.

    If your function returns boolean success/error responses, always use RETURN_TRUE and RETURN_FALSE respectively.


    Returning complex values

    ÇÔ¼ö´Â object³ª array°°Àº complex dataµµ ¹ÝȯÇÒ ¼ö ÀÖ´Ù.

    Returning an object:

    The functions used to populate an object are:

    Returning an array:

    The functions used to populate an array are:


    Using the resource list

    PHP 3.0Àº ¿©·¯ ÀÚ¿øÀÇ °¡Áö ÇüŸ¦ ´Ù·ç´Â Ç¥ÁØÀûÀÎ ¹æ¹ýÀ» °¡Áö°í ÀÖ´Ù. ÀÌ°ÍÀº PHP 2.0ÀÇ ¸ðµç Áö¿ªÀûÀÎ linked list¸¦ ´ëüÇÑ´Ù.

    Available functions:

    Typically, these functions are used for SQL drivers but they can be used for anything else; for instance, maintaining file descriptors.

    Typical list code would look like this:

    Example 0-7. Adding a new resource

    RESOURCE *resource;
    /* ...allocate memory for resource and acquire resource... */
    /* add a new resource to the list */
    return_value->value.lval = php3_list_insert((void *) resource, LE_RESOURCE_TYPE);
    return_value->type = IS_LONG;

    Example 0-8. Using an existing resource

    pval *resource_id;
    RESOURCE *resource;
    int type;
    convert_to_long(resource_id);
    resource = php3_list_find(resource_id->value.lval, &type);
    if (type != LE_RESOURCE_TYPE) {
            php3_error(E_WARNING,"resource index %d has the wrong type",resource_id->value.lval);
            RETURN_FALSE;
    }
    /* ...use resource... */
     

    Example 0-9. Deleting an existing resource

    pval *resource_id;
    RESOURCE *resource;
    int type;
    convert_to_long(resource_id);
    php3_list_delete(resource_id->value.lval);
     

    The resource types should be registered in php3_list.h, in enum list_entry_type. In addition, one should add shutdown code for any new resource type defined, in list.c's list_entry_destructor() (even if you don't have anything to do on shutdown, you must add an empty case).


    Using the persistent resource table

    PHP 3.0Àº ¿µ±¸ÀûÀÎ ÀÚ¿ø(persistent resources; i.e., resources that are kept in between hits)À» ÀúÀåÇϴ ǥÁØÀûÀÎ ¹æ¹ýÀ» °¡Áö°í ÀÖ´Ù. ÀÌ ¹æ¹ýÀº MySQL ¸ðµâ¿¡¼­ óÀ½»ç¿ëµÇ¾ú°í, mSQLµµ ÀÌ°ÍÀ» µû¸£°í ÀÖ´Ù. µû¶ó¼­ persistent resource¸¦ ¾î¶»°Ô »ç¿ëÇϴ°¡¿¡ ´ëÇØ ¾Ë°í ½Í´Ù¸é ¿ì¼± mysql.c¸¦ Àоµµ·ÏÇÏÀÚ. ÁÖÀÇÇؼ­ º¼ ÇÔ¼öµéÀº ´ÙÀº°ú °°´Ù. :

    php3_mysql_do_connect

    php3_mysql_connect()

    php3_mysql_pconnect()

    persistence ¸ðµâÀÇ ÀϹÝÀûÀÎ idea´Â ´ÙÀ½°ú °°´Ù. :

    If you read mysql.c, you'll notice that except for the more complex connect function, nothing in the rest of the module has to be changed.

    The very same interface exists for the regular resource list and the persistent resource list, only 'list' is replaced with 'plist':

    However, it's more than likely that these functions would prove to be useless for you when trying to implement a persistent module. Typically, one would want to use the fact that the persistent resource list is really a hash table. For instance, in the MySQL/mSQL modules, when there's a pconnect() call (persistent connect), the function builds a string out of the host/user/passwd that were passed to the function, and hashes the SQL link with this string as a key. The next time someone calls a pconnect() with the same host/user/passwd, the same key would be generated, and the function would find the SQL link in the persistent list.

    Until further documented, you should look at mysql.c or msql.c to see how one should use the plist's hash table abilities.

    One important thing to note: resources going into the persistent resource list must *NOT* be allocated with PHP's memory manager, i.e., they should NOT be created with emalloc(), estrdup(), etc. Rather, one should use the regular malloc(), strdup(), etc. The reason for this is simple - at the end of the request (end of the hit), every memory chunk that was allocated using PHP's memory manager is deleted. Since the persistent list isn't supposed to be erased at the end of a request, one mustn't use PHP's memory manager for allocating resources that go to it.

    When you register a resource that's going to be in the persistent list, you should add destructors to it both in the non-persistent list and in the persistent list. The destructor in the non-persistent list destructor shouldn't do anything. The one in the persistent list destructor should properly free any resources obtained by that type (e.g. memory, SQL links, etc). Just like with the non-persistent resources, you *MUST* add destructors for every resource, even it requires no destructotion and the destructor would be empty. Remember, since emalloc() and friends aren't to be used in conjunction with the persistent list, you mustn't use efree() here either.


    Adding runtime configuration directives

    ¸¹Àº PHPÀÇ ±â´É(feature)µéÀÌ ½ÇÇàÁß¿¡ ¼³Á¤ °¡´ÉÇÏ´Ù. ÀÌ ¼³Á¤ Áö½ÃÀÚ(configuration directives)´Â php3.ini¿¡ ¼³Á¤µÇ°Å³ª, Apache ¸ðµâÀÇ °æ¿ì .conf ÆÄÀÏ¿¡ ¼³Á¤°¡´ÉÇϵµ·Ï µÇ¾î ÀÖ´Ù. Apache .conf ÆÄÀÏ¿¡ ¼³Á¤ÇÏ´Â °ÍÀÇ ÀåÁ¡Àº µð·ºÅ丮º°·Î ¼³Á¤À» ´Ù¸£°Ô ÇÒ ¼ö ÀÖ´Ù´Â Á¡ÀÌ´Ù. ÀÌ°ÍÀº ¿¹¸¦µé¾î ¾î¶² µð·ºÅ丮°¡ ´Ù¸¥ µð·ºÅ丮¸¦ °¡Áö°í À־, ÇØ´çÇÏ´Â ÇÑ µð·ºÅ丮¿¡¸¸ safemodeexecdir ¼³Á¤À» ÇÒ ¼ö ÀÖ´Ù´Â °ÍÀÌ´Ù. ÀÌ °³º° ¼³Á¤ ±â´ÉÀº ¼­¹ö°¡ multiple virtual hosts¸¦ Áö¿øÇÒ ¶§ ¹«Ã´ À¯¿ëÇÏ´Ù.

    The steps required to add a new directive:


    Calling User Functions

    ³»ºÎ ÇÔ¼ö(internal function)¿¡¼­ »ç¿ëÀÚ ÇÔ¼ö¸¦ ºÎ¸£·Á¸é, call_user_function() ÇÔ¼ö¸¦ »ç¿ëÇÏ¿©¾ß ÇÑ´Ù.

    call_user_function() returns SUCCESS on success, and FAILURE in case the function cannot be found. You should check that return value! If it returns SUCCESS, you are responsible for destroying the retval pval yourself (or return it as the return value of your function). If it returns FAILURE, the value of retval is undefined, and you mustn't touch it.

    All internal functions that call user functions must be reentrant. Among other things, this means they must not use globals or static variables.

    call_user_function() takes six arguments:


    HashTable *function_table

    This is the hash table in which the function is to be looked up.


    pval *object

    This is a pointer to an object on which the function is invoked. This should be NULL if a global function is called. If it's not NULL (i.e. it points to an object), the function_table argument is ignored, and instead taken from the object's hash. The object *may* be modified by the function that is invoked on it (that function will have access to it via $this). If for some reason you don't want that to happen, send a copy of the object instead.


    pval *function_name

    The name of the function to call. Must be a pval of type IS_STRING with function_name.str.val and function_name.str.len set to the appropriate values. The function_name is modified by call_user_function() - it's converted to lowercase. If you need to preserve the case, send a copy of the function name instead.


    pval *retval

    A pointer to a pval structure, into which the return value of the invoked function is saved. The structure must be previously allocated - call_user_function() does NOT allocate it by itself.


    int param_count

    The number of parameters being passed to the function.


    pval *params[]

    An array of pointers to values that will be passed as arguments to the function, the first argument being in offset 0, the second in offset 1, etc. The array is an array of pointers to pval's; The pointers are sent as-is to the function, which means if the function modifies its arguments, the original values are changed (passing by reference). If you don't want that behavior, pass a copy instead.


    Reporting Errors

    ³»ºÎ ÇÔ¼ö¿¡¼­ ¿¡·¯¸¦ reportÇÒ ¶§´Â php3_error()ÇÔ¼ö¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù. ÀÌ ÇÔ¼ö´Â ÃÖ¼Ò µÎ°³ÀÇ Àμö¸¦ °¡Áö°í È£ÃâµÈ´Ù. ù¹ø°´Â ¿¡·¯ÀÇ levelÀÌ°í, ´Ù¸¥ Çϳª´Â ¿¡·¯ ¸Þ¼¼Áö¸¦ À§ÇÑ format string( printf()¿¡¼­ »ç¿ëµÇ´Â °Í°ú °°Àº ÇüÅÂ) ÀÌ´Ù. ±×¸®°í ±× ³ª¸ÓÁö´Â ÁÖ¾îÁø format stringÀÇ parameter°¡ µÈ´Ù. ¿¡·¯ levelÀº ´ÙÀ½°ú °°´Ù. :


    E_NOTICE

    Notice´Â ±âº»ÀûÀ¸·Î´Â Ãâ·ÂµÇÁö ¾Ê´Â´Ù. ÀÌ°ÍÀº ½ºÅ©¸³Æ®°¡ ¹º°¡ ¿¡·¯¸¦ °¨ÁöÇßÁö¸¸, ±×°ÍÀÌ Á¤»óÀûÀÎ »óȲ¿¡¼­ ¹ß»ýÇÏ´Â °ÍÀ̶ó´Â ÀǹÌÀÌ´Ù. ¿¹¸¦µé¾î ¼³Á¤µÇÁö ¾ÊÀº º¯¼ö¸¦ »ç¿ëÇÏ·Á Ç߰ųª, Á¸ÀçÇÏÁö ¾Ê´Â ÆÄÀÏ¿¡ stat() ÇÔ¼ö¸¦ È£ÃâÇÏ´Â °Í µîÀÌ´Ù.


    E_WARNING

    WarningÀº ±âº»ÀûÀ¸·Î Ãâ·ÂµÈ´Ù. ±×·¯³ª, ½ºÅ©¸³Æ®ÀÇ ½ÇÇàÀ» ¸ØÃßÁö´Â ¾Ê´Â´Ù. ÀÌ°ÍÀº È£ÃâÀÌ ¿Ï·áµÇ±â Àü¿¡ ½ºÅ©¸³Æ®¿¡ ÀÇÇØ ÀâÇôÁ®¾ß ÇÏ´Â ¹®Á¦¸¦ °¡¸®Å²´Ù. ¿¹¸¦µé¾î À߸øµÈ regular expressionÀ¸·Î ereg()¸¦ È£ÃâÇÏ´Â °Í µîÀÌ´Ù.


    E_ERROR

    Errorµµ ±âº»ÀûÀ¸·Î Ãâ·ÂµÈ´Ù. ±×¸®°í, ÇÔ¼öÀÇ ½ÇÇàÀÌ ¿Ï·áµÈ Á÷ÈÄ, ½ºÅ©¸³Æ®ÀÇ ½ÇÇàÀ» ¸ØÃá´Ù. ÀÌ°ÍÀº memory allocation ¹®Á¦°°Àº º¹±¸°¡ ºÒ°¡´ÉÇÑ ¿¡·¯¸¦ ÀǹÌÇÑ´Ù.


    E_PARSE

    Parse error´Â ¿ÀÁ÷ Parser¸¸ÀÌ »ý¼º°¡´ÉÇÏ´Ù. code°¡ listµÈ´Ù.


    E_CORE_ERROR

    PHPÀÇ core¿¡ÀÇÇØ »ý¼ºµÈ´Ù´Â Á¡À» Á¦¿ÜÇÏ°í´Â E_ERROR¿Í µ¿ÀÏÇÏ´Ù. ÀÏ¹Ý ÇÔ¼ö·Î´Â ÀÌ ÇüÅÂÀÇ ¿¡·¯¸¦ ¸¸µéÁö ¸øÇÑ´Ù.


    E_CORE_WARNING

    PHPÀÇ core¿¡ÀÇÇØ »ý¼ºµÈ´Ù´Â Á¡À» Á¦¿ÜÇÏ°í´Â E_WARNING¿Í µ¿ÀÏÇÏ´Ù. ÀÏ¹Ý ÇÔ¼ö·Î´Â ÀÌ ÇüÅÂÀÇ ¿¡·¯¸¦ ¸¸µéÁö ¸øÇÑ´Ù.


    Appendix C. The PHP Debugger


    Using the Debugger

    PHPÀÇ ³»Àå µð¹ö°Å´Â ÆľÇÇϱâ Èûµç ¹ö±×¸¦ ã¾Æ³»´Âµ¥ ¸Å¿ì À¯¿ëÇÑ µµ±¸ÀÌ´Ù. µð¹ö°Å´Â PHP°¡ ½ÃÀÛµÉ ¶§¸¶´Ù TCP Æ÷Æ®¿¡ Á¢¼ÓÇÏ¿© µ¿ÀÛÇÑ´Ù. ¿ä±¸¿¡ ´ëÇÑ ¸ðµç ¿¡·¯ ¸Þ¼¼Áö°¡ ÀÌ Á¡¼ÓÀ» ÅëÇØ Àü´ÞµÈ´Ù. This information is intended for "debugging server" that can run inside an IDE or programmable editor (such as Emacs).

    debugger ¼³Á¤ ¹æ¹ý:

    1. configuration file ÀÇ (debugger.port)¿¡ µð¹ö°Å¸¦ À§ÇÑ TCP Æ÷Æ®¸¦ ¼³Á¤ÇÏ°í (debugger.enabled)¸¦ ¼³Á¤ÇØ enble½ÃŲ´Ù.
    2. ¾î´À ½Ã½ºÅÛ¿¡ TCP listener¸¦ ¼³Á¤ÇÑ Æ÷Æ®·Î ¼ºÁ¤ÇÑ´Ù. (¿¹¸¦µé¾î UNIX¿¡¼­´Â socket -l -s 1400 ¶ó°í ½ÇÇàÇÑ´Ù).
    3. code¿¡ "debugger_on(host)"¸¦ ½ÇÇàÇÑ´Ù. host ´Â TCP listener°¡ µ¹°í ÀÖ´Â ½Ã½ºÅÛÀÇ IP ¹øÈ£³ª host À̸§ÀÌ´Ù.

    ÀÌÁ¦, ¸ðµç warning°ú notice µîÀÌ listener socket¿¡ Ç¥½ÃµÉ °ÍÀÌ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ error_reporting()¸¦ »ç¿ëÇؼ­ reportÇÏÁö ¸øÇϵµ·Ï Çصµ ÀÌ ·¹Æ÷Æ®´Â µ¿ÀÛÇÑ´Ù.


    Debugger Protocol

    debugger protocolÀº ¶óÀÎ ´ÜÀ§ÀÌ´Ù. °¢ ¶óÀÎÀº typeÀ» °¡Áö°í ÀÖ°í, ¿©·¯¶óÀÎÀÌ ÇϳªÀÇ ¸Þ¼¼Áö¸¦ ±¸¼ºÇÑ´Ù. °¢ ¸Þ¼¼Áö´Â start type À¸·Î ½ÃÀÛÇÏ°í, end typeÀ¸·Î ³¡³­´Ù. PHP´Â µ¿½Ã¿¡ ¿©·¯ ´Ù¸¥ ¸Þ¼¼ÁöÀÇ ¶óÀÎÀ» º¸³¾ ¼öµµ ÀÖ´Ù.

    ÇÑ ÁÙÀº ´ÙÀ½°ú °°Àº formatÀ¸·Î µÇ¾î ÀÖ´Ù.:

    date time 
    host(pid
    type
    message-data

    date
    Date in ISO 8601 format (yyyy-mm-dd)
    time
    Time including microseconds: hh:mm:uuuuuu
    host
    script error °¡ »ý±ä DNS name À̳ª IP address
    pid
    ÀÌ ¿¡·¯¸¦ ¸¸µç PHP script processÀÇ hostÀÇ PID (process id)
    type
    ¶óÀÎÀÇ type. Tells the receiving program about what it should treat the following data as:

    Table C-1. Debugger Line Types

    Name

    Meaning

    start

    Tells the receiving program that a debugger message starts here. The contents of data will be the type of error message, listed below.

    message

    The PHP error message.

    location

    File name and line number where the error occured. The first location line will always contain the top-level location. data will contain file:line. There will always be a location line after message and after every function.

    frames

    Number of frames in the following stack dump. If there are four frames, expect information about four levels of called functions. If no "frames" line is given, the depth should be assumed to be 0 (the error occured at top-level).

    function

    Name of function where the error occured. Will be repeated once for every level in the function call stack.

    end

    Tells the receiving program that a debugger message ends here.

    data
    Line data.

    Table C-2. Debugger Error Types

     

    Example C-1. Example Debugger Message

    1998-04-05 23:27:400966 lucifer.guardian.no(20481) start: notice
    1998-04-05 23:27:400966 lucifer.guardian.no(20481) message: Uninitialized variable
    1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: (null):7
    1998-04-05 23:27:400966 lucifer.guardian.no(20481) frames: 1
    1998-04-05 23:27:400966 lucifer.guardian.no(20481) function: display
    1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: /home/ssb/public_html/test.php3:10
    1998-04-05 23:27:400966 lucifer.guardian.no(20481) end: notice

     

    Notes

    [1]

    Be careful here. The value part must be malloc'ed manually because the memory management code will try to free this pointer later. Do not pass statically allocated memory into a SET_VAR_STRING.