À¥ ÄÁ¼³ÆÃÀÇ µ¿¹ÝÀÚ PHP

¾çÀϵî / FBISKR@orgio.net

 

     

    ¾È³çÇϼ¼¿ä. °èÀýÀÇ ¿©¿Õ 5¿ùÀÔ´Ï´Ù. È­»çÇÑ ²ÉµéÀÇ Çâ±â°¡ ±æ°Å¸®¸¦ °ÉÀ» ¶§¸¶´Ù ¾îÁö·¯¿ï Á¤µµ·Î °¡µæÇÕ´Ï´Ù. À̹ø È£¿¡¼­´Â ¿ì¸®ÀÇ À¥ ÄÁ¼³ÆÃÀÇ µ¿¹ÝÀÚÀÎ PHP¿¡ ´ëÇؼ­ Á»´õ ÀÚ¼¼È÷ ¾Ë¾Æº¼±î ÇÕ´Ï´Ù.

     

1. Æø³ÐÀº ÇÔ¼ö±º

    PHP´Â ½Ã´ëÀÇ Ã·´ÜÀ» °È°í ÀÖ½À´Ï´Ù. ¸ðµç Àαâ ÀÖ´Â °ÍµéÀ» ¸ðµÎ Èí¼öÇÏ¿© ³ª³¯ÀÌ µ¢Ä¡°¡ Ä¿Áö°í ÀÖ½À´Ï´Ù. ¹°·Ð ÀÚ±â ÀÚ½ÅÀÌ ±×°ÍÀ» ¸ðµÎ ±¸ÇöÇÏ´Â °ÍÀº ¾Æ´Ï°í »óÈ£ ¿¬°èµÈ ÇÔ¼ö±ºµéÀ» Á¦°øÇÑ´Ù´Â °ÍÀÔ´Ï´Ù.

    Çлý½ÃÀý À¯¸íÇß´ø TURBO½Ã¸®Áî¿¡¼­ »©³õÀ» ¼ö ¾ø´Â °ÍÀÌ ¹Ù·Î Turbo C¿Í Turbo PascalÀÔ´Ï´Ù. Áö±ÝÀÇ Áß°ß ÇÁ·Î±×·¡¸Ó¶ó¸é ÀÌ Á¦Ç°À» Çѹø¾¿Àº ´Ù »ç¿ëÇØ º¸¾ÒÀ» Á¤µµ·Î À¯¸íÇÕ´Ï´Ù. ±×Áß¿¡ Áö±Ýµµ Turbo C 2.0 ¶óÀ̺귯¸® ¸Å´º¾óÀ̶ó´Â µÎ²¨¿î Ã¥ÀÌ Ã¥Àå Çѱ¸¼®À» Â÷ÁöÇÏ°í ÀÖ½À´Ï´Ù. ´ç½Ã Ã¥ÀÇ µÎ²² ÀÚü¸¸À¸·Îµµ ÇູÇß½À´Ï´Ù. ÀڱⰡ ÇÊ¿äÇÑ °ÍÀ» ¶óÀ̺귯¸®¿¡¼­ ã¾Æ¼­ »ç¿ëÇÏ¸é µÇ±â ¶§¹®À̾úÁÒ. ±×·¡¼­ ¾î¶² ³»¿ëÀÌ ÇÊ¿äÇÏ¸é ±×°ÍÀ» Áö¿øÇÏ´Â ÇÔ¼ö°¡ ÀÖ³ª ã¾Æº¸¸ç °í½ÉÇÏ´ø »ý°¢ÀÌ ³³´Ï´Ù. ¾ð¾îÀûÀÎ °üÁ¡¿¡¼­ PHP´Â ÀڽŰú »ó°ü¾ø´Â ÇÔ¼öµéÀ» °¡Áö°í ÀÖÁö¸¸(ÁÖ·Î µ¥ÀÌÅͺ£À̽º ¿¬°á) ÀÌ°ÍÀº ¿ì¸®¿¡°Ô ¾ÆÁÖ ÇÊ¿äÇÑ °ÍÀÓÀ» ¿ì¸®´Â ¾Ë ¼ö ÀÖ½À´Ï´Ù. ¾î¼¸é ÀÌ·¯ÇÑ °Í ¶§¹®¿¡ PHP°¡ ³¯·Î Àα⸦ ´õÇØ °¡´ÂÁöµµ ¸ð¸£°Ú½À´Ï´Ù.

    ¾Æ·¡ÀÇ ¸®½ºÆ®¸¦ º¸¸é µ¥ÀÌÅͺ£À̽º Á¦Ç°º°·Î °¢°¢ÀÇ ÇÔ¼ö¸¦ Áö¿øÇÏ´Â °ÍÀ» º¼ ¼ö°¡ ÀÖ½À´Ï´Ù. ¶Ç Àç¹ÌÀÖ´Â °ÍÀº Compression functions°ú Image functions°ú °°Àº ÇÔ¼öµéÀÔ´Ï´Ù. À̰͵µ PHP¿ëÀ¸·Î °³¹ßµÈ °ÍÀº ¾Æ´ÏÁö¸¸ ÄÄÆÄÀÏÇÒ ¶§ °°ÀÌ ÄÄÆÄÀÏÇÏ¸é ¾Æ¹«·± »ý°¢¾øÀÌ(?)ÀÌ ±â´ÉµéÀ» ÀÌ¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÏ·Ê·Î ¿ì¸®´Â C¿¡¼­ »ç¿ëÇÑ °Íó·³ printfÇÔ¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ°í ±×°Íµµ ½ÈÀ¸¸é echoÇÔ¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.

    ÀÚ, ±×·³ ¿ì¸®°¡ ÁÖ·Î »ç¿ëÇÏ´Â ÇÔ¼öµéÀ» »ìÆ캸°Ú½À´Ï´Ù.

    ¥°.     Adabas D functions
    ¥±.     Apache-specific functions
    ¥².     Array functions
    ¥³.     Aspell functions
    ¥´.     Arbitrary precision mathematics functions
    ¥µ.     Calendar functions
    ¥¶.     ClibPDF functions
    ¥·.     Date and Time functions
    ¥¸.     Database(dbm-style) abstraction layer functions
    ¥¹.      dBase functions
    XI .     dbm functions
    XII .    Directory functions
    XIII.    Dynamic Loading functions
    XIV.    Program Execution functions
    XV.     Forms Data Format functions
    XVI.    filePro functions
    XVII.   Filesystem functions
    XVIII.  Functions related to HTTP
    XIX.   Hyperwave functions
    XX.    Image functions
    XXI.   IMAP functions
    XXII.  PHP options & information
    XXIII. Informix functions
    XXIV. InterBase functions
    XXV.  LDAP functions
    XXVI . Mail functions
    XXVII . Mathematical functions
    XXVIII . Encryption functions
    XXIX . Hash functions
    XXX . Miscellaneous functions
    XXXI . mSQL functions
    XXXII . Microsoft SQL Server functions
    XXXIII . MySQL functions
    XXXIV. Sybase functions
    XXXV. Network functions
    XXXVI . NIS functions
    XXXVII . ODBC functions
    XXXVIII. Oracle 8 functions
    XXXIX . Oracle functions
    XL . Perl-compatible Regular Expression functions
    XLI . PDF functions
    XLII . PostgreSQL functions
    XLIII . Regular expression functions
    XLIV. Semaphore and shared memory functions
    XLV. Solid functions
    XLVI . SNMP functions
    XLVII . String functions
    XLVIII . URL functions
    XLIX . Variable functions
    L . Vmailmgr functions
    LI . WDDX functions
    LII . Compression functions
    LIII . XML parser functions

 

