BACKRUSH  ´ëÈ­¹æÀÔÀå  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   Exploit   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ¿ÀÀ̱î±â   ½©
ÁöÇÏö³ë¼±   Whois   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡
ÇÑ±Û PHP3 Manual

PHP3 Manual

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

Edited by Stig Sæther Bakken

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

Copyright ¨Ï 1997, 1998 by the PHP Documentation Group


Dedication

ÀÛ¼ºÀÏ : 1999-01-15

Release : 3.0.7

Â÷·Ê
¼­¹®
ÀÌ ¸Å´º¾ó¿¡ ´ëÇÏ¿©
I. Language Reference
1. PHP3ÀÇ ¼Ò°³ (An Introduction to PHP3)
2. PHP3ÀÇ ±â´É (PHP3 features)
3. ¼³Ä¡ (Installation)
4. ¼³Á¤ (Configuration)
5. ±¸¹®°ú ¹®¹ý (Syntax and grammar)
6. ¾ð¾î ±¸¼º (Language constructs)
7. Ç¥Çö½Ä (Expressions)
II. ÇÔ¼ö ¸ñ·Ï (Function Reference)
I. Adabas D Functions
II. Apache Specific Functions
III. Array Functions
IV. Aspell Functions
V. BC (Arbitrary Precision) Functions
VI. Calendar Functions
VII. Date/Time Functions
VIII. dBase Functions
IX. dbm Functions
X. Directory Functions
XI. Dynamic Loading Functions
XII. Program Execution Functions
XIII. filePro Functions
XIV. Filesystem Functions
XV. Functions related to HTTP
XVI. Hyperwave functions
XVII. Image functions
XVIII. IMAP Functions
XIX. PHP options & information
XX. Informix Functions
XXI. InterBase Functions
XXII. LDAP Functions
XXIII. Mail Functions
XXIV. Mathematical Functions
XXV. Miscellaneous Functions
XXVI. mSQL Functions
XXVII. MS SQL Server Functions
XXVIII. MySQL Functions
XXIX. Sybase Functions
XXX. Network Functions
XXXI. ODBC Functions
XXXII. Oracle 8 functions
XXXIII. Oracle functions
XXXIV. PDF functions
XXXV. PostgreSQL functions
XXXVI. Regular expression functions
XXXVII. Semaphore and Shared Memory Functions
XXXVIII. Solid Functions
XXXIX. SNMP Functions
XL. String functions
XLI. URL functions
XLII. Variable functions
XLIII. Vmailmgr Functions
XLIV. WDDX functions
XLV. Gz-file Functions
XLVI. XML Parser Functions
III. ºÎ·Ï (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. Language Reference

Table of Contents
1. PHP3ÀÇ ¼Ò°³ (An Introduction to PHP3)
2. PHP3ÀÇ ±â´É (PHP3 features)
3. ¼³Ä¡ (Installation)
4. ¼³Á¤ (Configuration)
5. ±¸¹®°ú ¹®¹ý (Syntax and grammar)
6. ¾ð¾î ±¸¼º (Language constructs)
7. Ç¥Çö½Ä (Expressions)


Chapter 1. PHP3ÀÇ ¼Ò°³ (An introduction to PHP3)

Table of Contents
PHP3¶õ ¹«¾ùÀΰ¡?
PHP3´Â ¹«¾ùÀ» ÇÒ ¼ö Àִ°¡?
PHPÀÇ ¿ª»ç


PHP3¶õ ¹«¾ùÀΰ¡?

PHP Version 3.0Àº server-side HTML-embedded scripting languageÀÔ´Ï´Ù.


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

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

Oracle

Adabas D

Sybase

FilePro

mSQL

Velocis

MySQL

Informix

Solid

dBase

ODBC

Unix dbm

PostgreSQL

 


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ÀÇ »ç¿ë¼öº¸´Ù ¸¹´Ù.


Chapter 2. PHP3ÀÇ ±â´É (PHP3 features)


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 2-1. HTTP Authentication example

<?php
  if(!$PHP_AUTH_USER) {
    Header("WWW-authenticate: basic realm=\"My Realm\"");
    Header("HTTP/1.0 401 Unauthorized");
    echo "Text to send if user hits Cancel button\n"
    exit;
  } else {
    echo "Hello $PHP_AUTH_USER.<P>";
    echo "You entered $PHP_AUTH_PW as your password.<P>";
  }
?>

¿©·¯ºÐÀº $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"¹öưÀ» ¸¸µå´Âµ¥ »ç¿ëÇÑ´Ù.

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

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


PHP¿¡¼­ GIFÀÇ »ý¼º (GIF creation with PHP)

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

Example 2-2. GIF creation with PHP

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

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


File upload support

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½ÃŰ¸é °¡´ÉÇÏ´Ù.)

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

Example 2-3. File Upload Form

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

¿©±â¼­_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º¯¼ö¸¦ °¡Áö°í ƯÁ¤ÇÑ Å¸ÀÔ¿¡ ¸ÂÁö ¾Ê´Â ÆÄÀÏÀ» ¹ö¸± ¼ö ÀÖ´Ù. ¾î¶² ·ÎÁ÷ÀÌ´ø, ¿©·¯ºÐÀº Àӽà µð·ºÅ丮¿¡ ÀÖ´Â ÆÄÀÏÀ» Áö¿ì°Å³ª ³ªÁß¿¡ ÇÊ¿äÇÒ °æ¿ì¿¡´Â ´Ù¸¥ °÷¿¡ À̵¿½ÃÄÑ¾ß ÇÑ´Ù.

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


HTTP cookie support

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

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


Database support

PHP´Â native mode¿Í ODBC¸¦ ÅëÇØ ¼ö¸¹Àº database¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

Adabas D

MySQL

dBase

Oracle

Empress

PostgreSQL

FilePro

Solid

Informix

Sybase

InterBase

Velocis

mSQL

Unix dbm


Regular expressions

Regular expressionÀº PHP¿¡¼­ º¹ÀâÇÑ ¹®ÀÚ¿­ Á¶ÀÛÀ» À§ÇØ »ç¿ëÇÑ´Ù. regular expressionÀ» Áö¿øÇϱâ À§ÇØ ´ÙÀ½ÀÇ ÇÔ¼ö°¡ »ç¿ëµÈ´Ù. :

À§ÀÇ ÇÔ¼öµéÀº regular expression ¹®ÀÚ¿­À» ù Àμö(argument)·Î °¡Áø´Ù. PHP´Â Posix 1003.2¿¡¼­ Á¤ÀÇµÈ Posix È®Àå regular expressionÀ» »ç¿ëÇÑ´Ù. Posix regular expressions¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ¼³¸íÀº PHP distributionÀÇ regexµð·ºÅ丮¿¡ ÀÖ´Â regex man page¸¦ ÂüÁ¶Çϱ⠹ٶõ´Ù.

Example 2-4. Regular expression examples

ereg("abc",$string);
/* Returns true if "abc"
is found anywhere in $string. */
ereg("^abc",$string);
/* Returns true if "abc"
is found at the beginning of $string. */
ereg("abc$",$string);
/* Returns true if "abc"
is found at the end of $string. */
eregi("(ozilla.[23]|MSIE.3)",$HTTP_USER_AGENT);
/* Returns true if client browser
is Netscape 2, 3 or MSIE 3. */
ereg("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)",
$string,$regs);
/* Places three space separated words
into $regs[1], $regs[2] and $regs[3]. */
ereg_replace("^","<BR>",$string);
/* Put a <BR> tag at the beginning of $string. */
ereg_replace("$","<BR>",$string);
/* Put a <BR> tag at the end of $string. */
ereg_replace("\n","",$string);
/* Get rid of any carriage return
characters in $string. */


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¶ó´Â Àü¿ªº¯¼ö¿¡¼­ ¿¡·¯ ¸Þ½ÃÁö¸¦ ãÀ» ¼ö ÀÖÀ» °ÍÀÌ´Ù.


Connection Handling

ÀÌ ±â´ÉÀº 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À» ¹ÝȯÇÑ´Ù.


PHP source viewer


Chapter 3. ¼³Ä¡ (Installation)

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


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


Downloading Source

¿©·¯ºÐÀº ÃֽŹöÀüÀÇ ¼Ò½º¸¦ http://www.php.net¿¡¼­ ³»·Á ¹ÞÀ» ¼ö ÀÖ´Ù.


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

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


¼³Á¤ (Configuration)

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

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


Apache ¸ðµâ

PHP3¸¦ ¾ÆÆÄÄ¡ ¸ðµâ·Î ¸¸µé·Á¸é, "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 ¸ðµâ

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


CGI version

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


Database Áö¿ø ¿É¼Ç

PHP3´Â ´ÙÀ½ÀÇ 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Áß Çϳª¸¦ Áö¿øÇϵµ·Ï ÇÑ´Ù. ¸¸¾à PHP3°¡ 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


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¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.


±âŸ ¼³Á¤ ¿É¼Ç


--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

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


--with-system-regex

      --with-system-regex

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


--with-config-file-path

      --with-config-file-path=DIR     

PHP°¡ ½ÃÀÛµÉ ¶§ »ç¿ëÇÒ the 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     

¶óÀ̺귯¸®³ª ½ÇÇà ÆÄÀÏ¿¡ µð¹ö±× Á¤º¸¸¦ Æ÷ÇÔ½ÃŰÁö ¾Ê´Â´Ù. µð¹ö±× Á¤º¸´Â ¹ö±×ÀÇ À§Ä¡¸¦ Á¤È®ÇÏ°Ô ³ªÅ¸³»´Âµ¥ µµ¿òÀ» ÁØ´Ù. µû¶ó¼­, PHP3°¡ 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 µÉ ¼ö ÀÖ´Ù.

See also the magic_quotes_gpc and the magic_quotes_sybase directives.


--enable-debugger

      --enable-debugger     

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

See also the Debugger Configuration directives in the configuration file.


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


--enable-url-includes

      --enable-url-includes     

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

See also the include_path option in the configuration file.


--disable-syntax-hl

      --disable-syntax-hl 

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


CPPFLAGS and LDFLAGS

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


Building

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

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


VPATH


Testing

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


Benchmarking

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


PHP3 Installation Guide for Windows

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

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

Personal Web Server (Newest version recommended)

Internet Information Server 3 or 4

Apache 1.3.x

Omni HTTPd 2.0b1


PHP3¿¡¼­ÀÇ ¼³Á¤ÀÇ º¯°æ

¸ðµç ¸ðµâÀº 'php3_'·Î ½ÃÀ۵Ǿî¾ß ÇÕ´Ï´Ù. You will need to change your php3.ini file and/or any scripts loading extensions with the dl() function (or you could always remove the 'php3_' prefix). À̰ÍÀº php modules°ú ´Ù¸¥ ¶óÀ̺귯¸®°£ÀÇ È¥¶õÀ» ÇÇÇϱâ À§ÇÑ °ÍÀÌ´Ù.

ChangeLog¿Í FAQ, ÃÖ½ÅÀÇ ¹®¼­µéÀº °ø½Ä PHP À¥»çÀÌÆ®¿Í À̵éÀÇ ¹Ì·¯ »çÀÌÆ®¿¡¼­ ãÀ» ¼ö ÀÖ½À´Ï´Ù.


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

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


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

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


Windows 9x/NT¿Í Apache 1.3.x

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

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

To use the source code highlighting feature, simply create a PHP script file and stick this code in: . Substitute original_php_script.php3 with the name of the file you wish to show the source of. (this is only one way of doing it).

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 3-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

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


Bug reports

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


Other problems

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

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


Security

PHP´Â ¸Å¿ì °­·ÂÇÑ µµ±¸ÀÌ´Ù. ´Ù¸¥ ¸¹Àº °­·ÂÇÑ µµ±¸¿Í °°ÀÌ, ÀÌ °­·ÂÇÑ ±â´ÉÀÌ ¿©·¯ºÐ Àڽſ¡°Ô ÇÇÇØ¸¦ ÁÙ ¼öµµ ÀÖ´Ù. PHP¸¦ ¹«½ÉÄÚ »ç¿ëÇÏ´Ù º¸¸é, ¿©·¯ºÐÀÇ ½Ã½ºÅÛ¿¡ ½É°¢ÇÑ º¸¾È ¹®Á¦¸¦ °¡Á®´Ù ÁÙ¼öµµ ÀÖ´Ù. ÀÌ·¯ÇÑ ¹®Á¦¸¦ ¹æÁöÇÏ´Â °¡Àå ÁÁÀº ¹æ¹ýÀº ¿©·¯ºÐÀÌ ÇÏ´Â ÀÛ¾÷ÀÌ ¹«¾ùÀÎÁö¸¦ È®½ÇÈ÷ ¾Ë°í ÇÏ´Â °ÍÀÌ´Ù. º¸´Ù ÀÚ¼¼ÇÑ »çÇ×Àº Security chapter¸¦ Àо±â ¹Ù¶õ´Ù.


Chapter 4. ¼³Á¤(Configuration)


The php3.ini file

php3.iniÆÄÀÏÀº PHPÀÇ parser°¡ ½ÇÇà µÉ ¶§ ÀÐÇôÁø´Ù. ¼­¹ö ¸ðµâ ÇüÅÂÀÇ PHP´Â ÀÌ ÀÛ¾÷À» ¼­¹ö°¡ ½ÇÇà µÉ ¶§ Çѹø¸¸ ÇÏ°Ô µÈ´Ù. CGIÇüÅÂÀÇ °æ¿ì´Â ºÒ·ÁÁú ¶§¸¶´Ù ¸Å¹ø ÀϾ´Ù.

