PHP3 Manual

by Stig Sther Bakken, Alexander Aulbach, Egon Schmid, Jim Winstead, Lars
Torben Wilson, Rasmus Lerdorf, and Zeev Suraski

Edited by Stig Sther Bakken

 : Ȳ

Copyright  1997, 1998 by the PHP Documentation Group



      Ŵ Ͽ
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)
     1. Adabas D Functions
     2. Array Functions
     3. BC (Arbitrary Precision) Functions
     4. Calendar Functions
     5. Date/Time Functions
     6. dBase Functions
     7. dbm Functions
     8. Directory Functions
     9. Dynamic Loading Functions
     10. Program Execution Functions
     11. filePro Functions
     12. Filesystem Functions
     13. Functions related to HTTP
     14. Image functions
     15. IMAP Functions
     16. PHP options & information
     17. LDAP Functions
     18. Mail Functions
     19. Mathematical Functions
     20. Miscellaneous Functions
     21. mSQL Functions
     22. MySQL Functions
     23. Sybase Functions
     24. Network Functions
     25. ODBC Functions
     26. Oracle functions
     27. PostgreSQL functions
     28. Regular expression functions
     29. Solid Functions
     30. SNMP Functions
     31. String functions
     32. URL functions
     33. Variable functions
     34. Gz-file 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)

  ------------------------------------------------------------------------

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 1.x and 2.x Velocis
     MySQL            ODBC interface ִ  DB system
     Solid            dBase
     Generic ODBC     Unix dbm
     PostgreSQL

     -----------------------------------------------------------------

PHP3 Concepts

  ------------------------------------------------------------------------

Some examples

  ------------------------------------------------------------------------

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 ȣ ĺ    ٴ ̴.

  ------------------------------------------------------------------------

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.php?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 - ε   Ǿ ִ  ӽ ϸ

     $userfile_name - ε ýۿ ϴ   ̸.

     $userfile_size - byte Upload  ũ.

     $userfile_type -  browser ε  mime  ȴٸ, 
     mime . (Ex. "image/gif").

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

  ------------------------------------------------------------------------

Regular expressions

Regular expression PHP  ڿ   Ѵ. regular
expression ϱ   Լ ȴ. :

     ereg()

     ereg_replace()

     eregi()

     eregi_replace()

     split()

 Լ 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 ǥ(expression) "@" տ ̰ ȣǸ error reporting
 ʴ´.  track_errors  Enabled Ǿ ִµ ش 忡
 ߻ߴٸ, $php_errormsg   ޽ ã 
 ̴.

  ------------------------------------------------------------------------

Supressing errors

  ------------------------------------------------------------------------

PHP source viewer

  ------------------------------------------------------------------------

Chapter 3. ġ (Installation)

       PHP3 ġϰ ϴ   ϰ ִ.
     ʿ İ Ʈ :

          ⺻ UNIX  ("make" C Ϸ )

          ANSI C Ϸ

          web  (ݵ ˾ƾ )

  ------------------------------------------------------------------------

Unix ҽ ġ (Installing From Source on UNIX)

  ------------------------------------------------------------------------

Downloading Source

 ֽŹ ҽ http://www.php.net    ִ.

  ------------------------------------------------------------------------

 (Configuration)

PHP3 ϴ  ũ ΰ ִ.

     PHP3 Բ Ǵ "setup" ũƮ ϴ  ִ. 
     ũƮ (PHP/FI 2.0 "install" ũƮ ſ ϰ) Ϸ
       Ŀ,  "configure"  Ų.  ũƮ
     Ű ./setup Էϸ ȴ.

      ũƮ "do-conf" Ҹ ϵ µ,  
     "configure" Ѱ ɼ ׵鿡    ִ. 
       ,ΰ ɼ Ϸ Ѵٸ, "setup" ų
     ʿ   ϸ  ̴. Ŀ ./do-conf ԷϿ
      ɼ  configure ϸ ȴ.

         ./configure --help Է  
     ɼǵ  켱   .

    ɼǵ ڼ ̴.

  ------------------------------------------------------------------------

Apache 

PHP3 ġ  , "Build as an Apache module?" 
"yes" ϰ, Apache  base 丮  ָ ȴ.
(configure --with-apache=DIR ɼ ָ ȴ.)   Apache
ҽ  /usr/local/www/apache_1.2.4 Ǯ Ҵٸ,  丮
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

  ------------------------------------------------------------------------

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

  ------------------------------------------------------------------------

Win95/NT ġ (Installing PHP on Windows95/NT)

  ------------------------------------------------------------------------

Apache/NT Stronghold/NT

Unix   .

(  : Apache Ŵ  ڼ   ְ, apache
srm.conf    ־ Ѵ.
AddType application/x-httpd-php3 .php3
ScriptAlias /php3-bin/ C:/php3
Action application/x-httpd-php3 /php3-bin/php.exe )

  ------------------------------------------------------------------------

IIS and MS-PWS

 php.exe  ϴ ũƮ 丮 ־ δ ͸
php ũƮ   ְ, http://my.server/scripts/php.exe/page.php
   ϴ.

  http://my.server/page.php   𷺼Ͽ
ϱ⸦ Ѵٸ   registry Ͽ Ѵ.

     NOTE: Disclaimer: registry ϱ  ݵ  
     registry   . PHP   registry ļյ
     å ʽϴ.  registry ջ   OS  
      õ   ֽϴ.

 regedit.exe ̿Ͽ Ʈ   ֽϴ. ؾ
Ʈ
HKEY_LOCAL_MACHINE:System:CurrentControlSet:Services:W3Svc:Parameters:ScriptMapԴϴ.
̰  php ũƮ  Ȯ(extension) ڿ 
߰ϰ,  ͷ php   Path մϴ.   .phtm3
"c:\webshare\scripts\php.exe"  ˴ϴ.
(  : Ȩ Ʈ  .phtm3 "c:\webshare\scripts\php.exe %s"
 %s ߰϶ մϴ. )

PHP ISAPI   .phtm "c:\webshare\scripts\php3_isapi.dll" 
˴ϴ.
(  : 98 9   ISAPI   ʾҴ. )

  丮 php ũƮ  ϵ   ֽϴ.
 ۾ IIS ڰ ϰ ˴ϴ. ڼ  IIS  ϼ.

ٸ  ش   ϶.

쿡 PHP.INI  Ǵµ PHP    
 ڵ ã´. 켱 windows os 丮 ã(c:\windows or
c:\winnt,  Ŀ PHP  ִ 丮 ˻Ѵ. ,
PHPRC=\pathto\php3.ini  ȯ溯   ͵ ϴ.
(ȯ溯 ϴ  Apache ٸ   ʴ´.)

(  : ġ     Install α׷
php3.ini  ʴ´.   php.exe ִ 丮
php.ini-dist  windows 丮(c:\windows) php.ini  
ϵ Ѵ. )

  ------------------------------------------------------------------------

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 )

  ------------------------------------------------------------------------

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 valueenabled reporting
 1        normal errors
 2        normal warnings
 4        parser errors
 8        non-critical style-related warnings

⺻ 7 ̴(normal errors normal warnings, parser errors Ʈ
ȴ).
gpc_order string

GET / POST / COOKIE  ؼ  Ѵ. ⺻ "GPC"̴.
 "GP" Ѵٸ, PHP cookie  ϰ,  ̸
 POST  ִ GET  POST     ȴ.
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
magic_quotes_runtime boolean
magic_quotes_sybase boolean
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

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  ִ 

  ------------------------------------------------------------------------

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       
Ƴ Ǿ ִ. :

     ý Ϸ  : http://my.host/cgi-bin/php?/etc/passwd

      url ǥ(?)Ŀ ִ û CGI ̽  command
     line argument Ϳ ޵ȴ.  ʹ Ŀǵ
      ù ° argument  о  Ѵ.

     CGI binary   PHP  command line argument 
     Ѵ.

         : http://my.host/cgi-bin/php/secret/doc.html

      url PHP binary  path (/secret/doc.html) Ϲ
     CGI α׷  а ؼǾ   ̸ ȴ. 
        (Apache  Action)
     http://my.host/secret/script.php3   û PHP 
     Ʈ ϴµ ȴ. ̷ ϸ,  켱 /secret
     丮   ˻ Ŀ
     http://my.host/cgi-bin/php/secret/script.php3 Ʈ û ϰ
     ȴ. ,  û  form ־ ̶, 
     /secret/script.php3 Ͽ    ˻縦  ʰ,
     /cgi-bin/php Ͽ  ˻縸 Ѵ.   ϸ
     /cgi-bin/php   ڴ   ȣ 鵵
       ִ.

     PHP   tree   ִ 丮  ִٸ,
     Ͻÿ --enable-force-cgi-redirect  ɼ ְ, ÿ
     doc_root user_dir ڸ Ͽ   Ƴ  ִ.
     Ʒ   ٸ    ڼ   ִ.

  ------------------------------------------------------------------------

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

  ------------------------------------------------------------------------

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>

  ------------------------------------------------------------------------

Instruction separation

  ------------------------------------------------------------------------

Variable types

(  :Ϲ PHP  type  . :

   * Scalar types
        * Integer (is_long())
        * Float (is_double())
        * String (is_string())
   * Array Types (is_array())
        * Linear Arrays
        * Hashes/Associative Arrays
   * Objects (is_object())

δ Լ Ŭ  ǵǱ  ̰͵ Ϲ
 üũ ʴ´. )

  ------------------------------------------------------------------------

 ʱȭ (Variable initialization)

PHP  ʱȭϴ  ܼ      ָ ȴ.
Array Object    ٸ   κ 
̰  ̰  ̴.

  ------------------------------------------------------------------------

迭 ʱȭ (Initializing Arrays)

迭 ְ ʱȭ   ִ :   ϴ
(sequential assign), array() construct   ִ. (Array
functions κп ڼ  ִ).

迭   ϴ  迭 ÷  ׳ ϸ ȴ.
׷     迭   ÷ȴ.

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

  ------------------------------------------------------------------------

ü ʱȭ (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 ϰ   ִ :

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

  ------------------------------------------------------------------------

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

  ------------------------------------------------------------------------

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

  ȯ ϴ. :

     (int), (integer) - cast to integer

     (real), (double), (float) - cast to double

     (string) - cast to string

     (array) - cast to array

     (object) - cast to object

ǰ  ȣȿ õȴ.      ϴ. :

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

 ȯ  ڼ Unix manual page strtod(3) ƶ.

  ------------------------------------------------------------------------

迭 (Array manipulation)

PHP scalar 迭 associative 迭   Ѵ.   
̴ .  array() Լ Ͽ 迭 ų,  
  ־ 迭   ִ.

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

迭  ϴ Ŀ  sort(), ksort(), asort() Լ ̿
   ִ.

count() Լ ϸ 迭     ִ.

next() prev() Լ ̿Ͽ 迭  Ž  ִ. 迭 
Žϴ  each() Լ   ִ.

  ------------------------------------------------------------------------

Chapter 6. Language constructs

PHP3 ũƮ (statement)  . 忡
Թ(assignment), Լȣ(function call), ȯ(loop),
ǹ(conditional statement) ִ. ϳ   ݷ( ;
) δ´. ,  ߰ȣ( { } ) Ͽ ϳ 
(statement-group)   ִ.   ϳ ó  
ִ.  忡    type  Ǿ ִ. (:
̰ ⺻  C ȴٰ ϰ  ణ Ͽ Ͽ)

  ------------------------------------------------------------------------

ǥ (Expressions)

  "$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 ĳ Ͱ . :

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++;
}

 ó  ƺδ. ׷  ϴٴ  ˾ƾ Ѵ.

FOR   ¸ ϴ. 'FOR(expr): ... ENDFOR;'  
ʴ´.

    FOR(expr): ... ENDFOR;  is NOT supported.

  ------------------------------------------------------------------------

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

  ------------------------------------------------------------------------

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
ȯ⿡ ̴.

  ------------------------------------------------------------------------

CLASS

(  :  κ  Ŵ  κ PHP Ȩ Note
Ͽ. )

Class  Java subset̶ Ҹŭ ϴ.

Ŭ Ϸ    ϴ Լ ̴. Ŭ
  · ȴ.

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

This defines a class named Cart that consists of an associative array of
articles in the cart and two functions to add and remove items from this
cart.

Classes are types, that is, they are blueprints for actual variables. You
have to create a variables of the desired type with the new operator.

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

This creates an object $cart of the class Cart. The function add_item() of
that object is being called to add 1 item of article number 10 to the cart.

Classes can be extensions of other classes. The extended or derived class
has all variables and functions of the base class and what you add in the
extended defintion. This is done using the extends keyword.

class Named_Cart extends Cart {
  var $owner;

  function set_owner($name) {
    $this->owner = $name;
  }
}

This defines a class Named_Cart that has all variables and functions of
Cart plus an additional variable $owner and an additional function
set_owner(). You create a named cart the usual way and can now set and get
the carts owner. You can still use normal cart functions on named carts:

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

Within functions of a class the variable $this means this object. You have
to use $this->something to access any variable or function named something
within your current object.

  ------------------------------------------------------------------------

Chapter 7. Expressions

  ------------------------------------------------------------------------

Mathematical expressions

  ------------------------------------------------------------------------

Operators

(  :  κ  Ŵ  κ PHP Ȩ Note
Ͽ. )

PHP has a number of arithmetic operators that can be used to form
arithmetic expressions. If you know C, C++ or Java, most of these will be
familar to you and work as you exspect. Some operators are associative,
that is, you can build more complex expressions from them by combining
multiple operators in one expression. If you write a multi-operator
expression like (1+2+3), it may be evaluated from the left like (1+2)+3 or
from the right like 1+(2+3). Some operators are left-associative,
preferring the order given in first example, others are right-associative
like the second example. Nonassociative operators cannot be combined into
larger expressions. Associative Operators have precedence over others, that
is, if you use them in context with other operators there will be default
parentheses that dictate how the expression is evaluated. You know this
from normal mathematics, where multiplication and division take precedence
over addition and substraction. In this manual, operators are presented
from lowest to highest precedence. Boolean operators return a true or false
as a result. In PHP, false is defined as either the empty string "" or the
number zero, depending on the context. All other values are considered
true.

OR, left-associative
     The OR operator evaluates both expressions and returns false, if and
     only if both of them are false.
XOR, left-associative
     The XOR operator evaluates both expressions and returns false, if and
     only if both have the same logical value (both are true or both are
     false).
AND, left-associative
     The AND operator evaluates both expressions and returns false, unless
     both expressions are true.
= (assignments), left-associative
     The assignment operator returns the value that has been assigned to a
     variable. It is left-associative. This results in contructs like these
     being valid PHP: $a = $b = $c = 0.

     The assignment operator is also available with an included operation,
     as in C: +=, -=, *=, /=, .=, %=, &=, |=, ^=, <<=, >>= are available
     and do what they to in C, C++ and Java. For non-C-programmers: $a +=
     1; is defined as being equivalent to $a = $a + 1;. Very handy for
     string operations is the expression $a .= "appended string";
?: (Conditional expression), left-associative
     The (boolean-expression)?expression1:expression2 operator is a
     conditional expression, a calculated if-statement. If the
     boolean-expression is true, the result is the result of expression1,
     otherwise it is the result of expression2. You use it like this: $a =
     isset($input)?$input:"no input given". After this statement, $a either
     has the value of $input or the value "no input given".
|| (boolean or), left-associative
     Like OR, but with a higherr precedence.
&&(boolean and), left-associative
     Like AND, but with a higher precedence.
| (arithmetic or), left-associative
     This is an arithmetic or-operation. It differs from || in that it
     takes its operands as bit patterns and operates on the individual bits
     of the operands. The result, like the operands, are thus integers, not
     bools.
^ (arithmetic xor), left-associative
     The corresponding arithmetic xor-operation
& (arithmetic and), left-associative
     The corresponding arithmetic and-operation
==, !=, non-associative
     These comparison operators test for equiality/inequality. The result
     is true is both operands are equal/not equal. They are nonassociative:
     You can't write $a == $b == $c.
<, <=, >=, >, non-associative
     These comparison operators test for the left operand being lower,
     lower-or-equal, greater-or-equal and greater than the right operand.
     Note that greater-or-equal is written >=, while => is a different
     operator (see below)!
<lt;, >gt;, left-associative
     These two operators take their left operand as a bit-pattern and shift
     it as many bits to the left (to the right) as the right operand
     indicates.
+, -, ., left-associative
     These operators represent the arithmethic operations addition (+,
     plus) and substraction (-, minus) and the string operation
     concatencation (., dot).
*, /, %, left-associative
     These operators represent the arithmetic operations multiplication (*,
     asterisk), division (/, slash) and modulus (%, percent).
!, ~ (tilde), ++, --, (int), (float), (string), (array), (object), @,
right-associative
     These are unary operators, they are right-associative. They operate on
     their single argument. ! (bang) is a boolean negation operator: It
     turns a true value false and vice-versa. ~ (tilde) is the integer
     complement operator into its two's complement. ++ and -- are integer
     increment and decrement operators respectively. They increment or
     decrement their argument by one.

     The following operators are casts, that is, they change the type of
     their single argument into the indicated type. (int) may as well be
     written (integer) and turns a variable into a numberic integer type.
     (real), (double) and (float) all do the same and turn their argument
     into a floating point type. (string) has no aliases and turns it into
     a string variable. (int) and (string) are often useful to force the
     comparison operators to produce a numeric or lexical comparison. Less
     usefull, but provided for completeness are (array) and (object).

     The '@' operator silences warnings. If some PHP operatings throws a
     warning and you don't care about it, you can silence that particular
     warning by preceding the operation with an '@'. For example,
     @reset($a) won't warn you, if $a is not set or not an array.
new, non-associative
     Create a new object, given a class. $obj = new Classname

  ------------------------------------------------------------------------

Overloaded operators

  ------------------------------------------------------------------------

II. Function Reference

(:  Reference κ   ̰,  Ȯ
ϱ  Ư 츦 ϰ  κи Ͽ.)

Table of Contents
1. Adabas D Functions
2. Array Functions
3. BC (Arbitrary Precision) Functions
4. Calendar Functions
5. Date/Time Functions
6. dBase Functions
7. dbm Functions
8. Directory Functions
9. Dynamic Loading Functions
10. Program Execution Functions
11. filePro Functions
12. Filesystem Functions
13. Functions related to HTTP
14. Image functions
15. IMAP Functions
16. PHP options & information
17. LDAP Functions
18. Mail Functions
19. Mathematical Functions
20. Miscellaneous Functions
21. mSQL Functions
22. MySQL Functions
23. Sybase Functions
24. Network Functions
25. ODBC Functions
26. Oracle functions
27. PostgreSQL functions
28. Regular expression functions
29. Solid Functions
30. SNMP Functions
31. String functions
32. URL functions
33. Variable functions
34. Gz-file Functions

  ------------------------------------------------------------------------

Adabas D Functions

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

  ------------------------------------------------------------------------