2. ³¯Â¥°ü·Ã ÇÔ¼öµé(VIII . Date and Time functions)

    checkdate     - validate a date/time
    date             - format a local time/date
    strftime         - format a local time/date according to locale settings
    gmstrftime    - format a GMT/CUT time/date according to locale settings
    getdate         - get date/time information
    gettimeofday - get current time
    gmdate        - format a GMT/CUT date/time
    mktime         - get UNIX timestamp for a date
    gmmktime    - get UNIX timestamp for a GMT date
    time             - return current UNIX timestamp
    microtime     - return current UNIX timestamp with microseconds

    2-1. dateÇÔ¼ö

    string date(string format, int [timestamp] );

    format ÀÎÀÚ°ª

    a - ¡°am¡± or ¡°pm¡±
    A - ¡°AM¡± or ¡°PM¡±
    d - day of the month, 2 digits with leading zeros; i.e. ¡°01¡± to ¡°31¡±
    D - day of the week, textual, 3 letters; i.e. ¡°Fri¡±
    F - month, textual, long; i.e. ¡°January¡±
    h - hour, 12-hour format; i.e. ¡°01¡± to ¡°12¡±
    H - hour, 24-hour format; i.e. ¡°00¡± to ¡°23¡±
    g - hour, 12-hour format without leading zeros; i.e. ¡°1¡± to ¡°12¡±
    G - hour, 24-hour format without leading zeros; i.e. ¡°0¡± to ¡°23¡±
    i - minutes; i.e. ¡°00¡± to ¡°59¡±
    j - day of the month without leading zeros; i.e. ¡°1¡± to ¡°31¡±
    l (lowercase ¡®L¡¯) - day of the week, textual, long; i.e. ¡°Friday¡±
    L - boolean for whether it is a leap year; i.e. ¡°0¡± or ¡°1¡±
    m - month; i.e. ¡°01¡± to ¡°12¡±
    n - month without leading zeros; i.e. ¡°1¡± to ¡°12¡±
    M - month, textual, 3 letters; i.e. ¡°Jan¡±
    s - seconds; i.e. ¡°00¡± to ¡°59¡±
    S - English ordinal suffix, textual, 2 characters; i.e. ¡°th¡±, ¡°nd¡±
    t - number of days in the given month; i.e. ¡°28¡± to ¡°31¡±
    U - seconds since the epoch
    w - day of the week, numeric, i.e. ¡°0¡± (Sunday) to ¡°6¡± (Saturday)
    Y - year, 4 digits; i.e. ¡°1999¡±
    y - year, 2 digits; i.e. ¡°99¡±
    z - day of the year; i.e. ¡°0¡± to ¡°365¡±
    Z - timezone offset in seconds (i.e. ¡°-43200¡± to ¡°43200¡±)

    ¿¹Á¦
    <HTML>
    <HEAD>
    <TITLE>Figure 1-1</TITLE>
    </HEAD>
    <BODY>
    Today¡¯s Date: <? print(Date(¡°l F d, Y¡±)); ?>
    </BODY>
    </HTML>

    Ãâ·Â
    Today¡¯s Date: Wednesday April 12, 2000

    ³¯Â¥ °ü·Ã ÇÔ¼öµéÀ» ÀûÀýÈ÷ Á¶ÀýÇÏ¸é µ¿¾ç±ÇÀÇ ³¯Â¥ Çü½ÄÀ¸·Î Ãâ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù. ±×¸®°í °£´ÜÇÑ ÄÚµå·Î Ä«¿îÅÍ(Àϸí D-day)µµ ¸¸µé ¼ö ÀÖ½À´Ï´Ù.
     

    D-<? echo date(¡°z¡±, mktime(0,0,0,4,29,2000)) - date(¡°z¡±,time()); ?>ÀÏ

 

    °á°ú´Â ¡°D-??ÀÏ¡±ÀÌ Ãâ·ÂµË´Ï´Ù. ¸ÕÀú mktimeÀ¸·Î ÁöÁ¤µÈ ½Ã°£ÀÇ UNIX timestampÀ» ¼³Á¤ÇÏ°í ÇöÀç ½Ã°£À» ¼³Á¤ÇÕ´Ï´Ù. ¿©±â¼­ timestamp½Ã°£À» »©¸é ³ª¸ÓÁö ½Ã°£ÀÌ ³ª¿À´Âµ¥ ÀÌ°ÍÀ» dateÀÇ zÀÎÀÚ·Î ³Ñ°ÜÁ־ 365ÀÏ ³¯Â¥¸¦ °è»êÇÕ´Ï´Ù. Áï 1¿ù 31ÀÏ ´ÙÀ½ 2¿ù 1À̸é 32·Î Ãâ·ÂÀÌ µÇ´Â °ÍÀÔ´Ï´Ù.

     

