Will add the removed files soon.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@38988 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Egon Schmid 2001-01-09 12:26:23 +00:00
parent a8a8b56e06
commit 21a62e5546
4 changed files with 0 additions and 482 deletions

View file

@ -1,32 +0,0 @@
<chapter id="features.cookies">
<title>Cookies</title>
<para>
PHP는 HTTP Cookie를 투명하게(transparently) 지원한다.
Cookie 메카니즘은 트래킹이나 사용자 식별 등을 위해 원격 browser에
저장된 데이터를 돌려 받는 과정을 말한다.
여러분은 cookie를 설정하기 위해 <function>setcookie</function> 함수를 사용할 수 있다.
Cookie는 HTTP 헤더의 한 부분이므로, <function>setcookie</function> 함수는 브라우저로
보내는 어떤 데이터보다도 앞에 사용해야 한다.
이 제약은 <function>header</function> 함수와 같은 제약으로 보면 된다.</para>
<para>
클라이언트가 보내준 모든 cookie는 자동적으로 GET이나 POST 방식 데이터와 같은 PHP 변수로 변환된다.
만약 여러분이 동일한 cookie에 여러 값을 저장하고 싶다면 Cookie이름에 <emphasis>[]</emphasis>를 더하면 된다.
자세한 것은 <function>setcookie</function> 함수 설명을 참조하자.
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View file