Array Functions

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

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



(  :  array_walk  Ŵ󿡴    ִ Լ̹Ƿ
÷ )

array_walk

array_walk -- 迭  ҿ  Լ Ѵ.

Description

void array_walk(array array, string function_name);

array_walk applies each element of an array to the first argument of a
function.

Example:
  $a=array("a","b","c","d");

  function show($elt) {
    print $elt."<br>\n";
  }

  array_walk($a,"show");

  ------------------------------------------------------------------------

BC (Arbitrary Precision) Functions

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

Get the modulus of the left operand using modulus. The scale parameter sets
the number of digits after the decimal place in the result.

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

  ------------------------------------------------------------------------

Calendar Functions

PHP  ٸ ¥(޷) ¸ ȯ ִ Լ Ѵ. Julian
Day Count ⺻ ȴ. ̰ BC4000    
װ  ¥    ̴.  Julian Day
Count Ϲ ϴ Julian ޷° ٸٴ  ˾Ƶ.
Calendar ýۿ  ڼ ˰ ʹٸ
http://genealogy.org/~scottlee/cal-overview.html 湮Ͽ . 
߿     "" ѷ ΰ ִ.

(  :  Լ dl/calender extension Load Ŀ 밡ϴ.
dl/README  о. )

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

  ------------------------------------------------------------------------

Date/Time Functions

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:

     year is between 1900 and 32767 inclusive

     month is between 1 and 12 inclusive

     day is within the allowed number of days for the given month. Leap
     years are taken into consideration.

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:

     U - seconds since the epoch

     Y - year, numeric, 4 digits

     y - year, numeric, 2 digits

     F - month, textual, long; i.e. "January"

     M - month, textual, 3 letters; i.e. "Jan"

     m - month, numeric

     z - day of the year, numeric; i.e. "299"

     d - day of the month, numeric

     l (lowercase 'L') - day of the week, textual, long; i.e. "Friday"

     D - day of the week, textual, 3 letters; i.e. "Fri"

     w - day of the week, numeric, 1 digit

     H - hour, numeric, 24 hour format

     h - hour, numeric, 12 hour format

     i - minutes, numeric

     s - seconds, numeric

     A - "AM" or "PM"

     a - "am" or "pm"

     S - English ordinal suffix, textual, 2 characters; i.e. "th", "nd"

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

See also gmdate() and mktime().

getdate

getdate -- date/time  ´.

Description

array getdate(int timestamp);

Returns an associative array containing the date information of the
timestamp as the following array elements:

     "seconds" - seconds

     "minutes" - minutes

     "hours" - hours

     "mday" - day of the month

     "wday" - day of the week, numeric

     "mon" - month, numeric

     "year" - year, numeric

     "yday" - day of the year, numeric; i.e. "299"

     "weekday" - day of the week, textual, full; i.e. "Friday"

     "month" - month, textual, full; i.e. "January"

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

set_time_limit