3. µð·ºÅ丮 °ü·ÃÇÔ¼öµé(XII. Directory functions)

     

    chdir       - change directory
    dir          - directory class
    closedir   - close directory handle
    opendir   - open directory handle
    readdir    - read entry from directory handle
    rewinddir - rewind directory handle

 

    PHP¸¦ »ç¿ëÇϸ鼭 ´À³¢´Â °ÍÀº ÅëÀϼºÀ» Áشٴ °ÍÀÔ´Ï´Ù. ÀÌ°ÍÀº Ç÷§Æû¿¡ »ó°ü¾øÀÌ °³¹ßÀ» ÇÒ ¼ö ÀÖ´Ù´Â °ÍÀε¥, ¾ð¶æ µéÀ¸¸é ¾Æ¹« °Íµµ ¾Æ´Ñ °Í °°Áö¸¸ °ú¼­ ANSI CÀÇ Ç¥ÁؾÈÀ» µû¸£Áö ¾Ê´Â ¹®¹ý°ú ÇÔ¼ö¸¦ »ç¿ëÇÏ¸é ´Ù¸¥ ±âÁ¾ÀÇ Æ÷ÆÃÀÌ ¾î·Á¿ü½À´Ï´Ù. ÇöÀç Apache, PHP, mSQL, MySQLµî ÀαâÀÖ´Â Á¦Ç°µéÀÌ UNIX°è¿­°ú MS°è¿­¿¡¼­ ¸ðµÎ È°¹ßÇÏ°Ô °³¹ßµÇ°í ÀÖ½À´Ï´Ù. ÀÌ°ÍÀº ¿ì¸®°¡ ´Ù¸¥ ±âÁ¾¿¡¼­ÀÇ Æ÷Æù®Á¦¿¡ ±×¸® Å« °í¹ÎÀ» ÇÏÁö ¾Ê¾Æµµ µÈ´Ù´Â À̾߱âÀÔ´Ï´Ù. ÀÚ Àá±ñ ´Ù¸¥ ¹æÇâÀ¸·Î ÁøÇàµÈ °Í °°Àºµ¥, µð·ºÅ丮 ÇÔ¼ö ±ºÀ» »ìÆ캸¸é 6°³ Á¤µµÀÇ ÇÔ¼ö°¡ ÀÖ½À´Ï´Ù.
     

    <?php
        $handle=opendir(¡®/.¡¯);
        echo ¡°Directory handle: $handle¡± . ¡°<br>¡±;
        echo ¡°Files:¡± . ¡°<br>¡±;
        while ($file = readdir($handle)) {
            echo ¡°$file¡± . ¡°<br>¡±;
        }
        closedir($handle);

        $d = dir(¡°./¡±);
        echo ¡°Handle: ¡°.$d->handle.¡±<br>¡¬n¡±;
        echo ¡°Path: ¡°.$d->path.¡±<br>¡¬n¡±;
        while($entry=$d->read()) {
            echo $entry.¡±<br>¡¬n¡±;
        }
        
        $d->close();
    ?>

    Directory handle: 1
    Files:
    BOOTLOG.TXT
    COMMAND.COM
    SUHDLOG.DAT
    FRUNLOG.TXT
    MSDOS.---
    SETUPLOG.TXT
    WINDOWS
    NETLOG.TXT
    AUTOEXEC.BAT
    WINGAME
    MSDOS.SYS
    CONFIG.SYS
    DETLOG.TXT
    BOOTLOG.PRV
    SYSTEM.1ST
    IO.SYS
    Program Files
    My Documents
    RECYCLED
    HNC
    WORK
    ffastun.ffl
    ffastun0.ffx
    ffastun.ffo
    ffastun.ffa
    cjgolf2
    usr
    access.txt
    tcpsp
    PDOXUSRS.NET
    Sierra
    N2pInst.log
    N2PActiveX.log
    My Music
    Cjgolf2.bak
    SCANDISK.LOG
    Handle: 2
    Path: ./
    .
    ..
    1.bak
    1.php3

    test
    my
    drv

 

    µÎ °¡Áö ¹æ¹ýÀ¸·Î µð·ºÅ丮¸¦ Ž»öÇÏ´Â ¿¹ÀÔ´Ï´Ù. Çϳª´Â opendirÀ» »ç¿ëÇÑ °ÍÀÌ°í ´Ù¸¥ °ÍÀº dirŬ·¡½º¸¦ »ç¿ëÇÑ °ÍÀÔ´Ï´Ù. ¼ÒÇÁÆ®¿þ¾î °øÇÐÀÇ ÃÖ°íºÀÀ¸·Î ±º¸²Çß´ø OOP(Object Oriented Programming)´Â ±× º¹À⼺ ¶§¹®¿¡ ½ÇÁ¦ »ç¿ëÀÚµé·ÎºÎÅÍ °¢±¤À» ¹ÞÁö ¸øÇß½À´Ï´Ù. ±×·¡¼­ º¹ÀâÇÑ Å¬·¡½º¸¦ ¼³°èÇÏ´Â °Í º¸´Ù´Â °£´ÜÇÑ ÇÔ¼öµéÀÇ Á¶ÇÕÀ» ´õ ¸¹ÀÌ »ç¿ëÇÏ´Â °Í °°½À´Ï´Ù. »ç¿ëÇØ º¸½Ã°í ÆíÇÑ °ÍÀ» ¼±ÅÃÇؼ­ »ç¿ëÇÏ½Ã¸é µË´Ï´Ù.

 