À̰÷¿¡ ³ª¿­µÈ °³°³ÀÇ Áö½ÃÀÚ(directive)µéÀº ±×°Í°ú ÀÏÄ¡ÇÏ´Â ApacheÀÇ httpd.conf Áö½ÃÀÚ¸¦ °¡Áø´Ù. httpd.conf¿¡¼­ ±× Áö½ÃÀÚ¸¦ »ç¿ëÇÏ´Â ¹æ¹ýÀº ´Ü¼øÈ÷ À̰÷¿¡ ³ª¿­µÈ À̸§ ¾Õ¿¡ php3_¸¦ ºÙÀÌ¸é µÈ´Ù.

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

´ëºÎºÐÀÇ ¼³Á¤°ªÀº phpinfo()ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© È®ÀÎÇØ º¼ ¼ö ÀÖ´Ù.


General Configuration Directives

auto_append_file string

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

noneÀ̶ó´Â Ưº°ÇÑ °ªÀ» ÁÖ°Ô µÇ¸é auto-appendingÀÌ disableµÈ´Ù.

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

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 4-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·Î ÁöÁ¤µÈ´Ù.

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

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 4-1. UNIX include_path

include_path=.:/home/httpd/php-lib

Example 4-2. Windows include_path

include_path=.;c:\www\phplib

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

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 (<? ?>)ÀÇ »ç¿ëÀ» Çã°¡Çϰųª ºÒÇãÇÑ´Ù. ¿©·¯ºÐÀº PHP3¿Í 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)·Î ÀÛµ¿µÇ°Å ÇÑ´Ù.

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.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ÀÇ À̸§. ±âº»°ªÀº ¾ø´Ù.


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 Á¢¼ÓÀÇ ÃÖ´ë °³¼ö


Apache Module


Apache module configuration directives


CGI redirection module/action module


CGI


Virtual hosts


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"·Î ¼³Á¤µÇ¾î ÀÖ´Ù.)


Chapter 5. ±¸¹®°ú ¹®¹ý (Syntax and grammar)Chapter 5. ±¸¹®°ú ¹®¹ý (Syntax and grammar)

PHPÀÇ ±¸¹®µéÀº ±âº»ÀûÀ¸·Î C¿¡¼­ ºô·Á¿Ô´Ù. ¶ÇÇÑ ÀÚ¹Ù¿Í Perl¿¡¼­µµ ¿µÇâÀ» ¹Þ¾Ò´Ù.


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

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

Example 5-1. Ways of escaping from HTML

1.  <? echo("this is the simplest, an SGML processing instruction\n"); ?>
2.  <?php echo("if you want to serve XML documents, do like this\n"); ?>
3.  <script language="php">
      echo("some editors (like FrontPage) don't like processing instructions");
    </script>
4. <% echo("As of PHP 3.0.4 you may optionally use ASP-style tags"); %>


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

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

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

  <?php
      echo("this is example\n");
  ?>
 
  <? echo("this is example\n") ?>


º¯¼ö ÇüÅ (Variable types)

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

PHP supports the following types:

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

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

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

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


º¯¼ö ÃʱâÈ­ (Variable initialization)

PHP¿¡¼­ º¯¼ö¸¦ ÃʱâÈ­ÇÏ´Â °ÍÀº ´Ü¼øÈ÷ ÀÌ º¯¼ö¿¡ ¾î¶² °ªÀ» ÁöÁ¤ÇØ ÁÖ¸é µÈ´Ù. Array³ª ObjectµîÀÇ °æ¿ì´Â ³»ºÎÀûÀ¸·Î Á¶±Ý ´Ù¸¦ ¼öµµ ÀÖÀ¸³ª ´ëºÎºÐÀÇ °æ¿ì À̰ÍÀÌ °¡Àå Á÷Á¢ÀûÀÌ°í ¼ö¿ùÇÑ ¹æ¹ýÀÌ´Ù.


¹è¿­ ÃʱâÈ­ (Initializing Arrays)

¹è¿­Àº ÁÖ°¡Áö¹æ¹ýÀ¸·Î ÃʱâÈ­ µÉ ¼ö ÀÖ´Ù : °ªÀ» ¼øÂ÷ÀûÀ¸·Î ´ëÀÔÇÏ´Â ¹æ¹ý(sequential assign)°ú, array()¶ó´Â construct¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. (Array functions ºÎºÐ¿¡ ÀÚ¼¼ÇÑ ¼³¸íÀÌ ÀÖ´Ù).

¹è¿­¿¡ ¼øÂ÷ÀûÀ¸·Î °ªÀ» ´ëÀÔÇÏ´Â ¹æ¹ýÀº ¹è¿­¿¡ ÷ÀÚ ¾øÀÌ ±×³É ´ëÀÔÇÏ¸é µÈ´Ù. ±×·¯¸é »õ·Î ´ëÀÔÇÑ °ªÀº ±× ¹è¿­ÀÇ Á¦ÀÏ ¸¶Áö¸·¿¡ ÷°¡µÈ´Ù.

$names[] = "Jill";   // $names[0] = "Jill"
$names[] = "Jack";   // $names[1] = "Jack"  

C³ª Perl°ú ¸¶Âù°¡Áö·Î ¹è¿­ÀÇ Ã³À½Àº 1ÀÌ ¾Æ´Ñ 0À¸·Î ½ÃÀÛÇÑ´Ù.


°´Ã¼ÀÇ ÃʱâÈ­ (Initializing objects)

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

class foo {
   function do_foo() { 
      echo "Doing foo."; 
   }
}
$bar = new foo;
$bar->do_foo();   


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

º¯¼ö°¡ »ç¿ë°¡´ÉÇÑ °÷Àº ±× º¯¼ö°¡ ¼±¾ðµÈ °÷ ¾È¿¡¼­ ¸¸ÀÌ´Ù. PHP º¯¼öÀÇ ´ëºÎºÐÀº ÇÑ °³ÀÇ ¹üÀ§(single scope)¸¸À» °¡Áö°í ÀÖ´Ù. ±âº»ÀûÀ¸·Î ÇÔ¼ö ¾È¿¡¼­ ¼±¾ðµÈ °ÍÀº ÇÔ¼ö ¾È¿¡¼­¸¸ »ç¿ëµÇ´Â Áö¿ª º¯¼öÀÌ´Ù. ¶ÇÇÑ ÇÔ¼ö ¾È¿¡¼­ »ç¿ëµÇ´Â ÇÔ¼öµéÀº ±âº»ÀûÀ¸·Î Áö¿ª º¯¼ö¶ó°í °¡Á¤Çϰí ã°Ô µÈ´Ù. ¿¹¸¦ µé¾î:

    $a=1; /* global scope */
    Function Test() {
        echo $a; /* reference to local scope variable */
    }
    Test();

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

    $a=1;
    $b=2;
    Function Sum() {
        global $a,$b;
        $b = $a + $b;
    } 
    Sum();
    echo $b;

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

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

    $a=1;
    $b=2;
    Function Sum() {
        $GLOBALS["b"] = $GLOBALS["a"] + $GLOBALS["b"];
    } 
    Sum();
    echo $b;

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

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

    Function Test() {
        $a=0;
        echo $a;
        $a++;
    }

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

    Function Test() {
        static $a=0;
        echo $a;
        $a++;
    }

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

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

Function Test() {
static $count=0;
$count++;
echo $count;
if($count < 10) {
Test();
}
$count--;
}

 


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

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

$a = "hello"; 

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

$$a = "world";  

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

echo "$a ${$a}";    

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

echo "$a $hello";  

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 5-2. Simple form variable

<form action="foo.php3" method="post">
Name: <input type="text" name="name"><br>
<input type="submit">
</form>

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

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

Example 5-3. More complex form variables

<form action="array.html" method="post">
Name: <input type="text" name="personal[name]"><br>
Email: <input type="text" name="personal[email]"><br>
Beer: <br>
<select multiple name="beer[]">
<option value="warthog">Warthog
<option value="guinness">Guinness
</select>
<input type="submit">
</form>

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


IMAGE SUBMITÀÇ º¯¼ö À̸§

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

<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À̸§¿¡ []¸¦ ´õÇÏ¸é µÈ´Ù. ¿¹¸¦ µé¾î :

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

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

Example 5-2. SetCookie Example

$Count++;
SetCookie("Count",$Count, time()+3600);
SetCookie("Cart[$Count]",$item, time()+3600); 


ȯ°æ º¯¼ö (Environment variables)

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

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

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


Server configuration directives


Type Àüȯ (Type juggling)

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

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

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

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

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


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

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


Type casting

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

$foo = 10;   // $foo is an integer
$bar = (double) $foo;   // $bar is a double   

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

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

$foo = (int) $bar;
$foo = ( int ) $bar;


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

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

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

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

$foo = 1 + "10.5";      // $foo is a double (11.5)
$foo = 1 + "-1.3e3";    // $foo is a double (-1299)
$foo = 1 + "bob-1.3e3"; // $foo is a double (1)
$foo = 1 + "bob3";      // $foo is an integer (1)
$foo = 1 + "10 Small Pigs";     // $foo is an integer (11)
$foo = 1 + "10 Little Piggies"; // $foo is a double (11); the string contains 'e'
$foo = "10.0 pigs " + 1;        // $foo is int (11)
$foo = "10.0 pigs " + 1.0;      // $foo is double (11)

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

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


¹è¿­ (Array manipulation)

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

$a[0] = "abc";
$a[1] = "def";
$b["foo"] = 13; 

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

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

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

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

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


Chapter 6. Language constructs

PHP3 ½ºÅ©¸³Æ®´Â ¹®Àå(statement)ÀÇ ³ª¿­·Î ¸¸µé¾îÁø´Ù. ¹®Àå¿¡´Â ´ëÀÔ¹®(assignment), ÇÔ¼öÈ£Ãâ(function call), ¼øÈ¯¹®(loop), Á¶°Ç¹®(conditional statement)µîÀÌ ÀÖ´Ù. ÇϳªÀÇ ¹®ÀåÀº º¸Åë ¼¼¹ÌÄÝ·Ð( ; )À¸·Î ³¡¸Î´Â´Ù. ¶ÇÇÑ, ¹®ÀåµéÀº Áß°ýÈ£( { } )¸¦ »ç¿ëÇÏ¿© ÇϳªÀÇ º¹¹®Àå (statement-group)À¸·Î ¸¸µé ¼ö ÀÖ´Ù. ÀÌ º¹¹®ÀåÀº ÇϳªÀÇ ¹®Àåó·³ »ç¿ëµÉ ¼ö ÀÖ´Ù. ÀÌ Àå¿¡¼­´Â ¿©·¯ °¡Áö ¹®ÀåÀÇ type¿¡ ´ëÇØ ±â¼úµÇ¾î ÀÖ´Ù. (¿ªÀÚÁÖ: À̰÷ÀÇ ±âº»ÀûÀÎ ¹®¹ýÀº C¸¦ ¾È´Ù°í °¡Á¤ÇÏ°í ¿ø¹®À» ¾à°£ ¿ä¾àÇÏ¿© Á¤¸®ÇÏ¿´À½)


»ó¼ö(Constants)

PHP´Â ¾à°£ÀÇ ±âº»ÀûÀÎ »ó¼öµéÀ» Á¦°øÇϰí, ½ÇÇà½Ã »ó¼ö¸¦ ¼³Á¤ÇÒ ¼ö ÀÖ´Â ¸ÞÄ«´ÏÁòÀ» Áö¿øÇÑ´Ù. »ó¼ö´Â º¯¼ö¿Í ºñ½ÁÇÏ´Ù. ±×·¯³ª ¾à°£ÀÇ ¹®¹ý¿¡ Â÷À̰¡ ÀÖ´Ù.

±âº»ÀûÀ¸·Î Á¦°øµÇ´Â »ó¼ö´Â __FILE__°ú __LINE__ÀÌ´Ù. ÀÌ »ó¼öµéÀº ÇöÀç ó¸®ÁßÀÎ ÆÄÀϸí°ú ¶óÀÎ ¹øÈ£¸¦ ³»¿ëÀ¸·Î ÇÑ´Ù.

Example 6-1. Using __FILE__ and __LINE__

<?php
function report_error($file, $line, $message) {
echo "An error occured in $file on line $line: $message.";
}
report_error(__FILE__,__LINE__, "Something went wrong!");
?>

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

Example 6-2. Defining Constants

<?php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
?>


