cvs: phpdoc-ja /appendices migration5.xml

From: Date: Fri, 27 Feb 2004 04:39:45 +0000
Subject: cvs: phpdoc-ja /appendices migration5.xml
Groups: php.doc.ja 
Request: Send a blank email to doc-ja+get-683@lists.php.net to get a copy of this message
hirokawa Thu Feb 26 23:39:45 2004 EDT Added files: /phpdoc-ja/appendices migration5.xml Log: added migration5.xml in ja.

http://cvs.php.net/co.php/phpdoc-ja/appendices/migration5.xml?r=1.1&p=1 Index: phpdoc-ja/appendices/migration5.xml +++ phpdoc-ja/appendices/migration5.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.9 Maintainer: hirokawa Status: working --> <appendix id="migration5"> <title>PHP 4 から PHP 5への移行</title> <section id='migration5.changes'> <title>PHP 5における変更点</title> <para> PHP 5 および PHP 5に組み込まれたZend Engine 2 により、PHPの性能と機能は 著しく向上させます。同時に既存のコードへの影響を最小限とするよう配慮されている ため、PHP 4から5への移行は非常に簡単なはずです。 多くの既存の PHP 4用のコードは、変更せずに動作するはずです。 しかし、<link linkend="migration5.incompatible">若干の差異</link>に ついても知っておく必要があります。 また、実運用環境のバージョンを変更する前にあなたのコードを十分にテストする 必要があります。 </para> </section> <section id="migration5.incompatible"> <title>下位互換性のない変更点</title> <para> 多くの既存のPHP 4のコードは変更無しで動作するはずですが、 以下の下位互換性がない変更点について注意する必要があります。 </para> <itemizedlist> <listitem><simpara> <function>strrpos</function> と <function>strripos</function> は、 needleとして文字列全体を使用するようになりました。 </simpara></listitem> <listitem><simpara> 文字列オフセットの不正な使用は、<constant>E_WARNING</constant>ではなく、 <constant>E_ERROR</constant> を発生します。 </simpara></listitem> <listitem><simpara> <function>array_merge</function> は、配列のみを指定できるよう 変更されました。配列以外の変数を指定した場合は、各パラメータ毎に <constant>E_WARNING</constant> が発生します。あなたのコードで 突然 <constant>E_WARNING</constant> が発生し始める可能性が あるため注意して下さい。 </simpara></listitem> <listitem><simpara> サーバー変数PATH_TRANSLATEDは、Apache2 SAPIでは暗黙のうちに設定されません。 この動作は、Apacheにより設定されていない場合にSCRIPT_FILENAMEと同じ値に 設定するPHP 4と異なります。 この変更は、<ulink url="&url.cgispecs;">CGIの規約</ulink>に従う ためのものです。詳細については、 <ulink url="&url.php.bugs;23610">bug #23610</ulink> を参照して下さい。 </simpara></listitem> <listitem><simpara> 定数 <constant>T_ML_CONSTANT</constant> は、 <link linkend="ref.tokenizer">Tokenizer</link> 拡張モジュールで 定義されなくなりました。error_reportingに<constant>E_ALL</constant> を指定した場合、PHPは通知(notice)を生成します。 /* */ については、<constant>T_ML_CONSTANT</constant> の代わりに <constant>T_COMMENT</constant> 定数が使用され、これにより、 // と /* */ が共に <constant>T_COMMENT</constant> 定数で解釈される ことになります。しかし、PHP5からPHPにより解釈されるようになった PHPDoc形式のコメント /** */ は、<constant>T_DOC_COMMENT</constant> と認識されます。 </simpara></listitem> <listitem><simpara> <link linkend="ini.variables-order">variables_order</link> に "S"が含まれる場合に、$_SERVER が argcおよびargv と共に設定されます。 $_SERVERを作成しないような特別な設定を行った場合、当然、argcおよびargv は 設定されません。 この変更は、CLI版において <link linkend="ini.variables-order">variables_order</link>の 設定によらず常にargcおよびargvを作成するために行われました。 これにより、CLI版では、常にグローバル変数 $argc および $argv が設定されるようになりました。 <!-- $_SERVER should be populated with argc and argv if <link linkend="ini.variables-order">variables_order</link> includes "S". If you have specifically configured your system to not create $_SERVER, then of course it shouldn't be there. The change was to always make argc and argv available in the CLI version regardless of the <link linkend="ini.variables-order">variables_order</link> setting. As in, the CLI version will now always populate the global $argc and $argv variables. --> </simpara></listitem> <listitem><simpara> クラスは、使用前に宣言する必要があります。 </simpara></listitem> </itemizedlist> <para> <example> <title><function>strrpos</function> と <function>strripos</function> は、 needleとして文字列全体を使用する</title> <programlisting role="php"> <![CDATA[ <?php var_dump(strrpos('ABCDEF','DEF')); //int(3) var_dump(strrpos('ABCDEF','DAF')); //bool(false) ?> ]]> </programlisting> </example> </para> <para> 以下の例はPHP 4では有効でしたが、PHP 5では致命的なエラーを 発生します。 </para> <para> <example> <title>クラスは使用前に宣言する必要がある</title> <programlisting role="php"> <![CDATA[ <?php $test = new fubar(); $test->barfu(); class fubar { function barfu() { echo 'fubar'; } } ?> ]]> </programlisting> </example> </para> </section> <section id="migration5.cli-cgi"> <title>CLI と CGI</title> <para> PHP 5 では、CLI および CGI のファイル名にいくつかの変更があります。 PHP 5 では、CGI版は <literal>php-cgi.exe</literal> に変更されました。 (以前は <literal>php.exe</literal>) CLI版はメインディレクトリに 置かれるようになりました。(以前は、<literal>cli/php.exe</literal>)) </para> <para> PHP 5では、新しいモード <literal>php-win.exe</literal> が追加されました。 これは、CLI版と同じですが、php-win は出力を行わず、コンソールを提供しない ところが異なります。("DOS窓"は現れません。) この動作は、php-gtk に似ています。 </para> <para> PHP 5では、CLI版は常にグローバル変数$argv と $argcを設定します。 </para> </section> <section id="migration5.configuration"> <title>設定ファイルの移行</title> <para> SAPIモジュールの名前がphp4xxxからphp5xxxに変更されたため、 設定ファイルを変更すうr必要があります。 また、CLIおよびCGIのファイル名も変更されています。詳細については、 <link linkend="migration5.cli-cgi">対応するセクション</link>を 参照して下さい。 </para> <para> Apache設定の移行は非常に簡単です。必要な変更については、 以下の例を参照して下さい。 <informalexample> <programlisting role="apache-conf"> <![CDATA[ # change this line: LoadModule php4_module /php/sapi/php4apache2.dll # with this one: LoadModule php5_module /php/php5apache2.dll ]]> </programlisting> </informalexample> </para> <para> サーバ上でCGIモードでPHPを実行している場合、 CGI版の名前がphp.exeからphp-cgi.exeに変更されたことに注意する必要があります。 Apacheでは、以下のようにする必要があります。 <informalexample> <programlisting role="apache-conf"> <![CDATA[ # change this line: Action application/x-httpd-php "/php/php.exe" # with this one: Action application/x-httpd-php "/php/php-cgi.exe" ]]> </programlisting> </informalexample> </para> <para> 他のWebサーバの場合、CGIまたはSAPIモジュールのファイル名を変更する必要があります。 </para> </section> <section id="migration5.functions"> <title>新しい関数</title> <para> PHP 5では、新しい関数がいくつかあります。 以下にそれらのリストを示します。 </para> <para>配列:</para> <itemizedlist> <listitem><simpara> <function>array_combine</function> - Creates an array by using one array for keys and another for its values </simpara></listitem> <listitem><simpara> <function>array_diff_uassoc</function> - Computes the difference of arrays with additional index check which is performed by a user supplied callback function </simpara></listitem> <listitem><simpara> <function>array_udiff</function> - Computes the difference of arrays by using a callback function for data comparison </simpara></listitem> <listitem><simpara> <function>array_udiff_assoc</function> - Computes the difference of arrays with additional index check. The data is compared by using a callback function </simpara></listitem> <listitem><simpara> <function>array_udiff_uassoc</function> - Computes the difference of arrays with additional index check. The data is compared by using a callback function. The index check is done by a callback function also </simpara></listitem> <listitem><simpara> <function>array_walk_recursive</function> - Apply a user function recursively to every member of an array </simpara></listitem> </itemizedlist> <para>InterBase:</para> <itemizedlist> <listitem><simpara> <function>ibase_affected_rows</function> - Return the number of rows that were affected by the previous query </simpara></listitem> <listitem><simpara> <function>ibase_backup</function> - Initiates a backup task in the service manager and returns immediately </simpara></listitem> <listitem><simpara> <function>ibase_commit_ret</function> - Commit a transaction without closing it </simpara></listitem> <listitem><simpara> <function>ibase_db_info</function> - Request statistics about a database </simpara></listitem> <listitem><simpara> <function>ibase_drop_db</function> - Drops a database </simpara></listitem> <listitem><simpara> <function>ibase_errcode</function> - Return an error code </simpara></listitem> <listitem><simpara> <function>ibase_free_event_handler</function> - Cancels a registered event handler </simpara></listitem> <listitem><simpara> <function>ibase_gen_id</function> - Increments the named generator and returns its new value </simpara></listitem> <listitem><simpara> <function>ibase_maintain_db</function> - Execute a maintenance command on the database server </simpara></listitem> <listitem><simpara> <function>ibase_name_result</function> - Assigns a name to a result set </simpara></listitem> <listitem><simpara> <function>ibase_num_params</function> - Return the number of parameters in a prepared query </simpara></listitem> <listitem><simpara> <function>ibase_param_info</function> - Return information about a parameter in a prepared query </simpara></listitem> <listitem><simpara> <function>ibase_restore</function> - Initiates a restore task in the service manager and returns immediately </simpara></listitem> <listitem><simpara> <function>ibase_rollback_ret</function> - Rollback transaction and retain the transaction context </simpara></listitem> <listitem><simpara> <function>ibase_server_info</function> - Request statistics about a database </simpara></listitem> <listitem><simpara> <function>ibase_service_attach</function> - Connect to the service manager </simpara></listitem> <listitem><simpara> <function>ibase_service_detach</function> - Disconnect from the service manager </simpara></listitem> <listitem><simpara> <function>ibase_set_event_handler</function> - Register a callback function to be called when events are posted </simpara></listitem> <listitem><simpara> <function>ibase_wait_event</function> - Wait for an event to be posted by the database </simpara></listitem> </itemizedlist> <para>iconv:</para> <itemizedlist> <listitem><simpara> <function>iconv_mime_decode</function> - Decodes a MIME header field </simpara></listitem> <listitem><simpara> <function>iconv_mime_decode_headers</function> - Decodes multiple MIME header fields at once </simpara></listitem> <listitem><simpara> <function>iconv_mime_encode</function> - Composes a MIME header field </simpara></listitem> <listitem><simpara> <function>iconv_strlen</function> - Returns the character count of string </simpara></listitem> <listitem><simpara> <function>iconv_strpos</function> - Finds position of first occurrence of a needle within a haystack </simpara></listitem> <listitem><simpara> <function>iconv_strrpos</function> - Finds the last occurrence of a needle within the specified range of haystack </simpara></listitem> <listitem><simpara> <function>iconv_substr</function> - Cut out part of a string </simpara></listitem> </itemizedlist> <para>Streams:</para> <itemizedlist> <listitem><simpara> <function>stream_copy_to_stream</function> - Copies data from one stream to another </simpara></listitem> <listitem><simpara> <function>stream_get_line</function> - Gets line from stream resource up to a given delimiter </simpara></listitem> <listitem><simpara> <function>stream_socket_accept</function> - Accept a connection on a socket created by <function>stream_socket_server</function> </simpara></listitem> <listitem><simpara> <function>stream_socket_client</function> - Open Internet or Unix domain socket connection </simpara></listitem> <listitem><simpara> <function>stream_socket_get_name</function> - Retrieve the name of the local or remote sockets </simpara></listitem> <listitem><simpara> <function>stream_socket_recvfrom</function> - Receives data from a socket, connected or not </simpara></listitem> <listitem><simpara> <function>stream_socket_sendto</function> - Sends a message to a socket, whether it is connected or not </simpara></listitem> <listitem><simpara> <function>stream_socket_server</function> - Create an Internet or Unix domain server socket </simpara></listitem> </itemizedlist> <para>Other:</para> <itemizedlist> <listitem><simpara> <function>convert_uudecode</function> - decode a uuencoded string </simpara></listitem> <listitem><simpara> <function>convert_uuencode</function> - uuencode a string </simpara></listitem> <listitem><simpara> <function>dba_key_split</function> - Splits a key in string representation into array representation </simpara></listitem> <listitem><simpara> <function>dbase_get_header_info</function> - Get the header info of a dBase database </simpara></listitem> <listitem><simpara> <function>dbx_fetch_row</function> - Fetches rows from a query-result that had the DBX_RESULT_UNBUFFERED flag set </simpara></listitem> <listitem><simpara> <function>file_put_contents</function> - Write a string to a file </simpara></listitem> <listitem><simpara> <function>ftp_alloc</function> - Allocates space for a file to be uploaded </simpara></listitem> <listitem><simpara> <function>get_declared_interfaces</function> - Returns an array of all declared interfaces </simpara></listitem> <listitem><simpara> <function>get_headers</function> - Fetches all the headers sent by the server in response to a HTTP request </simpara></listitem> <listitem><simpara> <function>headers_list</function> - Returns a list of response headers sent (or ready to send) </simpara></listitem> <listitem><simpara> <function>http_build_query</function> - Generate URL-encoded query string </simpara></listitem> <listitem><simpara> <function>idate</function> - Format a local time/date as integer </simpara></listitem> <listitem><simpara> <function>image_type_to_extension</function> - Get file extension for image-type returned by <function>getimagesize</function>, <function>exif_read_data</function>, <function>exif_thumbnail</function>, <function>exif_imagetype</function> </simpara></listitem> <listitem><simpara> <function>imagefilter</function> - Applies Filter an image using a custom angle </simpara></listitem> <listitem><simpara> <function>imap_getacl</function> - Gets the ACL for a given mailbox </simpara></listitem> <listitem><simpara> <function>ldap_sasl_bind</function> - Bind to LDAP directory using SASL </simpara></listitem> <listitem><simpara> <function>pcntl_getpriority</function> - Get the priority of any process </simpara></listitem> <listitem><simpara> <function>pcntl_wait</function> - Waits on or returns the status of a forked child as defined by the waitpid() system call </simpara></listitem> <listitem><simpara> <function>pg_version</function> - Returns an array with client, protocol and server version (when available) </simpara></listitem> <listitem><simpara> <function>php_check_syntax</function> - Check the syntax of the specified file </simpara></listitem> <listitem><simpara> <function>php_strip_whitespace</function> - Return source with stripped comments and whitespace </simpara></listitem> <listitem><simpara> <function>proc_nice</function> - Change the priority of the current process </simpara></listitem> <listitem><simpara> <function>pspell_config_data_dir</function> - Change location of language data files </simpara></listitem> <listitem><simpara> <function>pspell_config_dict_dir</function> - Change location of the main word list </simpara></listitem> <listitem><simpara> <function>setrawcookie</function> - Send a cookie with no url encoding of the value </simpara></listitem> <listitem><simpara> <function>snmp_read_mib</function> - Reads and parses a MIB file into the active MIB tree </simpara></listitem> <listitem><simpara> <function>sqlite_fetch_column_types</function> - Return an array of column types from a particular table </simpara></listitem> <listitem><simpara> <function>str_split</function> - Convert a string to an array </simpara></listitem> <listitem><simpara> <function>strpbrk</function> - Search a string for any of a set of characters </simpara></listitem> <listitem><simpara> <function>substr_compare</function> - Binary safe optionally case insensitive comparison of two strings from an offset, up to length characters </simpara></listitem> <listitem><simpara> <function>time_nanosleep</function> - Delay for a number of seconds and nano seconds </simpara></listitem> </itemizedlist> </section> <section id="migration5.newconf"> <title>新しいディレクティブ</title> <para> &php.ini にも変更が行われており、PHP 5でディレクティブが 追加されています。以下のそのリストを示します。 </para> <itemizedlist> <listitem><simpara> mail.force_extra_paramaters - 指定されたパラメータをextraパラメータとしてsendmailバイナリに強制的に追加 します。これらのパラメータは、セーフモードの場合でも <function>mail</function> の5番目のパラメータの値を置換します。 </simpara></listitem> <listitem><simpara> <link linkend="ini.register-long-arrays">register_long_arrays</link> - は、古い $HTTP_*_VARS をPHPが登録するかどうかを設定します。 </simpara></listitem> <listitem><simpara> <link linkend="ini.session.hash-function">session.hash_function</link> - は、ハッシュ関数を選択します。(MD5またはSHA-1) </simpara></listitem> <listitem><simpara> <link linkend="ini.session.hash-bits-per-character">session.hash_bits_per_character</link> - は、バイナリハッシュデータを可読な形式に変換する際に各文字に保存するビット数 (4 から 6 まで)を指定します。 </simpara></listitem> </itemizedlist> </section> <section id="migration5.databases"> <title>データベース</title> <para> PHP 5では、データベースに関していくつかの変更があります。(MySQL および SQLite). </para> <para> PHP 5では、ライセンス上の問題やその他の問題により、MySQLクライアントライブラリは バンドルされていません。 詳細については、<link linkend="faq.databases.mysql.php5"> FAQエントリ</link>を参照して下さい。 </para> <para> 新しい拡張モジュールとして、MySQL 4.1以降で動作するよう設計された <link linkend="ref.mysqli">MySQLi (Improved MySQL)</link> もあります。 </para> <para> PHP 5以降、<link linkend="ref.sqlite">SQLite</link> 拡張モジュールが PHPに組み込まれています。 SQLiteは、組み込み可能なSQLデータベースエンジンで、 (MySQLまたはPostgreSQLのような) 大きなデータベースサーバーへの接続に使用されるクライアントライブラリでは ありません。SQLiteは組み込み可能なSQLデータベースエンジンで、 クライアントライブラリではなく、ディスク上のデータベースファイルから 直接読み書きします。 </para> </section> <section id='migration5.oop'> <title>新しいオブジェクトモデル</title> <para> PHP 5では、新しいオブジェクトモデルが採用されています。 PHPにおけるオブジェクトの処理は完全に書き直され、性能と機能が向上しています。 詳細については、<ulink url="http://www.php.net/zend-engine-2.php">http://www.php.net/zend-engine-2.php</ulink> を参照して下さい。 </para> </section> </appendix> <!-- 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 indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.doc.ja (#683) next »