CVS update: php3/doc/chapters
| From: | eschmid | Date: | Sun, 06 Dec 1998 12:47:56 +0000 |
| Subject: | CVS update: php3/doc/chapters | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-2682@lists.php.net to get a copy of this message | ||
Date: Sunday December 6, 1998 @ 7:47
Author: eschmid
Update of /repository/php3/doc/chapters
In directory asf:/u/temp/cvs-serv9360
Modified Files:
features.sgml
Log Message:
Typo in image creation. Made regular expressions example more readable.
Index: php3/doc/chapters/features.sgml
diff -c php3/doc/chapters/features.sgml:1.17 php3/doc/chapters/features.sgml:1.18
*** php3/doc/chapters/features.sgml:1.17 Sun Oct 25 10:11:44 1998
--- php3/doc/chapters/features.sgml Sun Dec 6 07:47:55 1998
***************
*** 58,67 ****
<sect1 id="feature-images">
<title>GIF creation with PHP</title>
<simpara>
! PHP is not limited to creating just HTML output. It can also be
! used to create GIF image files, or even more convenient GIF image streams.
! You will need to compile PHP with the GD library of image functions for
! this to work.
</simpara>
<para>
<example>
--- 58,67 ----
<sect1 id="feature-images">
<title>GIF creation with PHP</title>
<simpara>
! PHP is not limited to creating just HTML output. It can also be
! used to create GIF image files, or even more convenient GIF image
! streams. You will need to compile PHP with the GD library of
! image functions for this to work.
</simpara>
<para>
<example>
***************
*** 72,105 ****
$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);
?>
</programlisting></example>
! This example would be called from a page with a tag like:
! <img src="button.php?text">
! The above button.php3 script then takes this "text"
! string an overlays it on top of a base image which in this case
! is "images/button1.gif" and outputs the resulting
! image. This is a very convenient way to avoid having to draw
! new button images every time you want to change the text of a
! button. With this method they are dynamically generated.
</para>
<sect1 id="feature-fileupload">
<title>File upload support</title>
<simpara>
! PHP is capable of receiving file uploads from any RFC-1867 compliant
! browser. This feature lets people upload both text and binary
! files. With PHP's authentication and logical functions, you have full
! control over who is allowed to upload and what is to be done with the
! file once it has been uploaded.
</simpara>
<para>
! A file upload screen can be built by creating a special form which looks
! something like this:
<example>
<title>File Upload Form</title>
--- 72,106 ----
$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);
?>
</programlisting></example>
!
! This example would be called from a page with a tag like: <img
! src="button.php3?text"> The above button.php3 script
! then takes this "text" string an overlays it on top of a
! base image which in this case is "images/button1.gif"
! and outputs the resulting image. This is a very convenient way to
! avoid having to draw new button images every time you want to
! change the text of a button. With this method they are
! dynamically generated.
</para>
<sect1 id="feature-fileupload">
<title>File upload support</title>
<simpara>
! PHP is capable of receiving file uploads from any RFC-1867
! compliant browser. This feature lets people upload both text and
! binary files. With PHP's authentication and logical functions,
! you have full control over who is allowed to upload and what is to
! be done with the file once it has been uploaded.
</simpara>
<para>
! A file upload screen can be built by creating a special form which
! looks something like this:
<example>
<title>File Upload Form</title>
***************
*** 110,227 ****
<INPUT TYPE="submit" VALUE="Send File">
</FORM>
</programlisting></example>
! The _URL_ should point to a php html file. The MAX_FILE_SIZE hidden
! field must precede the file input field and its value is the maximum filesize
! accepted. The value is in bytes. In this destination file, the following
! variables will be defined upon a successful upload:
<para>
! <itemizedlist>
! <listitem><simpara>$userfile - The temporary filename in which the uploaded file was
stored on
! the server machine.</simpara></listitem>
! <listitem><simpara>$userfile_name - The original name of the file on the
sender's system.</simpara></listitem>
! <listitem><simpara>$userfile_size - The size of the uploaded file in
bytes.<simpara></listitem>
! <listitem><simpara>$userfile_type - The mime type of the file if the browser provided
this information.
! An example would be "image/gif".</simpara></listitem>
! </itemizedlist>
! Note that the "$userfile" part of the above variables is whatever the name
of
! the INPUT field of TYPE=file is in the upload form. In the above upload form example,
! we chose to call it "userfile".
! <simpara>
! Files will by default be stored in the server's default temporary directory. This
! can be changed by setting the environment variable TMPDIR in the environment in which
! PHP runs. Setting it using a PutEnv() call from within a PHP script will not
! work though.
! <simpara>
! The PHP script which receives the uploaded file should implement whatever
! logic is necessary for determining what should be done with the uploaded file.
! You can for example use the $file_size variable to throw away any files that are
! either too small or too big. You could use the $file_type variable to throw away
! any files that didn't match a certain type criteria. Whatever the logic, you should
! either delete the file from the temporary directory or move it elsewhere.
! <simpara>
! Please note that the CERN httpd seems to strip off everything starting at
! the first whitespace in the content-type mime header it gets from the
! client. As long as this is the case, CERN httpd will not support the
! file upload feature.
<sect1 id="feature-cookies">
<title>HTTP cookie support</title>
<para>
! PHP transparently supports HTTP cookies. Cookies are a mechanism for storing data in
! the remote browser and thus tracking or identifying return users.
! You can set cookies using the <function>setcookie</function> function. Cookies are
! part of the HTTP header, so the SetCookie() function must be called before any output
! is sent to the browser. This is the same restriction as for the
<function>Header</function>
! function.
! <para>
! Any cookies sent to you from the client will automatically be turned into a PHP
! variable just like GET and POST method data. If you wish to assign multiple values to
! a single cookie, just add <emphasis>[]</emphasis> to the cookie name.
! For more details see the <function>setcookie</function> function.
! </para>
<sect1 id="feature-databases">
<title>Database support</title>
<simpara>
! PHP supports a number of different databases in both native mode and through ODBC.
! </simpara>
<sect1 id="feature-regexps">
<title>Regular expressions</title>
<para>
! Regular expressions are used for complex string manipulation in PHP. The functions
! that support regular expressions are:
! <itemizedlist>
! <listitem><simpara><function>ereg</function></listitem>
! <listitem><simpara><function>ereg_replace</function></listitem>
! <listitem><simpara><function>eregi</function></listitem>
! <listitem><simpara><function>eregi_replace</function></listitem>
! <listitem><simpara><function>split</function></listitem>
! </itemizedlist>
! These functions all take a regular expression string as their first argument. PHP uses
! the Posix extended regular expressions as defined by Posix 1003.2. For a full description
! of Posix regular expressions see the regex man pages included in the regex directory in
! the PHP distribution.
</para>
<para>
<example>
<title>Regular expression examples</title>
<programlisting>
! 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. */
</programlisting></example>
</para>
<sect1 id="feature-error-handling">
<title>Error handling</title>
<para>
! There are 4 types of errors and warnings in PHP. They are:
! <itemizedlist>
! <listitem><simpara>1 - Normal Function Errors
! <listitem><simpara>2 - Normal Warnings
! <listitem><simpara>4 - Parser Errors
! <listitem><simpara>8 - Notices (warnings you can ignore but which may imply a bug in
your code)
! </itemizedlist>
! <simpara>
! The above 4 numbers are added up to define an error reporting level. The default error reporting
! level is 7 which is 1 + 2 + 4, or everything except notices. This level can be changed in the
php3.ini
! file with the error_reporting directive. It can also be set in your Apache httpd.conf file with
the
! php3_error_reporting directive or lastly it may be set at runtime within a script using the
! <function>error_reporting</function> function.
! <simpara>
All <link linkend="lang-expr">PHP expressions</link> can also be called
with the "@" prefix, which turns off error reporting for that particular
expression. If an error occurred during such an expression and the
<link linkend="ini.track-errors">track_errors</link> feature
is enabled, you can find the error message in the global variable
$php_errormsg.
! </simpara>
<sect1 id="feature-source-viewer">
<title>PHP source viewer</title>
--- 111,298 ----
<INPUT TYPE="submit" VALUE="Send File">
</FORM>
</programlisting></example>
!
! The _URL_ should point to a php html file. The MAX_FILE_SIZE
! hidden field must precede the file input field and its value is
! the maximum filesize accepted. The value is in bytes. In this
! destination file, the following variables will be defined upon a
! successful upload:
<para>
! <itemizedlist>
! <listitem>
! <simpara>
! $userfile - The temporary filename in which the uploaded file
! was stored on the server machine.
! </simpara>
! </listitem>
! <listitem>
! <simpara>
! $userfile_name - The original name of the file on the sender's
! system.
! </simpara>
! </listitem>
! <listitem>
! <simpara>
! $userfile_size - The size of the uploaded file in bytes.
! </simpara>
! </listitem>
! <listitem>
! <simpara>
! $userfile_type - The mime type of the file if the browser
! provided this information. An example would be
! "image/gif".
! </simpara>
! </listitem>
! </itemizedlist>
!
! Note that the "$userfile" part of the above variables is
! whatever the name of the INPUT field of TYPE=file is in the upload
! form. In the above upload form example, we chose to call it
! "userfile".
!
! <simpara>
! Files will by default be stored in the server's default temporary
! directory. This can be changed by setting the environment
! variable TMPDIR in the environment in which PHP runs. Setting it
! using a PutEnv() call from within a PHP script will not work
! though.
! <simpara>
! The PHP script which receives the uploaded file should implement
! whatever logic is necessary for determining what should be done
! with the uploaded file. You can for example use the $file_size
! variable to throw away any files that are either too small or too
! big. You could use the $file_type variable to throw away any
! files that didn't match a certain type criteria. Whatever the
! logic, you should either delete the file from the temporary
! directory or move it elsewhere.
! <simpara>
! Please note that the CERN httpd seems to strip off everything
! starting at the first whitespace in the content-type mime header
! it gets from the client. As long as this is the case, CERN httpd
! will not support the file upload feature.
<sect1 id="feature-cookies">
<title>HTTP cookie support</title>
<para>
! PHP transparently supports HTTP cookies. Cookies are a mechanism
! for storing data in the remote browser and thus tracking or
! identifying return users. You can set cookies using the
! <function>setcookie</function> function. Cookies are part of the
! HTTP header, so the SetCookie() function must be called before any
! output is sent to the browser. This is the same restriction as
! for the <function>Header</function> function.
! <para>
! Any cookies sent to you from the client will automatically be
! turned into a PHP variable just like GET and POST method data. If
! you wish to assign multiple values to a single cookie, just add
! <emphasis>[]</emphasis> to the cookie name. For more details see
! the <function>setcookie</function> function.
! </sect1>
<sect1 id="feature-databases">
<title>Database support</title>
<simpara>
! PHP supports a number of different databases in both native mode
! and through ODBC.
! </sect1>
<sect1 id="feature-regexps">
<title>Regular expressions</title>
<para>
! Regular expressions are used for complex string manipulation in
! PHP. The functions that support regular expressions are:
!
! <itemizedlist>
! <listitem>
! <simpara><function>ereg</function>
! </listitem>
! <listitem>
! <simpara><function>ereg_replace</function>
! </listitem>
! <listitem>
! <simpara><function>eregi</function>
! </listitem>
! <listitem>
! <simpara><function>eregi_replace</function>
! </listitem>
! <listitem>
! <simpara><function>split</function>
! </listitem>
! </itemizedlist>
!
! These functions all take a regular expression string as their
! first argument. PHP uses the Posix extended regular expressions
! as defined by Posix 1003.2. For a full description of Posix
! regular expressions see the regex man pages included in the regex
! directory in the PHP distribution.
</para>
+
<para>
<example>
<title>Regular expression examples</title>
<programlisting>
! 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. */
</programlisting></example>
</para>
<sect1 id="feature-error-handling">
<title>Error handling</title>
+
<para>
! There are 4 types of errors and warnings in PHP. They are:
!
! <itemizedlist>
! <listitem><simpara>1 - Normal Function Errors
! <listitem><simpara>2 - Normal Warnings
! <listitem><simpara>4 - Parser Errors
! <listitem><simpara>8 - Notices (warnings you can ignore but which
! may imply a bug in your code)
! </itemizedlist>
!
! <simpara>
! The above 4 numbers are added up to define an error reporting
! level. The default error reporting level is 7 which is 1 + 2 + 4,
! or everything except notices. This level can be changed in the
! php3.ini file with the error_reporting directive. It can also be
! set in your Apache httpd.conf file with the php3_error_reporting
! directive or lastly it may be set at runtime within a script using
! the <function>error_reporting</function> function.
!
! <simpara>
All <link linkend="lang-expr">PHP expressions</link> can also be called
with the "@" prefix, which turns off error reporting for that particular
expression. If an error occurred during such an expression and the
<link linkend="ini.track-errors">track_errors</link> feature
is enabled, you can find the error message in the global variable
$php_errormsg.
!
! </sect1>
<sect1 id="feature-source-viewer">
<title>PHP source viewer</title>
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net