Ç¥Çö½Ä (Expressions)

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

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

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

      function foo()
      {
          return 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 »ç¿ëÀÚµéÀº ¾Æ¹«°Íµµ ¹Ù²îÁö ¾Ê¾Ò´Ù°í ´À³¥ °ÍÀÌ´Ù. PHP3´Â °ÅÀÇ ¸ðµç °ÍÀÌ Ç¥Çö½ÄÀ¸·Î Ç¥ÇöµÈ´Ù´Â Á¡¿¡¼­, Ç¥Çö Á᫐ ¾ð¾î (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'À¸·Î Ç¥ÇöÇÒ ¼ö ÀÖ´Â °ÍÀÌ´Ù. -=, *=, /=, .= µîµµ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

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

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

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

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

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


IF

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

if (expr)
  statement

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

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

if ($a > $b)
  print "a is bigger than b";

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

if ($a>$b) {
  print "a is bigger than b";
  $b = $a;
}


ELSE

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

if ($a>$b) {
    print "a is bigger than b";
} else {
    print "a is NOT bigger than b";
}


ELSEIF

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

if ($a > $b) {
    print "a is bigger than b";
} elseif ($a == $b) {
    print "a is equal to b";
} else {
    print "a is smaller than b";
}

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


IFÀÇ ´Ù¸¥ Ç¥Çö (Alternative syntax for IF statements): IF(): ... ENDIF;

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

<?php if ($a==5): ?>
A = 5
<?php endif; ?>

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

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

if ($a==5):
    print "a equals to 5";
    print "...";
elseif ($a==6):
    print "a equals to 6";
    print "!!!";
else
    print "a is not 5 nor 6";
endif;


WHILE

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

    WHILE(expr) statement

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

    WHILE(expr): statement ... ENDWHILE;

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

/* example 1 */
$i=1;
while ($i<=10) {
    print $i++;  /* the printed value would be $i before the increment (post-increment) */
}
/* example 2 */
$i=1;
while ($i<=10):
    print $i;
    $i++;
endwhile;


DO..WHILE

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

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

$i = 0;
do {
    print $i;
} while ($i>0);


FOR

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

    FOR (expr1; expr2; expr3) statement

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

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

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

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

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

/* example 1 */
for ($i=1; $i<=10; $i++) {
    print $i;
}
/* example 2 */
for ($i = 1;;$i++) {
    if ($i > 10) {
        break;
    }
    print $i;
}
/* example 3 */
$i = 1;
for (;;) {
    if ($i > 10) {
        break;
    }
    print $i;
    $i++;
}
/* example 4 */
for ($i=1; $i<=10; print $i, $i++) ;

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

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

FOR (expr1; expr2; expr3): statement; ...; endfor;

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


BREAK

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

$i = 0;
while ($i < 10) {
if ($arr[$i] == "stop") {
break;
}
$i++;
}


CONTINUE

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

while (list($key,$value) = each($arr)) {
if ($key % 2) { // skip even members
continue;
}
do_something_odd($value);
}


SWITCH

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

/* example 1 */
if ($i == 0) {
    print "i equals 0";
}
if ($i == 1) {
    print "i equals 1";
}
if ($i == 2) {
    print "i equals 2";
}
 
/* example 2 */
switch ($i) {
    case 0:
        print "i equals 0";
        break;
    case 1:
        print "i equals 1";
        break;
    case 2:
        print "i equals 2";
        break;
}

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

/* example 3 */
switch ($i) {
  case 0:
    print "i equals 0";
  case 1:
    print "i equals 1";
  case 2:
    print "i equals 2";
}

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

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

/* example 4 */
switch ($i) {
    case 0:
        print "i equals 0";
        break;
    case 1:
        print "i equals 1";
        break;
    case 2:
        print "i equals 2";
        break;
    default:
        print "i is not equal to 0, 1 or 2";
}

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


REQUIRE

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

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

require('header.inc');


INCLUDE

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

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

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

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

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

/* This is WRONG and will not work as desired. */
if ($condition)
include($file);
else
include($other);
/* This is CORRECT. */
if ($condition) {
include($file);
} else {
include($other);
}

ÁöÁ¤µÈ ÆÄÀÏÀÌ Æò°¡µÉ ¶§, ÆÄ¼­´Â "HTML-mode"¿¡¼­ ½ÃÀÛÇÑ´Ù. µû¶ó¼­ PHP ¹®ÀåÀº PHP ½ÃÀÛ ÅÃ(<?)À» ÁÖ°í ½ÃÀÛÇÏ¿©¾ß ÇÑ´Ù.

See also readfile(), virtual().


FUNCTION

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

function foo( $arg_1, $arg_2, ..., $arg_n ) {
   echo "Example function.\n";
   return $retval;
}
     

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


Returning values

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

function my_sqrt( $num ) {
   return $num * $num;
}
echo my_sqrt( 4 );   // outputs '16'.  

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

function foo() {
   return array( 0, 1, 2 );
}
list( $zero, $one, $two ) = foo();  


Arguments

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

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


Passing by reference

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

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

function foo( &$bar ) {
   $bar .= ' and something extra.';
}
$str = 'This is a string, ';
foo2( $str );
echo $str;    // outputs 'This is a string, and something extra.'   

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

function foo( $bar ) {
   $bar .= ' and something extra.';
}
$str = 'This is a string, ';
foo2( $str );
echo $str;    // outputs 'This is a string, '
foo2( &$str );
echo $str;    // outputs 'This is a string, and something extra.'   


Default values

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

function makecoffee( $type = "cappucino" ) {
   echo "Making a cup of $type.\n";
}
echo makecoffee();
echo makecoffee( "espresso" );     

À§ÀÇ ´ÜÆíÀÇ ½ÇÇà °á°ú´Â ´ÙÀ½°ú °°´Ù :

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

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

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

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

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 . 

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

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

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

Making a bowl of acidophilus raspberry.  


OLD_FUNCTION

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

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

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


CLASS

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

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

<?php
class Cart {
var $items; // Items in our shopping cart
// Add $num articles of $artnr to the cart
function add_item($artnr, $num) {
$this->items[$artnr] += $num;
}
// Take $num articles of $artnr out of the cart
function remove_item($artnr, $num) {
if ($this->items[$artnr] > $num) {
$this->items[$artnr] -= $num;
return true;
} else {
return false;
}
}
}
?>

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

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

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

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

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

class Named_Cart extends Cart {
var $owner;
function set_owner($name) {
$this->owner = $name;
}
}

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

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

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

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

class Auto_Cart extends Cart {
function Auto_Cart() {
$this->add_item("10", 1);
}
}

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

class Constructor_Cart {
function Constructor_Cart($item = "10", $num = 1) {
$this->add_item($item, $num);
}
}
// Shop the same old boring stuff.
$default_cart = new Constructor_Cart;
// Shop for real...
$different_cart = new Constructor_Cart("20", 17);


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


¿¬»êÀÚ (Operators)


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

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

Table 7-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¸¦ ³ª´« ³ª¸ÓÁö.

³ª´©±â ¿¬»êÀÚ("/") ´Â µÎ °³ÀÇ ÇÇ¿¬»êÀÚ°¡ ¸ðµÎ Á¤¼ö°ªÀÏ ¶§ (ȤÀº Á¤¼ö·Î º¯È¯µÇ´Â stringÀÏ ¶§), °á°ú°ªÀ¸·Î ³ª´°¼ÀÀÇ ¸ò¿¡ ÇØ´çÇÏ´Â Á¤¼ö¸¦ ¹ÝȯÇÑ´Ù. µÎ ÇÇ¿¬»êÀÚ°¡ ½Ç¼öÀÏ ¶§´Â ½Ç¼ö ³ª´°¼ÀÀ» ÇÑ´Ù.


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

¹®ÀÚ¿­ ¿¬»êÀÚ´Â µü ÇÑ °³¸¸ ÀÖ´Ù. µÎ ¹®ÀÚ¿­À» ¿¬°áÇÏ´Â concatenation ¿¬»êÀÚ (".") ¸¸ÀÌ ÀÖ´Ù.

$a = "Hello ";
$b = $a . "World!"; // now $b = "Hello World!"


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

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

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

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

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

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


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

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

Table 7-2. Bitwise Operators

example

name

result

$a & $b

And

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

$a | $b

Or

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

~ $a

Not

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


Logical Operators

Table 7-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" ¿¬»êÀÚ°¡ µÎ°¡ÁöÀÇ ´Ù¸¥ ÇüŸ¦ °¡Áö°í ÀÖ´Â ÀÌÀ¯´Â ÀÌ ¿¬»êÀÚµéÀÌ ¼­·Î ´Ù¸¥ ¿ì¼±¼øÀ§¸¦ °¡Áö°í Àֱ⠶§¹®ÀÌ´Ù. (¾Æ·¡¸¦ º¸¶ó.)


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

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

Table 7-4. Comparson Operators

example

name

result

$a == $b

Equal

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

$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.


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


II. Function Reference

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

Table of Contents
I. Adabas D Functions
II. Apache Specific Functions
III. Array Functions
IV. Aspell Functions
V. BC (Arbitrary Precision) Functions
VI. Calendar Functions
VII. Date/Time Functions
VIII. dBase Functions
IX. dbm Functions
X. Directory Functions
XI. Dynamic Loading Functions
XII. Program Execution Functions
XIII. filePro Functions
XIV. Filesystem Functions
XV. Functions related to HTTP
XVI. Hyperwave functions
XVII. Image functions
XVIII. IMAP Functions
XIX. PHP options & information
XX. Informix Functions
XXI. InterBase Functions
XXII. LDAP Functions
XXIII. Mail Functions
XXIV. Mathematical Functions
XXV. Miscellaneous Functions
XXVI. mSQL Functions
XXVII. MS SQL Server Functions
XXVIII. MySQL Functions
XXIX. Sybase Functions
XXX. Network Functions
XXXI. ODBC Functions
XXXII. Oracle 8 functions
XXXIII. Oracle functions
XXXIV. PDF functions
XXXV. PostgreSQL functions
XXXVI. Regular expression functions
XXXVII. Semaphore and Shared Memory Functions
XXXVIII. Solid Functions
XXXIX. SNMP Functions
XL. String functions
XLI. URL functions
XLII. Variable functions
XLIII. Vmailmgr Functions
XLIV. WDDX functions
XLV. Gz-file Functions
XLVI. XML Parser Functions


I. Adabas D Functions

Table of Contents
ada_afetch
ada_autocommit
ada_close
ada_commit
ada_connect
ada_exec
ada_fetchrow
ada_fieldname
ada_fieldnum
ada_fieldtype
ada_freeresult
ada_numfields
ada_numrows
ada_result
ada_resultall
ada_rollback

Adabas D ÇÔ¼öµéÀº º°·Î ÁÁÀº Æò°¡¸¦ ¹ÞÁö ¸øÇÔ´Ù. ¾Æ¸¶µµ Unified ODBC functionsÀ» ´ë½Å ¾²´Â °ÍÀÌ ÁÁÀ» °ÍÀÌ´Ù.

ada_afetch

ada_afetch -- result row¸¦ ¹è¿­·Î °¡Á®¿Â´Ù.

Description

See odbc_fetch_into()

ada_autocommit

ada_autocommit -- autocommit µ¿ÀÛÀ» Çϰųª ¾ÈÇÏ°Ô ÇÑ´Ù.

Description

See odbc_autocommit().

ada_close

ada_close -- Adabas D server·ÎÀÇ ¿¬°áÀ» ´Ý´Â´Ù.

Description

See odbc_close().

ada_commit

ada_commit -- transactionÀ» commit ÇÑ´Ù.

Description

See odbc_commit()

ada_connect

ada_connect -- Adabas D datasource¿¡ ¿¬°áÇÑ´Ù.

Description

See odbc_connect().

ada_exec

ada_exec -- SQL ¹®ÀåÀ» ÁغñÇÏ°í ½ÇÇàÇÑ´Ù.

Description

See odbc_exec() or odbc_do().

ada_fetchrow

ada_fetchrow -- result·Î ºÎÅÍ row¸¦ °¡Á®¿Â´Ù.

Description

See odbc_fetch_row().

ada_fieldname

ada_fieldname -- columnnameÀ» ±¸ÇÑ´Ù.

Description

See odbc_field_name().

ada_fieldnum

ada_fieldnum -- column number¸¦ ±¸ÇÑ´Ù.

Description

See odbc_field_num().

ada_fieldtype

ada_fieldtype -- fieldÀÇ datatypeÀ» ±¸ÇÑ´Ù.

Description

See odbc_field_type().

ada_freeresult

ada_freeresult -- result¿¡ ÇÒ´çµÈ resource¸¦ ÇØÁ¦ÇÑ´Ù.

Description

See odbc_free_result().

ada_numfields

ada_numfields -- resultÀÇ column °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

See odbc_num_fields().

ada_numrows

ada_numrows -- resultÀÇ row °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

See odbc_num_rows().

ada_result

ada_result -- result·ÎºÎÅÍ data¸¦ ±¸ÇÑ´Ù.

Description

See odbc_result().

ada_resultall

ada_resultall -- result¸¦ HTML table·Î Ãâ·ÂÇÑ´Ù.

Description

See odbc_result_all().

ada_rollback

ada_rollback -- transactionÀ» rollback ÇÑ´Ù.

Description

See odbc_rollback().

II. Apache Specific Functions

Table of Contents
apache_lookup_uri
apache_note
getallheaders
virtual

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

$headers = getallheaders();
while (list($header, $value) = each($headers)) {
echo "$header: $value<br>\n";
}

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

Note: GetAllHeaders() is currently only supported when PHP runs as an Apache module.

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 should use include() or require().

III. Array Functions

Table of Contents
array
array_walk
arsort
asort
count
current
each
end
key
ksort
list
next
pos
prev
reset
rsort
sizeof
sort
uasort
uksort
usort

array

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

Description

array array(...);

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

Note that array() really 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

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

See also: list().

array_walk

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

Description

int array_walk(array arr, string func);

Applies the function named by func to each element of arr. The elements are passed as the first argument of func; if func requires more than one argument, 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 that func will actually be working with the elements of arr, so any changes made to those elements will actually be made in the array itself.

Example 1. array_walk() example

$fruits = array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");
function test_alter( $item1 ) {
$item1 = 'bogus';
}
function test_print( $item2 ) {
echo "$item2<br>\n";
}
array_walk( $fruits, 'test_print' );
array_walk( $fruits, 'test_alter' );
array_walk( $fruits, 'test_print' );

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

$fruits = array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");
arsort($fruits);
for(reset($fruits); $key = key($fruits); next($fruits)) {
    echo "fruits[$key] = ".$fruits[$key]."\n";
}

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

$fruits = array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");
asort($fruits);
for(reset($fruits); $key = key($fruits); next($fruits)) {
    echo "fruits[$key] = ".$fruits[$key]."\n";
}

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().

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 0 if the variable is not set.

Returns 1 if the variable is not an array.

See also: sizeof(), isset(), and is_array().

current

current -- ¹è¿­ÀÇ ÇöÀç ¿ø¼Ò¸¦ µ¹·ÁÁØ´Ù.

Description

mixed current(array array);

°¢°¢ÀÇ ¹è¿­ º¯¼ö´Â ±×°ÍÀÇ ¿ø¼Ò¸¦ °¡¸£Å°´Â ³»ºÎÀûÀÎ pointer¸¦ °¡Áö°í ÀÖ´Ù. °Ô´Ù°¡, ¹è¿­ÀÇ ¸ðµç ¿ø¼ÒµéÀº °Ë»öÀÌ ¿ëÀÌÇϵµ·Ï ¾ç¹æÇâ linked list·Î ¿¬°áµÇ¾î ÀÖ´Ù. ÀÌ ³»ºÎÀûÀÎ pointer´Â ´Ù¸¥ ¾î¶² Á¶ÀÛÀ» Çϱâ Àü¿¡´Â Ç×»ó ù ¹øÂ° ¿ä¼Ò¸¦ °¡¸£Å°°í ÀÖ´Ù.

current() ÇÔ¼ö´Â ´Ü¼øÈ÷ ³»ºÎÀûÀÎ Pointer°¡ °¡¸£Å°°í ÀÖ´Â ¿ø¼Ò¸¦ ¹ÝȯÇÒ »ÓÀÌ´Ù. ¸¸¾à ÀÌ pointer°¡ ¿ø¼Ò listÀÇ ¹üÀ§¸¦ ³Ñ¾î¼­ Áö½ÃÇϰí ÀÖ´Ù¸é current()´Â false¸¦ ¹ÝȯÇÑ´Ù.

( ¿ªÀÚÁÖ : ¹ö±×ÀÎ°Í °°Áö¸¸, 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

$foo = array( "bob", "fred", "jussi", "jouni" );
$bar = each( $foo );    

$bar now contains the following key/value pairs:

    0 => 0
    1 => 'bob'
    key => 0
    value => 'bob'

$foo = array( "Robert", => "Bob", "Seppo" => "Sepi" );
$bar = each( $foo );    

$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()

echo "Values submitted via POST method:<br>";
while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) {
   echo "$key => $val<br>";
}   

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()

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()

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

$fruits = array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");
ksort($fruits);
for(reset($fruits); $key = key($fruits); next($fruits)) {
    echo "fruits[$key] = ".$fruits[$key]."\n";
}

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

<table>
 <tr>
  <th>Employee name</th>
  <th>Salary</th>
 </tr>
<?php
$result = mysql($conn, "SELECT id, name, salary FROM employees");
while (list($id, $name, $salary) = mysql_fetch_row($result)) {
    print(" <tr>\n".
          "  <td><a href=\"info.php3?id=$id\">$name</a></td>\n".
          "  <td>$salary</td>\n".
          " </tr>\n");
}
?></table>

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.

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.

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()

reset

reset -- ¹è¿­ÀÇ internal pointer¸¦ ¸Ç óÀ½ ¿ø¼Ò·Î ¼³Á¤ÇÑ´Ù.

Description

reset(array array);

reset() rewinds array's internal pointer to the first 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

    $fruits = array("lemon","orange","banana","apple");
    rsort($fruits);
    for(reset($fruits); $key = key($fruits); next($fruits)) {
        echo "fruits[$key] = ".$fruits[$key]."\n";
    }
        

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().

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

$fruits = array("lemon","orange","banana","apple");
sort($fruits);
for(reset($fruits); $key = key($fruits); next($fruits)) {
    echo "fruits[$key] = ".$fruits[$key]."\n";
}

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

function mycompare($a, $b) {
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}
$a = array(4 => "four", 3 => "three", 20 => "twenty", 10 => "ten");
uksort($a, mycompare);
while(list($key, $value) = each($a)) {
echo "$key: $value\n";
}

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.

Example 1. usort() example

function cmp($a,$b) {
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}
$a = array(3,2,5,6,1);
usort($a, cmp);
while(list($key,$value) = each($a)) {
echo "$key: $value\n";
}

This example would display: 0: 6 1: 5 2: 3 3: 2 4: 1 Obviously in this trivial case the rsort() function would be more appropriate.

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

IV. Aspell Functions

Table of Contents
aspell_new
aspell_check
aspell_check-raw
aspell_suggest

aspell() ÇÔ¼öµéÀº ¿©·¯ºÐ¿¡°Ô ´Ü¾îÀÇ Ã¶ÀÚ¸¦ °Ë»çÇÏ°í ¼öÁ¤»çÇ×À» Á¶¾ðÇØ ÁØ´Ù.

ÀÌ ÇÔ¼öµéÀ» »ç¿ëÇÏ·Á¸é aspell ¶óÀ̺귯¸®°¡ ÇÊ¿äÇÏ´Ù. ´ÙÀ½ »çÀÌÆ®¿¡¼­ ãÀ» ¼ö ÀÖÀ» °ÍÀÌ´Ù. : http://metalab.unc.edu/kevina/aspell/

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

$aspell_link=aspell_new("english");

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

$aspell_link=aspell_new("english");
if (aspell_check($aspell_link,"testt")) {
echo "This is a valid spelling";
} else {
echo "Sorry, wrong spelling";
}

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

$aspell_link=aspell_new("english");
if (aspell_check_raw($aspell_link,"testt")) {
echo "This is a valid spelling";
} else {
echo "Sorry, wrong spelling";
}

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

$aspell_link=aspell_new("english");
if (!aspell_check($aspell_link,"testt")) {
$suggestions=aspell_suggest($aspell_link,"testt");
for($i=0; $i < count($suggestions); $i++) {
echo "Possible spelling: " . $suggestions[$i] . "<br>";
}
}

 

V. BC (Arbitrary Precision) Functions

Table of Contents
bcadd
bccomp
bcdiv
bcmod
bcmul
bcpow
bcscale
bcsqrt
bcsub

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

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().


VI. Calendar Functions

Table of Contents
JDToGregorian
GregorianToJD
JDToJulian
JulianToJD
JDToJewish
JewishToJD
JDToFrench
FrenchToJD
JDMonthName
JDDayOfWeek

PHP¿¡´Â ¼­·Î ´Ù¸¥ ³¯Â¥(´Þ·Â) ÇüŸ¦ º¯È¯½ÃÄÑ ÁÖ´Â ÇÔ¼öµéÀ» Á¦°øÇÑ´Ù. Julian Day Count°¡ ±âº»ÀÌ µÈ´Ù. À̰ÍÀº BC4000³âÀÇ ¾î´À ½ÃÁ¡À» ±âÁØÀ¸·Î Àâ¾Æ ±×°÷¿¡¼­ºÎÅÍ ¾ó¸¶ÀÇ ³¯Â¥°¡ Áö³µ´ÂÁö¸¦ ±âÁØÀ¸·Î »ï´Â °ÍÀÌ´Ù. ÀÌ Julian Day Count´Â ÀϹÝÀûÀ¸·Î »ç¿ëÇÏ´Â Julian ´Þ·Â°ú´Â ´Ù¸£´Ù´Â °ÍÀ» ¾Ë¾ÆµÎÀÚ. Calendar ½Ã½ºÅÛ¿¡ ´ëÇØ ÀÚ¼¼È÷ ¾Ë°í ½Í´Ù¸é http://genealogy.org/~scottlee/cal-overview.html¸¦ ¹æ¹®ÇÏ¿© º¸¶ó. ÀÌ ¼³¸í¼­Áß¿¡¼­´Â À§ÀÇ ÆäÀÌÁö¿¡¼­ ¹ßÃéµÈ ³»¿ëÀ» ""·Î µÑ·¯ ½Î°í ÀÖ´Ù.

( ¿ªÀÚÁÖ : ÀÌ ÇÔ¼öµéÀº dl/calender extensionÀ» LoadÇÑ ÈÄ¿¡ »ç¿ë°¡´ÉÇÏ´Ù. dl/README ÆÄÀÏÀ» Àо¶ó. )

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

<?php
$jd = GregorianToJD(10,11,1970);
echo("$jd\n");
$gregorian = JDToGregorian($jd);
echo("$gregorian\n");
?>

 

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)

 

VII. Date/Time Functions

Table of Contents
checkdate
date
strftime
getdate
gettimeofday
gmdate
mktime
gmmktime
time
microtime

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.

Example 1. date() example

print(date( "l dS of F Y h:i:s A" ));
print("July 1, 2000 is on a " . date("l", mktime(0,0,0,7,1,2000)));

It is possible to use date() and mktime() together to find dates in the future or the past.

Example 2. date() and mktime() example

$tomorrow = mktime(0,0,0,date("m") ,date("d")+1,date("Y"));
$lastmonth = mktime(0,0,0,date("m")-1,date("d"), date("Y"));
$nextyear = mktime(0,0,0,date("m"), date("d", date("Y")+1);

To format dates in other languages, you should use the setlocale() and strftime() functions.

See also gmdate() and mktime().

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

setlocale ("LC_TIME", "C");
print(strftime("%A in Finnish is "));
setlocale ("LC_TIME", "fi");
print(strftime("%A, in French "));
setlocale ("LC_TIME", "fr");
print(strftime("%A and in German "));
setlocale ("LC_TIME", "de");
print(strftime("%A.\n"));

This example works if you have the respective locales installed in your system.

See also setlocale() 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

echo date( "M d Y H:i:s",mktime(0,0,0,1,1,1998) );
echo gmdate( "M d Y H:i:s",mktime(0,0,0,1,1,1998) );

See also date(), mktime() and gmmktime().

mktime

mktime -- ÁöÁ¤µÈ ³¯Â¥¸¦ date()ÇÔ¼ö µîÀÌ »ç¿ëÇÏ´Â timestamp·Î ¸¸µç´Ù.

Description

int mktime(int hour, int minute, int second, int month, int day, int year);

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.

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

echo date( "M-d-Y", mktime(0,0,0,12,32,1997) );
echo date( "M-d-Y", mktime(0,0,0,13,1,1997) );
echo date( "M-d-Y", mktime(0,0,0,1,1,1998) );

( ¿ªÀÚÁÖ : ´ÙÀ½°ú °°ÀÌ 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().

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.

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().

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().

VIII. dBase Functions

Table of Contents
dbase_create
dbase_open
dbase_close
dbase_pack
dbase_add_record
dbase_delete_record
dbase_get_record
dbase_numfields
dbase_numrecords

ÀÌ ÇÔ¼öµéÀº dBase ÇüÅÂÀÇ databse(dbf)¿¡ ÀúÀåµÈ ·¹ÄÚµåµéÀ» Á¢±ÙÇÒ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù.

index¿Í memo Çʵå´Â Áö¿øÇÏÁö ¾Ê´Â´Ù. ¶ÇÇÑ lockingµµ Áö¿øÇÏÁö ¾Ê´Â´Ù. µÎ °³ÀÇ À¥¼­¹ö ÇÁ·Î¼¼½º°¡ µ¿½Ã¿¡ °°Àº dBase ÆÄÀÏÀ» ¼öÁ¤ÇÏ·Á ÇÑ´Ù¸é, database ÀÚü°¡ ¸Á°¡Áú ¼öµµ ÀÖ´Ù.

SQL µ¥ÀÌÅͺ£À̽º¿Í ´Ù¸£°Ô dBase µ¥ÀÌÅͺ£À̽º´Â »ý¼ºÈÄ¿¡ ±× ±¸Á¶¸¦ ¹Ù²Ü ¼ö ¾ø´Ù. ÇÑ ÆÄÀÏÀÌ »ý¼ºµÇ¸é ÇØ´ç µ¥ÀÌÅͺ£À̽ºÀÇ ¼±¾ðÀº °íÁ¤µÈ´Ù. ¼Óµµ Çâ»ó µîÀ» À§ÇØ »ç¿ëÇÏ´Â indexµµ Áö¿øÇÏÁö ¾Ê´Â´Ù. dBase´Â °íÁ¤µÈ ±æÀÌÀÇ ·¹Äڵ带 °¡Áø ´Ü¼øÇÑ ¼øÂ÷ ÆÄÀÏÀÌ´Ù. »õ·¹ÄÚµå´Â ÆÄÀÏÀÇ ¸Ç µÚ¿¡ ºÙ°í, »èÁ¦µÈ ·¹ÄÚµå´Â dbase_pack()ÀÌ ¼öÇàµÇ±â Àü¿¡´Â µ¥ÀÌÅÍ ÀÚü´Â À¯ÁöµÈ´Ù.

¿ì¸®´Â dBase ÆÄÀÏÀº »ç¿ëÇÏÁö ¸»±â¸¦ ±ÇÇÑ´Ù. ´ë½Å ÁøÂ¥ SQL ¼­¹ö¸¦ »ç¿ëÇϱ⸦ ±ÇÇÑ´Ù. MySQLÀ̳ª PostgreSQLÀÌ PHP¿Í °°ÀÌ ¸¹¤· »ç¿ëµÈ´Ù. dBase Áö¿øÀº ´ÜÁö ¿©·¯ºÐÀÌ »ç¿ëÇÏ´Â µ¥ÀÌÅͺ£À̽º¿¡ µ¥ÀÌÅ͸¦ ÀоîµéÀ̰ųª ³»º¸³¾ ¶§¸¸ »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù. dBase Æ÷¸ËÀº ´ëºÎºÐÀÇ Windows¿ë ÇÁ·Î±×·¥ÀÌ »ç¿ë°¡´ÉÇÑ µ¥ÀÌÅÍ Æ÷¸ËÀ̱⠶§¹®ÀÌ´Ù.

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_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_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()

$rec = dbase_get_record($db, $recno);
$nf = dbase_numfields($db);
for ($i=0; $i < $nf; $i++) {
print $rec[$i]."<br>\n";
}

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.

IX. dbm Functions

Table of Contents
dbmopen
dbmclose
dbmexists
dbmfetch
dbminsert
dbmreplace
dbmdelete
dbmfirstkey
dbmnextkey
dblist

ÀÌ ÇÔ¼öµéÀº dbm ÇüÅÂÀÇ databse(dbf)¿¡ ÀúÀåµÈ ·¹ÄÚµåµéÀ» Á¢±ÙÇÒ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù. ÀÌ ÇüÅÂÀÇ database´Â Berkeley db, gdbm µî°ú ³»ÀåµÈ flatfile ¶óÀ̺귯¸® °°Àº ÀϺΠsystem ¶óÀ̺귯¸® µîÀÌ Áö¿øÇϴµ¥, ÀϹÝÀûÀÎ relational databases¿Í ´Þ¸® key/valueÀÇ ½ÖÀ¸·Î data¸¦ ÀúÀåÇÑ´Ù.

Example 1. dbm example

$dbm = dbmopen("lastseen", "w");
if (dbmexists($dbm, $userid)) {
$last_seen = dbmfetch($dbm, $userid);
} else {
dbminsert($dbm, $userid, time());
}
do_stuff();
dbmreplace($dbm, $userid, time());
dbmclose($dbm);

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" or "w" for read, new (implies write) and 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 from ftp://prep.ai.mit.edu/pub/gnu.

Example 1. dbm example

$dbm = dbmopen("lastseen", "w");

Example 1. dbm example

$dbm = dbmopen("lastseen", "w");
if (dbmexists($dbm, $userid)) {
$last_seen = dbmfetch($dbm, $userid);
} else {
dbminsert($dbm, $userid, time());
}

Example 1. dbm example

$dbm = dbmopen("lastseen", "w");
if (dbmexists($dbm, $userid)) {
$last_seen = dbmfetch($dbm, $userid);
} else {
dbminsert($dbm, $userid, time());
}
do_stuff();
dbmreplace($dbm, $userid, time());
dbmclose($dbm);
do_stuff();
dbmreplace($dbm, $userid, time());
dbmclose($dbm);
if (dbmexists($dbm, $userid)) {
$last_seen = dbmfetch($dbm, $userid);
} else {
dbminsert($dbm, $userid, time());
}
do_stuff();
dbmreplace($dbm, $userid, time());
dbmclose($dbm);

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.

$key = dbmfirstkey($dbm_id);
while ($key) {
    echo "$key = " . dbmfetch($dbm_id, $key) . "\n";
    $key = dbmnextkey($dbm_id, $key);
}
     

dblist

dblist -- »ç¿ëÁßÀÎ dbm-compatible library¿¡ ´ëÇÑ Á¤º¸¸¦ Ç¥½ÃÇÑ´Ù.

Description

string dblist(void);

X. Directory Functions

Table of Contents
chdir
dir
closedir
opendir
readdir
rewinddir

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

$d = dir("/etc");
echo "Handle: ".$d->handle."<br>\n";
echo "Path: ".$d->path."<br>\n";
while($entry=$d->read()) {
    echo $entry."<br>\n";
}
$d->close();
        

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

<?php
$handle=opendir('.');
echo "Directory handle: $handle\n";
echo "Files:\n";
while ($file = readdir($handle)) {
echo "$file\n";
}
closedir($handle);
?>

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.

XI. Dynamic Loading Functions

Table of Contents
dl

dl

dl -- PHP extensionÀ» ½ÇÇàÁß¿¡ loadÇÑ´Ù.

Description

int dl(string library);

Loads the PHP extension defined in library. See also the extension_dir configuration directive.

XII. Program Execution Functions

Table of Contents
escapeshellcmd
exec
system
passthru

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:

system(EscapeShellCmd($cmd))    

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.

See also system(), PassThru(), popen() and EscapeShellCmd().

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.

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.

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 the exec() and popen() functions.

passthru

passthru -- ¿ÜºÎ ÇÁ·Î±×·¥À» ½ÇÇàÇÏ°í ±× °á°ú¸¦ Á÷Á¢ (Áöü¾øÀÌ) Ãâ·ÂÇÑ´Ù.

Description

string 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.

See also exec() and fpassthru().

XIII. filePro Functions

Table of Contents
filepro
filepro_fieldname
filepro_fieldtype
filepro_fieldwidth
filepro_retrieve
filepro_fieldcount
filepro_rowcount

ÀÌ ÇÔ¼öµéÀº filePro ÇüÅÂÀÇ databse(dbf)¿¡ ÀúÀåµÈ ·¹ÄÚµåµéÀ» read-only·Î Á¢±ÙÇÒ ¼ö ÀÖ°Ô ÇØ ÁØ´Ù.

filePro´Â Fiserv, Inc.ÀÇ trademark·Î µî·ÏµÇ¾î ÀÖ´Ù. ¿©·¯ºÐÀº http://www.fileproplus.com/¿¡¼­ filePro¿¡ °üÇÑ ´õ ¸¹Àº Á¤º¸¸¦ ¾òÀ» ¼ö ÀÖ´Ù.

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().

XIV. Filesystem Functions

Table of Contents
basename
chgrp
chmod
chown
clearstatcache
copy
dirname
diskfreespace
fclose
feof
fgetc
fgets
fgetss
file
file_exists
fileatime
filectime
filegroup
fileinode
filemtime
fileowner
fileperms
filesize
filetype
fopen
fpassthru
fputs
fread
fseek
ftell
fwrite
is_dir
is_executable
is_file
is_link
is_readable
is_writeable
link
linkinfo
mkdir
pclose
popen
readfile
readlink
rename
rewind
rmdir
stat
lstat
symlink
tempnam
touch
umask
unlink

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()

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 fopen(), popen(), fsockopen(), and fgets().

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, 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 fopen(), popen(), or fsockopen().

See also 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(), and popen().

file

file -- ÆÄÀÏ Àüü¸¦ Àо ¹è¿­¿¡ ÀúÀåÇÑ´Ù.

Description

array file(string filename);

Identical to readfile(), except that file() returns the file in an array.

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.

See also clearstatcache().

fileatime

fileatime -- ÆÄÀÏ¿¡ ¸¶Áö¸·À¸·Î Á¢±ÙÇÑ ½Ã°£À» ±¸ÇÑ´Ù.

Description

int fileatime(string filename);

Returns the time the file was last accessed, or false in case of an error.

filectime

filectime -- ÆÄÀÏÀÇ inode°¡ º¯°æµÈ ½Ã°£À» ±¸ÇÑ´Ù.

Description

int filectime(string filename);

Returns the time the file was last changed, or false in case of an error.

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.

fileinode

fileinode -- ÆÄÀÏÀÇ inode¸¦ ±¸ÇÑ´Ù.

Description

int fileinode(string filename);

Returns the inode number of the file, or false in case of an error.

filemtime

filemtime -- ÆÄÀÏÀÌ ¼öÁ¤µÈ ½Ã°£À» ±¸ÇÑ´Ù.

Description

int filemtime(string filename);

Returns the time the file was last modified, or false in case of an 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.

fileperms

fileperms -- ÆÄÀÏÀÇ permissionÀ» ±¸ÇÑ´Ù.

Description

int fileperms(string filename);

Returns the permissions on the file, or false in case of an error.

filesize

filesize -- ÆÄÀÏÀÇ Å©±â¸¦ ±¸ÇÑ´Ù.

Description

int filesize(string filename);

Returns the size of the file, or false in case of an error.

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.

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().

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().

is_dir

is_dir -- ÁöÁ¤µÈ ÆÄÀϸíÀÌ directoryÀΰ¡ ¾Ë·ÁÁØ´Ù.

Description

bool is_dir(string filename);

Returns true if the filename exists and is a directory.

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.

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.

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.

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.

See also is_writeable().

is_writeable

is_writeable -- ÁöÁ¤µÈ ÆÄÀϸíÀÌ ¾²±â °¡´ÉÀΰ¡ ¾Ë·ÁÁØ´Ù.

Description

bool is_readable(string filename);

Returns true if the filename exists and 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.

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

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

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.

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.

XV. Functions related to HTTP

Table of Contents
header
setcookie

ÀÌ ÇÔ¼öµéÀº HTTP protocol leve¿¡¼­ µ¥ÀÌŸ¸¦ remote browser·Î Á÷Á¢ Àü¼ÛÇÒ ¼ö ÀÖµµ·Ï ÇØ ÁØ´Ù.

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.

Header("Location: http://www.php.net"); /* Redirect browser to PHP web site */
exit; /* Make sure that code below does not get executed when we redirect. */

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

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); // always modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0

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. 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. Some examples follow:

Example 1. SetCookie examples

SetCookie("TestCookie","Test Value");
SetCookie("TestCookie",$value,time()+3600);  /* expire in 1 hour */
SetCookie("TestCookie",$value,time()+3600,"/~rasmus/",".utoronto.ca",1);

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. ie. to see the contents of our test cookie in a script, simply do:

echo $TestCookie;

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.

XVI. Hyperwave functions

( ¿ªÀÚÁÖ : À̺κÐÀº ¹ø¿ªÀÌ ¹«Ã´ ¾î·Á¿ü´Ù. À߸øµÈ ´Ü¾îµµ ¸¹¾Ò°í, Àǹ̰¡ ¸íÈ®ÇÏÁö ¾ÊÀº ºÎºÐµµ ¸¹¾Ò´Ù. ¶ÇÇÑ ¿ªÀÚ°¡ »ç¿ëÇØ º¸Áö ¸øÇÑ ±â´ÉÀ̱⠶§¹®¿¡ ±× ³»¿ëÀ» Àß ¾ËÁö ¸øÇÏ´Â ÀÌÀ¯µµ ÀÖ´Ù. ¿À¿ªÀÌ ÀÖÀ» ¼öµµ ÀÖÀ¸¹Ç·Î °¡´ÉÇÏ¸é ¿ø¹®µµ ÇÔ²² º¸µµ·Ï ÇÑ´Ù.)
Table of Contents
hw_Changeobject
hw_Children
hw_ChildrenObj
hw_Close
hw_Connect
hw_Cp
hw_Deleteobject
hw_DocByAnchor
hw_DocByAnchorObj
hw_DocumentAttributes
hw_DocumentBodyTag
hw_DocumentSize
hw_ErrorMsg
hw_EditText
hw_Error
hw_Free_Document
hw_GetParents
hw_GetParentsObj
hw_GetChildColl
hw_GetChildCollObj
hw_GetSrcByDestObj
hw_GetObject
hw_GetAndLock
hw_GetText
hw_GetObjectByQuery
hw_GetObjectByQueryObj
hw_GetObjectByQueryColl
hw_GetObjectByQueryCollObj
hw_GetChildDocColl
hw_GetChildDocCollObj
hw_GetAnchors
hw_GetAnchorsObj
hw_Mv
hw_Identify
hw_InCollections
hw_Info
hw_InsColl
hw_InsDoc
hw_InsertDocument
hw_New_Document
hw_Objrec2Array
hw_OutputDocument
hw_pConnect
hw_PipeDocument
hw_Root
hw_Unlock
hw_Username


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 À̸§À» ¼±ÅÃÇÏ´Â °Í¸¸ÀÌ ÀÌ È¥¶õÀ» ÇÇÇÒ ¼ö ÀÖ´Ù.

ÀÌ °áÁ¤À» ³»¸®°Ô µÇ¸é µÎºÐ° ¹®Á¦°¡ »ý±ä´Ù. ¾î¶»°Ô php3¿¡ Æ÷ÇÔ½Ãų °ÍÀΰ¡? http://host/my_objectÀÇ URL·Î´Â ¾î¶² php3 ½ºÅ©¸³Æ®µµ È£ÃâÇÏÁö ¸øÇÑ´Ù. À̸¦ À§Çؼ­´Â ¿©·¯ºÐÀÌ À¥¼­¹ö¿¡ ÀÌÁÖ¼Ò¸¦ 'http://host/php3_script/my_object'°°Àº ÁÖ¼Ò·Î Àç¼³Á¤Çϵµ·Ï ¾Ë·ÁÁÖ¾î¾ß Çϰí, $PATH_INFO º¯¼ö¿Í Hyperwave serverÀÇ 'my_object'¶ó´Â À̸§ÀÇ object¸¦ °Ë»öÇÏ¿© Æò°¡ÇÏ´Â 'php3_script'¶ó´Â ½ºÅ©¸³Æ®°¡ ÀÖ¾î¾ß ÇÑ´Ù.

¿©±â¿¡´Â ½±°Ô °íÄ¥ ¼ö ÀÖ´Â °áÁ¡ÀÌ Çϳª ÀÖ´Ù. À¥¼­¹ö¿¡¼­ ¾ðÁ¦³ª ´Ù¸¥ ¹®¼­·ÎÀÇ Á¢±ÙÀÌ °¡´ÉÇÑ URLÀ» Àç¼³Á¤ÇÒ ¼ö ÀÖ´Â °ÍÀº ¾Æ´Ï¶ó´Â °ÍÀÌ´Ù. Hyperwave ¼­¹ö·ê °Ë»öÇϱâ À§ÇÑ php3 ½ºÅ©¸³Æ®´Â ¾Æ¸¶ ºÒ°¡´ÉÇÒ °ÍÀÌ´Ù. ±×·¯¹Ç·Î ¿©·¯ºÐÀº ÃÖ¼ÒÇÑ http://host/Hyperwave·Î ½ÃÀÛÇÏ´Â °Í °°Àº ƯÁ¤ URLÀº Á¦¿Ü½ÃŰ´Â µÎ ¹øÂ° Àç¼³Á¤ ±ÔÄ¢À» ¼³Á¤ÇÒ Çʿ䰡 ÀÖ´Ù. À̰ÍÀÌ À¥ÀÇ namespace¿Í Hyperwave ¼­¹ö¸¦ °øÀ¯ÇÏ´Â ±âº»ÀÌ µÈ´Ù.

¸µÅ©ÀÇ »ðÀÔÀº À§ÀÇ ¸ÞÄ«´ÏÁòÇÏ¿¡¼­ ÀÌ·ç¾î Áø´Ù. ¸¸¾à php3°¡ 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ÀÇ »ç¿ëÀÌ ÇʼöÀûÀ¸·Î ¿ä±¸µÈ´Ù.

PHP3¿¡ Hyperwave Áö¿øÀ» Ãß°¡ÇÔÀ¸·Î½á, interface customisationºÎºÐ¿¡¼­ PHP3ÀÇ ÇÁ·Î±×·¡¹Ö ¾ð¾îÀÇ ºÎÁ·ÇÑ ºÎºÐÀ» º¸ÃæÇÒ ¼ö ÀÖ´Ù. À̰ÍÀº 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 ¸ðµâÀº PHP3°¡ ¾ÆÆÄÄ¡ ¸ðµâ·Î ÄÄÆÄÀϵǾúÀ» ¶§ °¡Àå Àß »ç¿ëµÉ ¼ö ÀÖ´Ù. ÀÌ °æ¿ì¿¡ ¾ÆÆÄÄ¡°¡ ÀÚ½ÅÀÇ ÀçÀÛ¼º(rewriting) ¿£ÁøÀ» »ç¿ëÇÏ°Ô µÇ¸é Hyperwave ¼­¹öÀÇ Á¸Àç´Â »ç¿ëÀÚ°¡ °ÅÀÇ ´À³¥ ¼ö ¾ø°Ô µÈ´Ù. ´ÙÀ½ÀÇ ³»¿ëµéÀÌ À̰ÍÀ» ¼³¸íÇØ ÁÙ °ÍÀÌ´Ù.

Hyperwave¸¦ Áö¿øÇÏ´Â ¾ÆÆÄÄ¡·Î ¸¸µé¾îÁø PHP3°¡ wavemaster±â¹ÝÀÇ µ¶ÀÚÀûÀÎ Hyperwave ¼Ö·ç¼ÇÀ» ´ë½ÅÇÏ·Á ÇÒ ¶§ºÎÅÍ, ¾ÆÆÄÄ¡ ¼­¹ö°¡ Hyperwave À¥ ÀÎÅÍÆäÀ̽º¸¦ Áö¿øÇÏ´Â À¯ÀÏÇÑ ¼­¹ö°¡ µÇ¸®¶ó ´ç¿¬È÷ ÃßÁ¤µÇ¾ú´Ù.

À̰ÍÀº ¹Ýµå½Ã ÇÊ¿äÇÑ °ÍÀº ¾Æ´ÏÁö¸¸ ¼³Á¤À» ½±°Ô ÇØÁØ´Ù. °³³äÀº ´Ü¼øÇÏ´Ù. ¿ì¼±, ¿©·¯ºÐÀº PATH_INFO º¯¼ö¸¦ Æò°¡Çϰí ÀÌ º¯¼öÀÇ °ªÀ» Hyperwave object·Î ´Ù·ê PHP3 ½ºÅ©¸³Æ®°¡ ÇÊ¿äÇÏ´Ù. ÀÌÁ¦ ÀÌ ½ºÅ©¸³Æ®ÀÇ À̸§À» '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) ±ÔÄ¢Àº ´ÙÀ½°ú °°ÀÌ ¸Å¿ì ½±´Ù. :

RewriteRule ^/(.*) /usr/local/apache/htdocs/HyperWave/$1 [L]

ÀÌÁ¦ ¸ðµç URLÀº Hyperwave ¼­¹öÀÇ object¿Í ¿¬°áµÈ´Ù. À̰ÍÀº ºñ±³Àû °£´ÜÈ÷ ÇØ°áÇÒ ¼ö ÀÖ´Â ÇѰ¡Áö ¹®Á¦¸¦ ¸¸µé¾î ³½´Ù. À̷νá 'Hyperwave' ½ºÅ©¸³Æ® ÀÌ¿ÜÀÇ ´Ù¸¥ ½ºÅ©¸³Æ®(¿¹¸¦µé¾î, °Ë»öÀ» À§ÇÑ ½ºÅ©¸³Æ® µî)´Â ½ÇÇàÇÒ ¼ö ¾ø°Ô µÈ´Ù. À̸¦ ÇØ°áÇϱâ À§ÇÑ ¶Ç´Ù¸¥ ÀÛ¼º(rewriting) ±ÔÄ¢À» ´ÙÀ½°ú °°ÀÌ ÀÛ¼ºÇØ ÁØ´Ù. ¤Ó

RewriteRule ^/hw/(.*) /usr/local/apache/htdocs/hw/$1 [L]

À̰ÍÀ¸·Î Ãß°¡ÀûÀÎ ½ºÅ©¸³Æ®¿Í ÆÄÀϵéÀ» À§ÇÑ /usr/local/apache/htdocs/hw µð·ºÅ丮¸¦ ³²°ÜµÎ°Ô µÈ´Ù. ±×¸®°í ÀÌ ±ÔÄ¢À» À§ÀÇ ±ÔÄ¢º¸´Ù ¸ÕÀú Æò°¡µÇµµ·Ï ÇÑ´Ù. ¾à°£ÀÇ °áÁ¡ÀÌ Àִµ¥, 'hw/'·Î ½ÃÀÛÇÏ´Â À̸§À» °¡Áø Hyperwave object´Â Á¢±ÙÇÒ ¼ö ¾ø°Ô µÈ´Ù. ±×·¯¹Ç·Î ¿©·¯ºÐÀº ±×·± À̸§Àº ¾²Áö ¾Êµµ·Ï ÇÑ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ´õ ¸¹Àº µð·ºÅ丮(¿¹¸¦µé¾î, À̹ÌÁö¸¦ À§ÇÑ µð·ºÅ丮)°¡ ÇÊ¿äÇÏ´Ù¸é, »õ·Î¿î ±ÔÄ¢À» ÷°¡Çϰųª ¿øÇÏ´Â µð·ºÅ丮µéÀ» ¸ðµÎ ÇÑ µð·ºÅ丮 ¹Ø¿¡ ³õÀ¸¸é µÈ´Ù. ¸¶Áö¸·À¸·Î, ´ÙÀ½°ú °°ÀÌÇÏ¿© ÀçÀÛ¼º ¿£Áø(rewriting engine)À» Äѵµ·Ï ÇÑ´Ù. :

RewriteEngine on

³» °æÇèÀ¸·Î º¸¾ÒÀ» ¶§ ¿©·¯ºÐÀ» ´ÙÀ½ÀÇ ½ºÅ©¸³Æ®µéÀÌ ÇÊ¿äÇÏ°Ô µÉ °ÍÀÌ´Ù. :


Todo

¾ÆÁ÷ ÇØ¾ßÇÒ ÀÏÀº ´ÙÀ½°ú °°´Ù. :


hw_Changeobject

hw_Changeobject -- object¸¦ ¹Ù²Û´Ù.

Description

int hw_changeobject(int connection, int object_to_change, string commands);

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; commands adhere to the following syntax:

<command> ::= <remcmd> |
              <addcmd> |
              <remcmd> "\" <addcmd>

<remcmd>  ::= "rem " <attribute> "=" <value>

<addcmd>  ::= "add " <attribute> "=" <value>                

Note that in order to delete or remove an attribute its old value has to be supplied (some attributes are allowed more than once). A command like rem attr=value\add attr=value allows to modify attributes in one operation.

Returns TRUE if no error occurs otherwise FALSE.

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_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_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 objectID);

Returns the object record for the object with ID objectID.

See also hw_GetAndLock().

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, int rootID);

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 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.