@ -1,285 +0,0 @@
<chapter id="features.error-handling">
<title>Error Handling</title>
<para>
PHP에는 다음과 같은 여러 에러와 경고 형태가 있다.:
<table>
<title>PHP error types</title>
<tgroup cols="4">
<thead>
<row>
<entry>Value</entry>
<entry>Constant</entry>
<entry>Description</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry>E_ERROR</entry>
<entry>Normal Function Errors (일반적인 에러)</entry>
<entry/>
</row>
<row>
<entry>2</entry>
<entry>E_WARNING</entry>
<entry>Normal Warnings (일반적인 경고)</entry>
<entry/>
</row>
<row>
<entry>4</entry>
<entry>E_PARSE</entry>
<entry>Parser Errors (문법 에러)</entry>
<entry/>
</row>
<row>
<entry>8</entry>
<entry>E_NOTICE </entry>
<entry>
Notices (무시할 수 있는 알림이지만 버그의 가능성을 가지고 있는 경우)
</entry>
<entry/>
</row>
<row>
<entry>16</entry>
<entry>E_CORE_ERROR</entry>
<entry>fatal errors that occur during PHP's initial startup
(PHP가 처음 시작될 때 발생한 치명적 에러)</entry>
<entry>PHP 4 only</entry>
</row>
<row>
<entry>32</entry>
<entry>E_CORE_WARNING</entry>
<entry>warnings (non fatal errors) that occur during PHP's initial startup
(PHP가 처음 시작될 때 발생한 치명적이지 않은 경고)</entry>
<entry>PHP 4 only</entry>
</row>
<row>
<entry>64</entry>
<entry>E_COMPILE_ERROR</entry>
<entry>fatal compile-time errors (컴파일시 생긴 치명적 에러)</entry>
<entry>PHP 4 only</entry>
</row>
<row>
<entry>128</entry>
<entry>E_COMPILE_WARNING</entry>
<entry>compile-time warnings (non fatal errors) (컴파일시 발생한 치명적이지 않은 경고)</entry>
<entry>PHP 4 only</entry>
</row>
<row>
<entry>256</entry>
<entry>E_USER_ERROR</entry>
<entry>user-generated error message (사용자가 만든 에러 메세지)</entry>
<entry>PHP 4 only</entry>
</row>
<row>
<entry>512</entry>
<entry>E_USER_WARNING</entry>
<entry>user-generated warning message (사용자가 만든 경고 메세지)</entry>
<entry>PHP 4 only</entry>
</row>
<row>
<entry>1024</entry>
<entry>E_USER_NOTICE </entry>
<entry>user-generated notice message (사용자가 만든 알림 메세지)</entry>
<entry>PHP 4 only</entry>
</row>
<row>
<entry/>
<entry>E_ALL</entry>
<entry>all of the above, as supported (지원가능한 위의 것 모두)</entry>
<entry/>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
The above values (either numerical or symbolic) are used to build
up a bitmask that specifies which errors to report. You can use the
<link linkend="language.operators.bitwise">bitwise operators</link>
to combine these values or mask out certain types of errors. Note
that only '|', '~', '!', and '&amp;' will be understood within
<filename>php.ini</filename>, however, and that no bitwise
operators will be understood within <filename>php3.ini</filename>.
</para>
<para>
In PHP 4, the default <link linkend="ini.error-reporting">error_reporting</link> setting is
<literal>E_ALL &amp; ~E_NOTICE</literal>, meaning to display all errors
and warnings which are not E_NOTICE-level. In PHP 3, the default
setting is <literal>(E_ERROR | E_WARNING | E_PARSE)</literal>,
meaning the same thing. Note, however, that since constants are not
supported in PHP 3's <filename>php3.ini</filename>, the <link linkend="ini.error-reporting">error_reporting</link> setting there
must be numeric; hence, it is <literal>7</literal>.
</para>
<para>
The initial setting can be changed in the ini file with the <link linkend="ini.error-reporting">error_reporting</link> directive, in
your Apache <filename>httpd.conf</filename> file with the
php_error_reporting (php3_error_reporting for PHP 3) directive, and
lastly it may be set at runtime within a script by using the
<function>error_reporting</function> function.
</para>
<warning>
<para>
When upgrading code or servers from PHP 3 to PHP 4 you should
check these settings and calls to
<function>error_reporting</function> or you might disable
reporting the new error types, especially E_COMPILE_ERROR. This
may lead to empty documents without any feedback of what happened
or where to look for the problem.
</para>
</warning>
<para>
모든 <link linkend="language.expressions">PHP 표현식(expression)</link>은 "@"를 앞에 붙이고 호출되면 error reporting을 하지 않는다.
만약 <link linkend="ini.track-errors">track_errors</link> 옵션이 Enabled로 되어 있고 해당 문장에서 에러가 발생했다면,
$php_errormsg라는 전역변수에 에러 메시지가 담겨 있게 된다.
</para>
<warning>
<para>
Currently the <link linkend="language.operators.errorcontrol">@
error-control operator</link> prefix will even disable error
reporting for critical errors that will terminate script
execution. Among other things, this means that if you use <link linkend="language.operators.errorcontrol">@</link> to suppress
errors from a certain function and either it isn't available or
has been mistyped, the script will die right there with no
indication as to why.
</para>
</warning>
<para>
Below we can see an example of using the error handling capabilities in
PHP. We define a error handling function which logs the information into
a file (using an XML format), and e-mails the developer in case a critical
error in the logic happens.
<example>
<title>Using error handling in a script</title>
<programlisting role="php">
&lt;?php
// we will do our own error handling
error_reporting(0);
// user defined error handling function
function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars) {
// timestamp for the error entry
$dt = date(&quot;Y-m-d H:i:s (T)&quot;);
// define an assoc array of error string
// in reality the only entries we should
// consider are 2,8,256,512 and 1024
$errortype = array (
1 =&gt; &quot;Error&quot;,
2 =&gt; &quot;Warning&quot;,
4 =&gt; &quot;Parsing Error&quot;,
8 =&gt; &quot;Notice&quot;,
16 =&gt; &quot;Core Error&quot;,
32 =&gt; &quot;Core Warning&quot;,
64 =&gt; &quot;Compile Error&quot;,
128 =&gt; &quot;Compile Warning&quot;,
256 =&gt; &quot;User Error&quot;,
512 =&gt; &quot;User Warning&quot;,
1024=&gt; &quot;User Notice&quot;
);
// set of errors for which a var trace will be saved
$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
$err = &quot;&lt;errorentry&gt;\n&quot;;
$err .= &quot;\t&lt;datetime&gt;&quot;.$dt.&quot;&lt;/datetime&gt;\n&quot;;
$err .= &quot;\t&lt;errornum&gt;&quot;.$errno.&quot;&lt;/errnumber&gt;\n&quot;;
$err .= &quot;\t&lt;errortype&gt;&quot;.$errortype[$errno].&quot;&lt;/errortype&gt;\n&quot;;
$err .= &quot;\t&lt;errormsg&gt;&quot;.$errmsg.&quot;&lt;/errormsg&gt;\n&quot;;
$err .= &quot;\t&lt;scriptname&gt;&quot;.$filename.&quot;&lt;/scriptname&gt;\n&quot;;
$err .= &quot;\t&lt;scriptlinenum&gt;&quot;.$linenum.&quot;&lt;/scriptlinenum&gt;\n&quot;;
if (in_array($errno, $user_errors))
$err .= &quot;\t&lt;vartrace&gt;&quot;.wddx_serialize_value($vars,&quot;Variables&quot;).&quot;&lt;/vartrace&gt;\n&quot;;
$err .= &quot;&lt;/errorentry&gt;\n\n&quot;;
// for testing
// echo $err;
// save to the error log, and e-mail me if there is a critical user error
error_log($err, 3, &quot;/usr/local/php4/error.log&quot;);
if ($errno == E_USER_ERROR)
mail(&quot;phpdev@mydomain.com&quot;,&quot;Critical User Error&quot;,$err);
}
function distance ($vect1, $vect2) {
if (!is_array($vect1) || !is_array($vect2)) {
trigger_error(&quot;Incorrect parameters, arrays expected&quot;, E_USER_ERROR);
return NULL;
}
if (count($vect1) != count($vect2)) {
trigger_error(&quot;Vectors need to be of the same size&quot;, E_USER_ERROR);
return NULL;
}
for ($i=0; $i&lt;count($vect1); $i++) {
$c1 = $vect1[$i]; $c2 = $vect2[$i];
$d = 0.0;
if (!is_numeric($c1)) {
trigger_error(&quot;Coordinate $i in vector 1 is not a number, using zero&quot;,
E_USER_WARNING);
$c1 = 0.0;
}
if (!is_numeric($c2)) {
trigger_error(&quot;Coordinate $i in vector 2 is not a number, using zero&quot;,
E_USER_WARNING);
$c2 = 0.0;
}
$d += $c2*$c2 - $c1*$c1;
}
return sqrt($d);
}
$old_error_handler = set_error_handler(&quot;userErrorHandler&quot;);
// undefined constant, generates a warning
$t = I_AM_NOT_DEFINED;
// define some &quot;vectors&quot;
$a = array(2,3,&quot;foo&quot;);
$b = array(5.5, 4.3, -1.6);
$c = array (1,-3);
// generate a user error
$t1 = distance($c,$b).&quot;\n&quot;;
// generate another user error
$t2 = distance($b,&quot;i am not an array&quot;).&quot;\n&quot;;
// generate a warning
$t3 = distance($a,$b).&quot;\n&quot;;
?&gt;
</programlisting>
</example>
This is just a simple example showing how to use the
<link linkend="ref.errorfunc">Error Handling and Logging
functions</link>.
</para>
<para>
See also <function>error_reporting</function>,
<function>error_log</function>,
<function>set_error_handler</function>,
<function>restore_error_handler</function>,
<function>trigger_error</function>,
<function>user_error</function>
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View file