4. ¿ÜºÎ ½ÇÇà ÇÔ¼öµé(XIV. Program Execution functions)

    escapeshellcmd - escape shell metacharacters
    exec - Execute an external program
    system - Execute an external program and display output
    passthru - Execute an external program and display raw output

    °ú°Å C¿¡¼­ ¿ÜºÎ ½©·Î ºüÁ® ³ª°¥ ¶§ system(¡°command.com¡±)À» ½ÇÇà½ÃÅ°¸é ÀÛµ¿À» Çß½À´Ï´Ù. ÀÌ°ÍÀº ½Ã½ºÅÛ¸í·É¾î¸¦ ½ÇÇà½ÃÅ°´Â ÇÔ¼öÀε¥, ¿ª½Ã PHP¿¡¼­µµ Áö¿øÀ» ÇÕ´Ï´Ù.
     

    <pre>
    <%
            system($command);
    %>
    </pre>

    <form name=¡±form¡± method=¡±post¡± action=
    system.php3>

    <p><font face=¡±µ¸¿òü¡±>command : <input type=¡±text¡± name=¡±command¡± value=¡±<% echo $command; %>¡± size=¡±100¡± ></font></p>

    <p><input type=¡±submit¡± value=¡±run¡±></p>

    </form>

 

    À§¿Í °°ÀÌ Çϸé telnetÀ¸·Î ¼­¹ö¿¡ Á¢¼ÓÇÏ´Â ÀýÂ÷¸¦ °ÅÄ¡Áö ¾Ê°í °£´ÜÇÑ ¸í·ÉµéÀ» ½ÇÇà½ÃÅ°°í °á°ú¸¦ È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.

 