set_time_limit -- ࿡ ɸ ð Ų. (limit 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.

  ------------------------------------------------------------------------

dBase Functions

 Լ dBase  databse(dbf)  ڵ   ְ 
ش.

index memo ʵ  ʴ´.

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:

L

Boolean. These do not have a length or precision.
M

Memo. (Note that these aren't supported by PHP.) These do not have a length
or precision.
D

Date (stored as YYYYMMDD). These do not have a length or precision.
N

Number. These have both a length and a precision (the number of digits
after the decimal point).
C

String.

If the database is successfully created, a dbase_identifier is returned,
otherwise false is returned.

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.

dbase_numrecords

dbase_numrecords -- fdBase database record  Ѵ.

Description

int dbase_numrecords(int dbase_identifier);

Returns the number of records (rows) in the specified database.

  ------------------------------------------------------------------------

dbm Functions

 Լ dbm  databse(dbf)  ڵ   ְ 
ش.   database Berkeley db, gdbm   flatfile
̺귯  Ϻ system ̺귯  ϴµ, Ϲ relational
databases ޸ key/value  data Ѵ.

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.

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 -- describes the dbm-compatible library being used

Description

string dblist(void);
  ------------------------------------------------------------------------

Directory Functions

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.

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.

  ------------------------------------------------------------------------

Dynamic Loading Functions

dl

dl -- PHP extension ߿ loadѴ.

Description

int dl(string library);

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

  ------------------------------------------------------------------------

Program Execution Functions

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

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

  ------------------------------------------------------------------------

filePro Functions

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

  ------------------------------------------------------------------------

Filesystem Functions

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

Affected functions include stat(), file_exists(), filectime(), fileatime(),
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()

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.

fileumask

fileumask --  umask Ѵ.

Description

int fileumask(int umask);

Sets the umask to umask & 0777.

Returns the old umask.

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.

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.
Example 1. fopen() example

$fp = fopen( "/home/rasmus/file.txt", "r" );
$fp = fopen( "http://www.php.net/", "r" );

(  : URI username password   ֽϴ.
scheme://user:pass@domain.name/path/ )
(  : mode "r" - read, "w" - write, "a" - append ֽϴ. "a"
   մϴ. "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, returns false.

The file pointer must be valid, and must point to a file successfully
opened by fopen(), popen(), or 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.

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.

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

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:

     device
     inode
     number of links
     user id of owner
     group id owner
     device type if inode device *
     size in bytes
     time of last access
     time of last modification
     time of last change
     blocksize for filesystem I/O *
     number of blocks allocated

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

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.

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.

  ------------------------------------------------------------------------

Functions related to HTTP

 Լ HTTP protocol leve Ÿ remote browser   
ֵ  ش.

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.

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.0 Specification for more information on raw
http headers. Remember that the Header() function must be called before any
actual output is sent either by normal HTML tags or from PHP.

Header("Location: http://www.php.net");  /* Redirect browser to PHP web site */

(  :    ũƮ ó ϸ Ŭ̾Ʈ
cash proxy ź  ִ.
<?php
  header("Expires: 0");
  header("Cache-Control: no-cache, must-revalidate");
  header("Pragma: no-cache");
?> )

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.

  ------------------------------------------------------------------------

Image functions

  Լ JPEG, GIF, PNG ̹ ũ⸦ ˾ƺ  ִ.
  GD library(http://www.boutell.com/gd/ ִ.) 
ִٸ,  GIF ̹ ų   ִ.

GetImageSize

GetImageSize -- GIF JPG, PNG ׸ ũ⸦ Ѵ.

Description

array getimagesize(string filename);

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]; ?>>

     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 the color
identifier returned by imagecolorallocate().

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.

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 positionC data     description
              type
 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().

ImageTTFText

ImageTTFText -- TrueType Ʈ Ͽ ڿ .

Description

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

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...");
ImageGif($im);
ImageDestroy($im);
?>

This function requires both the GD library and the Freetype library.

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

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

  ------------------------------------------------------------------------

IMAP Functions

imap_append

imap_append --  Կ ڿ ޼ δ.

Description

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

Returns true on sucess, false on error.

imap_append() function appends a string message to the specified mailbox
mbox.

imap_base64

imap_base64 -- BASE64 encode text decodeѴ.

Description

string imap_base64(string text);

imap_base64() function decodes a BASE64 encoded text. The decoded message
is retunred as a string.

Note: This function uses built in c-client base64 decoding, not an internal
routine, so one must load the imap.so library to use this function.

imap_body

imap_body -- message body д´.

Description

string imap_body(int imap_stream, int msg_number);

imap_body() returns the body of the message, numbered msg_number in the
current mailbox.

imap_check

imap_check --  mailbox ˻Ѵ.

Description

array imap_check(int imap_stream);

Returns false if there are no new messages, else returns information about
the current mailbox.

imap_check() function checks the current mailbox status on the server and
returns the information in an associative array with following elements.

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

Returns true on success and false on error.

Close the imap stream.

imap_createmailbox

imap_createmailbox --   .

Description

int imap_createmailbox(int imap_stream, string mbox);

Returns true on success and false on error.

imap_createmailbox() creates a new mailbox specified by mbox.

imap_delete

imap_delete --  Կ  messge  ũ Ѵ.

Description

int imap_delete(int imap_stream, int msg_number);

Returns true on success and false on error.

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

Returns true on success and false on error.

imap_deletemailbox() deteles the specified mailbox.

imap_expunge

imap_expunge --  ũ Ǿ ִ  ޼ .

Description

int imap_expunge(int imap_stream);

Returns true on success and false on error.

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

imap_fetchbody

imap_fetchbody -- message body particular section  ´.

Description

string imap_fetchbody(int imap_stream, int msg_number, int part_number);

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.

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

array imap_header(int imap_stream, int msg_number);

This function returns an associative array of various header elements of
the specified message.

Date, From, From2, Subject, To, cc, ReplyTo, Recent, Unseen,
Flagged, Deleted, Msgno, MailDate, Size

imap_headerinfo

imap_headerinfo -- message header о´.

Description

array imap_headerinfo(int imap_stream, int msg_number);

Same as imap_header()

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

Returns an array containing the names of the mailboxes.

(  : Ȩ Note  Parameter  Ʋִٰ Ѵ. ڴ
 Լ  ʾ Ȯ Ͽ. )

imap_listsubscribed

imap_listsubscribed --  subscribed   о ´.

Description

array imap_listsubscribed(int imap_stream);

Returns an array of all the mailboxes that you have subscribed.

imap_mail_copy

imap_mail_copy -- Ư message ٸ  Ѵ.

Description

int imap_mail_copy(int imap_stream, string mbox, string msglist);

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.

imap_mail_move

imap_mail_move -- Ư message ٸ  ű.

Description

int imap_mail_move(int imap_stream, string mbox, string msglist);

Returns true on success and false on error.

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

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

Returns an IMAP stream on success and false on error.

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

Returns true on success and false on error.

This function renames on old mailbox to new mailbox.

imap_reopen

imap_reopen --  ִ IMAP stream   .

Description

int imap_reopen(string imap_stream, string username, string password);

Returns true on success and false on error.

This function reopens the specified stream to new mailbox.

imap_subscribe

imap_subscribe --   subscribeѴ.

Description

int imap_subscribe(int imap_stream, string mbox);

Returns true on success and false on error.

Subscribe to a new mailbox.

imap_undelete

imap_undelete --  ǥõ message  ǥø  .

Description

int imap_undelete(int imap_stream, int msg_number);

Returns true on success and false on error.

This function removes the deletion flag for a specified message, which is
set by imap_delete().

imap_unsubscribe

imap_unsubscribe --  unsubscribeѴ.

Description

int imap_unsubscribe(int imap_stream, string mbox);

Returns true on success and false on error.

Unsubscribe from a specified mailbox.

imap_qprint

imap_qprint -- quoted-printable ڿ 8 bit ڿ ٲ۴.

Description

int imap_unsubscribe(string string);

Returns an 8 bit (binary) string

Convert a quoted-printable string to an 8 bit string

imap_8bit

imap_8bit -- 8 bit ڿ quoted-printable ڿ ٲ۴.

Description

int imap_8bit(string string);

Returns a quoted-printable string

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

  ------------------------------------------------------------------------

PHP options & information

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
 0message 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.
 1message 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.
 2message 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.
 3message 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. This is a bitmask of the following values
(follow the links for the internal values to get their meanings):

Table 1. error_reporting() bit values
 valueinternal 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.

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.

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

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


  ------------------------------------------------------------------------

LDAP Functions

(  : LDAP  ڼ ڷ  Ʈ  .
Netscape - http://developer.netscape.com/tech/directory/
University of Michigan - http://www.umich.edu/~dirsvcs/ldap/index.html
LDAP World - http://elvira.innosoft.com/ldapworld/ )
(  : 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 code 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.

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 e
ntries from the result.

see also ldap_get_entries().

ldap_free_entry

ldap_free_entry -- entry result memory Ǯش.

Description

int ldap_free_entry(int result_entry_identifier);

Returns true on success and false on error.

ldap_free_entry() deallocates memory used to store the entries in LDAP
result. All memory allocated for entries is automatically freed when the
script terminates.

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.

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.

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

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.

    return_value["count"] = number of values for attribute
    return_value[0] = first value of attribute
    return_value[i] = ith value of attribute
Example 1.example code

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.
Example 1.example code

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

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.

ldap_search

ldap_search -- LDAP tree ˻Ѵ.

Description

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

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.
Example 1.example code

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

  $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>";



ldap_unbind

ldap_unbind -- LDAP directoryκ unbindѴ.

Description

int ldap_unbind(int link_identifier);

Returns true on success and false on error.

ldap_unbind() function unbinds from the LDAP directory.

        ------------------------------------------------------------
 (  : LDAP    LDAP ׵ PHP Ȩ Note
߰ ̴. ̿ܿ LDAP ؼ   ߰Ǿ LDAP
Ϸ  PHP Ȩ  鷯 Ȯϱ ٶ. )

Introduction to LDAP

LDAP is the Lightweight Directory Access Protocol, and is a protocol used
to access "Directory Servers". The Directory is a special kind of database
that holds information in a tree structure.

The concept is similar to your hard disk directory structure, except that
in this context, the root directory is "The world" and the first level
subdirectories are "countries". Lower levels of the directory structure
contain entries for companies, organisations or places, while yet lower
still we find directory entries for people, and perhaps equipment or
documents.

To refer to a file in a subdirectory on your hard disk, you might use
something like

    /usr/local/myapp/docs

The forwards slash marks each division in the reference, and the sequence
is read from left to right.

The equivalent to the fully qualified file reference in LDAP is the
"distinguished name", referred to simplay as "dn". An example dn might be

    cn=John Smith,ou=Accounts,o=My Company,c=US

The comma marks each division in the reference, and the sequence is read
from right to left. You would read this dn as ..

    country = US
    organization = My Company
    organizationalUnit = Accounts
    commonName = John Smith

In the same way as there are no hard rules about how you organise the
directory structure of a hard disk, a directory server manager can set up
any structure that is meaningful for the purpose. However, there are some
conventions that are used. The message is that you can not write code to
access a directory server unless you know something about its structure,
any more than you can use a database without some knowledge of what is
available.

           -----------------------------------------------------

Using the PHP LDAP calls:

You will need to get and compile LDAP client libraries from either the
University of Michigan ldap-3.3 package or the Netscape Directory SDK. You
will also need to recompile PHP with LDAP support enabled before PHP's LDAP
calls will work.

Before you can use the LDAP calls you will need to know ..

   * The name or address of the directory server you will use
   * The "base dn" of the server (the part of the world directory that is
     held on this server, which could be "o=My Company,c=US")
   * Whether you need a password to access the server (many servers will
     provide read access for an "anonymous bind" but require a password for
     anything else)

The typical sequence of LDAP calls you will make in an application will
follow this pattern:

  ldap_connect()    // establish connection to server
     |
  ldap_bind()       // anonymous or authenticated "login"
     |
  do something like search or update the directory
  and display the results
     |
  ldap_close()      // "logout"

           -----------------------------------------------------

 The calls ldap_read(), ldap_list() and ldap_search() return zero or more
existing entries from the server and can typically be performed using an
anonymous bind to the directory server (depending on how access security
has been set up on the server).

The calls ldap_add(), ldap_delete() and ldap_modify() change individual
directory entries and will usually require an authenticated bind, ie one
where a "dn" and its associated password are supplied to the directory
server (but this will also depend on how security has been set up on the
server).

The results from a search are handled using the functions ..
 ldap_count_entries()the number of entries returned from the search
                     return all entries and their constituent attributes
 ldap_get_entries()  and values from the search result in a
                     multi-dimensional array
 ldap_first_entry()  calls to traverse the search result one entry at a
 ldap_next_entry()   time

Each individual entry in a search result can be handled using the functions
..

 ldap_get_attributes()returns a multi-dimensional array of the attributes
                      and associated values for the current search entry
 ldap_get_dn()        returns the unique "distinguished name"

 ldap_get_values()    return zero or more values associated with a named
                      attribute for the current search entry
 ldap_first_attibute()calls to step through the attributes of the current
 ldap_next_attribute()entry

There are also some utility functions:

 ldap_dn2ufn()     strips out attribute information from a "dn" to make it
                   more presentable - ok for simple directory listings
                   returns the "dn" broken into either a simple array or
 ldap_explode_dn() an associative array that can be accesssed using the dn
                   attributes
 ldap_free_entry() free memory used by ldap_first/next_entry calls
                   free memory used by the directory search calls

 ldap_free_result()(This memory is freed automatically when the php script
                   finishes, but may be necessary if you do a lot of
                   searches within a single routine)



  ------------------------------------------------------------------------

Mail Functions

mail() Լ    ְ  ش.

mail

mail --  .

Description

void 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.
Example 2. Sending mail with extra headers.

mail("ssb@guardian.no", "the subject", $message, "X-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"); )

  ------------------------------------------------------------------------

Mathematical Functions

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

BinDec

BinDec -- binary to decimal

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 -- decimal to binary

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

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.

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

Returns a pseudo-random value between 0 and RAND_MAX.

Remember to seed the random number generator before use with srand().


Example 1. rand() example

function  randomint($max  =  100)  {
     static  $startseed  =  0;
     if  (!$startseed)  {
         $startseed  =  (double)microtime()*getrandmax();
         srand($startseed);
     }
     return  (rand()%$max);
 }

function  random($max  =  1)  {
     static  $startseed  =  0;
     if  (!$startseed)  {
         $startseed  =  (double)microtime()*getrandmax();
         srand($startseed);
     }
     return  ((rand()/getrandmax())*$max);
 }

See also srand() and 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() and getrandmax().

Tan

Tan -- tangent

Description

float tan(float arg);

Returns the tangent of arg in radians.

See also sin() and cos().

  ------------------------------------------------------------------------

Miscellaneous Functions

 Լ  ֿ ԽŰ  ͵̴.

sleep

sleep --   Ų.

Description

void sleep(int seconds);

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

See also usleep().

usleep

usleep --  鸸   Ų.

Description

void usleep(int micro_seconds);

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

See also sleep().

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.

(  : cookie ϵ unique id   Ϲ 
  ϸ .
$token = md5(uniqid("")); // no random portion
$better_token = md5(uniqid(random())); // better, difficult to guess
̷ ϸ 32 id .)

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.

  ------------------------------------------------------------------------

mSQL Functions

msql

msql -- mSQL Ǹ Ѵ.

Description

int msql(string database, string query, int link_identifier);

Returns a positive mSQL result identifier to the query result, or false on
error.

msql() selects a database and executes a query on it. If the optional link
identifier isn't specified, the function will try to find an open link to
the mSQL server and if no such link is found it'll try to create one as if
msql_connect() was called with no arguments (see msql_connect()).

msql_close

msql_close -- mSQL connection ݴ´.

Description

int msql_close(int link_identifier);

Returns true on success, false on error.

msql_close() closes the link to a mSQL database that's associated with the
specified link identifier. If the link identifier isn't specified, the last
opened link is assumed.

Note that this isn't usually necessary, as non-persistent open links are
automatically closed at the end of the script's execution.

msql_close() will not close persistent links generated by msql_pconnect().

See also: msql_connect() and msql_pconnect().

msql_connect

msql_connect -- mSQL connection .

Description

int msql_connect(string hostname);

Returns a positive mSQL link identifier on success, or false on error.

msql_connect() establishes a connection to a mSQL server. The hostname
argument is optional, and if it's missing, localhost is assumed.

In case a second call is made to msql_connect() with the same arguments, no
new link will be established, but instead, the link identifier of the
already opened link will be returned.

The link to the server will be closed as soon as the execution of the
script ends, unless it's closed earlier by explicitly calling msql_close().

See also msql_pconnect(), msql_close().

msql_create_db

msql_create_db -- mSQL database .

Description

int msql_create_db(void);

msql_create_db() attempts to create a new database on the server associated
with the specified link identifier.

See also: msql_drop_db().

msql_createdb

msql_createdb -- mSQL database .

Description

int msql_createdb(void);

Identical to msql_create_db().

msql_data_seek

msql_data_seek --  row pointer ̵Ѵ.

Description

int msql_data_seek(int result_identifier, int row_number);

Returns true on success, false on failure.

msql_data_seek() moves the internal row pointer of the mSQL result
associated with the specified result identifier to pointer to the specifyed
row number. The next call to msql_fetch_row() would return that row.

See also: msql_fetch_row().

msql_dbname

msql_dbname --  mSQL database ̸ Ѵ.

Description

string msql_dbname(string result, int i);

msql_dbname() returns the database name stored in position i of the result
pointer returned from the msql_listdbs() function. The msql_numrows()
function can be used to determine how many database names are available.

msql_drop_db

msql_drop_db -- mSQL database .(drop = delete)

Description

int msql_drop_db(string database_name, int link_identifier);

Returns true on success, false on failure.

msql_drop_db() attempts to drop (remove) an entire database from the server
associated with the specified link identifier.

See also: msql_create_db().

msql_dropdb

msql_dropdb -- mSQL database .(drop = delete)

Description

See msql_drop_db().

msql_error

msql_error --  mSQL ȣ  ޼ ȯѴ.

Description

string msql_error( );

Errors coming back from the mSQL database backend no longer issue warnings.
Instead, use these functions to retrieve the error string.

msql_fetch_array

msql_fetch_array -- row 迭 ´.

Description

int msql_fetch_array(int result);

Returns an array that corresponds to the fetched row, or false if there are
no more rows.

msql_fetch_array() is an extended version of msql_fetch_row(). In addition
to storing the data in the numeric indices of the result array, it also
stores the data in associative indices, using the field names as keys.

An important thing to note is that using msql_fetch_array() is NOT
significantly slower than using msql_fetch_row(), while it provides a
significant added value.

For further details, also see msql_fetch_row()

msql_fetch_field

msql_fetch_field -- ʵ  Ѵ.

Description

object msql_fetch_field(int result, int field_offset);

Returns an object containing field information

msql_fetch_field() can be used in order to obtain information about fields
in a certain query result. If the field offset isn't specified, the next
field that wasn't yet retreived by msql_fetch_field() is retreived.

The properties of the object are:

     name - column name

     table - name of the table the column belongs to

     not_null - 1 if the column cannot be null

     primary_key - 1 if the column is a primary key

     unique - 1 if the column is a unique key

     type - the type of the column

See also msql_field_seek().

msql_fetch_object

msql_fetch_object -- row ü(Object) ´.

Description

int msql_fetch_object(int result);

Returns an object with properties that correspond to the fetched row, or
false if there are no more rows.

msql_fetch_object() is similar to msql_fetch_array(), with one difference -
an object is returned, instead of an array. Indirectly, that means that you
can only access the data by the field names, and not by their offsets
(numbers are illegal property names).

Speed-wise, the function is identical to msql_fetch_array(), and almost as
quick as msql_fetch_row() (the difference is insignificant).

See also: msql_fetch_array() and msql_fetch_row().

msql_fetch_row

msql_fetch_row -- row 迭(enumerated array) ´.

Description

array msql_fetch_row(int result);

Returns an array that corresponds to the fetched row, or false if there are
no more rows.

msql_fetch_row() fetches one row of data from the result associated with
the specified result identifier. The row is returned as an array. Each
result column is stored in an array offset, starting at offset 0.

Subsequent call to msql_fetch_row() would return the next row in the result
set, or false if there are no more rows.

See also: msql_fetch_array(), msql_fetch_object(), msql_data_seek(), and
msql_result().

msql_fieldname

msql_fieldname -- ʵ ̸ Ѵ.

Description

string msql_fieldname(int result, int field);

msql_fieldname() returns the name of the specified field. result is the
result identifier, and field is the field index. msql_fieldname($result,
2); will return the name of the second field in the result associated with
the result identifier.

msql_field_seek

msql_field_seek -- ʵ offset Ѵ.

Description

int msql_field_seek(int result, int field_offset);

Seeks to the specified field offset. If the next call to msql_fetch_field()
won't include a field offset, this field would be returned.

See also: msql_fetch_field().

msql_fieldtable

msql_fieldtable -- ش ʵ带   Table ̸ Ѵ.

Description

int msql_fieldtable(int result, int field);

Returns the name of the table field was fetched from.

msql_fieldtype

msql_fieldtype -- ʵ type Ѵ.

Description

string msql_fieldtype(string result, int i);

msql_fieldtype() is similar to the msql_fieldname() function. The arguments
are identical, but the field type is returned. This will be one of "int",
"string" or "real".

msql_fieldflags

msql_fieldflags -- ʵ flag Ѵ.

Description

string msql_fieldflags(string result, int i);

msql_fieldflags() returns the field flags of the specified field. Currently
this is either, "not null", "primary key", a combination of the two or ""
(an empty string).

msql_fieldlen

msql_fieldlen -- ʵ ̸ Ѵ.

Description

int msql_fieldlen(string result, int i);

msql_fieldlen() returns the length of the specified field.

msql_free_result

msql_free_result -- result memory Ǯش.

Description

int msql_free_result(int result);

msql_free_result() frees the memory associated with result. When PHP
completes a request, this memory is freed automatically, so you only need
to call this function when you want to make sure you don't use too much
memory while the script is running.

msql_freeresult

msql_freeresult -- result memory Ǯش.

Description

See msql_free_result()

msql_list_fields

msql_list_fields -- result field Ѵ.

Description

int msql_list_fields(string database, string tablename);

msql_list_fields() retrieves information about the given tablename.
Arguments are the database name and the table name. A result pointer is
returned which can be used with msql_fieldflags(), msql_fieldlen(),
msql_fieldname(), and msql_fieldtype(). A result identifier is a positive
integer. The function returns -1 if a error occurs. A string describing the
error will be placed in $phperrmsg, and unless the function was called as
@msql_list_fields() then this error string will also be printed out.

See also msql_error().

msql_listfields

msql_listfields -- result field Ѵ.

Description

See msql_list_fields().

msql_list_dbs

msql_list_dbs -- server mSQL database Ѵ.

Description

int msql_list_dbs(void);

msql_list_dbs() will return a result pointer containing the databases
available from the current msql daemon. Use the msql_dbname() function to
traverse this result pointer.

msql_listdbs

msql_listdbs -- server mSQL database Ѵ.

Description

See msql_list_dbs().

msql_list_tables

msql_list_tables -- mSQL database table Ѵ.

Description

int msql_list_tables(string database);

msql_list_tables() takes a database name and result pointer much like the
msql() function. The msql_tablename() function should be used to extract
the actual table names from the result pointer.

msql_listtables

msql_listtables -- mSQL database table Ѵ.

Description

See msql_list_tables().

msql_num_fields

msql_num_fields -- result field  Ѵ.

Description

int msql_num_fields(int result);

msql_num_fields() returns the number of fields in a result set.

See also: msql(), msql_query(), msql_fetch_field(), and msql_num_rows().

msql_num_rows

msql_num_rows -- result row  Ѵ.

Description

int msql_num_rows(string result);

msql_num_rows() returns the number of rows in a result set.

See also: msql(), msql_query(), and msql_fetch_row().

msql_numfields

msql_numfields -- result field  Ѵ.

Description

int msql_numfields(void);

Identical to msql_num_fields().

msql_numrows

msql_numrows -- result row  Ѵ.

Description

int msql_numrows(void);

Identical to msql_num_rows().

msql_pconnect

msql_pconnect --  mSQL  .

Description

int msql_pconnect(string hostname);

Returns a positive mSQL persistent link identifier on success, or false on
error.

msql_pconnect() acts very much like msql_connect() with two major
differences.

First, when connecting, the function would first try to find a (persistent)
link that's already open with the same host. If one is found, an identifier
for it will be returned instead of opening a new connection.

Second, the connection to the SQL server will not be closed when the
execution of the script ends. Instead, the link will remain open for future
use (msql_close() will not close links established by msql_pconnect()).

This type of links is therefore called 'persistent'.

msql_query

msql_query -- mSQL Ǹ Ѵ.

Description

int msql_query(string query, int link_identifier);

msql_query() sends a query to the currently active database on the server
that's associated with the specified link identifier. If the link
identifier isn't specified, the last opened link is assumed. If no link is
open, the function tries to establish a link as if msql_connect() was
called, and use it.

Returns a positive mSQL result identifier on success, or false on error.

See also: msql(), msql_select_db(), and msql_connect().

msql_regcase

msql_regcase --  ǥ(regular expression) ,ҹڸ  ʵ
Ѵ.

Description

See sql_regcase().

msql_result

msql_result -- result data Ѵ.

Description

int msql_result(int result, int i, mixed field);

Returns the contents of the cell at the row and offset in the specified
mSQL result set.

msql_result() returns the contents of one cell from a mSQL result set. The
field argument can be the field's offset, or the field's name, or the
field's table dot field's name (fieldname.tablename). If the column name
has been aliased ('select foo as bar from...'), use the alias instead of
the column name.

When working on large result sets, you should consider using one of the
functions that fetch an entire row (specified below). As these functions
return the contents of multiple cells in one function call, they're MUCH
quicker than msql_result(). Also, note that specifying a numeric offset for
the field argument is much quicker than specifying a fieldname or
tablename.fieldname argument.

Recommended high-performance alternatives: msql_fetch_row(),
msql_fetch_array(), and msql_fetch_object().

msql_select_db

msql_select_db -- mSQL database Ѵ.

Description

int msql_select_db(string database_name, int link_identifier);

Returns true on success, false on error.

msql_select_db() sets the current active database on the server that's
associated with the specified link identifier. If no link identifier is
specified, the last opened link is assumed. If no link is open, the
function will try to establish a link as if msql_connect() was called, and
use it.

Every subsequent call to msql_query() will be made on the active database.

See also: msql_connect(), msql_pconnect(), and msql_query().

msql_selectdb

msql_selectdb -- mSQL database Ѵ.

Description

See msql_select_db().

msql_tablename

msql_tablename -- ش ʵ带   Table ̸ Ѵ.

Description

string msql_tablename(int result, int field);

msql_tablename() takes a result pointer returned by the msql_list_tables()
function as well as an integer index and returns the name of a table. The
msql_numrows() function may be used to determine the number of tables in
the result pointer.
Example 1. msql_tablename() example

<?php
msql_connect ("localhost");
$result = msql_list_tables("wisconsin");
$i = 0;
while ($i < msql_numrows($result)) {
    $tb_names[$i] = msql_tablename($result, $i);
    echo $tb_names[$i] . "<BR>";
    $i++;
}
?>

  ------------------------------------------------------------------------

MySQL Functions

(  : Solaris MySQL with pthreads note:
  MySQL threaded client library( default ƴϴ )
ϰ, PHP MySQL Ѵٸ Ƹ    
 ȴ....

Undefined first referenced
symbol in file
pthread_attr_setschedparam
/opt/GNUmysql/lib/mysql/libmysqlclient.a(my_pthread.o)
pthread_setschedparam
/opt/GNUmysql/lib/mysql/libmysqlclient.a(my_pthread.o)

̶ Makefile  ־ Ѵ. "LIBS" ۵Ǵ  ã
"-lpthreads"   Ѵ. Ŀ "make"ϸ  ̴. )

mysql_affected_rows

mysql_affected_rows -- ֱ ǿ  ޴ row  Ѵ.

Description

int mysql_affected_rows(int link_identifier );

Returns: The number of affected rows by the last query.

mysql_affected_rows() returns the number of rows affected by the last
insert, update or delete query on the server associated with the specified
link identifier. If the link identifier isn't specified, the last opened
link is assumed.

mysql_close

mysql_close -- MySQL connection ݴ´.

Description

int mysql_close(int link_identifier );

Returns: true on success, false on error

mysql_close() closes the link to a MySQL database that's associated with
the specified link identifier. If the link identifier isn't specified, the
last opened link is assumed.

Note that this isn't usually necessary, as non-persistent open links are
automatically closed at the end of the script's execution.

mysql_close() will not close persistent links generated by
mysql_pconnect().

See also: mysql_connect(), and mysql_pconnect().

mysql_connect

mysql_connect -- MySQL server connection .

Description

int mysql_connect(string hostname , string username , string password );

Returns: A positive MySQL link identifier on success, or false on error.

mysql_connect() establishes a connection to a MySQL server. All of the
arguments are optional, and if they're missing, defaults are assumed
('localhost', user name of the user that owns the server process, empty
password).

In case a second call is made to mysql_connect() with the same arguments,
no new link will be established, but instead, the link identifier of the
already opened link will be returned.

The link to the server will be closed as soon as the execution of the
script ends, unless it's closed earlier by explicitly calling
mysql_close().

See also mysql_pconnect(), and mysql_close().

mysql_create_db

mysql_create_db -- MySQL database .

Description

int mysql_create_db(string database name, int link_identifier );

mysql_create_db() attempts to create a new database on the server
associated with the specified link identifier.

See also: mysql_drop_db(). For downwards compatibility mysql_createdb() can
also be used.

mysql_data_seek

mysql_data_seek -- internal row pointer ű.

Description

int mysql_data_seek(int result_identifier, int row_number);

Returns: true on success, false on failure

mysql_data_seek() moves the internal row pointer of the MySQL result
associated with the specified result identifier to pointer to the specifyed
row number. The next call to mysql_fetch_row() would return that row.

See also: mysql_data_seek().

mysql_dbname

mysql_dbname --  MySQL database ̸ Ѵ.

Description

string mysql_dbname(string result, int i);

mysql_dbname() returns the database name stored in position i of the result
pointer returned from the mysql_list_dbs() function. The mysql_num_rows()
function can be used to determine how many database names are available.

mysql_db_query

mysql_db_query -- MySQL Ǹ Ѵ.

Description

int mysql_db_query(string database, string query, int link_identifier);

Returns: A positive MySQL result identifier to the query result, or false
on error.

mysql_db_query() selects a database and executes a query on it. If the
optional link identifier isn't specified, the function will try to find an
open link to the MySQL server and if no such link is found it'll try to
create one as if mysql_connect() was called with no arguments

See also mysql_connect(). For downwards compatibility mysql() can also be
used.

mysql_drop_db

mysql_drop_db -- MySQL database .(drop = delete)

Description

int mysql_drop_db(string database_name, int link_identifier );

Returns: true on success, false on failure.

mysql_drop_db() attempts to drop (remove) an entire database from the
server associated with the specified link identifier.

See also: mysql_create_db(). For downward compatibility mysql_dropdb() can
also be used.

mysql_errno

mysql_errno --  MySQL ȣ  ȣ ȯѴ.

Description

int mysql_errno();

Errors coming back from the mySQL database backend no longer issue
warnings. Instead, use these functions to retrieve the error number.

<?php
mysql_connect("marliesle");
echo mysql_errno().": ".mysql_error()."<BR>";
mysql_select_db("nonexistentdb");
echo mysql_errno().": ".mysql_error()."<BR>";
$conn = mysql_query("SELECT * FROM nonexistenttable");
echo mysql_errno().": ".mysql_error()."<BR>";
?>

See also: mysql_error()

mysql_error

mysql_error --  MySQL ȣ  ޼ ȯѴ.

Description

string mysql_error();

Errors coming back from the mySQL database backend no longer issue
warnings. Instead, use these functions to retrieve the error string.

<?php
mysql_connect("marliesle");
echo mysql_errno().": ".mysql_error()."<BR>";
mysql_select_db("nonexistentdb");
echo mysql_errno().": ".mysql_error()."<BR>";
$conn = mysql_query("SELECT * FROM nonexistenttable");
echo mysql_errno().": ".mysql_error()."<BR>";
?>

See also: mysql_errno()

mysql_fetch_array

mysql_fetch_array -- row 迭 ´.

Description

int mysql_fetch_array(int result);

Returns: An array that corresponds to the fetched row, or false if there
are no more rows.

mysql_fetch_array() is an extended version of mysql_fetch_row(). In
addition to storing the data in the numeric indices of the result array, it
also stores the data in associative indices, using the field names as keys.

An important thing to note is that using mysql_fetch_array() is NOT
significantly slower than using mysql_fetch_row(), while it provides a
significant added value.

For further details, also see mysql_fetch_row()

mysql_fetch_field

mysql_fetch_field -- ʵ  Ѵ.

Description

object mysql_fetch_field(int result, int field_offset );

Returns an object containing field information.

mysql_fetch_field() can be used in order to obtain information about fields
in a certain query result. If the field offset isn't specified, the next
field that wasn't yet retreived by mysql_fetch_field() is retreived.

The properties of the object are:

     name - column name
     table - name of the table the column belongs to
     max_length - maximum length of the column
     not_null - 1 if the column cannot be null
     primary_key - 1 if the column is a primary key
     unique_key - 1 if the column is a unique key
     multiple_key - 1 if the column is a non-unique key
     numeric - 1 if the column is numeric
     blob - 1 it the column is a BLOB
     type - the type of the column
     unsigned - 1 if the column is unsigned
     zerofill - 1 if the column is zero-filled

See also mysql_field_seek()

mysql_fetch_lengths

mysql_fetch_lengths -- output column ִ data ̸ Ѵ.

Description

int mysql_fetch_lengths(int result);

Returns: An array that corresponds to the lengths of each field in the last
row fetched by mysql_fetch_row(), or false on error.

mysql_fetch_lengths() stores the lengths of each result column in the last
row returned by mysql_fetch_row() in an array, starting at offset 0.

See also: mysql_fetch_row().

mysql_fetch_object

mysql_fetch_object -- row ü(Object) ´.

Description

int mysql_fetch_object(int result);

Returns: An object with properties that correspond to the fetched row, or
false if there are no more rows.

mysql_fetch_object() is similar to mysql_fetch_array(), with one difference
- an object is returned, instead of an array. Indirectly, that means that
you can only access the data by the field names, and not by their offsets
(numbers are illegal property names).

Speed-wise, the function is identical to mysql_fetch_array(), and almost as
quick as mysql_fetch_row() (the difference is insignificant).

See also: mysql_fetch_array() and mysql_fetch_row().

mysql_fetch_row

mysql_fetch_row -- row 迭(enumerated array) ´.

Description

array mysql_fetch_row(int result);

Returns: An array that corresponds to the fetched row, or false if there
are no more rows.

mysql_fetch_row() fetches one row of data from the result associated with
the specified result identifier. The row is returned as an array. Each
result column is stored in an array offset, starting at offset 0.

Subsequent call to mysql_fetch_row() would return the next row in the
result set, or false if there are no more rows.

See also: mysql_fetch_array(), mysql_fetch_object(), mysql_data_seek(),
mysql_fetch_lengths(), and mysql_result().

mysql_field_name

mysql_field_name -- ʵ ̸ Ѵ.

Description

string mysql_field_name(string result, int i);

mysql_field_name() returns the name of the specified field. Arguments to
the function is the result identifier and the field index, ie.
mysql_field_name($result,2);

Will return the name of the second field in the result associated with the
result identifier.

For downwards compatibility mysql_fieldname() can also be used.

mysql_field_seek

mysql_field_seek -- ʵ offset Ѵ.

Description

int mysql_field_seek(int result, int field_offset);

Seeks to the specified field offset. If the next call to
mysql_fetch_field() won't include a field offset, this field would be
returned.

See also: mysql_fetch_field().

mysql_field_table

mysql_field_table -- ش ʵ带   Table ̸ Ѵ.

Description

string mysql_field_table(int result, int field_offset);

Get the table name for field. For downward compatibility mysql_fieldtable()
can also be used.

mysql_field_type

mysql_field_type -- ʵ type Ѵ.

Description

string mysql_field_type(string result, int field_offset);

mysql_field_type() is similar to the mysql_field_name() function. The
arguments are identical, but the field type is returned. This will be one
of "int", "real", "string", or "blob".
Example 1. mysql field types

<?php
mysql_connect("localhost:3306");
mysql_select_db("wisconsin");
$result = mysql_query("SELECT * FROM onek");
$fields = mysql_num_fields($result);
$rows   = mysql_num_rows($result);
$i = 0;
$table = mysql_field_table($result, $i);
echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>";
echo "The table has the following fields <BR>";
while ($i < $fields) {
    $type  = mysql_field_type  ($result, $i);
    $name  = mysql_field_name  ($result, $i);
    $len   = mysql_field_len   ($result, $i);
    $flags = mysql_field_flags ($result, $i);
    echo $type." ".$name." ".$len." ".$flags."<BR>";
    $i++;
}
mysql_close();
?>

For downward compatibility mysql_fieldtype() can also be used.

mysql_field_flags

mysql_field_flags -- ʵ flag Ѵ.

Description

string mysql_field_flags(string result, int field_offset);

mysql_field_flags() returns the field flags of the specified field.
Currently this is either, "not null", "primary key", a combination of the
two or "" (an empty string).

For downward compatibility mysql_fieldflags() can also be used.

mysql_field_len

mysql_field_len -- ʵ ̸ Ѵ.

Description

int mysql_field_len(string result, int field_offset);

mysql_field_len() returns the length of the specified field. For downward
compatibility mysql_fieldlen() can also be used.

mysql_free_result

mysql_free_result -- result memory Ǯش.

Description

int mysql_free_result(int result);

mysql_free_result() only needs to be called if you are worried about using
too much memory while your script is running. All associated result memory
for the specified result identifier will automatically be freed.

For downward compatibility mysql_freeresult() can also be used.

mysql_insert_id

mysql_insert_id -- ֱ INSERT  id (generated id) Ѵ.

Description

int mysql_insert_id(void);

mysql_insert_id() returns the ID generated for an AUTO_INCREMENTED field.
This function takes no arguments. It will return the auto-generated ID
returned by the last INSERT query performed.

mysql_list_fields

mysql_list_fields -- result field Ѵ.

Description

int mysql_list_fields(string database, string tablename);

mysql_list_fields() retrieves information about the given tablename.
Arguments are the database name and the table name. A result pointer is
returned which can be used with mysql_field_flags(), mysql_field_len(),
mysql_field_name(), and mysql_field_type().

A result identifier is a positive integer. The function returns -1 if a
error occurs. A string describing the error will be placed in $phperrmsg,
and unless the function was called as @mysql() then this error string will
also be printed out.

For downward compatibility mysql_listfields() can also be used.

mysql_list_dbs

mysql_list_dbs -- server MySQL database Ѵ.

Description

int mysql_listdbs(void);

mysql_listdbs() will return a result pointer containing the databases
available from the current mysql daemon. Use the mysql_dbname() function to
traverse this result pointer.

For downward compatibility mysql_listdbs() can also be used.

mysql_list_tables

mysql_list_tables -- MySQL database table Ѵ.

Description

int mysql_list_tables(string database);

mysql_list_tables() takes a database name and result pointer much like the
mysql_db_query() function. The mysql_tablename() function should be used to
extract the actual table names from the result pointer.

For downward compatibility mysql_listtables() can also be used.

mysql_num_fields

mysql_num_fields -- result field  Ѵ.

Description

int mysql_num_fields(int result);

mysql_num_fields() returns the number of fields in a result set.

See also: mysql_db_query(), mysql_query(), mysql_fetch_field(),
mysql_num_rows().

For downward compatibility mysql_numfields() can also be used.

mysql_num_rows

mysql_num_rows -- result row  Ѵ.

Description

int mysql_num_rows(string result);

mysql_num_rows() returns the number of rows in a result set.

See also: mysql_db_query(), mysql_query() and, mysql_fetch_row().

For downward compatibility mysql_numrows() can also be used.

mysql_pconnect

mysql_pconnect --  MySQL  .

Description

int mysql_pconnect(string hostname , string username , string password);

Returns: A positive MySQL persistent link identifier on success, or false
on error

mysql_pconnect() acts very much like mysql_connect() with two major
differences.

First, when connecting, the function would first try to find a (persistent)
link that's already open with the same host, username and password. If one
is found, an identifier for it will be returned instead of opening a new
connection.

Second, the connection to the SQL server will not be closed when the
execution of the script ends. Instead, the link will remain open for future
use (mysql_close() will not close links established by mysql_pconnect()).

This type of links is therefore called 'persistent'.

mysql_query

mysql_query -- MySQL Ǹ Ѵ.

Description

int mysql_query(string query, int link_identifier );

Returns: A positive MySQL result identifier on success, or false on error.

mysql_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 mysql_connect() was
called, and use it.

(  : update, insert, delete    TRUE/FALSE
ȯϰ Ѵ. ׷, select  ϸ  result
identifier ȯϱ  ߿  free_result() Ͽ ϴ
  . )

See also: mysql_db_query(), mysql_select_db(), and mysql_connect().

mysql_result

mysql_result -- result data Ѵ.

Description

int mysql_result(int result, int row, mixed field);

Returns: The contents of the cell at the row and offset in the specified
MySQL result set.

mysql_result() returns the contents of one cell from a MySQL result set.
The field argument can be the field's offset, or the field's name, or the
field's table dot field's name (fieldname.tablename). If the column name
has been aliased ('select foo as bar from...'), use the alias instead of
the column name.

When working on large result sets, you should consider using one of the
functions that fetch an entire row (specified below). As these functions
return the contents of multiple cells in one function call, they're MUCH
quicker than mysql_result(). Also, note that specifying a numeric offset
for the field argument is much quicker than specifying a fieldname or
tablename.fieldname argument.

Recommended high-performance alternatives: mysql_fetch_row(),
mysql_fetch_array(), and mysql_fetch_object().

mysql_select_db

mysql_select_db -- MySQL database Ѵ.

Description

int mysql_select_db(string database_name, int link_identifier );

Returns: true on success, false on error

mysql_select_db() sets the current active database on the server that's
associated with the specified link identifier. If no link identifier is
specified, the last opened link is assumed. If no link is open, the
function will try to establish a link as if mysql_connect() was called, and
use it.

Every subsequent call to mysql_query() will be made on the active database.

See also: mysql_connect(), mysql_pconnect(), and mysql_query()

For downward compatibility mysql_selectdb() can also be used.

mysql_tablename

mysql_tablename -- ش ʵ带   Table ̸ Ѵ.

Description

string mysql_tablename(int result, int i);

mysql_tablename() takes a result pointer returned by the
mysql_list_tables() function as well as an integer index and returns the
name of a table. The mysql_num_rows() function may be used to determine the
number of tables in the result pointer.
Example 1. mysql_tablename() example

<?php
mysql_connect ("localhost:3306");
$result = mysql_listtables ("wisconsin");
$i = 0;
while ($i < mysql_num_rows ($result)) {
    $tb_names[$i] = mysql_tablename ($result, $i);
    echo $tb_names[$i] . "<BR>";
    $i++;
}
?>

  ------------------------------------------------------------------------

Sybase Functions

sybase_close

sybase_close -- Sybase connection ݴ´.

Description

int sybase_close(int link_identifier);

Returns: true on success, false on error

sybase_close() closes the link to a Sybase database that's associated with
the specified link identifier. If the link identifier isn't specified, the
last opened link is assumed.

Note that this isn't usually necessary, as non-persistent open links are
automatically closed at the end of the script's execution.

sybase_close() will not close persistent links generated by
sybase_pconnect().

See also: sybase_connect(), sybase_pconnect().

sybase_connect

sybase_connect -- Sybase server connection .

Description

int sybase_connect(string servername, string username, string password);

Returns: A positive Sybase link identifier on success, or false on error.

sybase_connect() establishes a connection to a Sybase server. The
servername argument has to be a valid servername that is defined in the
'interfaces' file.

In case a second call is made to sybase_connect() with the same arguments,
no new link will be established, but instead, the link identifier of the
already opened link will be returned.

The link to the server will be closed as soon as the execution of the
script ends, unless it's closed earlier by explicitly calling
sybase_close().

See also sybase_pconnect(), sybase_close().

sybase_data_seek

sybase_data_seek -- internal row pointer ű.

Description

int sybase_data_seek(int result_identifier, int row_number);

Returns: true on success, false on failure

sybase_data_seek() moves the internal row pointer of the Sybase result
associated with the specified result identifier to pointer to the specifyed
row number. The next call to sybase_fetch_row() would return that row.

See also: sybase_data_seek().

sybase_fetch_array

sybase_fetch_array -- row 迭 ´.

Description

int sybase_fetch_array(int result);

Returns: An array that corresponds to the fetched row, or false if there
are no more rows.

sybase_fetch_array() is an extended version of sybase_fetch_row(). In
addition to storing the data in the numeric indices of the result array, it
also stores the data in associative indices, using the field names as keys.

An important thing to note is that using sybase_fetch_array() is NOT
significantly slower than using sybase_fetch_row(), while it provides a
significant added value.

For further details, also see sybase_fetch_row()

sybase_fetch_field

sybase_fetch_field -- ʵ  Ѵ.

Description

object sybase_fetch_field(int result, int field_offset);

Returns an object containing field information.

sybase_fetch_field() can be used in order to obtain information about
fields in a certain query result. If the field offset isn't specified, the
next field that wasn't yet retreived by sybase_fetch_field() is retreived.

The properties of the object are:

     name - column name. if the column is a result of a function, this
     property is set to computed#N, where #N is a serial number.

     column_source - the table from which the column was taken

     max_length - maximum length of the column

     numeric - 1 if the column is numeric

See also sybase_field_seek()

sybase_fetch_object

sybase_fetch_object -- row ü(Object) ´.

Description

int sybase_fetch_object(int result);

Returns: An object with properties that correspond to the fetched row, or
false if there are no more rows.

sybase_fetch_object() is similar to sybase_fetch_array(), with one
difference - an object is returned, instead of an array. Indirectly, that
means that you can only access the data by the field names, and not by
their offsets (numbers are illegal property names).

Speed-wise, the function is identical to sybase_fetch_array(), and almost
as quick as sybase_fetch_row() (the difference is insignificant).

See also: sybase_fetch-array() and sybase_fetch-row().

sybase_fetch_row

sybase_fetch_row -- row 迭(enumerated array) ´.

Description

array sybase_fetch_row(int result);

Returns: An array that corresponds to the fetched row, or false if there
are no more rows.

sybase_fetch_row() fetches one row of data from the result associated with
the specified result identifier. The row is returned as an array. Each
result column is stored in an array offset, starting at offset 0.

Subsequent call to sybase_fetch_rows() would return the next row in the
result set, or false if there are no more rows.

See also: sybase_fetch_array(), sybase_fetch_object(), sybase_data_seek(),
sybase_fetch_lengths(), and sybase_result().

sybase_field_seek

sybase_field_seek -- ʵ offset Ѵ.

Description

int sybase_field_seek(int result, int field_offset);

Seeks to the specified field offset. If the next call to
sybase_fetch_field() won't include a field offset, this field would be
returned.

See also: sybase_fetch_field().

sybase_freeresult

sybase_freeresult -- result memory Ǯش.

Description

int sybase_freeresult(int result);

sybase_freeresult() only needs to be called if you are worried about using
too much memory while your script is running. All result memory will
automatically be freed when the script, you may call sybase_freeresult()
with the result identifier as an argument and the associated result memory
will be freed.

sybase_num_fields

sybase_num_fields -- result field  Ѵ.

Description

int sybase_num_fields(int result);

sybase_num_fields() returns the number of fields in a result set.

See also: sybase_db_query(), sybase_query(), sybase_fetch_field(),
sybase_num_rows().

sybase_num_rows

sybase_num_rows -- result row  Ѵ.

Description

int sybase_num_rows(string result);

sybase_num_rows() returns the number of rows in a result set.

See also: sybase_db_query(), sybase_query() and, sybase_fetch_row().

sybase_pconnect

sybase_pconnect --  Sybase  .

Description

int sybase_pconnect(string servername, string username, string password);

Returns: A positive Sybase persistent link identifier on success, or false
on error

sybase_pconnect() acts very much like sybase_connect() with two major
differences.

First, when connecting, the function would first try to find a (persistent)
link that's already open with the same host, username and password. If one
is found, an identifier for it will be returned instead of opening a new
connection.

Second, the connection to the SQL server will not be closed when the
execution of the script ends. Instead, the link will remain open for future
use (sybase_close() will not close links established by sybase_pconnect()).

This type of links is therefore called 'persistent'.

sybase_query

sybase_query -- Sybase Ǹ Ѵ.

Description

int sybase_query(string query, int link_identifier);

Returns: A positive Sybase result identifier on success, or false on error.

sybase_query() sends a query to the currently active database on the server
that's associated with the specified link identifier. If the link
identifier isn't specified, the last opened link is assumed. If no link is
open, the function tries to establish a link as if sybase_connect() was
called, and use it.

See also: sybase_db_query(), sybase_select_db(), and sybase_connect().

sybase_result

sybase_result -- result data Ѵ.

Description

int sybase_result(int result, int i, mixed field);

Returns: The contents of the cell at the row and offset in the specified
Sybase result set.

sybase_result() returns the contents of one cell from a Sybase result set.
The field argument can be the field's offset, or the field's name, or the
field's table dot field's name (fieldname.tablename). If the column name
has been aliased ('select foo as bar from...'), use the alias instead of
the column name.

When working on large result sets, you should consider using one of the
functions that fetch an entire row (specified below). As these functions
return the contents of multiple cells in one function call, they're MUCH
quicker than sybase_result(). Also, note that specifying a numeric offset
for the field argument is much quicker than specifying a fieldname or
tablename.fieldname argument.

Recommended high-performance alternatives: sybase_fetch_row(),
sybase_fetch_array(), and sybase_fetch_object().

sybase_select_db

sybase_select_db -- Sybase database Ѵ.

Description

int sybase_select_db(string database_name, int link_identifier);

Returns: true on success, false on error

sybase_select_db() sets the current active database on the server that's
associated with the specified link identifier. If no link identifier is
specified, the last opened link is assumed. If no link is open, the
function will try to establish a link as if sybase_connect() was called,
and use it.

Every subsequent call to sybase_query() will be made on the active
database.

See also: sybase_connect(), sybase_pconnect(), and sybase_query()

  ------------------------------------------------------------------------

Network Functions

fsockopen

fsockopen -- Internet̳ Unix domain socket connection .

Description

int fsockopen(string hostname, int port, int errno, string errstr);

Opens an Internet domain socket connection to hostname on port port and
returns a file pointer, which may be used by fgets(), fgetss(), fputs(),
and fclose(). If the call fails, it will return FALSE and if the optional
errno and errstr arguments are present they will be set to indicate the
actual system level error that ocurred on the system-level connect() call.
If the returned errno is 0, but the function returned FALSE, it is an
indication that the error occurred before the connect() call. This is most
likely due to a problem initializing the socket. Note that the errno and
errstr arguments should be passed by reference.

If port is 0 and the operating system supports Unix domain sockets,
hostname will be used as the filename of a Unix domain socket to connect
to.

The socket will by default be opened in blocking mode. You can switch it to
non-blocking mode by using the set_socket_blocking().
Example 1. fsockopen example

$fp = fsockopen("www.php.net", 80, &$errno, &$errstr);
if(!$fp) {
        echo "$errstr ($errno)<br>\n";
} else {
        while(!feof($fp)) {
                echo fgets($fp,128);
        }
        fclose($fp);
}


set_socket_blocking

set_socket_blocking --  blocking/non-blocking 带 Ѵ.

Description

int set_socket_blocking(int socket descriptor, int mode);

If mode is false, the given socket descriptor will be switched to
non-blocking mode, and if true, it will be switched to blocking mode. This
affects calls like fgets() that read from the socket. In non-blocking mode
an fgets() call will always return right away while in blocking mode it
will wait for data to become available on the socket.

gethostbyaddr

gethostbyaddr -- ־ IP address شϴ Internet host name Ѵ.

Description

string gethostbyaddr(string ip_address);

Returns the host name of the Internet host specified by ip_address. If an
error occurs, returns ip_address.

See also gethostbyname().

gethostbyname

gethostbyname -- ־ Internet host name شϴ IP address Ѵ.

Description

string gethostbyname(string hostname);

Returns the IP address of the Internet host specified by hostname.

See also gethostbyaddr().

gethostbynamel

gethostbynamel -- ־ Internet host name شϴ IP addresse
list Ѵ.

Description

array gethostbynamel(string hostname);

Returns a list of IP addresses to which the Internet host specified by
hostname resolves.

See also gethostbyname(), gethostbyaddr(), checkdnsrr(), getmxrr(), and the
named(8) manual page.

checkdnsrr

checkdnsrr -- ־ Internet host name or IP address شϴ DNS
record ˻Ѵ .

Description

int checkdnsrr(string host, string type);

Searches DNS for records of type type corresponding to host. Returns true
if any records are found; returns false if no records were found or if an
error occurred.

type may be any one of: A, MX, NS, SOA, PTR, CNAME, or ANY. The default is
MX.

host may either be the IP address in dotted-quad notation or the host name.

See also getmxrr(), gethostbyaddr(), gethostbyname(), gethostbynamel(), and
the named(8) manual page.

getmxrr

getmxrr -- ־ Internet host name شϴ MX record Ѵ.

Description

int getmxrr(string hostname, array mxhosts, array weight);

Searches DNS for MX records corresponding to hostname. Returns true if any
records are found; returns false if no records were found or if an error
occurred.

A list of the MX records found is placed into the array mxhosts. If the
weight array is given, it will be filled with the weight information
gathered.

See also checkdnsrr(), gethostbyname(), gethostbynamel(), gethostbyaddr(),
and the named(8) manual page.

openlog

openlog -- system logger connection .

Description

void openlog(string ident, int option, int facility);

openlog() opens a connection to the system logger for a program. The string
ident is added to each message. Values for option and facility are given in
the next section. The use of openlog() is optional; It will automatically
be called by syslog() if necessary, in which case ident will default to
false. See also syslog() and closelog().

syslog

syslog -- system log message .

Description

void syslog(int priority, string message);

syslog() generates a log message that will be distributed by the system
logger. priority is a combination of the facility and the level, values for
which are given in the next section. The remaining argument is the message
to send, except that the two characters %m will be replaced by the error
message string (strerror) corresponding to the present value of errno.

(  : UNIX  Լ C syslogԼ Ѵ.  ڼ
 man page ϶. )

closelog

closelog -- system logger connection ݴ´.

Description

string passthru(void);

closelog() closes the descriptor being used to write to the system logger.
The use of closelog() is optional.

debugger_on

debugger_on --  PHP debugger enable Ѵ.

Description

void debugger_on(string address);

Enables the internal PHP debugger, connecting it to address. The debugger
is still under development.

debugger_off

debugger_off --  PHP debugger disable Ѵ.

Description

void debugger_off(void);

Disables the internal PHP debugger. The debugger is still under
development.

  ------------------------------------------------------------------------

ODBC Functions

odbc_autocommit

odbc_autocommit -- autocommit  Ѱ, .

Description

int odbc_autocommit(int connection_id, int OnOff);

Returns true on success, false on failure.

By default, autocommit is on for a connection.

See also odbc_commit() and odbc_rollback().

odbc_binmode

odbc_binmode -- binary column data ٷ.

Description

int odbc_binmode(int result_id, int mode);

(ODBC SQL types affected: BINARY, VARBINARY, LONGVARBINARY)

     0: Passthru BINARY data
     1: Return as is
     2: Return and convert to char

When binary SQL data is converted to character C data, each byte (8 bits)
of source data is represented as two ASCII characters. These characters are
the ASCII character representation of the number in its hexadecimal form.
For example, a binary 00000001 is converted to "01" and a binary 11111111
is converted to "FF".

Table 1. LONGVARBINARY handling
 binmodelongreadlen result
 0      0           passthru
 1      0           passthru
 2      0           passthru
 0      0           passthru
 0      >0          passthru
 1      >0          return as is
 2      >0          return as char

* if odbc_fetch_into is used, passthru means that an empty string * is
returned for these columns.

If result_id is 0, the settings apply as default for new results.

     NOTE: Default for both longreadlen and binmode is 0. This means
     that columns of type binary and/or LONG get passedthru. Handling
     of binary Long columns is also affected by odbc_longreadlen()

odbc_close

odbc_close -- ODBC connection ݴ´.

Description

void odbc_close(int connection_id);

odbc_close() will close down the connection to the database server
associated with the given connection identifier.

     NOTE: This function will fail if there are open transactions on
     this connection. The connection will remain open in this case.

odbc_close_all

odbc_close_all --  ODBC connection ݴ´.

Description

void odbc_close_all(void);

odbc_close_all() will close down all connections to database server(s).

     NOTE: This function will fail if there are open transactions on a
     connection. This connection will remain open in this case.

odbc_commit

odbc_commit -- ODBC transaction commitѴ.

Description

int odbc_commit(int connection_id);

Returns: true on success, false on failure. All pending transactions on
connection_id are committed.

odbc_connect

odbc_connect -- datasource Ѵ.

Description

int odbc_connect(string dsn, string user, string password);

Returns an ODBC connection id or 0 (false) on error.

The connection id returned by this functions is needed by other ODBC
functions. You can have multiple connections open at once. For persistent
connections see odbc_pconnect().

odbc_cursor

odbc_cursor -- cursorname Ѵ.

Description

string odbc_cursor(int result_id);

odbc_cursor will return a cursorname for the given result_id.

odbc_do

odbc_do -- odbc_exec()

 .

Description

string odbc_do(int conn_id, string query);

odbc_do will execute a query on the given connection

odbc_exec

odbc_exec -- SQL  غϰ Ѵ.

Description

int odbc_exec(int connection_id, string query_string);

Returns false on error. Returns an ODBC result identifier if the SQL
command was executed successfully.

odbc_exec() will send an SQL statement to the database server specified by
connection_id. This parameter must be a valid identifier returned by
odbc_connect() or odbc_pconnect().

See also: odbc_prepare() and odbc_execute() for multiple execution of SQL
statements.

odbc_execute

odbc_execute --  غ   Ѵ.

Description

int odbc_execute(int result_id, array parameters_array);

Executes a statement prepared with odbc_prepare(). Returns true on
successful execution, false otherwise. The array arameters_array only needs
to be given if you really have parameters in your statement.

odbc_fetch_into

odbc_fetch_into -- Ѱ result row 迭 ´.

Description

int odbc_fetch_into(int result_id, int rownumber, array result_array);

Returns the number of columns in the result; false on error. result_array
must be passed by reference, but it can be of any type since it will be
converted to type array. The array will contain the column values starting
at array index 0.

odbc_fetch_row

odbc_fetch_row -- row ´.

Description

int odbc_fetch_row(int result_id, int row_number);

If odbc_fetch_row() was succesful (there was a row), true is returned. If
there are no more rows, false is returned.

odbc_fetch_row() fetches a row of the data that was returned by odbc_do() /
odbc_exec(). After odbc_fetch_row() is called, the fields of that row can
be accessed with odbc_result().

If row_number is not specified, odbc_fetch_row() will try to fetch the next
row in the result set. Calls to odbc_fetch_row() with and without
row_number can be mixed.

To step through the result more than once, you can call odbc_fetch_row()
with row_number 1, and then continue doing odbc_fetch_row() without
row_number to review the result. If a driver doesn't support fetching rows
by number, the row_number parameter is ignored.

odbc_field_name

odbc_field_name -- columnname Ѵ.

Description

string odbc_fieldname(int result_id, int field_number);

odbc_field_name() will return the name of the field occupying the given
column number in the given ODBC result identifier. Field numbering starts
at 1. false is returned on error.

odbc_field_num

odbc_field_num -- column number ȯѴ.

Description

int odbc_fieldnum(int result_id, string field_name);

odbc_field_num() will return the number of the column slot that corresponds
to the named field in the given ODBC result identifier. Field numbering
starts at 1. false is returned on error.

odbc_field_type

odbc_field_type -- field datatype Ѵ.

Description

string odbc_field_type(int result_id, mixed field);

odbc_field_type() will return the SQL type of the field referecend by name
or number in the given ODBC result identifier. Field numbering runs from 1.

odbc_free_result

odbc_free_result --  result õ resource Ѵ.

Description

int odbc_free_result(int result_id);

Always returns true.

odbc_free_result() only needs to be called if you are worried about using
too much memory while your script is running. All result memory will
automatically be freed when the script is finished. But, if you are sure
you are not going to need the result data anymore in a script, you may call
odbc_free_result(), and the memory associated with result_id will be freed.

     NOTE: If auto-commit is disabled (see odbc_autocommit()) and you
     call odbc_free_result() before commiting, all pending
     transactions are rolled back.

odbc_longreadlen

odbc_longreadlen -- LONG column ٷ.

Description

int odbc_longreadlen(int result_id, int length);

(ODBC SQL types affected: LONG, LONGVARBINARY) The number of bytes returned
to PHP is controled by the parameter length. If it is set to 0, Long column
data is passed thru to the client.

     NOTE: Handling of LONGVARBINARY columns is also affected by
     odbc_binmode()

odbc_num_fields

odbc_num_fields -- result column 

Description

int odbc_num_fields(int result_id);

odbc_num_fields() will return the number of fields (columns) in an ODBC
result. This function will return -1 on error. The argument is a valid
result identifier returned by odbc_exec().

odbc_pconnect

odbc_pconnect --  database connection .

Description

int odbc_pconnect(string dsn, string user, string password);

Returns an ODBC connection id or 0 (false) on error. This function is much
like odbc_connect(), except that the connection is not really closed when
the script has finished. Future requests for a connection with the same
dsn, user, password combination (via odbc_connect() and odbc_pconnect())
can reuse the persistent connection.

     NOTE: Persistent connections have no effect if PHP is used as a
     CGI program.

For more information on persistent connections, refer to the PHP3 FAQ.

odbc_prepare

odbc_prepare --   غѴ.

Description

int odbc_prepare(int connection_id, string query_string);

Returns false on error.

Returns an ODBC result identifier if the SQL command was prepared
successfully. The result identifier can be used later to execute the
statement with odbc_execute().

odbc_num_rows

odbc_num_rows -- result row 

Description

int odbc_num_rows(int result_id);

odbc_num_rows() will return the number of rows in an ODBC result. This
function will return -1 on error. For INSERT, UPDATE and DELETE statements
odbc_num_rows() returns the number of rows affected. For a SELECT clause
this can be the number of rows available.

Note: Using odbc_num_rows() to determine the number of rows available after
a SELECT will return -1 with many drivers.

odbc_result

odbc_result -- result data Ѵ.

Description

string odbc_result(int result_id, mixed field);

Returns the contents of the field.

Field indices start from 1. Regarding the way binary or long column data is
returned refer to odbc_binmode () and odbc_longreadlen().

odbc_result_all

odbc_result_all -- result HTML table μѴ.

Description

int odbc_result_all(int result_id, string format);

Returns the number of rows in the result or false on error.

odbc_result_all() will print all rows from a result identifier produced by
odbc_exec(). The result is printed in HTML table format. With the optional
string argument format, additional overall table formatting can be done.

odbc_rollback

odbc_rollback -- transaction Rollback Ѵ.

Description

int odbc_rollback(int connection_id);

Rolls back all pending statements on connection_id. Returns true on
success, false on failure.

  ------------------------------------------------------------------------

Oracle functions

Ora_Close

Ora_Close -- Oracle cursor ݴ´.

Description

int ora_close(int cursor);

Returns true if the close succeeds, otherwise false. Details about the
error can be retrieved using the ora_error() and ora_errorcode() functions.

(  :  Լ  "wrong parameter count" ̳"true" ȯѴ.
׷ C-API "ora_del_cursor()"  ƹ͵ ȯ ʵϵǾ
Ƿ ϵ Ѵ. )

This function closes a data cursor opened with ora_open().

Ora_ColumnName

Ora_ColumnName -- Oracle result column ̸ Ѵ.

Description

string Ora_ColumnName(int cursor, int column);

Returns the name of the field/column column on the cursor cursor. The
returned name is in all uppercase letters.

Ora_ColumnType

Ora_ColumnType -- Oracle result column type Ѵ.

Description

string Ora_ColumnType(int cursor, int column);

Returns the Oracle data type name of the field/column column on the cursor
cursor. The returned type will be one of the following:
"VARCHAR2"
"VARCHAR"
"CHAR"
"NUMBER"
"LONG"
"LONG RAW"
"ROWID"
"DATE"
"CURSOR"

Ora_Commit

Ora_Commit -- Oracle transaction commit Ѵ.

Description

int ora_commit(int conn);

Returns true on success, false on error. Details about the error can be
retrieved using the ora_error() and ora_errorcode() functions. This
function commits an Oracle transaction. A transaction is defined as all the
changes on a given connection since the last commit/rollback, autocommit
was turned off or when the connection was established.

Ora_CommitOff

Ora_CommitOff -- automatic commit disable Ѵ.

Description

int ora_commitoff(int conn);

Returns true on success, false on error. Details about the error can be
retrieved using the ora_error() and ora_errorcode() functions.

This function turns off automatic commit after each ora_exec().

Ora_CommitOn

Ora_CommitOn -- automatic commit enable Ѵ.

Description

int ora_commiton(int conn);

This function turns on automatic commit after each ora_exec() on the given
connection.

Returns true on success, false on error. Details about the error can be
retrieved using the ora_error() and ora_errorcode() functions.

Ora_Error

Ora_Error -- Oracle error message Ѵ.

Description

string Ora_Error(int cursor);

Returns an error message of the form XXX-NNNNN where XXX is where the error
comes from and NNNNN identifies the error message.

On UNIX versions of Oracle, you can find details about an error message
like this: $ oerr ora 00001 00001, 00000, "unique constraint (%s.%s)
violated" // *Cause: An update or insert statement attempted to insert a
duplicate key // For Trusted ORACLE configured in DBMS MAC mode, you may
see // this message if a duplicate entry exists at a different level. //
*Action: Either remove the unique restriction or do not insert the key

Ora_ErrorCode

Ora_ErrorCode -- Oracle error code Ѵ.

Description

int Ora_ErrorCode(int cursor);

Returns the numeric error code of the last executed statement on the
specified cursor.

Ora_Exec

Ora_Exec -- Oracle cursor ִ parse  Ѵ.

Description

int ora_exec(int cursor);

Returns true on success, false on error. Details about the error can be
retrieved using the ora_error() and ora_errorcode() functions.

Ora_Fetch

Ora_Fetch -- cursor data row ´.

Description

int ora_fetch(int cursor);

Returns true (a row was fetched) or false (no more rows, or an error
occured). If an error occured, details can be retrieved using the
ora_error() and ora_errorcode() functions. If there was no error,
ora_errorcode() will return 0. Retrieves a row of data from the specified
cursor.

Ora_GetColumn

Ora_GetColumn --  row data Ѵ.

Description

mixed ora_getcolumn(int cursor, mixed column);

Returns the column data. If an error occurs, False is returned and
ora_errorcode() will return a non-zero value. Note, however, that a test
for False on the results from this function may be true in cases where
there is not error as well (NULL result, empty string, the number 0, the
string "0"). Fetches the data for a column or function result.

Ora_Logoff

Ora_Logoff -- Oracle connection ݴ´.

Description

int ora_logoff(int connection);

Returns true on success, False on error. Details about the error can be
retrieved using the ora_error() and ora_errorcode() functions. Logs out the
user and disconnects from the server.

Ora_Logon

Ora_Logon -- Oracle connection .

Description

int ora_logon(string user, string password);

Establishes a connection between PHP and an Oracle database with the given
username and password.

Returns a connection index on success, or False on failure. Details about
the error can be retrieved using the ora_error() and ora_errorcode()
functions.

Ora_Open

Ora_Open -- Oracle cursor .

Description

int ora_open(int connection);

Opens an Oracle cursor associated with connection.

Returns a cursor index or False on failure. Details about the error can be
retrieved using the ora_error() and ora_errorcode() functions.

Ora_Parse

Ora_Parse -- SQL  ؼ(parse)Ѵ.

Description

int ora_parse(int cursor_ind, string sql_statement, int defer);

This function parses an SQL statement or a PL/SQL block and associates it
with the given cursor. Returns 0 on success or -1 on error.

(  : δ ϸ TRUE(-1), ϸ FALSE(0) ȯѴ. )

Ora_Rollback

Ora_Rollback -- transaction Rollback Ѵ.

Description

int ora_rollback(int connection);

This function undoes an Oracle transaction. (See ora_commit() for the
definition of a transaction.)

Returns true on success, false on error. Details about the error can be
retrieved using the ora_error() and ora_errorcode() functions.

        ------------------------------------------------------------
(  :  κ  Ŵ  κ PHP Ȩ Note
Ͽ. )

  Լ PHP3.0.2a ߰Ǿ.

Ora_Do($conn, $query)
     Ora_Do() is a shorthand function for the Ora_Parse(), Ora_Exec(),
     Ora_Fetch() sequence that is found for many single queries.
Ora_FetchInto($curs, &$ary)
     Ora_FetchInto is passed an array reference and fetches a whole result
     row into that array. The function returns the number of columns in
     that row or false.
ora_columnsize($curs, $colindex)
     The function returns the size of the type (see ora_columntype()) at
     the named column. The column numbering starts at 0.
ora_numcols($curs)
     Returns the number of columns in the result. The command only returns
     meaningful values after an ora_parse()/ora_exec()/ora_fetch() sequence
     has been executed (ora_do() will work as well).
ora_numrows($curs)
     See above, only this one returns rows.
ora_plogon()
     This function is identical to ora_login(), only that it will create a
     persistent connection. Persistent connections are meaningful only with
     mod_php, not with CGI PHP. They can make your mod_php database
     connects a lot of faster, but cost you memory. See the notes at
     mysql_pconnect() for more information. )

           -----------------------------------------------------

Oracle Example

Prerequisites

You need to know the values of the following environment variables:

ORACLE_HOME
     This is the path to your Oracle installation directory. It is usually
     defined in the UNIX login script of your oracle user and all Oracle
     client users.
ORACLE_SID
     This is the name of the database instance you want to connect to. It
     is also defined in the UNIX environment of your oracle user and all
     Oracle client users.

Find out the values of these variables by loggin in as a user who can
connect to the database in question with sqlplus. Then type at your Unix
shell prompt:

prompt> echo $ORACLE_HOME
/opt/oracle/oracle/8.0.3
prompt> echo $ORACLE_SID
ORACLE

A simple PHP script using ora_* functions

<?php
  putenv("ORACLE_SID=ORACLE");
  putenv("ORACLE_HOME=/opt/oracle/oracle/8.0.3");
  $conn = ora_login("scott", "tiger");
  $curs = ora_open($conn);
  ora_commitoff($conn);
  $query = sprintf(&quotselect * from cat");
/* Long version */
/*
  ora_parse($curs, $query);
  ora_exec($curs);
  ora_fetch($curs);
*/
/* Short Version */
  ora_do($conn, $query);

  $ncols = ora_numcols($curs);
  $nrows = ora_numrows($curs);
  printf("Result size is $ncols cols by $nrows rows.<br>");
  for ($i=0; $i<$ncols; $i++) {
    printf("col[%s] = %s type[%d] = %s<br>",$i, ora_columnname($curs, $I), $i, ora_columntype($curs, $I));
  }
  for ($j=0; $j<$nrows; $j++) {
    for ($i=0; $i<$ncols; $i++) {
      $col = ora_getcolumn($curs, $I);
      printf("val[%d, %d] = %s * ", $j, $i, ora_getcolumn($curs, $I);
    }
    printf("<br>");
  }
?>


           -----------------------------------------------------

Suppose your ORACLE_HOME is /opt/oracle/oracle/8.0.3 and you build a
version of PHP3 with Oracle support on Solaris like this:

./configure --with-oracle \
            --with-config-file-path=/opt/GNUphp3/lib \
            --with-exec-dir=/opt/bin \
            --enable-debug=yes \
            --enable-safe-mode=no \
            --enable-url-fopen-wrapper=yes \
            --enable-track-vars=yes \
            --prefix=/opt/GNUphp3

then the resulting PHP binary will be dynamically linked against
libclntsh.so in /opt/oracle/oracle/lib. The build process as generated by
configure will include this directory with an -L option, but not with an -R
option (run-time library search path). This means that the resulting binary
will not be able to find libclntsh.so by itself, but depends on an
appropriate LD_LIBRARY_PATH set within the web server CGI environment -
which usually is not there. To fix this, grab the Makefile generated by
configure and duplicate the -L/opt/oracle/oracle/8.0.3/lib option as an
-R/opt/oracle/oracle/8.0.3/lib option (your -L and -R strings will look
slightly different depending on the values for your oracle version and
ORACLE_HOME). The -R option will compile in the corrent search path for
libclntsh and you won't have any LD_LIBRARY_PATH pains any more.

  ------------------------------------------------------------------------

PostgreSQL functions

UC Berkeley Computer Science Department ó ߵ Postgres 
Ϻ  database  object-relational   
ôϿ. ̰ SQL92/SQL3  ϰ, transaction integrity type
Ȯ尡ɼ Ѵ. PostgreSQL public-domain̰, original Berkeley
code  ҽ Ѵ.

PostgreSQL  밡ϴ.   6.3.3 ְ,
www.postgreSQL.org ã  ִ.

version 6.3 (03/02/1998)ķ PostgreSQL unix domain socket ϰ,
   table ־.   /tmp/.s.PGSQL.5432 ã 
ִ.  ɼ postmaster '-i' flag ־ enableų  ִµ,
̰ "TCP/IP sockets ƴ϶ Unix domain socket û ޾Ƶ鿩."
ǹ̴.

Table 1. Postmaster and PHP
 Postmaster   PHP                           Status
 postmaster & pg_connect("", "", "", "",    OK
              "dbname");
 postmaster   pg_connect("", "", "", "",    OK
 -i &         "dbname");
 postmaster & pg_connect("localhost", "",   PostgreSQL server  
              "", "", "dbname");            : connectDB() failed: Is
                                            the postmaster running and
                                            accepting TCP/IP (with -i)
                                            connection at 'localhost' on
                                            port '5432'? in
                                            /path/to/file.php3 on line 20.
 postmaster   pg_connect("localhost", "",   OK
 -i &         "", "", "dbname");

large object (lo) interface Ϸ transaction block ѷ δ
 ʿϴ. transaction block begin ϰ,
transactionȮϴٸ commit end .  transaction
ְų ϸ transaction block abort rollback  
̴.
Example 1. Using Large Objects

<?php
$database = pg_Connect ("", "", "", "", "jacarta");
pg_exec ($database, "begin");
    $oid = pg_locreate ($database);
    echo ("$oid\n");
    $handle = pg_loopen ($database, $oid, "w");
    echo ("$handle\n");
    pg_lowrite ($handle, "gaga");
    pg_loclose ($handle);
pg_exec ($database, "commit")
pg_exec ($database, "end")
?>

pg_Close

pg_Close -- PostgreSQL connection ݴ´.

Description

void pg_close(int connection);

Returns false if connection is not a valid connection index, true
otherwise. Closes down the connection to a PostgreSQL database associated
with the given connection index.

pg_cmdTuples

pg_cmdTuples -- شϴ tuple  Ѵ.

Description

int pg_cmdtuples(int result_id);

pg_cmdTuples() returns the number of tuples (instances) affected by INSERT,
UPDATE, and DELETE queries. If no tuple is affected the function will
return 0.
Example 1. pg_cmdtuples

<?php
$result = pg_exec($conn, "INSERT INTO verlag VALUES ('Autor')");
$cmdtuples = pg_cmdtuples($result);
echo $cmdtuples . " <- cmdtuples affected.";
?>

pg_Connect

pg_Connect -- connection .

Description

int pg_connect(string host, string port, string options, string tty, string
dbname);

Returns a connection index on success, or false if the connection could not
be made. Opens a connection to a PostgreSQL database. Each of the arguments
should be a quoted string, including the port number. The options and tty
arguments are optional and can be left out. This function returns a
connection index that is needed by other PostgreSQL functions. You can have
multiple connections open at once.

(  :      argument Ͽ ȣ 
ִ.
pg_Connect("dbname=database user=username password=pwd"); )

See also pg_pConnect().

pg_DBname

pg_DBname -- database name

Description

string pg_dbname(int connection);

Returns the name of the database that the given PostgreSQL connection index
is connected to, or false if connection is not a valid connection index.

pg_ErrorMessage

pg_ErrorMessage -- error message

Description

string pg_errormessage(int connection);

Returns a string containing the error message, false on failure. Details
about the error probably cannot be retrieved using the pg_errormessage()
function if an error occured on the last database action for which a valid
connection exists, this function will return a string containing the error
message generated by the backend server.

pg_Exec

pg_Exec -- Ǹ Ѵ.

Description

int pg_exec(int connection, string query);

Returns a result index if query could be executed, false on failure or if
connection is not a valid connection index. Details about the error can be
retrieved using the pg_ErrorMessage() function if connection is valid.
Sends an SQL statement to the PostgreSQL database specified by the
connection index. The connection must be a valid index that was returned by
pg_Connect(). The return value of this function is an index to be used to
access the results from other PostgreSQL functions.

     NOTE: PHP2 returned 1 if the query was not expected to return
     data (inserts or updates, for example) and greater than 1 even on
     selects that did not return anything. No such assumption can be
     made in PHP3.

pg_FieldIsNull

pg_FieldIsNull -- field NULLΰ ˻Ѵ.

Description

int pg_fieldisnull(int result_id, int row, mixed field);

Test if a field is NULL or not. Returns 0 if the field in the given row is
not NULL. Returns 1 if the field in the given row is NULL. Field can be
specified as number or fieldname. Row numbering starts at 0.

pg_FieldName

pg_FieldName -- field ̸ ȯѴ.

Description

string pg_fieldname(int result_id, int field_number);

pg_FieldName() will return the name of the field occupying the given column
number in the given PostgreSQL result identifier. Field numbering starts
from 0.

pg_FieldNum

pg_FieldNum -- column  ȯѴ.

Description

string pg_fieldnum(int result_id, int field_name);

pg_FieldNum() will return the number of the column slot that corresponds to
the named field in the given PosgreSQL result identifier. Field numbering
starts at 0. This function will return -1 on error.

pg_FieldPrtLen

pg_FieldPrtLen --  ( ) Ѵ.

Description

int pg_fieldprtlen(int result_id, int row_number, string field_name);

pg_FieldPrtLen() will return the actual printed length (number of
characters) of a specific value in a PostgreSQL result. Row numbering
starts at 0. This function will return -1 on an error.

pg_FieldSize

pg_FieldSize --  field   Ҵ (internal storage)
ũ

Description

int pg_fieldsize(int result_id, string field_name);

pg_FieldSize() will return the internal storage size (in bytes) of the
named field in the given PostgreSQL result. A field size of 0 indicates a
variable length field. This function will return -1 on error.

pg_FieldType

pg_FieldType -- Returns the type name for the corresponding field number

Description

int pg_fieldtype(int result_id, int field_number);

pg_FieldType() will return a string containing the type name of the given
field in the given PostgreSQL result identifier. Field numbering starts at
0.

pg_FreeResult

pg_FreeResult -- result memory Ѵ.

Description

int pg_freeresult(int result_id);

pg_FreeResult() only needs to be called if you are worried about using too
much memory while your script is running. All result memory will
automatically be freed when the script is finished. But, if you are sure
you are not going to need the result data anymore in a script, you may call
pg_FreeResult() with the result identifier as an argument and the
associated result memory will be freed.

pg_GetLastOid

pg_GetLastOid -- ֱ object identifier ȯѴ.

Description

int pg_getlastoid(void);

pg_GetLastOid() can be used to retrieve the Oid assigned to an inserted
tuple if the last command sent via pg_Exec() was an SQL INSERT. This
function will return a positive integer if there was a valid Oid. It will
return -1 if an error occured or the last command sent via pg_Exec() was
not an INSERT.

pg_Host

pg_Host -- host ̸ ȯѴ.

Description

string pg_host(int connection_id);

pg_Host() will return the host name of the given PostgreSQL connection
identifier is connected to.

pg_loclose

pg_loclose -- large object ݴ´.

Description

void pg_loclose(int fd);

pg_loclose() closes an Inversion Large Object. fd is a file descriptor for
the large object from pg_loopen().

pg_locreate

pg_locreate -- large object Ѵ.

Description

int pg_locreate(int conn);

pg_locreate() creates an Inversion Large Object and returns the oid of the
large object. conn specifies a valid database connection. PostgreSQL access
modes INV_READ, INV_WRITE, and INV_ARCHIVE are not supported, the object is
created always with both read and write access. INV_ARCHIVE has been
removed from PostgreSQL itself (version 6.3 and above).

pg_loopen

pg_loopen -- large object .

Description

int pg_loopen(int conn, int objoid, string mode);

pg_loopen() open an Inversion Large Object and returns file descriptor of
the large object. The file descriptor encapsulates information about the
connection. Do not close the connection before closing the large object
file descriptor. objoid specifies a valid large object oid and mode can be
either "r", "w", or "rw".

pg_loread

pg_loread -- large object д´.

Description

void pg_loread(int fd, string bufvar);

pg_loread() reads at most len bytes from a large object into a variable
name bufvar. fd specifies a valid large object file descriptor. bufvar
specifies a valid buffer variable to contain the large object segment and
len specifies the maximum allowable size of the large object segment.

pg_loreadall

pg_loreadall -- large object ü д´.

Description

void pg_loreadall(int fd);

pg_loreadall() reads a large object and passes it straight through to the
browser after sending all pending headers. Mainly intended for sending
binary data like images or sound.

pg_lounlink

pg_lounlink -- large object .

Description

void pg_lounlink(int conn, int lobjid);

pg_lounlink() deletes a large object with the lobjid identifier for that
large object.

pg_lowrite

pg_lowrite -- large object .

Description

void pg_lowrite(int fd, string buf);

pg_lowrite() writes at most len bytes to a large object from a variable
buf. fd is a file descriptor for the large object from pg_loopen().

pg_NumFields

pg_NumFields -- field  ȯѴ.

Description

int pg_numfields(int result_id);

pg_NumFields() will return the number of fields (columns) in a PostgreSQL
result. The argument is a valid result identifier returned by pg_Exec().
This function will return -1 on error.

pg_NumRows

pg_NumRows -- row  ȯѴ.

Description

int pg_numfields(int result_id);

pg_NumFields() will return the number of rows in a PostgreSQL result. The
argument is a valid result identifier returned by pg_Exec(). This function
will return -1 on error.

pg_Options

pg_Options -- option ȯѴ.

Description

string pg_options(int connection_id);

pg_Options() will return a string containing the options specified on the
given PostgreSQL connection identifier.

pg_pConnect

pg_pConnect --  database connection .

Description

int pg_pconnect(string host, string port, string options, string tty,
string dbname);

Returns a connection index on success, or false if the connection could not
be made. Opens a persistent connection to a PostgreSQL database. Each of
the arguments should be a quoted string, including the port number. The
options and tty arguments are optional and can be left out. This function
returns a connection index that is needed by other PostgreSQL functions.
You can have multiple persistent connections open at once. See also
pg_Connect().

pg_Port

pg_Port -- port ȣ ȯѴ.

Description

int pg_port(int connection_id);

pg_Port() will return the port number that the given PostgreSQL connection
identifier is connected to.

pg_Result

pg_Result -- result identifier   Ѵ.

Description

mixed pg_result(int result_id, int row_number, mixed fieldname);

pg_Result() will return values from a result identifier produced by
pg_Exec(). The row_number and fieldname sepcify what cell in the table of
results to return. Row numbering starts from 0. Instead of naming the
field, you may use the field index as an unquoted number. Field indices
start from 0.

PostgreSQL has many built in types and only the basic ones are directly
supported here. All forms of integer, boolean and oid types are returned as
integer values. All forms of float, and real types are returned as double
values. All other types, including arrays are returned as strings formatted
in the same default PostgreSQL manner that you would see in the psql
program.

pg_tty

pg_tty -- tty ̸ ȯѴ.

Description

string pg_tty(int connection_id);

pg_tty() will return the tty name that server side debugging output is sent
to on the given PostgreSQL connection identifier.

  ------------------------------------------------------------------------

Regular expression functions

ereg

ereg -- regular expression  ־ Ͽ ´ ˻Ѵ.

Description

int ereg(string pattern, string string, array regs);

Searchs string for matches to the regular expression given in pattern. If
matches are found for parenthesized substrings of pattern and the function
is called with the third argument regs, the matches will be stored in the
elements of regs.

Searching is case sensitive.

Returns true if a match for pattern was found in string, or false if no
matches were found or an error occurred.

The following code snippet takes a date in ISO format (YYYY-MM-DD) and
prints it in DD.MM.YYYY format:
Example 1. ereg() example

if ( ereg( "([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs ) ) {
    echo "$regs[3].$regs[2].$regs[1]";
} else {
    echo "Invalid date format: $date";
}



(  : ü ڿ regs[0] ȴ. )

See also eregi(), ereg_replace(), and eregi_replace().

ereg_replace

ereg_replace -- regular expression  ġѴ.

Description

string ereg_replace(string pattern, string replacement, string string);

This function scans string for matches to pattern, then replaces the
matched text with replacement.

If pattern contains parenthesized substrings, replacement may contain
substrings of the form \\digit, which will be replaced by the text matching
the digit'th parenthesized substring; \\0 will produce the entire contents
of string. Up to nine substrings may be used. Parentheses may be nested, in
which case they are counted by the opening parenthesis. For example, the
following code snippet prints "This was a test" three times:
Example 1. ereg_replace() example

$string = "This is a test";
echo ereg_replace( " is", " was", $string );
echo ereg_replace( "( )is", "\\1was", $string );
echo ereg_replace( "(( )is)", "\\2was", $string );

See also ereg(), eregi(), and eregi_replace().

eregi

eregi -- regular expression  ־ Ͽ ´ ,ҹ  ʰ
˻Ѵ.

Description

int eregi(string pattern, string string, array regs);

This function is identical to ereg() save that this ignores case
distinction when matching alphabetic characters.

See also ereg(), ereg_replace(), and eregi_replace().

eregi_replace

eregi_replace -- regular expression  ,ҹ  ʰ
ġѴ.

Description

string eregi_replace(string pattern, string replacement, string string);

This function is identical to ereg_replace() save that this ignores case
distinction when matching alphabetic characters.

See also ereg(), eregi(), and ereg_replace().

split

split -- ڿ regular expression  .

Description

array split(string pattern, string string, int limit);

Returns an array of strings, each of which is a substring of string formed
by splitting it on boundaries formed by pattern. If an error occurs,
returns false.

To get the first five fields from a line from /etc/passwd:
Example 1. split() example

$passwd_list = split( ":", $passwd_line, 5 );

See also explode() and implode(). .

sql_regcase

sql_regcase -- ,ҹ  ʴ ˻縦  regular expression
.

Description

string sql_regcase(string string);

Returns a valid regular expression which will match string, ignoring case.
This expression is string with each character converted to a bracket
expression; this bracket expression contains that character's uppercase and
lowercase form if applicable, otherwise it contains the original character
twice.
Example 1. sql_regcase() example

echo sql_regcase( "Foo bar" );

prints

[Ff][Oo][Oo][  ][Bb][Aa][Rr]

.

This can be used to achieve case insensitive pattern matching in products
which support only case sensitive regular expressions.

  ------------------------------------------------------------------------

Solid Functions

Solid Լ  򰡸  ϰ ִ. Ƹ Unified ODBC
functions  ϴ   ̴.

solid_close

solid_close -- Solid connection ݴ´.

Description

See odbc_close().

solid_connect

solid_connect -- Solid data source Ѵ.

Description

See odbc_connect().

solid_exec

solid_exec -- Solid Ǹ Ѵ.

Description

See odbc_exec().

solid_fetchrow

solid_fetchrow -- Solid Ƿκ Ÿ row ´.

Descriptio

See odbc_fetch_row()

solid_fieldname

solid_fieldname -- Solid Ƿκ column ̸ Ѵ.

Description

See odbc_field_name().

solid_fieldnum

solid_fieldnum -- Solid Ƿκ column index Ѵ.

Description

See odbc_field_num().

solid_freeresult

solid_freeresult -- Solid Ƿκ result memory Ѵ.

Description

See odbc_free_result().

solid_numfields

solid_numfields -- Solid result field  Ѵ.

Description

See odbc_num_fields().

solid_numrows

solid_numrows -- Solid result row  Ѵ.

Description

See odbc_num_rows().

solid_result

solid_result -- Solid resultκ data Ѵ.

Description

See odbc_result().

  ------------------------------------------------------------------------

SNMP Functions

 SNMP Լ SNMP dynamically loadable PHP extension ؼ ȴ.
  extension PHP3 distribution dl/ directory ã  
̴.

snmpget

snmpget -- SNMP object ´.

Description

int snmpget(string hostname, string community, string object_id);

Returns SNMP object value on success and false on error.

The snmpget() function is used to read the value of an SNMP object
specified by the object_id. SNMP agent is specified by the hostname and the
read community is specified by the community parameter.

snmpget("127.0.0.1", "public", "system.SysContact.0")

snmpwalk

snmpwalk -- agent   SNMP object ´.

Description

int snmpwalk(int hostname, string community, string object_id);

Returns an array of SNMP object values starting from the object_id as root
and false on error.

snmpwalk() function is used to read all the values from an SNMP agent
specified by the hostname. Community specifies the read community for that
agent. A null object_id is taken as the root of the SNMP objects tree and
all objects under that tree are returned as an array. If object_id is
specified, all the SNMP objects below that object_id are returned.

 $a = snmpwalk("127.0.0.1", "public", "");

Above function call would return all the SNMP objects from the SNMP agent
running on localhost. One can step through the values with a loop

for($i=0; $i<count($a); $i++) {
        echo $a[$i];
}

  ------------------------------------------------------------------------

String functions

 Լ ڿ ٷ Լ̴.  ڼ  regular expression
̳ URL handling   κ ϶.

AddSlashes

AddSlashes -- ʿ  backslash Ѵ.

Description

string addslashes(string str);

Returns a string with backslashes before characters that need to be quoted
in database queries etc. These characters are single quote ('), double
quote ("), and backslash (\).

See also stripslashes() and quotemeta().

Chop

Chop --  鸦 Ѵ.

Description

string chop(string str);

Returns the argument string without trailing whitespace.
Example 1. chop() example

$trimmed = Chop($line);

See also trim().

Chr

Chr --  ڸ ȯѴ.

Description

string chr(int ascii);

Returns a one-character string containing the character specified by ascii.
Example 1. chr() example

$str .= chr(27); /* add an escape character at the end of $str */

This function complements ord().

crypt

crypt -- ڿ DES encryption ȯ(encrypt)Ѵ.

Description

string crypt(string str, string salt);

crypt() will encrypt a string using the standard Unix DES encryption
method. Arguments are a string to be encrypted and an optional
two-character salt string to base the encryption on. See the Unix man page
for your crypt function for more information. If you do not have a crypt
function on your Unix system, you can use Michael Glad's public domain
UFC-Crypt package which was developed in Denmark and hence not restricted
by US export laws as long as you ftp it from an non-US site.

There is no decrypt function, since crypt() uses a one-way algorithm.

echo

echo -- ϳ ̻ ڿ Ѵ.

Description

echo(string arg1, string argn...);

Outputs all parameters.

(  : echo  Լ ƴϹǷ () ʿ.)

See also: print() printf() flush()

explode

explode -- ڿ ڿ  .

Description

array explode(string separator, string string);

Returns an array of strings containing the elements separated by separator.
Example 1. explode() example

$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);

See also split() and implode().

flush

flush -- output buffer FlushѴ.

Description

void flush(void);

Flushes the output buffers of PHP and whatever backend PHP is using (CGI, a
web server, etc.) This effectively tries to push all the output so far to
the user's browser.

htmlspecialchars

htmlspecialchars -- Ưڵ HTML entity ȯѴ.

Description

string htmlspecialchars(string string);

Certain characters have special significance in HTML, and should be
represented by HTML entities if they are to preserve their meanings. This
function returns a string with these conversions made.

At present, the translations that are done are:

     '&' (ampersand) becomes '&amp;'
     '"' (double quote) becomes '&quot;'
     '<' (less than) becomes '&lt;'
     '>' (greater than) becomes '&gt;'

Note that this functions does not translate anything beyond what is listed
above. For full entity translation, see htmlentities().

See also htmlentities() and nl2br().

htmlentities

htmlentities --   ڵ HTML entity ٲ۴.

Description

string htmlentities(string string);

This function is identical to htmlspecialchars() in all ways, except that
all characters which have HTML entity equivalents are translated into these
entities.

At present, the ISO-8859-1 character set is used.

See also htmlspecialchars() and nl2br().

implode

implode -- 迭 ҵ ڿ  Ѵ.

Description

string implode(array pieces, string glue);

Returns a string containing a string representation of all the array
elements in the same order, with the glue string between each element.
Example 1. implode() example

$colon_separated = implode($array, ":");

See also explode(), join(), and split().

join

join -- 迭 ҵ ڿ  Ѵ

Description

string join(array pieces, string glue);

join() is an alias to implode(), and is identical in every way.

nl2br

nl2br -- newline HTML line break ȯѴ.

Description

string nl2br(string string);

Returns string with '<BR>' inserted before all newlines.

See also htmlspecialchars() and htmlentities().

Ord

Ord --  ASCII  Ѵ.

Description

int ord(string string);

Returns the ASCII value of the first character of string. This function
complements chr().
Example 1. ord() example

if (ord($str) == 10) {
    echo("The first character of \$str is a line feed.\n");
}

See also chr().

print

print -- ڿ Ѵ.

Description

print(string arg);

Outputs arg.

See also: echo() printf() flush()

printf

printf -- ڿ formatϿ Ѵ.

Description

int printf(string format, mixed args...);

Produces output according to format, which is described in the
documentation for sprintf().

See also: print(), sprintf(), and flush().

QuoteMeta

QuoteMeta -- meta character backslash  ڷ ȯѴ.

Description

int quotemeta(string str);

Returns a version of str with a backslash character (\) before every
character that is among these:

. \\ + * ? [ ^ ] ( $ )

See also addslashes(), htmlentities(), htmlspecialchars(), and nl2br().

rawurldecode

rawurldecode -- URL-encoded ڿ decodeѴ.

Description

string rawurldecode(string str);

Returns a string in which the sequences with percent (%) signs followed by
two hex digits have been replaced with literal characters. For example, the
string

foo%20bar%40baz

decodes into

foo bar@baz

See also rawurlencode().

rawurlencode

rawurlencode -- RFC1738  URL-encodeѴ.

Description

string rawurlencode(string str);

Returns a string in which all non-alphanumeric characters except

-_.

have been replaced with a percent (%) sign followed by two hex digits. This
is the encoding described in RFC1738 for protecting literal characters from
being interpreted as special URL delimiters, and for protecting URL's from
being mangled by transmission media with character conversions (like some
email systems). For example, if you want to include a password in an ftp
url:
Example 1. rawurlencode() example 1

echo '<A HREF="ftp://user:', rawurlencode ('foo @+%/'),
     '@ftp.my.com/x.txt">';

Or, if you pass information in a path info component of the url:
Example 2. rawurlencode() example 2

echo '<A HREF="http://x.com/department_list_script/',
     rawurlencode ('sales and marketing/Miami'), '">';

See also rawurldecode().

setlocale

setlocale -- locale information Ѵ.

Description

string setlocale(string category, string locale);

category is a string specifying the category of the functions affected by
the locale setting:

     LC_ALL for all of the below
     LC_COLLATE for string comparison - not currently implemented in PHP
     LC_CTYPE for character classification and conversion, for example
     strtoupper()
     LC_MONETARY for localeconv() - not currently implemented in PHP
     LC_NUMERIC for decimal separator
     LC_TIME for time formats - not currently implemented in PHP

If locale is the empty string "", the locale names will be set from the
values of environment variables with the same names as the above
categories, or from "LANG".

If locale is zero or "0", the locale setting is not affected, only the
current setting is returned.

Setlocale returns the new current locale, or false if the locale
functionality is not implemented in the plattform, the specified locale
does not exist or the category name is invalid. An invalid category name
also causes a warning message.

sprintf

sprintf -- format ڿ ȯѴ.

Description

sprintf(string format, mixed args...);

Returns a string produced according to the formatting string format.

The format string is composed by zero or more directives: ordinary
characters (excluding %) that are copied directly to the result, and
conversion specifications, each of which results in fetching its own
parameter. This applies to both sprintf() and printf()

Each conversion specification consists of these elements, in order:

     An optional padding specifier that says what character will be used
     for padding the results to the right string size. This may be a space
     character or a 0 (zero character). The default is to pad with spaces.
     An alternate padding character can be specified by prefixing it with a
     single quote ('). See the examples below.

     An optional alignment specifier that says if the result should be
     left-justified or right-justified. The default is right-justified; a -
     character here will make it left-justified.

     An optional number, a width specifier that says how many characters
     (minimum) this conversion should result in.

     An optional precision specifier that says how many decimal digits
     should be displayed for floating-point numbers. This option has no
     effect for other types than double.

     A type specifier that says what type the argument data should be
     treated as. Possible types:
     % - a literal percent character. No argument is required.
     b - the argument is treated as an integer, and presented as a binary
     number.
     c - the argument is treated as an integer, and presented as the
     character with that ASCII value.
     d - the argument is treated as an integer, and presented as a decimal
     number.
     f - the argument is treated as a double, and presented as a
     floating-point number.
     o - the argument is treated as an integer, and presented as an octal
     number.
     s - the argument is treated as and presented as a string.
     x - the argument is treated as an integer and presented as a
     hexadecimal number (with lowercase letters).
     X - the argument is treated as an integer and presented as a
     hexadecimal number (with uppercase letters).

See also: printf()

Examples

Example 1. sprintf: zero-padded integers

$isodate = sprintf("%04d-%02d-%02d", $year, $month, $day);

strchr

strchr -- ش ڰ ó Ÿ  ã´.

Description

string strchr(string haystack, string needle);

This function is an alias for strstr(), and is identical in every way.

strcmp

strcmp -- binary  ڿ 

Description

int strcmp(string str1, string str2);

Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2,
and 0 if they are equal.

Note that this comparison is case sensitive.

See also ereg(), substr(), and strstr().

StripSlashes

StripSlashes -- addslashes quote ڿ un-quoteѴ.

Description

string stripslashes(string str);

Returns a string with backslashes stripped off. (\' becomes ' and so on.)
Double backslashes are made into a single backslash.

See also addslashes().

strlen

strlen -- ڿ ̸ Ѵ.

Description

int strlen(string str);

Returns the length of string.

strrpos

strrpos -- ڿ ش ڰ Ÿ   ġ Ѵ.

Description

string strrpos(string haystack, char needle);

Returns the numeric position of the last occurrence of needle in the
haystack string. Note that the needle in this case can only be a single
character. If a string is passed as the needle, then only the first
character of that string will be used.

If needle is not found, returns false.

If needle is not a string, it is converted to an integer and applied as the
ordinal value of a character.

See also strpos(), strrchr(), substr(), and strstr().

strpos

strpos -- ش ڿ Ÿ ù ġ Ѵ.

Description

string strpos(string haystack, string needle);

Returns the numeric position of the first occurrence of needle in the
haystack string. Unlike the strrpos(), this function can take a full string
as the needle parameter and the entire string will be used.

If needle is not found, returns false.

If needle is not a string, it is converted to an integer and applied as the
ordinal value of a character.

See also strrpos(), strrchr(), substr(), and strstr().

strtok

strtok -- ڿ tokenȭ Ѵ.

Description

string strtok(string arg1, string arg2);

strtok() is used to tokenize a string. That is, if you have a string like
"This is an example string" you could tokenize this string into its
individual words by using the space character as the token.
Example 1. strtok() example

    $string = "This is an example string";
    $tok = strtok($string," ");
    while($tok) {
        echo "Word=$tok<br>";
        $tok = strtok(" ");
    }

Note that only the first call to strtok uses the string argument. Every
subsequent call to strtok only needs the token to use, as it keeps track of
where it is in the current string. To start over, or to tokenize a new
string you simply call strtok with the string argument again to initialize
it. Note that you may put multiple tokens in the token parameter. The
string will be tokenized when any one of the characters in the argument are
found.

See also split() and explode().

strrchr

strrchr -- ڿ  Ÿ ġ Ѵ.

Description

string strrchr(string haystack, string needle);

This function returns the portion of haystack which starts at the last
occurrence of needle and goes until the end of haystack.

Returns false if needle is not found.

If needle is not found, false is returned.

If needle contains more than one character, the first is used.

If needle is not a string, it is converted to an integer and applied as the
ordinal value of a character.
Example 1. strrchr() example

// get last directory in $PATH
$dir = substr( strrchr( $PATH, ":" ), 1 );
// get everything after last newline
$text = "Line 1\nLine 2\nLine 3";
$last = substr( strrchr( $text, 10 ), 1 );

See also substr() and strstr().

strrev

strrev -- ڿ ReverseѴ.

Description

string strrev(string string);

Returns string, reversed.

strstr

strstr -- ڿ ó Ÿ ġ ڿ ȯѴ.

Description

string strstr(string haystack, string needle);

Returns all of haystack from the first occurrence of needle to the end.

If needle is not found, returns false.

If needle is not a string, it is converted to an integer and applied as the
ordinal value of a character.

See also strrchr(), substr(), and ereg().

strtolower

strtolower -- ҹڷ .

Description

string strtolower(string str);

Returns string with all alphabetic characters converted to lowercase.

Note that 'alphabetic' is determined by the current locale. This means that
in i.e. the default "C" locale, characters such as umlaut-A () will not be
converted.

See also strtoupper() and ucfirst().

strtoupper

strtoupper -- 빮ڷ .

Description

string strtoupper(string string);

Returns string with all alphabetic characters converted to uppercase.

Note that 'alphabetic' is determined by the current locale. For instance,
in the default "C" locale characters such as umlaut-a () will not be
converted.

See also strtolower() and ucfirst().

strtr

strtr -- Ư ڿ ġ(translate)Ѵ.

Description

string strtr(string str, string from, string to);

This function operates on str, translating all occurrences of each
character in from to the corresponding character in to and returning the
result.

If from and to are different lengths, the extra characters in the longer of
the two are ignored.
Example 1. strtr() example

$addr = strtr($addr, "", "aao");


See also ereg_replace().

substr

substr -- ڿ Ϻκ ȯѴ.

Description

string substr(string string, int start, int length);

Substr returns the portion of string specified by the start and length
parameters.

If start is positive, the returned string will start at the start'th
character of string.

If start is negative, the returned string will start at the start'th
character from the end of string.

If length is given and is positive, the string returned will end length
characters from start. If this would result in a string with negative
length, then the returned string will contain the single character at
start.

If length is given and is negative, the string returned will end length
characters from the end of string. If this would result in a string with
negative length, then the returned string will contain the single character
at start.

See also strrchr() and ereg().

ltrim

ltrim -- ڿ   Ѵ.

Description

string ltrim(string str);

This function strips whitespace from the start of a string and returns the
stripped string.

See also chop() and trim().

trim

trim -- ڿ ,  θ Ѵ.

Description

string trim(string str);

This function strips whitespace from the start and the end of a string and
returns the stripped string.

See also chop() and ltrim().

ucfirst

ucfirst -- ڿ ó ڸ 빮ڷ .

Description

string ucfirst(string str);

Capitalizes the first character of str if that character is alphabetic.

Note that 'alphabetic' is determined by the current locale. For instance,
in the default "C" locale characters such as umlaut-a () will not be
converted.

See also strtoupper() and strtolower().

md5

md5 -- ڿ md5 hash  Ѵ.

Description

string md5(string str);

Calculates the MD5 hash of str.

(  : MD5 algorithm ڼ  RFC 1321 . )

soundex

soundex -- ڿ soundex key Ѵ.(:   ã 
,  )

Description

string soundex(string str);

Calculates the soundex key of str.

Soundex keys have the property that words pronounced similarly produce the
same soundex key, and can thus be used to simplify searches in databases
where you know the pronunciation but not the spelling. This soundex
function returns a string 4 characters long, starting with a letter.

This particular soundex function is one described by Donald Knuth in "The
Art Of Computer Programming, vol. 3: Sorting And Searching", Addison-Wesley
(1973), pp. 391-392.
Example 1. Soundex Examples

soundex("Euler") == soundex("Ellery") == 'E460';
soundex("Gauss") == soundex("Ghosh") == 'G200';
soundex("Knuth") == soundex("Kant") == 'H416';
soundex("Lloyd") == soundex("Ladd") == 'L300';
soundex("Lukasiewicz") == soundex("Lissajous") == 'L222';


parse_str

parse_str -- ڿ  ؼ(parse)Ѵ.

Description

void parse_str(string str);

Parses str as if it were the query string passed via an URL and sets
variables in the current scope.
Example 1. Using parse_str()

$str = "first=value&second[]=this+works&second[]=another";
parse_str($str);
echo $first; /* prints "value" */
echo $second[0]; /* prints "this works" */
echo $second[1]; /* prints "another" */

  ------------------------------------------------------------------------

URL functions

parse_url

parse_url -- PHP form data ؼϵ query string ؼ(parse)Ѵ.

Description

array parse_url(string url);

Returns: This function returns an associative array returning any of the
various components of the URL that are present. This includes the "scheme",
"host", "port", "user", "pass", "path", "query", and "fragment".

urldecode

urldecode -- URL-encode ڿ decodeѴ.

Description

string urldecode(string str);

Decodes any %## encoding in the given string. The decoded string is
returned.
Example 1. urldecode() example

$a = split ('&', $querystring);
$i = 0;
while ($i < count ($a)) {
  $b = split ('=', $a [$i]);
  echo 'Value for parameter ', htmlspecialchars (urldecode ($b [0])),
       ' is ', htmlspecialchars (urldecode ($b [1])), "<BR>";
  $i++;
}

See also urlencode()

urlencode

urlencode -- ڿ URL-encodeѴ.

Description

string urlencode(string str);

Returns a string in which all non-alphanumeric characters except -_. have
been replaced with a percent (%) sign followed by two hex digits and spaces
encoded as plus (+) signs. It is encoded the same way that the posted data
from a WWW form is encoded, that is the same way as in
application/x-www-form-urlencoded media type. This differs from the RFC1738
encoding (see rawurlencode() ) in that for historical reasons, spaces are
encoded as plus (+ ) signs. This function is convenient when encoding a
string to be used in a query part of an URL, as a convinient way to pass
variables to the next page:
Example 1. urlencode() example

echo '<A HREF="mycgi?foo=', urlencode ($userinput), '">';

See also urldecode()

base64_encode

base64_encode -- base64  encodeѴ.

Description

string base64_encode(string data);

base64_encode() returns data encoded with base64. This encoding is designed
to make binary data survive transport through transport layers that are not
8-bit clean, such as mail bodies.

Base64-encoded data takes about 33% more space than the original data.

See also: base64_decode(), RFC-2045 section 6.8.

base64_decode

base64_decode -- base64 encode ڿ decode Ѵ.

Description

string base64_decode(string encoded_data);

base64_decode() decodes encoded_data and returns the original data. The
returned data may be binary.

See also: base64_encode(), RFC-2045 section 6.8.

  ------------------------------------------------------------------------

Variable functions

gettype

gettype --  type Ѵ.

Description

string gettype(mixed var);

Returns the type of the PHP variable var.

Possibles values for the returned string are:

     "integer"
     "double"
     "string"
     "array"
     "class"
     "object"
     "unknown type"

See also settype().

intval

intval --   Ѵ.

Description

int intval(mixed var, int base);

Returns the integer value of var, using the specified base for the
conversion (the default is base 10).

var may be any scalar type. You cannot use intval() on arrays or objects.

See also doubleval(), strval(), settype() and Type juggling.

doubleval

doubleval --  Ǽ(double) Ѵ.

Description

double doubleval(mixed var);

Returns the double (floating point) value of var.

var may be any scalar type. You cannot use doubleval() on arrays or
objects.

See also intval(), strval(), settype() and Type juggling.

empty

empty --    ִ° ˻Ѵ.

Description

int empty(mixed var);

Returns false if var exists and has a value; true otherwise.

See also isset().

strval

strval --  ڿ  Ѵ.

Description

string strval(mixed var);

Returns the string value of var.

var may be any scalar type. You cannot use strval() on arrays or objects.

See also doubleval(), intval(), settype() and Type juggling.

is_array

is_array --  迭ΰ ˻Ѵ.

Description

int is_array(mixed var);

Returns true if var is an array, false otherwise.

See also is_double(), is_float(), is_int(), is_integer(), is_real(),
is_string(), is_long(), and is_object().

is_double

is_double --  Ǽΰ ˻Ѵ..

Description

int is_double(mixed var);

Returns true if var is a double, false otherwise.

See also is_array(), is_float(), is_int(), is_integer(), is_real(),
is_string(), is_long(), and is_object().

is_float

is_float --  Ǽΰ ˻Ѵ.

Description

int is_float(mixed var);

This function is an alias for is_double().

See also is_double(), is_real(), is_int(), is_integer(), is_string(),
is_object(), is_array(), and is_long().

is_int

is_int --  ΰ ˻Ѵ.

Description

int is_int(mixed var);

This function is an alias for is_long().

See also is_double(), is_float(), is_integer(), is_string(), is_real(),
is_object(), is_array(), and is_long().

is_integer

is_integer --  ΰ ˻Ѵ.

Description

int is_integer(mixed var);

This function is an alias for is_long().

See also is_double(), is_float(), is_int(), is_string(), is_real(),
is_object(), is_array(), and is_long().

is_long

is_long --  ΰ ˻Ѵ.

Description

int is_long(mixed var);

Returns true if var is an integer (long), false otherwise.

See also is_double(), is_float(), is_int(), is_real(), is_string(),
is_object(), is_array(), and is_integer().

is_object

is_object --  ü(object)ΰ ˻Ѵ.

Description

int is_object(mixed var);

Returns true if var is an object, false otherwise.

See also is_long(), is_int(), is_integer(), is_float(), is_double(),
is_real(), is_string(), and is_array().

is_real

is_real --  Ǽΰ ˻Ѵ.

Description

int is_real(mixed var);

This function is an alias for is_double().

See also is_long(), is_int(), is_integer(), is_float(), is_double(),
is_object(), is_string(), and is_array().

is_string

is_string --  ڿΰ ˻Ѵ.

Description

int is_string(mixed var);

Returns true if var is a string, false otherwise.

See also is_long(), is_int(), is_integer(), is_float(), is_double(),
is_real(), is_object(), and is_array().

isset

isset --   ִ° ˻Ѵ.

Description

int isset(mixed var);

Returns true if var exists and has a value; false otherwise.

See also empty().

settype

settype --  type Ѵ.

Description

int settype(string var, string type);

Set the type of variable var to type.

Possibles values of type are:

     "integer"
     "double"
     "string"
     "array"
     "object"

Returns true if successful; otherwise returns false.

See also gettype().

  ------------------------------------------------------------------------

Gz-file Functions

  gzip(.gz)   ϰ( ó) а
  Jean-loup Gailly Mark Adler  zlib >= 1.0.9
(http://www.cdrom.com/pub/infozip/zlib/) Լ Ѵ.

gzclose

gzclose -- gz-file pointer ݴ´.

Description

int gzclose(int zp);

The gz-file pointed to by zp is closed.

Returns true on success and false on failure.

The gz-file pointer must be valid, and must point to a file successfully
opened by gzopen().

gzeof

gzeof -- gz-file pointer end-of-file ִ° ˻Ѵ.

Description

int gzeof(int zp);

Returns true if the gz-file pointer is at EOF or an error occurs; otherwise
returns false.

The gz-file pointer must be valid, and must point to a file successfully
opened by gzopen().

gzfile

gzfile -- gz-file  迭 д´.

Description

array gzfile(string filename);

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

See also readgzfile(), and gzopen().

gzgetc

gzgetc -- gz-file pointer  ڸ д´.

Description

string gzgetc(int zp);

Returns a string containing a single (uncompressed) character read from the
file pointed to by zp. Returns FALSE on EOF (as does gzeof()).

The gz-file pointer must be valid, and must point to a file successfully
opened by gzopen().

See also gzopen(), and gzgets().

gzgets

gzgets -- gz-file pointer   д´.

Description

string gzgets(int zp, int length);

Returns a (uncompressed) string of up to length - 1 bytes read from the
file pointed to by fp. Reading ends when length - 1 bytes have been read,
on a newline, or on EOF (whichever comes first).

If an error occurs, returns false.

The file pointer must be valid, and must point to a file successfully
opened by gzopen().

See also gzopen(), and gzgetc().

gzgetss

gzgetss -- gz-file pointer   о HTML tag stripѴ.

Description

string gzgetss(int zp, int length);

Identical to gzgets(), except that gzgetss attempts to strip any HTML and
PHP tags from the text it reads.

See also gzgets(), and gzopen().

gzopen

gzopen -- gz-file .

Description

int gzopen(string filename, string mode);

Opens a gzip (.gz) file for reading or writing. The mode parameter is as in
fopen() ("rb" or "wb") but can also include a compression level ("wb9") or
a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman only
compression as in "wb1h". (See the description of deflateInit2 in zlib.h
for more information about the strategy parameter.)

Gzopen can be used to read a file which is not in gzip format; in this case
gzread will directly read from the file without decompression.

Gzopen returns a file pointer to the file opened, after that, everything
you read from this file descriptor will be transparently decompressed and
what you write gets compressed.

If the open fails, the function returns false.
Example 1. gzopen() example

$fp = gzopen("/tmp/file.gz", "r");

See also gzclose().

gzpassthru

gzpassthru -- gz-file pointer ִ  Ÿ
(output)Ѵ.

Description

int gzpassthru(int zp);

Reads to EOF on the given gz-file pointer and writes the (uncompressed)
results to standard output.

If an error occurs, returns false.

The file pointer must be valid, and must point to a file successfully
opened by gzopen().

gzputs

gzputs -- gz-file pointer .

Description

int gzputs(int zp, string str, int length);

gzputs() is an alias to gzwrite(), and is identical in every way.

gzread

gzread -- gz-file  Ÿ д´.

Description

string gzread(int zp, int length);

gzread() reads up to length bytes from the gz-file pointer referenced by
zp. Reading stops when length (uncompressed) bytes have been read or EOF is
reached, whichever comes first.

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

See also gzwrite(), gzopen(), gzgets(), gzgetss(), gzfile(), and
gzpassthru().

gzrewind

gzrewind -- gz-file pointer ġ   .

Description

int gzrewind(int zp);

Sets the file position indicator for zp to the beginning of the file
stream.

If an error occurs, returns 0.

The file pointer must be valid, and must point to a file successfully
opened by gzopen().

See also gzseek() and gztell().

gzseek

gzseek -- gz-file pointer ű.

Description

int gzseek(int zp, int offset);

Sets the file position indicator for the file referenced by zp to offset
bytes into the file stream. Equivalent to calling (in C) gzseek( zp,
offset, SEEK_SET ).

If the file is opened for reading, this function is emulated but can be
extremely slow. If the file is opened for writing, only forward seeks are
supported; gzseek then compresses a sequence of zeroes up to the new
starting position.

Upon success, returns 0; otherwise, returns -1. Note that seeking past EOF
is not considered an error.

See also gztell() and gzrewind().

gztell

gztell -- gz-file pointer а,  ġ ȯѴ.

Description

int gztell(int zp);

Returns the position of the file pointer referenced by zp; i.e., its offset
into the file stream.

If an error occurs, returns false.

The file pointer must be valid, and must point to a file successfully
opened by gzopen().

See also gzopen(), gzseek() and gzrewind().

readgzfile

readgzfile -- gz-file (output)Ѵ.

Description

int readgzfile(string filename);

Reads a file, decompresses it and writes it to standard output.

Returns the number of (uncompressed) bytes read from the file. If an error
occurs, false is returned and unless the function was called as
@readgzfile, an error message is printed.

The file filename will be opened from the filesystem and its contents
written to standard output.

See also gzpassthru(), gzfile(), and gzopen().

gzwrite

gzwrite -- gz-file  Ÿ .

Description

int gzwrite(int zp, string string, int length);

gzwrite() writes the contents of string to the gz-file stream pointed to by
zp. If the length argument is given, writing will stop after length
(uncompressed) bytes have been written or the end of string is reached,
whichever comes first.

Note that if the length argument is given, then the magic_quotes_runtime
configuration option will be ignored and no slashes will be stripped from
string.

See also gzread(), gzopen(), and gzputs().

  ------------------------------------------------------------------------

III. η (Appendixes)

Table of Contents
A. Migrating from PHP/FI 2.0 to PHP 3.0
B. PHP development
C. The PHP Debugger

  ------------------------------------------------------------------------

Appendix A. Migrating from PHP/FI 2.0 to PHP 3.0

  ------------------------------------------------------------------------

(: ̺κ  ̿   ǹǷ  Ѵ.)

About the incompatbilities in 3.0

PHP 3.0 is rewritten from the ground up. It has a proper parser that is
much more robust and consistent than 2.0's. 3.0 is also significantly
faster, and uses less memory. However, some of these improvements have not
been possible without compatibility changes, both in syntax and
functionality.

In addition, PHP's developers have tried to clean up both PHP's syntax and
semantics in version 3.0, and this has also caused some incompatibilities.
In the long run, we believe that these changes are for the better.

This chapter will try to guide you through the incompatibilities you might
run into when going from PHP/FI 2.0 to PHP 3.0 and help you resolve them.
New features are not mentioned here unless necessary.

A conversion program that can automatically convert your old PHP/FI 2.0
scripts exists. It can be found in the convertor subdirectory of the PHP
3.0 distribution. This program only catches the syntax changes though, so
you should read this chapter carefully anyway.

  ------------------------------------------------------------------------

Start/end tags

The first thing you probably will notice is that PHP's start and end tags
have changed. The old <? > form has been replaced by three new possible
forms:
Example A-1. Migration: old start/end tags

<? echo "This is PHP/FI 2.0 code.\n"; >

As of version 2.0, PHP/FI also supports this variation:
Example A-2. Migration: first new start/end tags

<? echo "This is PHP 3.0 code!\n"; ?>

Notice that the end tag now consists of a question mark and a greater-than
character instead of just greater-than. However, if you plan on using XML
on your server, you will get problems with the first new variant, because
PHP may try to execute the XML markup in XML documents as PHP code. Because
of this, the following variation was introduced:
Example A-3. Migration: second new start/end tags

<?php echo "This is PHP 3.0 code!\n"; ?>

Some people have had problems with editors that don't understand the
processing instruction tags at all. Microsoft FrontPage is one such editor,
and as a workaround for these, the following variation was introduced as
well:
Example A-4. Migration: third new start/end tags

<script language="php">
  echo "This is PHP 3.0 code!\n";
</script>

  ------------------------------------------------------------------------

if..endif syntax

The `alternative' way to write if/elseif/else statements, using if();
elseif(); else; endif; cannot be efficiently implemented without adding a
large amount of complexity to the 3.0 parser. Because of this, the syntax
has been changed:
Example A-5. Migration: old if..endif syntax

if ($foo);
    echo "yep\n";
elseif ($bar);
    echo "almost\n";
else;
    echo "nope\n";
endif;

Example A-6. Migration: new if..endif syntax

if ($foo):
    echo "yep\n";
elseif ($bar):
    echo "almost\n";
else:
    echo "nope\n";
endif;

Notice that the semicolons have been replaced by colons in all statements
but the one terminating the expression (endif).

  ------------------------------------------------------------------------

while syntax

Just like with if..endif, the syntax of while..endwhile has changed as
well:
Example A-7. Migration: old while..endwhile syntax

while ($more_to_come);
    ...
endwhile;

Example A-8. Migration: new while..endwhile syntax

while ($more_to_come):
    ...
endwhile;

                                  WARNING
 If you use the old while..endwhile syntax in PHP 3.0, you will get a
 never-ending loop.

  ------------------------------------------------------------------------

Expression types

PHP/FI 2.0 used the left side of expressions to determine what type the
result should be. PHP 3.0 takes both sides into account when determining
result types, and this may cause 2.0 scripts to behave unexpectedly in 3.0.

Consider this example:

$a[0]=5;
$a[1]=7;
$key = key($a);
while ("" != $key) {
    echo "$keyn";
    next($a);
}

In PHP/FI 2.0, this would display both of $a's indices. In PHP 3.0, it
wouldn't display anything. The reason is that in PHP 2.0, because the left
argument's type was string, a string comparison was made, and indeed ""
does not equal "0", and the loop went through. In PHP 3.0, when a string is
compared with an integer, an integer comparison is made (the string is
converted to an integer). This results in comparing atoi("") which is 0,
and variablelist which is also 0, and since 0==0, the loop doesn't go
through even once.

The fix for this is simple. Replace the while statement with:

while ((string)$key != "") {

  ------------------------------------------------------------------------

Error messages have changed

PHP 3.0's error messages are usually more accurate than 2.0's were, but you
no longer get to see the code fragment causing the error. You will be
supplied with a file name and a line number for the error, though.

  ------------------------------------------------------------------------

Short-circuited boolean evaluation

In PHP 3.0 boolean evaluation is short-circuited. This means that in an
expression like (1 || test_me()), the function test_me() would not be
executed since nothing can change the result of the expression after the 1.

This is a minor compatibility issue, but may cause unexpected side-effects.

  ------------------------------------------------------------------------

Function true/false return values

Most internal functions have been rewritten so they return TRUE when
successful and FALSE when failing, as opposed to 0 and -1 in PHP/FI 2.0,
respectively. The new behaviour allows for more logical code, like $fp =
fopen("/your/file") or fail("darn!");. Because PHP/FI 2.0 had no clear
rules for what functions should return when they failed, most such scripts
will probably have to be checked manually after using the 2.0 to 3.0
convertor.
Example A-9. Migration from 2.0: return values, old code

$fp = fopen($file, "r");
if ($fp == -1);
    echo("Could not open $file for reading<br>\n");
endif;

Example A-10. Migration from 2.0: return values, new code

$fp = @fopen($file, "r") or print("Could not open $file for reading<br>\n");

  ------------------------------------------------------------------------

Other incompatibilities

     The PHP 3.0 Apache module no longer supports Apache versions prior to
     1.2. Apache 1.2 or later is required.

     echo() no longer supports a format string. Use the printf() function
     instead.

     In PHP/FI 2.0, an implementation side-effect caused $foo[0] to have
     the same effect as $foo. This is not true for PHP 3.0.

     Reading arrays with $array[] is no longer supported

     That is, you cannot traverse an array by having a loop that does $data
     = $array[]. Use current() and next() instead.

     Also, $array1[] = $array2 does not append the values of $array2 to
     $array1, but appends $array2 as the last entry of $array1. See also
     multidimensional array support.

     "+" is no longer overloaded as a concatenation operator for strings,
     instead it converts it's arguments to numbers and performs numeric
     addition. Use "." instead.

Example A-11. Migration from 2.0: concatenation for strings

echo "1" + "1";

In PHP 2.0 this would echo 11, in PHP 3.0 it would echo 2. Instead use:

echo "1"."1";
$a = 1;
$b = 1;
echo $a + $b;

This would echo 2 in both PHP 2.0 and 3.0.

$a = 1;
$b = 1;
echo $a.$b;

This will echo 11 in PHP 3.0.

  ------------------------------------------------------------------------

Appendix B. PHP development

  ------------------------------------------------------------------------

Adding functions to PHP3

  ------------------------------------------------------------------------

Reporting Errors

 Լ  report  php3_error()Լ ϴ  .
 Լ ּ ΰ μ  ȣȴ. ù°  level̰,
ٸ ϳ  ޼  format string( printf() Ǵ Ͱ
 ) ̴. ׸   ־ format string parameter
ȴ.  level  . :

  ------------------------------------------------------------------------

E_NOTICE

Notice ⺻δ µ ʴ´. ̰ ũƮ  
, װ  Ȳ ߻ϴ ̶ ǹ̴. 
   Ϸ ߰ų,  ʴ Ͽ stat() Լ
ȣϴ  ̴.

  ------------------------------------------------------------------------

E_WARNING

Warning ⺻ µȴ. ׷, ũƮ   ʴ´.
̰ ȣ ϷǱ  ũƮ   ϴ  Ų.
 ߸ regular expression ereg() ȣϴ  ̴.

  ------------------------------------------------------------------------

E_ERROR

Error ⺻ µȴ. ׸, Լ  Ϸ , ũƮ
 . ̰ memory allocation   Ұ 
ǹѴ.

  ------------------------------------------------------------------------

E_PARSE

Parse error  Parser ϴ. code listȴ.

  ------------------------------------------------------------------------

E_CORE_ERROR

  ------------------------------------------------------------------------

E_CORE_WARNING

  ------------------------------------------------------------------------

Hitchhiker's guide to PHP internals

  ------------------------------------------------------------------------

Appendix C. The PHP Debugger

  ------------------------------------------------------------------------

Using the Debugger

PHP  Ŵ ľϱ  ׸ ãƳµ ſ  ̴.
Ŵ PHP ۵  TCP Ʈ Ͽ Ѵ. 䱸  
 ޼    ޵ȴ. This information is intended for
"debugging server" that can run inside an IDE or programmable editor (such
as Emacs).

debugger  :

     php3.ini (debugger.port) Ÿ  TCP Ʈ ϰ
     (debugger.enabled)  enbleŲ.

      ýۿ TCP listener  Ʈ Ѵ. (
     UNIX socket -l -s 1400  Ѵ).

     code "debugger_on(host)" Ѵ. host  TCP listener 
     ִ ý IP ȣ host ̸̴.

,  warning notice  listener socket ǥõ ̴. 
 error_reporting() ؼ report ϵ ص  Ʈ
Ѵ.

  ------------------------------------------------------------------------

Debugger Protocol

debugger protocol  ̴.   type  ְ, 
ϳ ޼ Ѵ.  ޼ start type  ϰ, end
type . PHP ÿ  ٸ ޼    ִ.

    format Ǿ ִ.:

date time host(pid) type: message-data

date

Date in ISO 8601 format (yyyy-mm-dd)
time

Time including microseconds: hh:mm:uuuuuu
host

script error   DNS name ̳ IP address
pid

   PHP script process host PID (process id)
type

 type. Tells the receiving program about what it should treat the
following data as:

Table C-1. Debugger Line Types
 Name    Meaning
 start   Tells the receiving program that a debugger message starts here.
         The contents of data will be the type of error message, listed
         below.
 message The PHP error message.
 locationFile name and line number where the error occured. The first
         location line will always contain the top-level location. data
         will contain file:line. There will always be a location line
         after message and after every function.
 frames  Number of frames in the following stack dump. If there are four
         frames, expect information about four levels of called functions.
         If no "frames" line is given, the depth should be assumed to be 0
         (the error occured at top-level).
 functionName of function where the error occured. Will be repeated once
         for every level in the function call stack.
 end     Tells the receiving program that a debugger message ends here.

data

Line data.

Table C-2. Debugger Error Types
 Debugger    PHP Internal
 warning     E_WARNING
 error       E_ERROR
 parse       E_PARSE
 notice      E_NOTICE
 core-error  E_CORE_ERROR
 core-warningE_CORE_WARNING
 unknown     (any other)

Example C-1. Example Debugger Message

1998-04-05 23:27:400966 lucifer.guardian.no(20481) start: notice
1998-04-05 23:27:400966 lucifer.guardian.no(20481) message: Uninitialized variable
1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: (null):7
1998-04-05 23:27:400966 lucifer.guardian.no(20481) frames: 1
1998-04-05 23:27:400966 lucifer.guardian.no(20481) function: display
1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: /home/ssb/public_html/test.php3:10
1998-04-05 23:27:400966 lucifer.guardian.no(20481) end: notice