If rootID is unequal to 0 the link is constructed from all the names starting at the object with the id rootID 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 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.

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.

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.

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.

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 source 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.

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 defined by collection id_array. When the fourth parameter return_collectionsis 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_putdocument(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.

See also hw_PipeDocument().

hw_New_Document

hw_New_Document -- »õ document¸¦ ¸¸µç´Ù.

Description

int hw_new_document(string document_data, string object_record, 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.

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_Username

hw_Username -- ÇöÀç log in Çϰí ÀÖ´Â userÀÇ À̸§

Description

string hw_getusername(int connection);

Returns the username of the connection.

XVII. Image functions

Table of Contents
GetImageSize
ImageArc
ImageChar
ImageCharUp
ImageColorAllocate
ImageColorTransparent
ImageCopyResized
ImageCreate
ImageCreateFromGif
ImageDashedLine
ImageDestroy
ImageFill
ImageFilledPolygon
ImageFilledRectangle
ImageFillToBorder
ImageFontHeight
ImageFontWidth
ImageGif
ImageInterlace
ImageLine
ImageLoadFont
ImagePolygon
ImageRectangle
ImageSetPixel
ImageString
ImageStringUp
ImageSX
ImageSY
ImageTTFBBox
ImageTTFText
ImageColorAt
ImageColorClosest
ImageColorExact
ImageColorResolve
ImageColorSet
ImageColorsForIndex
ImageColorsTotal

¿©·¯ºÐÀº ¿©±âÀÇ ÇÔ¼öµé·Î JPEG, GIF, PNG À̹ÌÁöÀÇ Å©±â¸¦ ¾Ë¾Æº¼ ¼ö ÀÖ´Ù. ¶ÇÇÑ ¿©·¯ºÐÀÌ GD library(http://www.boutell.com/gd/¿¡ ÀÖ´Ù.)¸¦ °¡Áö°í ÀÖ´Ù¸é, ¿©·¯ºÐÀº GIF À̹ÌÁö¸¦ ¸¸µé°Å³ª ¼öÁ¤ÇÒ ¼ö ÀÖ´Ù.

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

<?php $size = GetImageSize("img/flag.jpg"); ?>
<IMG SRC="img/flag.jpg" <?php echo $size[3]; ?>>

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

<?php
$size = GetImageSize("testimg.jpg",&$info);
if (isset($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
var_dump($iptc);
}
?>

Note: This function does not require the GD image library.

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 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().

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.

$white = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0,0,0);

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.

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 -- ÆÄÀÏÀ̳ª URL·ÎºÎÅÍ »õ image¸¦ ¸¸µç´Ù.

Description

int imagecreatefromgif(string filename);

ImageCreateFromGif returns an image identifier representing the image obtained from the given filename.

ImageDashedLine

ImageDashedLine -- Á¡¼±À» ±×¸°´Ù.

Description

int imagedashedline(int im, int x1, int y1, int x2, int y2, int col);

ImageLine 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 width of a character in 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 -- browser³ª ÆÄÀÏ·Î ±×¸²À» Ãâ·ÂÇÑ´Ù.

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 the header function, you can create a PHP script that outputs GIF images directly.

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, int 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().

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

<?php
Header("Content-type: image/gif");
$im = imagecreate(400,30);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
ImageTTFText($im, 20, 0, 10, 20, $white, "/path/arial.ttf", "Testing... Omega: &#937;");
ImageGif($im);
ImageDestroy($im);
?>

This function requires both the GD library and the FreeType< library.

See also ImageTTFBBox().

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

int 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().

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().

XVIII. IMAP Functions

Table of Contents
imap_append
imap_base64
imap_body
imap_check
imap_close
imap_createmailbox
imap_delete
imap_deletemailbox
imap_expunge
imap_fetchbody
imap_fetchstructure
imap_header
imap_headers
imap_listmailbox
imap_listsubscribed
imap_mail_copy
imap_mail_move
imap_num_msg
imap_num_recent
imap_open
imap_ping
imap_renamemailbox
imap_reopen
imap_subscribe
imap_undelete
imap_unsubscribe
imap_qprint
imap_8bit
imap_binary
imap_scanmailbox
imap_mailboxmsginfo
imap_rfc822_write_address
imap_rfc822_parse_adrlist
imap_setflag_full
imap_clearflag_full
imap_sort
imap_fetchheader
imap_uid

ÀÌ ÇÔ¼öµéÀ» µ¿ÀÛ½ÃŰ·Á¸é 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_append

imap_append -- ÁöÁ¤ÇÑ ÆíÁöÇÔ¿¡ ¹®ÀÚ¿­ ¸Þ¼¼Áö¸¦ µ¡ºÙÀδÙ.

Description

int imap_append(int imap_stream, string mbox, string message, stringflags);

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.

imap_base64

imap_base64 -- BASE64·Î encodeµÈ text¸¦ decodeÇÑ´Ù.

Description

string imap_base64(string text);

imap_base64() function decodes BASE-64 encoded text. The decoded message is returned as a string.

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

array 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.

Date : date of the message
Driver : driver
Mailbox : name of the mailbox
Nmsgs : number of messages
Recent : number of recent messages

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.

imap_createmailbox

imap_createmailbox -- »õ ÆíÁöÇÔÀ» ¸¸µç´Ù.

Description

int imap_createmailbox(int imap_stream, string mbox);

imap_createmailbox() creates a new mailbox specified by mbox.

Returns true on success and false on error.

imap_delete

imap_delete -- ÇöÀç ÆíÁöÇÔ¿¡¼­ ¾î¶² messge¿¡ »èÁ¦ ¸¶Å©¸¦ ÇÑ´Ù.

Description

int imap_delete(int imap_stream, int msg_number);

Returns true.

imap_delete() function marks message pointed by msg_number for deletion. Actual deletion of the messages is done by imap_expunge().

imap_deletemailbox

imap_deletemailbox -- ÆíÁöÇÔÀ» Áö¿î´Ù.

Description

int imap_deletemailbox(int imap_stream, string mbox);

imap_deletemailbox() deletes the specified mailbox.

Returns true on success and false on error.

imap_expunge

imap_expunge -- »èÁ¦ ¸¶Å©°¡ µÇ¾î ÀÖ´Â ¸ðµç ¸Þ¼¼Áö¸¦ Áö¿î´Ù.

Description

int imap_expunge(int imap_stream);

imap_expunge() deletes all the messages marked for deletion by imap_delete().

Returns true.

imap_fetchbody

imap_fetchbody -- messageÀÇ bodyÁß particular sectionÀ» °¡Áö°í ¿Â´Ù.

Description

string imap_fetchbody(int imap_stream, int msg_number, int 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 ()e a bitmask with one or more of the following

imap_fetchstructure

imap_fetchstructure -- particular messageÀÇ ±¸Á¶¸¦ Àоî¿Â´Ù.

Description

array imap_fetchstructure(int imap_stream, int msg_number);

This function causes a fetch of all the structured information for the given msg_number. The returned value is an object with following elements.

type, encoding, ifsubtype, subtype, ifdescription, description, ifid,
id, lines, bytes, ifparameters

It also returns an array of objects called parameters[]. This object has following properties.

attribute, value

In case of multipart, it also returns an array of objects of all the properties, called parts[].

imap_header

imap_header -- messageÀÇ header¸¦ Àоî¿Â´Ù.

Description

object imap_header(int imap_stream, int msg_number, int fromlength, int subjectlength, int defaulthost);

This function returns an object of various header elements

       remail,date,Date,subject,Subject,in_reply_to,message_id,newsgroups,
       followup_to,references
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_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 pat);

Returns an array containing the names of the mailboxes.

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. The ref and pattern arguments specify the base location to search from and the pattern the mailbox name must match.

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.

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);

Moves mail messages specified by msglist to specified mailbox. msglist is a range not just message numbers.

Returns true on success and false on error.

imap_num_msg

imap_num_msg -- ÇöÀç ÆíÁöÇÔÀÇ ¸Þ¼¼Áö °³¼ö¸¦ ±¸ÇÑ´Ù.

Description

int imap_num_msg(void);

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. To connect to an IMAP server running on port 143 on the local machine, do the following:

$mbox = imap_open("{localhost:143}INBOX","user_id","password");

To connect to a POP3 server on port 110 on the local server, use:

$mbox = imap_open("{localhost/pop3:110}INBOX","user_id","password");

To connect to an NNTP server on port 119 on the local server, use:

$nntp = imap_open("{localhost/nntp:119}comp.test","","");

To connect to a remote server replace "localhost" with the name or the IP address of the server you want to connect to.

The options are a bit mask with noe or more of the following:

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.

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.

Returns true on success and false on error.

imap_reopen

imap_reopen -- ±âÁ¸¿¡ ¿­·ÁÀÖ´Â IMAP streamÀ» »õ ÆíÁöÇÔÀ¸·Î ¿¬´Ù.

Description

int imap_reopen(string imap_stream, string mailbox, string [flags]);

Returns true on success and false on error.

This function reopens the specified stream to new mailbox.

the options are a bit mask with noe or more of the following:

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().

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

Returns an 8 bit (binary) string

imap_8bit

imap_8bit -- 8 bit ¹®ÀÚ¿­À» quoted-printable ¹®ÀÚ¿­·Î ¹Ù²Û´Ù.

Description

string imap_8bit(string string);

Convert an 8bit string to a quoted-printable string.

Returns a quoted-printable string

imap_binary

imap_binary -- 8bit ¹®ÀÚ¿­À» base64 ¹®ÀÚ¿­·Î ¹Ù²Û´Ù.

Description

string imap_binary(string string);

Convert an 8bit string to a base64 string.

Returns a base64 string

imap_scanmailbox

imap_scanmailbox -- mailboxµéÀÇ list¸¦ Àаí, °Ë»öÇÒ ¹®ÀÚ¿­À» mailboxÀÇ text¿¡¼­ ÃëÇÑ´Ù.

takes a string to search for in the text of the mailbox

Description

array imap_scanmailbox(int imap_stream, string string);

Returns an array containing the names of the mailboxes that have string in the text of the mailbox.

imap_mailboxmsginfo

imap_mailboxmsginfo -- ÇöÀç mailbox¿¡ ´ëÇÑ Á¤º¸¸¦ ±¸ÇÑ´Ù.

Description

array 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 and returns the information in an object with following properties.

       Date : date of the message
       Driver : driver
       Mailbox : name of the mailbox
       Nmsgs : number of messages
       Recent : number of recent messages
       Unread : number of unread messages
       Size : mailbox size

imap_rfc822_write_address

imap_rfc822_write_address -- ÁÖ¾îÁø mailbox¿Í host, personal info·Î ÀûÇÕÇÑ ¸ð¾çÀÇ email address¸¦ ¸¸µé¾î ³½´Ù.

Returns a properly formatted email address given the mailbox, host, and personal info.

Description

string imap_rfc822_write_address(string mailbox, string host, string personal);

Returns a properly formatted email address given the mailbox, host, and personal info.

imap_rfc822_parse_adrlist

imap_rfc822_parse_adrlist -- address ¹®ÀÚ¿­À» parsingÇÑ´Ù.

Description

string imap_rfc822_parse_adrlist(string address, string default_host);

This function parses the address tring and for each address, returns an array of objects. The 4 objects are:

     mailbox - the mailbox name (username)
     host   - the host name
     personal - the personal name
     adl - at domain source route
    

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 options are a bit mask with one or more of the following:

        ST_UID          The sequence argument contains UIDs instead of sequence numbers 

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 options are a bit mask with one or more of the following:

        ST_UID          The sequence argument contains UIDs instead of sequence numbers

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

Rev 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

stringimap_fetchheader(int imap_stream, int msgno, int flags);

This function causes a fetch of the complete, unfiltered RFC 822 format header of the specified message as a text string and returns that text string.

The options are:

        FT_UID          The msgno argument is a UID 
        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

string imap_uid(string mailbox, int msgno);

This function returns the UID for the given message sequence number


XIX. PHP options & information

Table of Contents
error_log
error_reporting
getenv
get_cfg_var
et_current_user
get_magic_quotes_gpc
get_magic_quotes_runtime
getlastmod
getmyinode
getmypid
getmyuid
phpinfo
phpversion
putenv
set_magic_quotes_runtime
set_time_limit

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

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().

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().

putenv

putenv -- ȯ°æ º¯¼ö(environment variable)ÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù.

Description

void putenv(string setting);

Adds setting to the environment.

Example 1. Setting an Environment Variable

putenv("UNIQID=$uniqid");
      

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.

XX. Informix Functions

Table of Contents
ifx_connect
ifx_pconnect
ifx_close
ifx_query
ifx_prepare
ifx_do
ifx_error
ifx_errormsg
ifx_affected_rows
ifx_fetch_row
ifx_htmltbl_result
ifx_fieldtypes
ifx_fieldproperties
ifx_num_fields
ifx_num_rows
ifx_free_result
ifx_create_char
ifx_free_char
ifx_update_char
ifx_get_char
ifx_create_blob
ifx_copy_blob
ifx_free_blob
ifx_get_blob
ifx_update_blob
ifx_blobinfile_mode
ifx_textasvarchar
ifx_byteasvarchar
ifx_nullformat
ifxus_create_slob
ifx_free_slob
ifxus_close_slob
ifxus_open_slob
ifxus_tell_slob
ifxus_seek_slob
ifxus_read_slob
ifxus_write_slob

InformixÀÇ Online (ODS) 7.x¿Í SE 7.x, Universal Server (IUS) 9.x¸¦ À§ÇÑ µå¶óÀ̹ö´Â "functions/ifx.ec"¿Í "functions/php3_ifx.h"¿¡ ±¸ÇöµÇ¾î ÀÖ´Ù. À̱ÛÀÌ ¾²¿©Áú ´ç½Ã ¿ÏÀüÇÑ BLOB Áö¿øÀ» Æ÷ÇÔÇÏ¿©, ODS 7.2¿¡ ´ëÇÑ Áö¿ø´Â °ÅÀÇ ¿Ï¼ºµÇ¾ú´Ù. IUS 9.1¿¡ ´ëÇÑ Áö¿øÀº ºÎºÐÀûÀ¸·Î¸¸ ¿Ï·áµÇ¾ú´Ù. »õ·Î¿î µ¥ÀÌÅÍ Å¸ÀÔµéÀº ¿Ï·áµÇ¾úÀ¸³ª, SLOBS¿¡ ´ëÇÑ Áö¿øÀº ¾ÆÁ÷ ÁøÇàÁßÀÌ´Ù.

¼³Á¤½Ã ÁÖÀÇ »çÇ× (Configuration notes) :

"configure" ½ºÅ©¸³Æ®¸¦½ÇÇàÇϱâ Àü¿¡, ¹Ýµå½Ã "INFORMIXDIR" ȯ°æ º¯¼ö¸¦ ¼³Á¤ÇØ ³õ¾Æ¾ß ÇÑ´Ù.

ÀÌ·¸°Ô ÇØ ³õ°í "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) :

ÇöÀç ¹öÀü(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 Çʵåó·³ »ç¿ëÇÒ ¼ö ÀÖ´Ù. PHP3¿¡¼­ ¸ðµç ¹®ÀÚ¿­ÀÌ °è»ê("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·Î ¼³Á¤µÇ¾îÀÖÀ¸¸é µÚ¿¡ ºÙÀº °ø¹é¹®ÀÚ¸¦ ÀÚµ¿À¸·Î Á¦°ÅÇÑ´Ù.


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

$conn_id = ifx_pconnect (mydb@ol_srv1, "imyself", "mypassword");

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

$conn_id = ifx_connect (mydb@ol_srv, "itsme", "mypassword");
... some queries and stuff ...
ifx_close($conn_id);

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

ifx_textasvarchar(1); // use "text mode" for blobs
$res_id = ifx_query("select * from orders", $conn_id);
if (! $res_id) {
printf("Can't select orders : %s\n<br>%s<br>\n",
ifx_error();
ifx_errormsg();
die;
}
ifx_htmltbl_result($res_id, "border=\"1\");
ifx_free_result($res_id);

Example 2. Insert some values into the "catalog" table

// create blob id's for a byte and text column
$textid = ifx_create_blob(0, 0, "Text column in memory");
$byteid = ifx_create_blob(1, 0, "Byte column in memory");
// store blob id's in a blobid array
$blobidarray[] = $textid;
$blobidarray[] = $byteid;
// launch query
$query = "insert into catalog (stock_num, manu_code, " .
"cat_descr,cat_picture) values(1,'HRO',?,?)";
$res_id = ifx_query($query, $conn_id, $blobidarray);
if (! $res_id) {
... error ...
}
// free result id
ifx_free_result($res_id);

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]

where x = space : no error

E : error

N : no more data

W : warning

? : undefined

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()

printf("%s\n<br>", ifx_errormsg(-201));

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

$rid = ifx_prepare ("select * from emp where name like " . $name, $connid);
if (! $rid) {
... error ...
}
$rowcount = ifx_affected_rows ($rid);
if ($rowcount > 1000) {
printf ("Too many rows in result set (%d)\n<br>", $rowcount);
die ("Please restrict your query<br>\n");
}

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

$rid = ifx_prepare ("select * from emp where name like " . $name,
$connid, IFX_SCROLL);
if (! $rid) {
... error ...
}
$rowcount = ifx_affected_rows($rid);
if ($rowcount > 1000) {
printf ("Too many rows in result set (%d)\n<br>", $rowcount);
die ("Please restrict your query<br>\n");
}
if (! ifx_do ($rid)) {
... error ...
}
$row = ifx_fetch_row ($rid, "NEXT");
while (is_array($row)) {
for(reset($row); $fieldname=key($row); next($row)) {
$fieldvalue = $row[$fieldname];
printf ("%s = %s,", $fieldname, $fieldvalue);
}
printf("\n<br>");
$row = ifx_fetch_row ($rid, "NEXT");
}
ifx_free_result ($rid);

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

$rid = ifx_prepare ("select * from emp where name like " . $name,
$connid, IFX_SCROLL);
if (! $rid) {
... error ...
}
$rowcount = ifx_affected_rows ($rid);
if ($rowcount > 1000) {
printf ("Too many rows in result set (%d)\n<br>", $rowcount);
die ("Please restrict your query<br>\n");
}
if (! ifx_do($rid) {
... error ...
}
ifx_htmltbl_result ($rid, "border=\"2\"");
ifx_free_result($rid);

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

$types = ifx_fieldtypes ($resultid);
if (! isset ($types)) {
... error ...
}
for ($i = 0; $i < count($types); $i++) {
$fname = key($types);
printf("%s :\t type = %s\n", $fname, $types[$fname]);
next($types);
}

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

$properties = ifx_fieldtypes ($resultid);
if (! isset($properties)) {
... error ...
}
for ($i = 0; $i < count($properties); $i++) {
$fname = key ($properties);
printf ("%s:\t type = %s\n", $fname, $properties[$fname]);
next ($properties);
}

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_blob(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.

XXI. InterBase Functions

Table of Contents
ibase_connect
ibase_pconnect
ibase_close
ibase_query
ibase_fetch_row
ibase_free_result
ibase_prepare
ibase_bind
ibase_execute
ibase_free_query
ibase_timefmt

ibase_connect

ibase_connect --

Description

ibase_connect( );

ibase_pconnect

ibase_pconnect --

Description

ibase_pconnect( );

ibase_close

ibase_close --

Description

ibase_close( );

ibase_query

ibase_query --

Description

ibase_query( );

ibase_fetch_row

ibase_fetch_row --

Description

ibase_fetch_row( );

ibase_free_result

ibase_free_result --

Description

ibase_free_result( );

ibase_prepare

ibase_prepare --

Description

ibase_prepare( );

ibase_bind

ibase_bind --

Description

ibase_bind( );

ibase_execute

ibase_execute --

Description

ibase_execute( );

ibase_free_query

ibase_free_query --

Description

ibase_free_query( );

ibase_timefmt

ibase_timefmt --

Description

ibase_timefmt( );

XXI. LDAP Functions

Table of Contents
ldap_add
ldap_bind
ldap_close
ldap_connect
ldap_count_entries
ldap_delete
ldap_dn2ufn
ldap_explode_dn
ldap_first_attribute
ldap_first_entry
ldap_free_result
ldap_get_attributes
ldap_get_dn
ldap_get_entries
ldap_get_values
ldap_list
ldap_modify
ldap_next_attribute
ldap_next_entry
ldap_read
ldap_search
ldap_unbind

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

<?php
// basic sequence with LDAP is connect, bind, search, interpret search
// result, close connection
echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
$ds=ldap_connect("localhost"); // must be a valid LDAP server!
echo "connect result is ".$ds."<p>";
if ($ds) {
echo "Binding ...";
$r=ldap_bind($ds); // this is an "anonymous" bind, typically
// read-only access echo "Bind result is
echo "Bind result is ".$r."<p>";
echo "Searching for (sn=S*) ...";
// Search surname entry
$sr=ldap_search($ds,"o=My Company, c=US", "sn=S*");
echo "Search result is ".$sr."<p>";
echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."<p>";
echo "Getting entries ...<p>";
$info = ldap_get_entries($ds, $sr);
echo "Data for ".$info["count"]." items returned:<p>";
for ($i=0; $i<$info["count"]; $i++) {
echo "dn is: ". $info[$i]["dn"] ."<br>";
echo "first cn entry is: ". $info[$i]["cn"][0] ."<br>";
echo "first email entry is: ". $info[$i]["mail"][0] ."<p>";
}
echo "Closing connection";
ldap_close($ds);
} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}
?>


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 ÇüÅ·ΠÀÖ½À´Ï´Ù.


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

<?php
$ds=ldap_connect("localhost"); // assuming the LDAP server is on this host
if ($ds) {
// bind with appropriate dn to give update access
$r=ldap_bind($ds,"cn=root, o=My Company, c=US", "secret");
// prepare data
$info["cn"]="John Jones";
$info["sn"]="Jones";
$info["mail"]="jonj@here.and.now";
$info["objectclass"]="person";
// add data to directory
$r=ldap_add($ds, "cn=John Jones, o=My Company, c=US", $info);
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?>

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

string ldap_dn2ufn(string dn);

ldap_dn2ufn() function is used to turn a DN into a more user-friendly form, stripping off type names.

ldap_explode_dn

ldap_explode_dn -- DNÀ» ±×°ÍÀÇ ±¸¼º ºÎºÐÀ¸·Î ³ª´«´Ù.

Description

string 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 1 and to get only values set it to 0.

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 comlete 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

// $ds is the link identifier for the directory
// $sr is a valid search result from a prior call to
// one of the ldap directory search calls
$entry = ldap_first_entry($ds, $sr);
$attrs = ldap_get_attributes($ds, $entry);
echo $attrs["count"]." attributes held for this entry:<p>";
for ($i=0; $i<$attrs["count"]; $i++)
echo $attrs[$i]."<br>";

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

// $ds is a valid link identifier for a directory server
// $sr is a valid search result from a prior call to
// one of the ldap directory search calls
// $entry is a valid entry identifier from a prior call to
// one of the calls that returns a directory entry
$values = ldap_get_values($ds, $entry,"mail");
echo $values["count"]." email addresses for this entry.<p>";
for ($i=0; $i < $values["count"]; $i++)
echo $values[$i]."<br>";

ldap_list

ldap_list -- Single-level °Ë»ö (search)

Description

int ldap_list(int link_identifier, string base_dn, string filter);

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

// $ds is a valid link identifier for a directory server
$basedn = "o=My Company, c=US";
$justthese = array("ou");
$sr=ldap_list($ds, $basedn, "ou=*", $justthese);
$info = ldap_get_entries($ds, $sr);
for ($i=0; $i<$info["count"]; $i++)
echo $info[$i]["ou"][0] ;

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

// $ds is a valid link identifier for a directory server
// $person is all or part of a person's name, eg "Jo"
$dn = "o=My Company, c=US";
$filter="(|(sn=$person*)(givenname=$person*))";
$justthese = array( "ou", "sn", "givenname", "mail");
$sr=ldap_search($ds, $dn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
print $info["count"]." entries returned<p>";

When you perform a search, and too much data comes back (alot of entries) you will get a warning, and ldap_get_entries() will fail. The trick here is to turn off the warnings, then check the return value.

$normerr = error_reporting ();
error_reporting (0);  // turn off warnings!
$sr = ldap_search ($ds, $dn, $searchfor);
$normerr = error_reporting ($normerr);
if (!$sr) {
    print "too many entries!";
} else .....
      

You could try narrowing the scope, by adding an extra filter eg. (cn=a*), but It would be nicer to be able to grab the results in bits (eg. 1-100, 101-200...).

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.

XXIII. Mail Functions

Table of Contents
mail

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 space between each address in to.

Example 1. Sending mail.

mail("rasmus@lerdorf.on.ca", "My Subject", "Line 1\nLine 2\nLine 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.

mail("ssb@guardian.no", "the subject", $message,
"From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" . phpversion());

( ¿ªÀÚÁÖ : ´ÙÀ½°ú °°ÀÌ \r\nÀ» »ç¿ëÇÏ¿© header¿¡ ¿©·¯ ³»¿ëÀ» ÷°¡ÇÒ ¼ö ÀÖ´Ù.
mail("ssb@guardian.no", "the subject", $message, "X-Mailer: PHP/" . phpversion()."\r\nFrom:webmaster@yourhost.com\r\nReply-To: webmaster@yourhost.com"); )

XXIV. Mathematical Functions

Table of Contents
Abs
Acos
Asin
Atan
Atan2
base_convert
BinDec
Ceil
Cos
DecBin
DecHex
DecOct
Exp
Floor
getrandmax
HexDec
Log
Log10
max
min
mt_rand
mt_srand
mt_getrandmax
number_format
OctDec
pi
pow
rand
round
Sin
Sqrt
srand
Tan


Introduction

ÀÌ ¼öÇÐ ÇÔ¼öµéÀº ¿©·¯ºÐÀÇ ÄÄÇ»ÅÍÀÇ long°ú double ÇüÅ·θ¸ »ç¿ëµË´Ï´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ÀÌ ÀÌ»óÀÇ ¼ýÀÚ¸¦ ´Ù·ç¾î¾ßÇÑ´Ù¸é arbitrary precision math functions¸¦ »ç¿ëÇϵµ·ÏÇÑ´Ù.


Math constants

PHPÀÇ ¼öÇÐ ÇÔ¼ö È®Àå¿¡¼­ ´ÙÀ½°ªÀÌ »ó¼ö·Î ÁöÁ¤µÇ¾îÀÖ´Ù. :

Table 1. Math constants

Constant

Value

Description

M_PI

3.14159265358979323846

The value of ¥ð(pi)

 

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()

$binary = base_convert($hexadecimal, 16, 2);

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().

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´ÜÀ§¿Í ¼Ò¼öÁ¡¿¡ ,¿Í .µîÀ» Âï¾îÁØ´Ù.

format a number with grouped thousands

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 hexadecimal number represented by the hex_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().

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().

XXV. Miscellaneous Functions

Table of Contents
connection_aborted
connection_status
connection_timeout
eval
extract
die
exit
function_exists
ignore_user_abort
iptcparse
leak
pack
register_shutdown_function
serialize
sleep
unpack
unserialize
uniqid
usleep

ÀÌ ÇÔ¼öµéÀº ±âÁ¸ ¹üÁÖ¿¡ Æ÷ÇÔ½Ã۱⠰ï¶õÇÑ °ÍµéÀÌ´Ù.

connection_aborted

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

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

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.

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

<?php
$string = 'cup';
$name = 'coffee';
$str = 'This is a $string with my $name in it.<br>';
echo $str;
eval( "\$str = \"$str\";" );
echo $str;
?>

The above example will show:

This is a $string with my $name in it.
This is a cup with my coffee in it.

extract

extract -- ÇÑ ¹è¿­¿¡¼­ symbol table·Î º¯¼öµéÀ» ÀÐ¾î µéÀδÙ.

Description

void extract(array var_array, int extract_type, string [var_array]);

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.

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

<?
/* Suppose that $var_array is an array returned from
wddx_deserialize */
$size = "large";
$var_array = array("color" => "blue",
"size" => "medium",
"shape" => "sphere");
extract($var_array, EXTR_PREFIX_SAME, "wddx");
print "$color, $size, $shape, $wddx_size\n";
?>

The above example will produce:

blue, large, sphere, medium

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.

die

die -- ¸Þ½ÃÁö¸¦ Ãâ·ÂÇϰí ÇöÀç ½ºÅ©¸³Æ®ÀÇ ½ÇÇàÀ» Áß´ÜÇÑ´Ù.

Description

void die(string message);

This language construct outputs a message and terminates parsing of the script. It does not return.

Example 1. die example

<?php
$filename = '/path/to/data-file';
$file = fopen($filename, 'r')
or die "unable to open file ($filename)";
?>

exit

exit -- ÇöÀç ½ºÅ©¸³Æ®ÀÇ ½ÇÇàÀ» Áß´ÜÇÑ´Ù.

Description

void exit(void);

This language construct terminates parsing of the script. It does not return.

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.

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. 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

Example 1. pack format string

$binarydata = pack("nvc*", 0x1234, 0x5678, 65, 66);

The resulting binary string will be 6 bytes long and contain the byte sequence 0x12, 0x34, 0x78, 0x56, 0x41, 0x42.

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.

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

// $session_data contains a multi-dimensional array with session
// information for the current user. We use serialize() to store
// it in a database at the end of the request.
$conn = odbc_connect("webdb", "php", "chicken");
$stmt = odbc_prepare($conn,
"UPDATE sessions SET data = ? WHERE id = ?");
$sqldata = array(serialize($session_data), $PHP_AUTH_USER);
if (!odbc_execute($stmt, &$sqldata)) {
$stmt = odbc_prepare($conn,
"INSERT INTO sessions (id, data) VALUES(?, ?)");
if (!odbc_execute($stmt, &$sqldata)) {
/* Something went wrong. Bitch, whine and moan. */
}
}

sleep

sleep -- ½ÇÇàÀ» Àá½Ã Áö¿¬½ÃŲ´Ù.

Description

void sleep(int seconds);

The sleep function delays program execution for the given number of seconds.

See also usleep().

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

$array = unpack("c2chars/nint", $binarydata);

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 °ªÀ¸·Î ¸¸µé¾îÁØ´Ù.

creates a PHP value from a stored representation

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

// Here, we use unserialize() to load session data from a database
// into $session_data. This example complements the one described
// with serialize().
$conn = odbc_connect("webdb", "php", "chicken");
$stmt = odbc_prepare($conn, "SELECT data FROM sessions WHERE id = ?");
$sqldata = array($PHP_AUTH_USER);
if (!odbc_execute($stmt, &$sqldata) || !odbc_fetch_into($stmt, &$tmp)) {
// if the execute or fetch fails, initialize to empty array
$session_data = array();
} else {
// we should now have the serialized data in $tmp[0].
$session_data = unserialize($tmp[0]);
if (!is_array($session_data)) {
// something went wrong, initialize to empty array
$session_data = array();
}
}

uniqid

uniqid -- À¯ÀÏÇÑ id¸¦ »ý¼ºÇÑ´Ù.

Description

int uniqid(string prefix);

uniqid() returns a prefixed unique identifier based on 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. The prefix can be up to 114 characters long.

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

$token = md5(uniqid("")); // no random portion
$better_token = md5(uniqid(random())); // better, difficult to guess

This will create a 32 character identifier (a 128 bit hex number) that is extremely difficult to predict.

usleep

usleep -- ½ÇÇàÀ» ¹é¸¸ºÐÀÇ ÀÏÃÊ ´ÜÀ§·Î Áö¿¬½ÃŲ´Ù.

Description

void usleep(int micro_seconds);

The sleep function delays program execution for the given number of micro_seconds.

See also sleep().

XXVI. mSQL Functions

Table of Contents
msql
msql_affected_rows
msql_close
msql_connect
msql_create_db
msql_createdb
msql_data_seek
msql_dbname