@ -1,116 +0,0 @@
<chapter id="features.http-auth">
<title>HTTP authentication with PHP</title>
<simpara>
(역자주. HTTP authentication이란 Web Client에게 ID와 Password를 입력받아,
그 ID와 Password로 Web문서에 접근을 허가, 불허하는 기능을 말한다.
자세히 알고 싶다면 RFC1945의 Authentication 부분을 참고하기 바란다.
http://pec.etri.re.kr/!qkim/HTTP/에 한글 번역 문서도 있으니 참조하자.)
</simpara>
<simpara>
PHP를 사용한 HTTP 인증은 Apache 모듈로 사용될 때만 동작한다.
CGI 버젼에서는 이 기능을 사용할 수 없다.
Apache 모듈의 PHP 스크립트에서 <function>Header</function>라는 함수를 사용하면
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"만이 지원된다.
자세한 사용법은 <function>Header</function> 함수를 살펴 보자.</simpara>
<para>
client authentication을 사용하여 그 입력된 값을 출력하는 예제가 아래에 있다. :
<example>
<title>HTTP Authentication example</title>
<programlisting role="php">
&lt;?php
if(!isset($PHP_AUTH_USER)) {
Header(&quot;WWW-Authenticate: Basic realm=\&quot;My Realm\&quot;&quot;);
Header(&quot;HTTP/1.0 401 Unauthorized&quot;);
echo &quot;Text to send if user hits Cancel button\n&quot;;
exit;
} else {
echo &quot;Hello $PHP_AUTH_USER.&lt;P&gt;&quot;;
echo &quot;You entered $PHP_AUTH_PW as your password.&lt;P&gt;&quot;;
}
?>
</programlisting>
</example>
</para>
<para>
여러분은 $PHP_AUTH_USER 와 $PHP_AUTH_PW를 단순히 출력하는 대신,
사용자의 식별을 위해 username과 password를 사용하기를 원할 것이다.
이때는 Database에 Query하거나 직접 dbm 파일에서 찾아보는 등의 방법으로 가능할 것이다.</para>
<para>
Internet Explorer browser에서는 버그로 인해 Header의 순서가 매우 까다롭다.
<emphasis>WWW-Authenticate</emphasis>
<errorcode>HTTP/1.0 401</errorcode>보다 먼저 보내는 것이 현재 가능한 트릭으로 보인다.
</para>
<simpara>
비밀번호의 유출을 우려하여 HTTP에서 제공하는 인증을 사용하는 대신
기존의 외부 메카니즘을 사용할 경우에는 물론 PHP_AUTH 변수는 설정되지 않는다.
이런경우 externally-authenticated user를 확인하기 위해 $REMOTE_USER 변수를 사용할 수 있다.
</simpara>
<simpara>
유의할 점은 인증이 필요한 페이지와 인증이 필요없는 페이지가 같은 서버상에 존재할 때,
인증이 필요없는 URL을 control할 수 있는 누군가가,
인증이 필요한 URL의 암호를 훔쳐보는 것은 막을 수 없다는 점이다.
</simpara>
<simpara>
Netscape와 Internet Explorer 모두 401응답 코드를 서버에서 받게되면
local browser window의 authentication cache를 clear한다.
즉, 이것은 "log out"개념이 되는 것으로, 사용자들로 하여금 username과 암호를 다시 입력하게 한다.
일부는 이것을 통해 login의 "time out"이나 "log-out"버튼을 만드는데 사용한다
</simpara>
<example>
<title>HTTP Authentication example forcing a new name/password</title>
<programlisting role="php">
&lt;?php
function authenticate() {
Header( &quot;WWW-authenticate: basic realm=\&quot;Test Authentication System\&quot;&quot;);
Header( &quot;HTTP/1.0 401 Unauthorized&quot;);
echo &quot;You must enter a valid login ID and password to access this resource\n&quot;;
exit;
}
if(!isset($PHP_AUTH_USER) || ($SeenBefore == 1 &amp;&amp; !strcmp($OldAuth, $PHP_AUTH_USER)) ) {
authenticate();
}
else {
echo &quot;Welcome: $PHP_AUTH_USER&lt;BR&gt;&quot;;
echo &quot;Old: $OldAuth&quot;;
echo &quot;&lt;FORM ACTION=\&quot;$PHP_SELF\&quot; METHOD=POST&gt;\n&quot;;
echo &quot;&lt;INPUT TYPE=HIDDEN NAME=\&quot;SeenBefore\&quot; VALUE=\&quot;1\&quot;&gt;\n&quot;;
echo &quot;&lt;INPUT TYPE=HIDDEN NAME=\&quot;OldAuth\&quot; VALUE=\&quot;$PHP_AUTH_USER\&quot;&gt;\n&quot;;
echo &quot;&lt;INPUT TYPE=Submit VALUE=\&quot;Re Authenticate\&quot;&gt;\n&quot;;
echo &quot;&lt;/FORM&gt;\n&quot;;
}
?>
</programlisting>
</example>
<simpara>
그러나 이 동작은 HTTP Basic authentication 기준에 보장된 것은 아니므로 이 기능에 의존하여서는 안된다.
Lynx에서는 401 서버 응답을 받아도 authentication 정보를 clear하지 않는다.
따라서 Back을 누르고 다시 Forward 버튼을 눌러서 다시 접근할 수 있다.</simpara>
<simpara>
또한 이 Authentication 기능은 Microsoft's IIS server에서
CGI version의 PHP를 사용할 경우에는 IIS의 제약으로인해 동작하지 않는다.
</simpara>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View file

@ -1,49 +0,0 @@
<chapter id="features.images">
<title>PHP에서 이미지 생성과 수정(Creating and manipulating images)</title>
<simpara>
PHP는 단지 HTML출력을 만드는 것만 할 수 있는 것이 아니다.
PHP는 GIF image file도 만들 수 있을 있을 뿐아니라,
사용하기에 편리한 GIF image stream까지 만들 수 있다.
이를 위해서 여러분은 PHP를 컴파일 할 때, image 함수를 가지고 있는 GD 라이브러리를 포함하여야 한다.
GD와 PHP는 사용하는 이미지 포맷 형태에 따라 다른 라이브러리도 요구한다.
GD는 버전 1.6부터 GIF 이미지 지원을 하지 않는다.
</simpara>
<para>
<example>
<title>PNG creation with PHP</title>
<programlisting role="php">
&lt;?php
Header("Content-type: image/png");
$string=implode($argv," ");
$im = imageCreateFromPng("images/button1.png");
$orange = ImageColorAllocate($im, 220, 210, 60);
$px = (imagesx($im)-7.5*strlen($string))/2;
ImageString($im,3,$px,9,$string,$orange);
ImagePng($im);
ImageDestroy($im);
?>
</programlisting>
</example>
위의 예제는 &lt;img src=&quot;button.php?text&quot;&gt; 와 같은 tag이 있는 페이지로부터 불려지게 될 것이다.
그러면 위에있는 button.php 스크립트는 "text"라는 문자열을
"images/button1.gif"에 오버레이 시켜 결과 image에 출력한다.
이렇게 하면 버튼에 들어가는 글씨를 매번 손쉽게 바꿔 쓸 수 있고,
또한 매번 이미지 파일을 만들 필요가 없어 효율적이고 간단하다.
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->