5. ÆÄÀÏ °ü·Ã ÇÔ¼öµé(XVII. Filesystem functions)

    basename - return filename component of path
    chgrp - change file group
    chmod - change file mode
    chown - change file owner
    clearstatcache - clear file stat cache
    copy - copy file
    delete - a dummy manual entry
    dirname - return directory name component of path
    diskfreespace - return available space in directory
    fclose - close an open file pointer
    feof - test for end-of-file on a file pointer
    fgetc - get character from file pointer
    fgetcsv - get line from file pointer and parse for CSV fields
    fgets - get line from file pointer
    fgetss - get line from file pointer and strip HTML tags
    file - read entire file into an array
    file_exists - Check whether a file exists.
    fileatime - get last access time of file
    filectime - get inode change time of file
    filegroup - get file group
    fileinode - get file inode
    filemtime - get file modification time
    fileowner - get file owner
    fileperms - get file permissions
    filesize - get file size
    filetype - get file type
    flock - portable advisory file locking
    fopen - open file or URL
    fpassthru - output all remaining data on a file pointer
    fputs - write to a file pointer
    fread - Binary-safe file read
    fseek - seek on a file pointer
    ftell - tell file pointer read/write position
    fwrite - Binary-safe file write
    set_file_buffer - Sets file buffering on the given file pointer
    is_dir - tells whether the filename is a directory
    is_executable - tells whether the filename is executable
    is_file - tells whether the filename is a regular file
    is_link - tells whether the filename is a symbolic link
    is_readable - tells whether the filename is readable
    is_writeable - tells whether the filename is writeable
    link - Create a hard link
    linkinfo - Get information about a link
    mkdir - make directory
    pclose - close process file pointer
    popen - open process file pointer
    readfile - output a file
    readlink - Return the target of a symbolic link
    rename - rename a file
    rewind - rewind the position of a file pointer
    rmdir - remove directory
    stat - give information about a file
    lstat - give information about a file or symbolic link
    symlink - Create a symbolic link
    tempnam - create unique file name
    touch - set modification time of file
    umask - changes the current umask
    unlink - Delete a file

    ¿ì¸®°¡ ÇÁ·Î±×·¡¹ÖÀ» Çϸ鼭 ¸¹ÀÌ ´Ù·ç´Â °ÍÀÌ ÆÄÀÏÀÔ´Ï´Ù. µ¥ÀÌÅÍÀÇ ÃÖÁ¾º¸Á¸À» À§Çؼ­ ÆÄÀÏ¿¡ ÀúÀåÇϱ⠶§¹®ÀÔ´Ï´Ù. ¿äÁò À¥¿¡¼­´Â µ¥ÀÌÅÍ º£À̽º¸¦ »ç¿ëÇϱ⠶§¹®¿¡ ÆÄÀÏ¿¡ Á÷Á¢ µ¥ÀÌÅ͸¦ ±â·ÏÇÏ´Â °æ¿ì´Â µå¹°Áö¸¸ Á¶±×¸¸ ¾çÀÇ µ¥ÀÌÅ͸¦ ±â·ÏÇÏ´Â °ÍÀº µ¥ÀÌÅÍ º£À̽º º¸´Ù È¿°úÀûÀÔ´Ï´Ù.
     

    <HTML>
    <HEAD>
    <TITLE>fopen</TITLE>
    </HEAD>
    <BODY>
    <?
            print(¡°<H1>HTTP</H1>¡¬n¡±);

            // open a file using http protocol
            if(!($myFile = fopen(¡°http://www.clearink.com/¡±, ¡°r¡±)))
            {
                    print(¡°file could not be opened¡±);
                    exit;
            }

            while(!feof($myFile))
            {
                    // read a line from the file
                    $myLine = fgetss($myFile, 255);
                    print(¡°$myLine <BR>¡¬n¡±);
            }

            // close the file
            fclose($myFile);

            print(¡°<H1>FTP</H1>¡¬n¡±);
            print(¡°<HR>¡¬n¡±);

            // open a file using ftp protocol
            if(!($myFile = fopen(¡°ftp://ftp.php.net/welcome.msg¡±, ¡°r¡±)))
            {
                    print(¡°file could not be opened¡±);
                    exit;
            }

            while(!feof($myFile))
            {
                    // read a line from the file
                    $myLine = fgetss($myFile, 255);
                    print(¡°$myLine <BR>¡¬n¡±);
            }

            // close the file
            fclose($myFile);

            print(¡°<H1>Local</H1>¡¬n¡±);
            print(¡°<HR>¡¬n¡±);

            // open a local file
            if(!($myFile = fopen(¡°data.txt¡±, ¡°r¡±)))
            {
                    print(¡°file could not be opened¡±);
                    exit;
            }

            while(!feof($myFile))
            {
                    // read a line from the file
                    $myLine = fgetss($myFile, 255);
                    print(¡°$myLine <BR>¡¬n¡±);
            }

            // close the file
            fclose($myFile);
     ?>
    </BODY>
    </HTML>

 

    fopenÇÔ¼ö´Â localÆÄÀÏ ¹× ÀÎÅͳÝÀÇ ÆÄÀÏÀ» Á÷Á¢ ¿­ ¼ö°¡ ÀÖ½À´Ï´Ù. ¿©±â¿¡ HTMLÅױ׸¦ ½ºÅµÇؼ­ Àоî¿À´Â fgetss¸¦ »ç¿ëÇؼ­ ÀÐ°í ±×°ÍÀ» Ãâ·ÂÇÕ´Ï´Ù. »ç¿ëÀÚ ÀÔÀå¿¡¼­ º¸¸é ·ÎÄÃÆÄÀÏÀ» Àд°Ͱú µ¿ÀÏÇÏ°Ô »ý°¢ÇÒ ¼ö ÀÖ½À´Ï´Ù.

 

6. ¹®ÀÚ¿­ ó¸® ÇÔ¼öµé(String functions)

    AddSlashes - quote string with slashes
    bin2hex - convert binary data into hexadecimal representation
    Chop - remove trailing whitespace
    Chr - return a specific character
    chunk_split - Split a string into smaller chunks
    convert_cyr_string - Convert from one Cyrillic character set to another
    crypt - DES-encrypt a string
    echo - output one or more strings
    explode - split a string by string
    flush - flush the output buffer
    get_meta_tags - Extracts all meta tag content attributes from a file and returns an array
    htmlspecialchars - Convert special characters to HTML entities.
    htmlentities - Convert all applicable characters to HTML entities.
    implode - join array elements with a string
    join - join array elements with a string
    ltrim - Strip whitespace from the beginning of a string.
    md5 - calculate the md5 hash of a string
    nl2br - Converts newlines to HTML line breaks.
    Ord - return ASCII value of character
    parse_str - parses the string into variables
    print - output a string
    printf - output a formatted string
    quoted_printable_decode - Convert a quoted-printable string to an 8 bit string
    QuoteMeta - quote meta characters
    rawurldecode - decode URL-encoded strings
    rawurlencode - URL-encode according to RFC1738
    setlocale - set locale information
    similar_text - calculate the similarity between two strings
    soundex - calculate the soundex key of a string
    sprintf - return a formatted string
    strchr - Find the first occurrence of a character.
    strcmp - binary safe string comparison
    strcspn - find length of initial segment not matching mask
    strip_tags - Strip HTML and PHP tags from a string
    StripSlashes - un-quote string quoted with addslashes
    strlen - get string length
    strrpos - Find position of last occurrence of a char in a string.
    strpos - Find position of first occurrence of a string.
    strrchr - Find the last occurrence of a character in a string.
    strrev - Reverse a string.
    strspn - find length of initial segment matching mask
    strstr - Find first occurrence of a string.
    strtok - tokenize string
    strtolower - Make a string lowercase.
    strtoupper - Make a string uppercase.
    str_replace - Replace all occurrences of needle in haystack with str
    strtr - Translate certain characters.
    substr - Return part of a string.
    trim - Strip whitespace from the beginning and end of a string.
    ucfirst - Make a string¡¯s first character uppercase
    ucwords - Uppercase the first character of each word in a string

    ¿ì¸®¿¡°Ô Norton À¯Æ¿¸®Æ¼·Î À¯¸íÇÑ ÇÇÅÍ ³ëÅϾ¾´Â ¡°ÈǸ¢ÇÑ ÇÁ·Î±×·¡¸Ó°¡ µÇ±â À§Çؼ­´Â ½ºÆ®¸µÀ» ÀÚÀ¯ÀÚÁ¦·Î ´Ù·ç¾î¾ß ÇÑ´Ù¡±¶ó°í ¸»¾¸Çϼ̽À´Ï´Ù. ½ºÆ®¸µÀº ÀÚ·áó¸®ÀÇ ±âÃÊ°¡ µË´Ï´Ù. ±×·¡¼­ ¾ð¾îÀûÀÎ °üÁ¡¿¡¼­ ±× ¾ð¾î°¡ ¾ó¸¶³ª ½ºÆ®¸µ 󸮿¡ °­·ÂÇÑ°¡ ÇÏ´Â °Íµµ ¾ð¾î¸¦ Æò°¡ÇÏ´Â ±âÁØ¿¡ ¼ÓÇÕ´Ï´Ù. PHP´Â ¿ì¸®°¡ ÀϹÝÀûÀ¸·Î »ç¿ëÇÏ´Â ½ºÆ®¸µ¿Ü¿¡ ÁÁÀº °ÍµéÀº ¸ðµÎ °¡Áö°í ÀÖ½À´Ï´Ù. ¿¹·Î Visual Basic¿¡¼­ ¾²ÀÌ´Â trimµµ ÀÖ°í À¥»ó¿¡¼­ À¯¿ëÇÏ°Ô ¾²ÀÌ´Â nl2br¿Í °°Àº ÇÔ¼öµµ ÀÖ½À´Ï´Ù. ¹°·Ð ±¸ÇöÇϱ⿡ ¾î·ÆÁö´Â ¾ÊÁö¸¸ ¹ö±×Å×½ºÆ®¸¦ ¸¶Ä£ ÇÔ¼öµéÀ» »ç¿ëÇÏ´Â °ÍÀÌ ´õ ³º½À´Ï´Ù.
     

    strtok¿¹Á¦

    <HTML>
    <HEAD>
    <TITLE>strtok</TITLE>
    </HEAD>
    <BODY>
    <?
            // create a demo string
            $line = ¡°leon¡¬tatkinson¡¬tleon@clearink.com¡±;

            // loop while there are still tokens
            for($token = strtok($line, ¡°¡¬t¡±);
                    $token != ¡°¡±;
                    $token = strtok(¡°¡¬t¡±))
            {
                    print(¡°token: $token<BR>¡¬n¡±);
            }
            
    ?>
    </BODY>
    </HTML>

    explode¿¹Á¦

    <HTML>
    <HEAD>
    <TITLE>explode</TITLE>
    </HEAD>
    <BODY>
    <?
            /*
            ** convert tab-delimited list into an array
            */
            $data = ¡°red¡¬tgreen¡¬tblue¡±;
            $colors = explode(¡°¡¬t¡±, $data);

            // print out the values
            for($index=0; $index < count($colors); $index++)
            {
                    print(¡°$index : $colors[$index] <BR>¡¬n¡±);
            }
    ?>
    </BODY>
    </HTML>

 

    À§ µÎ ¿¹Á¦ ¸ðµÎ ½ºÆ®¸µÀ» Çü½Ä¿¡ ¸Â°Ô ³ª´©¾î¼­ ó¸®ÇÏ´Â ¿¹ÀÔ´Ï´Ù. ±âÁ¸ÀÇ ANSI C¿¡ ÀÖ´Â strtok´Â ½ºÆ®¸µÀ» ÅäÅ«º°·Î ³ª´©´Â ±â´ÉÀÌ ÀÖÁö¸¸ »ç¿ëÀÚ°¡ ºÎ°¡ÀûÀΠ󸮸¦ ÇØ¾ß ÇÕ´Ï´Ù. ¿©±â¿¡ PHP´Â explodeÇÔ¼ö¸¦ Ãß°¡ÇÏ¿´´Âµ¥ PHPÀÇ °­·ÂÇÑ º¯¼öÇü º¯È¯±â´ÉÀ» ÇÕÃļ­ ¹Ù·Î ¹è¿­·Î ÅäÅ«À» ¹ÝȯÇÕ´Ï´Ù. ÇÏÁö¸¸ ¾î´À °ÍÀ» »ç¿ëÇϴ°¡´Â ¿©·¯ºÐÀÇ ¼±ÅÃÀÔ´Ï´Ù.

     

7. zlib ÇÔ¼öµé(LII. Compression functions)

    gzclose - close an open gz-file pointer
    gzeof - test for end-of-file on a gz-file pointer
    gzfile - read entire gz-file into an array
    gzgetc - get character from gz-file pointer
    gzgets - get line from file pointer
    gzgetss - get line from gz-file pointer and strip HTML tags
    gzopen - open gz-file
    gzpassthru - output all remaining data on a gz-file pointer
    gzputs - write to a gz-file pointer
    gzread - Binary-safe gz-file read
    gzrewind - rewind the position of a gz-file pointer
    gzseek - seek on a gz-file pointer
    gztell - tell gz-file pointer read/write position
    readgzfile - output a gz-file
    gzwrite - Binary-safe gz-file write

     // get contents of a gz-file into a string
    $filename = ¡°/usr/local/something.txt.gz¡±;
    $zd = gzopen( $filename, ¡°r¡± );
    $contents = gzread( $zd, 10000 );
    gzclose( $zd );

    zlib´Â ¿ì¸®°¡ ÀϹÝÀûÀ¸·Î .gz À¸·Î ¾ÐÃàµÈ ÆÄÀÏÀ» º¯È¯°úÁ¤¾øÀÌ ¹Ù·Î ´Ù·ê ¼ö ÀÖµµ·Ï ÇÏ´Â ¶óÀ̺귯¸®ÀÔ´Ï´Ù. ÀÌ°Í ¶ÇÇÑ ¿©·¯ ±âÁ¾°ú ¾ð¾î·Î Æ÷Æà µÇ¾ú½À´Ï´Ù.

 

8. ¸¶Ä¡¸ç

    ±× ¿Ü PHPÀÇ ÇÔ¼öµéÀº µ¥ÀÌÅÍ º£À̽º ÇÔ¼ö¿Í Å©°Ô GD ¶óÀ̺귯¸® ÇÔ¼öµé·Î ±¸¼ºµÇ¾î ÀÖ½À´Ï´Ù. PHP¸¦ »ç¿ëÇϸ鼭 ¡°¾î¶² µ¥ÀÌÅÍ º£À̽º¸¦ »ç¿ëÇÒ±î?¡± ÇÏ´Â ÇູÇÑ °í¹Î¿¡ ºüÁö°Ô ÇÕ´Ï´Ù. ÀÚ ÀÌ·¸°Ô PHPÀÇ ÇÔ¼öµéÀ» »ìÆ캸¾Ò½À´Ï´Ù.

    ±×·±µ¥ PHP¿¡ ´ëÇÑ µµ¿òÀ» ¾ò°íÀÚ ÇÏ·Á¸é ¾î¶»°Ô ÇØ¾ß ÇÒ±î¿ä? PCÅë½Å µ¿È£È¸ °¢Á¾ PHP°ü·Ã »çÀÌÆ®(¿ì¸®³ª¶ó)¿¡¼­ Á¤º¸¸¦ ¾òÀ¸½Ã·Á°í ³ë·ÂÇÒ °ÍÀÔ´Ï´Ù. ÇÏÁö¸¸ Á¶±Ý¸¸ ³ë·ÂÀ» Çϸé ÇϳªÀÇ Æ®¸¯À» ã±â À§ÇØ ¸î ³¯ ¸îÀÏ ÀÎÅͳÝÀ» Çì¸Å½Ç ÇÊ¿ä°¡ ¾ø°í ¹ö±× ¾Æ´Ñ ¹ö±×¿Í »çÅõ¸¦ ¹úÀÏ ÇÊ¿ä°¡ ¾ø½À´Ï´Ù.. ±×°ÍÀº ¹Ù·Î ¸ÞÀϸµ ¸®½ºÆ® °¡ÀÔ°ú ¼Ò½º¿¡ Æ÷ÇԵǾî ÀÖ´Â µµÅ¥¸àÆ®¸¦ º¸´Â °ÍÀÔ´Ï´Ù. ÀÌ ±Û ¾²¸é¼­µµ php 3.0.12ÀÇ µµÅ¥¸ÕÆ®¿Í core phpÀÇ ¿¹Á¦µé ±×¸®°í PHP ¸ÞÀϸµ ¸®½ºÆ®¸¦ ÂüÁ¶ÇÏ¿´½À´Ï´Ù. ÀÌ°ÍÀº ¾çÁúÀÇ Á¤º¸¸¦ ¾òÀ» ¼ö ÀÖ´Â °÷À̱⠶§¹®ÀÔ´Ï´Ù.
    ¿¹¸¦ µé¾î ¸ÞÀÏÀ» º¸³»¸é¼­ ÆÄÀÏÀ» ÷ºÎÇϴ ȨÆäÀÌÁö¸¦ ¸¸µé°í ½ÍÀ» °æ¿ì¿¡ µµÅ¥¸ÕÆ®¿¡ Ä£ÀýÈ÷ ¼³¸íÀ» ÇØ ÁÖ°í ÀÖ½À´Ï´Ù.

    ÀÌ°ÍÀ¸·Î PHP¿¡ ´ëÇØ ÀÚ¼¼È÷ ¾Ë¾Æº¸¾Ò½À´Ï´Ù. ¼Ò°³¸¦ ¸øÇØ µå¸° °ÍµéÀº µ¶ÀÚ ¿©·¯ºÐÀÇ ¸òÀ¸·Î ³²°Ü ³õ°Ú½À´Ï´Ù.
    ´ÙÀ½È£¿¡¼­´Â ½ÇÁ¦ ÇÁ·Î±×·¡¹ÖÀ» Çϸ鼭 »ìÆ캸°Ú½À´Ï´Ù.




¡ã top

homeÀ¸·Î...