Index: phpdoc/ja/appendices/migration4.xml diff -u phpdoc/ja/appendices/migration4.xml:1.2 phpdoc/ja/appendices/migration4.xml:1.3 --- phpdoc/ja/appendices/migration4.xml:1.2 Tue Mar 13 14:59:45 2001 +++ phpdoc/ja/appendices/migration4.xml Sun May 20 00:43:01 2001 @@ -202,7 +202,7 @@

- 推奨されない関数と拡張Deprecate functions and extensions + 推奨されない関数と拡張 Adabas および Solid データベース拡張は、もはや推奨されません。 今後は、unified ODBC 拡張を代わりに使用して下さい。 Index: phpdoc/ja/functions/com.xml diff -u phpdoc/ja/functions/com.xml:1.5 phpdoc/ja/functions/com.xml:1.6 --- phpdoc/ja/functions/com.xml:1.5 Thu Jan 4 22:29:04 2001 +++ phpdoc/ja/functions/com.xml Sun May 20 00:43:01 2001 @@ -1,13 +1,233 @@ Windows用のCOMサポート関数 COM - + 以下の関数は、Windows版のPHPでのみ利用可能です。これらの関数は、 PHP4で追加されました。 + + + + COM + COM class + + + $obj = new COM("server.object") + + + 説明 + + COM クラスは、PHPスクリプトに統合された (D)COMコンポーネントのフ + レームワークを提供します。 + + + + メソッド + + + string COM::COM + string module_name + string + server_name + + int + codepage + + + + + COM クラスのコンストラクタ。 パラメータ: + + module_name + + + リクエストされたコンポーネントの名前またはクラスID。 + + + + server_name + + + コンポーネントを取得するDCOMサーバの名前。 + NULLの場合には、 + localhostが指定されたと仮定されます。 + DCOMを使用するためには、php.iniで + com.allow_dcom を + TRUEに設定してある必要があります。 + + + + codepage + + + PHPの文字列のUNICODE文字列への変換およびその逆変換で使用され + るコードページを指定します。使用可能な値は、 + CP_ACP, CP_MACCP, + CP_OEMCP, + CP_SYMBOL, + CP_THREAD_ACP, + CP_UTF7, CP_UTF8で + す。 + + + + + + + + COM の例 (1) + +// Wordを起動 +$word = new COM("word.application") or die("Unable to instanciate Word"); +print "Loaded Word, version {$word->Version}\n"; + +// 前面に表示 +$word->Visible = 1; + +// 空のドキュメントをオープン +$word->Documents->Add(); + +// 何か単純な作業をする +$word->Selection->TypeText("This is a test..."); +$word->Documents[1]->SaveAs("Useless test.doc"); + +// Wordを閉じる +$word->Quit(); + +// オブジェクトを開放 +$word->Release(); +$word = null; + + + + + + COM の例 (2) + +$conn = new COM("ADODB.Connection") or die("Cannot start ADO"); +$conn->Open("Provider=SQLOLEDB; Data Source=localhost; +Initial Catalog=database; User ID=user; Password=password"); + +$rs = $conn->Execute("SELECT * FROM sometable"); // Recordset + +$num_columns = $rs->Fields->Count(); +echo $num_columns . "\n"; + +for ($i=0; $i < $num_columns; $i++) +{ + $fld[$i] = $rs->Fields($i); +} + +$rowcount = 0; +while (!$rs->EOF) +{ + for ($i=0; $i < $num_columns; $i++) + { + echo $fld[$i]->value . "\t"; + } + echo "\n"; + $rowcount++; // 行カウンタを増やす + $rs->MoveNext(); +} + +$rs->Close(); +$conn->Close(); + +$rs->Release(); +$conn->Release(); + +$rs = null; +$conn = null; + + + + + + + + + VARIANT + VARIANT クラス + + + $vVar = new VARIANT($var) + + + 説明 + + VARIANT構造体に変数をラップするための簡単なコンテナクラス。 + + + + メソッド + + + string VARIANT::VARIANT + mixed + value + + int + type + + int + codepage + + + + + VARIANT クラスのコンストラクタ。 パラメータ: + + value + + + 初期値。省略した場合には、VT_EMPTYオブジェクトが作成されます。 + + + + type + + + VARIANTオブジェクトのcontent型を指定します。使用可能な値は、 + VT_UI1, VT_UI2, + VT_UI4, VT_I1, + VT_I2, VT_I4, + VT_R4, VT_R8, + VT_INT, VT_UINT, + VT_BOOL, VT_ERROR, + VT_CY, VT_DATE, + VT_BSTR, + VT_DECIMAL, + VT_UNKNOWN, + VT_DISPATCH, + VT_VARIANTです。これらの値は相互に排他的 + ですが、値があることを指定するために + VT_BYREFを組み合わせることが可能です。 + 省略された場合には、value の型が使用さ + れます。その他の情報については、MSDNライブラリを参照下さい。 + + + + codepage + + + PHPの文字列のUNICODE文字列への変換およびその逆変換で使用され + るコードページを指定します。使用可能な値は、 + CP_ACP, CP_MACCP, + CP_OEMCP, + CP_SYMBOL, + CP_THREAD_ACP, + CP_UTF7, CP_UTF8で + す。 + + + + + + + @@ -27,12 +247,22 @@ server name + int + + codepage + + com_loadは、新規のCOMコンポーネントを作成し、 このコンポーネントへのリファレンスを返します。失敗した場合に falseを返します。 + Possible values for codepage are + CP_ACP, CP_MACCP, + CP_OEMCP, CP_SYMBOL, + CP_THREAD_ACP, CP_UTF7 + and CP_UTF8. @@ -180,10 +410,50 @@ com_objectが指すCOMコンポーネントの - propertyの値を設定します。 - propertyが設定されている場合に - trueを返します。エラー時に - falseを返します。 + propertyの値を設定します。成功時に新規に設 + 定された値、エラーの場合にfalseを返します。 + + + + + + + com_addref + + コンポーネントリファレンスカウンタを増やす + + + + 説明 + + + void com_addref + + + + + コンポーネントリファレンスカウンタを増やします。 + + + + + + + com_release + + コンポーネントリファレンスカウンタを減らす + + + + 説明 + + + void com_release + + + + + コンポーネントリファレンスカウンタを減らします。 Index: phpdoc/ja/functions/dbx.xml diff -u phpdoc/ja/functions/dbx.xml:1.3 phpdoc/ja/functions/dbx.xml:1.4 --- phpdoc/ja/functions/dbx.xml:1.3 Sat May 5 21:54:00 2001 +++ phpdoc/ja/functions/dbx.xml Sun May 20 00:43:01 2001 @@ -214,7 +214,7 @@ Microsoft SQL Serverに関するエラーメッセージは、実際には - mssql_get_last_message 関数の結果となります。 + mssql_get_last_message 関数の結果となります。 Index: phpdoc/ja/functions/fbsql.xml diff -u phpdoc/ja/functions/fbsql.xml:1.1 phpdoc/ja/functions/fbsql.xml:1.2 --- phpdoc/ja/functions/fbsql.xml:1.1 Sat May 5 21:54:00 2001 +++ phpdoc/ja/functions/fbsql.xml Sun May 20 00:43:01 2001 @@ -1,5 +1,5 @@ - FrontBase 関数 + FrontBase functions FrontBase @@ -23,7 +23,9 @@ FrontBase に関するドキュメントは、&url.fbsql.docs; から入手可能です。 - + + Frontbase のサポートは、PHP 4.0.6 で追加されました。 + @@ -92,7 +94,7 @@ bool fbsql_autocommit - int + resource link_identifier bool @@ -106,6 +108,7 @@ fbsql_autocommit returns the current autocommit status. if the optional OnOff parameter is given the auto commit status will be changed. + @@ -120,7 +123,7 @@ 説明 - int fbsql_change_user + resource fbsql_change_user string user string password string @@ -141,21 +144,22 @@ optional parameter link_identifier. If a database is specified, this will default or current database after the user has been changed. If the new user and password authorization fails, - the current connected user stays active. + the current connected user stays active. + fbsql_close - FrontBase 接続を閉じる + Close FrontBase connection 説明 - int fbsql_close - int + boolean fbsql_close + resource link_identifier @@ -163,7 +167,7 @@ - Returns: true on success, false on error. + Returns: TRUE on success, FALSE on error. fbsql_close closes the connection to the FrontBase server that's associated with the specified link @@ -175,17 +179,15 @@ as non-persistent open links are automatically closed at the end of the script's execution. - - - FrontBase close example + <function>fbsql_close</function> example <?php $link = fbsql_connect ("localhost", "_SYSTEM", "secret") or die ("Could not connect"); print ("Connected successfully"); fbsql_close ($link); -?> +?> @@ -198,15 +200,13 @@ fbsql_connect - - FrontBase サーバへの接続をオープンする - + Open a connection to a FrontBase Server 説明 - int fbsql_connect + resource fbsql_connect string hostname @@ -248,7 +248,7 @@ fbsql_close. - FrontBase connect example + <function>fbsql_connect</function> example <?php @@ -260,7 +260,8 @@ ?> - See also + + See also fbsql_pconnect, and fbsql_close. @@ -270,15 +271,15 @@ fbsql_create_db - FrontBaseデータベースを作成する + Create a FrontBase database 説明 - int fbsql_create_db + bool fbsql_create_db string database name - int + resource link_identifier @@ -291,17 +292,17 @@ identifier. - FrontBase create database example + <function>fbsql_create_db</function> example <?php $link = fbsql_pconnect ("localhost", "_SYSTEM", "secret") or die ("Could not connect"); if (fbsql_create_db ("my_db")) { - print ("Database created successfully\n"); + print("Database created successfully\n"); } else { - printf ("Error creating database: %s\n", fbsql_error ()); + printf("Error creating database: %s\n", fbsql_error ()); } -?> +?> @@ -313,19 +314,19 @@ fbsql_data_seek - 内部的な結果ポインタを移動する + Move internal result pointer 説明 - int fbsql_data_seek - int result_identifier + bool fbsql_data_seek + resource result_identifier int row_number - Returns: true on success, false on failure. + Returns: TRUE on success, FALSE on failure. fbsql_data_seek moves the internal row @@ -338,7 +339,7 @@ - FrontBase data seek example + <function>fbsql_data_seek</function> example <?php $link = fbsql_pconnect ("localhost", "_SYSTEM", "secret") @@ -347,7 +348,7 @@ fbsql_select_db ("samp_db") or die ("Could not select database"); - $query = "SELECT last_name, first_name FROM friends"; + $query = "SELECT last_name, first_name FROM friends;"; $result = fbsql_query ($query) or die ("Query failed"); @@ -362,11 +363,11 @@ if(!($row = fbsql_fetch_object ($result))) continue; - printf ("%s %s<BR>\n", $row->last_name, $row->first_name); + printf("%s %s<BR>\n", $row->last_name, $row->first_name); } fbsql_free_result ($result); -?> +?> @@ -375,16 +376,16 @@ fbsql_db_query - FrontBaseクエリを送信する + Send a FrontBase query 説明 - int fbsql_db_query + resource fbsql_db_query string database string query - int + resource link_identifier @@ -393,7 +394,7 @@ Returns: A positive FrontBase result identifier to the query result, - or false on error. + or FALSE on error. fbsql_db_query selects a database and @@ -412,15 +413,15 @@ fbsql_drop_db - FrontBaseデータベースを破棄(削除)する + Drop (delete) a FrontBase database 説明 - int fbsql_drop_db + bool fbsql_drop_db string database_name - int + resource link_identifier @@ -428,7 +429,7 @@ - Returns: true on success, false on failure. + Returns: TRUE on success, FALSE on failure. fbsql_drop_db attempts to drop (remove) an @@ -441,16 +442,15 @@ fbsql_errno - - 直近のFrontBase処理によるエラーメッセージ番号を返す - + Returns the numerical value of the error message from previous + FrontBase operation 説明 int fbsql_errno - int + resource link_identifier @@ -477,9 +477,9 @@ echo fbsql_errno().": ".fbsql_error()."<BR>"; fbsql_select_db("nonexistentdb"); echo fbsql_errno().": ".fbsql_error()."<BR>"; -$conn = fbsql_query("SELECT * FROM nonexistenttable"); +$conn = fbsql_query("SELECT * FROM nonexistenttable;"); echo fbsql_errno().": ".fbsql_error()."<BR>"; -?> +?> @@ -493,16 +493,15 @@ fbsql_error - - 直近のFrontBase処理によるエラーメッセージのテキストを返す - + Returns the text of the error message from previous + FrontBase operation 説明 string fbsql_error - int + resource link_identifier @@ -528,9 +527,9 @@ echo fbsql_errno().": ".fbsql_error()."<BR>"; fbsql_select_db("nonexistentdb"); echo fbsql_errno().": ".fbsql_error()."<BR>"; -$conn = fbsql_query("SELECT * FROM nonexistenttable"); +$conn = fbsql_query("SELECT * FROM nonexistenttable;"); echo fbsql_errno().": ".fbsql_error()."<BR>"; -?> +?> @@ -545,7 +544,7 @@ fbsql_fetch_array - 連想配列、数値配列、または両方の配列として結果レコードを取得する + Fetch a result row as an associative array, a numeric array, or both. @@ -553,7 +552,7 @@ array fbsql_fetch_array - int result + resource result int result_type @@ -562,7 +561,7 @@ - Returns an array that corresponds to the fetched row, or false + Returns an array that corresponds to the fetched row, or FALSE if there are no more rows. fbsql_fetch_array is an extended version of @@ -598,7 +597,7 @@ fbsql_fetch_row and fbsql_fetch_assoc. - <function>fbsql_fetch_array</function> + <function>fbsql_fetch_array</function> example <?php fbsql_connect ($host, $user, $password); @@ -610,7 +609,7 @@ echo "fullname: ".$row[1]."<br>\n"; } fbsql_free_result ($result); -?> +?> @@ -620,7 +619,7 @@ fbsql_fetch_assoc - 連想配列として結果レコードを取得する + Fetch a result row as an associative array @@ -628,12 +627,12 @@ array fbsql_fetch_assoc - int result + resource result Returns an associative array that corresponds to the fetched row, - or false if there are no more rows. + or FALSE if there are no more rows. fbsql_fetch_assoc is equivalent to calling fbsql_fetch_array with FBSQL_ASSOC for the @@ -659,7 +658,7 @@ fbsql_fetch_row and fbsql_fetch_array. - <function>fbsql_fetch_assoc</function> + <function>fbsql_fetch_assoc</function> example <?php fbsql_connect ($host, $user, $password); @@ -669,7 +668,7 @@ echo $row["fullname"]; } fbsql_free_result ($result); -?> +?> @@ -679,7 +678,7 @@ fbsql_fetch_field - 結果からカラム情報を取得し、オブジェクトとして返す + Get column information from a result and return as an object @@ -687,7 +686,7 @@ object fbsql_fetch_field - int result + resource result int field_offset @@ -735,7 +734,7 @@ - <function>fbsql_fetch_field</function> + <function>fbsql_fetch_field</function> example <?php fbsql_connect ($host, $user, $password) @@ -760,7 +759,7 @@ $i++; } fbsql_free_result ($result); -?> +?> @@ -773,7 +772,7 @@ fbsql_fetch_lengths - 結果の各出力の長さを得る + Get the length of each output in a result @@ -781,16 +780,15 @@ array fbsql_fetch_lengths - int - - result - + resource + result + Returns: An array that corresponds to the lengths of each field in the last row fetched by fbsql_fetch_row, - or false on error. + or FALSE on error. fbsql_fetch_lengths stores the lengths of @@ -809,14 +807,14 @@ fbsql_fetch_object - オブジェクトとして結果レコードを取得する + Fetch a result row as an object 説明 object fbsql_fetch_object - int result + resource result int result_type @@ -826,7 +824,7 @@ Returns an object with properties that correspond to the fetched - row, or false if there are no more rows. + row, or FALSE if there are no more rows. fbsql_fetch_object is similar to @@ -856,7 +854,7 @@ echo $row->fullname; } fbsql_free_result ($result); -?> +?> @@ -870,18 +868,18 @@ fbsql_fetch_row - 数値配列として結果レコードを得る + Get a result row as an enumerated array 説明 array fbsql_fetch_row - int result + resource result - Returns: An array that corresponds to the fetched row, or false + Returns: An array that corresponds to the fetched row, or FALSE if there are no more rows. @@ -892,7 +890,7 @@ Subsequent call to fbsql_fetch_row would - return the next row in the result set, or false if there are no + return the next row in the result set, or FALSE if there are no more rows. @@ -909,7 +907,7 @@ fbsql_field_flags - 結果において指定したフィールドに関するフラグを得る + Get the flags associated with the specified field in a result @@ -917,7 +915,7 @@ string fbsql_field_flags - int result + resource result int field_offset @@ -934,7 +932,7 @@ fbsql_field_name - 結果において指定したフィールドの名前を得る + Get the name of the specified field in a result @@ -942,7 +940,7 @@ string fbsql_field_name - int result + resource result int field_index @@ -993,7 +991,7 @@ fbsql_field_len - 指定したフィールドの長さを得る + Returns the length of the specified field @@ -1001,7 +999,7 @@ int fbsql_field_len - int result + resource result int field_offset @@ -1016,15 +1014,15 @@ fbsql_field_seek - 指定したフィールドオフセットに結果ポインタを設定する + Set result pointer to a specified field offset 説明 - int fbsql_field_seek - int result + bool fbsql_field_seek + resource result int field_offset @@ -1044,7 +1042,7 @@ fbsql_field_table - 指定したフィールドがあるテーブルの名前を得る + Get name of the table the specified field is in @@ -1052,12 +1050,13 @@ string fbsql_field_table - int result + resource result int field_offset - 指定したフィールドがあるテーブルの名前を返します。 + Returns the name of the table that the specifed field is + in. @@ -1066,7 +1065,7 @@ fbsql_field_type - 結果の中で指定したフィールドの型を得る + Get the type of the specified field in a result @@ -1074,7 +1073,7 @@ string fbsql_field_type - int result + resource result int field_offset @@ -1086,13 +1085,13 @@ detailed in the FrontBase documentation. - fbsql field types + <function>fbsql_field_type</function> example <?php -fbsql_connect ("localhost:3306"); +fbsql_connect ("localhost", "_SYSTEM", ""); fbsql_select_db ("wisconsin"); -$result = fbsql_query ("SELECT * FROM onek"); +$result = fbsql_query ("SELECT * FROM onek;"); $fields = fbsql_num_fields ($result); $rows = fbsql_num_rows ($result); $i = 0; @@ -1109,7 +1108,7 @@ } fbsql_close(); -?> +?> @@ -1119,13 +1118,13 @@ fbsql_free_result - 結果保持用のメモリを開放する + Free result memory 説明 - int fbsql_free_result + bool fbsql_free_result int result @@ -1146,7 +1145,7 @@ fbsql_insert_id - 直近のINSERT処理で生成されたIDを得る + Get the id generated from the previous INSERT operation @@ -1154,7 +1153,7 @@ int fbsql_insert_id - int + resource link_identifier @@ -1163,14 +1162,14 @@ fbsql_insert_id returns the ID generated for - an AUTO_INCREMENT column by the previous INSERT query using the + an column defined as DEFAULT UNIQUE by the previous INSERT query using the given link_identifier. If link_identifier isn't specified, the last opened link is assumed. fbsql_insert_id returns 0 if the previous - query does not generate an AUTO_INCREMENT value. If you need to + query does not generate an DEFAULT UNIQUE value. If you need to save the value for later, be sure to call fbsql_insert_id() immediately after the query that generates the value. @@ -1178,22 +1177,10 @@ The value of the FrontBase SQL function LAST_INSERT_ID() always contains the most - recently generated AUTO_INCREMENT value, and is not reset + recently generated DEFAULT UNIQUE value, and is not reset between queries. - - - fbsql_insert_id converts the return type of - the native FrontBase C API function - fbsql_insert_id() to a type of - long. If your AUTO_INCREMENT column has - a column type of BIGINT, the value returned by - fbsql_insert_id will be incorrect. - Instead, use the internal FrontBase SQL function - LAST_INSERT_ID(). - - @@ -1201,15 +1188,15 @@ fbsql_list_dbs - FrontBaseサーバで利用可能なデータベースの一覧を得る + List databases available on a FrontBase server 説明 - int fbsql_list_dbs - int + resource fbsql_list_dbs + resource link_identifier @@ -1258,16 +1245,16 @@ fbsql_list_fields - FrontBase結果フィールドの一覧を得る + List FrontBase result fields 説明 - int fbsql_list_fields + resource fbsql_list_fields string database_name string table_name - int + resource link_identifier @@ -1322,15 +1309,15 @@ fbsql_list_tables - FrontBaseデータベースのテーブル一覧を得る + List tables in a FrontBase database 説明 - int fbsql_list_tables + resource fbsql_list_tables string database - int + resource link_identifier @@ -1347,17 +1334,61 @@ + + + fbsql_next_result + Move the internal result pointer to the next result + + + 説明 + + + bool + fbsql_next_result + + int result_id + + + + When sending more than one SQL statement to the server or executing a stored procedure + with multiple results will cause the server to return multiple result sets. + This function will test for additional results available form the server. if an + additional result set exists it will free the existing result set and prepare to + fetch the wors from the new result set. + The function will return TRUE if an additional result set was + available or FALSE othervise. + + + <function>fbsql_next_result</function> example + +<?php + $link = fbsql_connect ("localhost", "_SYSTEM", "secret"); + fbsql_select_db("MyDB", $link); + $SQL = "Select * from table1; select * from table2;"; + $rs = fbsql_query($SQL, $link); + do { + while ($row = fbsql_fetch_row($rs)) { + } + } while (fbsql_next_result($rs)); + fbsql_free_result($rs); + fbsql_close ($link); +?> + + + + + fbsql_num_fields - 結果のフィールド数を得る + Get number of fields in result 説明 int fbsql_num_fields - int result + resource result @@ -1376,14 +1407,14 @@ fbsql_num_rows - 結果のレコード数を得る + Get number of rows in result 説明 int fbsql_num_rows - int result + resource result @@ -1399,7 +1430,7 @@ $link = fbsql_connect("localhost", "username", "password"); fbsql_select_db("database", $link); -$result = fbsql_query("SELECT * FROM table1", $link); +$result = fbsql_query("SELECT * FROM table1;", $link); $num_rows = fbsql_num_rows($result); echo "$num_rows Rows\n"; @@ -1422,21 +1453,16 @@ fbsql_pconnect - FrontBaseサーバへの持続的な接続をオープンする + Open a persistent connection to a FrontBase Server 説明 - int fbsql_pconnect + resource fbsql_pconnect string - - hostname - :port - :/path/to/socket - - + hostname string username @@ -1448,25 +1474,22 @@ Returns: A positive FrontBase persistent link identifier on success, - or false on error. + or FALSE on error. fbsql_pconnect establishes a connection to a FrontBase server. The following defaults are assumed for - missing optional parameters: host:port = - 'localhost:3306', username = name of the - user that owns the server process and - password = empty password. + missing optional parameters: host = + 'localhost', username = "_SYSTEM" + and password = empty password. - The hostname string can also include a port - number. eg. "hostname:port" or a path to a socket - eg. ":/path/to/socket" for the localhost. - - fbsql_pconnect acts very much like fbsql_connect with two major differences. + + To set Frontbase server port number, use fbsql_select_db. + First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, @@ -1487,15 +1510,15 @@ fbsql_query - FrontBaseクエリを送信する + Send a FrontBase query 説明 - int fbsql_query + resource fbsql_query string query - int + resource link_identifier @@ -1511,27 +1534,27 @@ - The query string should not end with a semicolon. + The query string shall always end with a semicolon. - fbsql_query returns TRUE (non-zero) or FALSE + fbsql_query returns TRUE (non-zero) or FALSE to indicate whether or not the query succeeded. A return value - of TRUE means that the query was legal and could be executed by + of TRUE means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows. The following query is syntactically invalid, so - fbsql_query fails and returns FALSE: + fbsql_query fails and returns FALSE: - <function>fbsql_query</function> + <function>fbsql_query</function> example <?php $result = fbsql_query ("SELECT * WHERE 1=1") or die ("Invalid query"); -?> +?> @@ -1539,19 +1562,19 @@ The following query is semantically invalid if my_col is not a column in the table my_tbl, so fbsql_query - fails and returns FALSE: + fails and returns FALSE: - <function>fbsql_query</function> + <function>fbsql_query</function> example <?php $result = fbsql_query ("SELECT my_col FROM my_tbl") or die ("Invalid query"); -?> +?> - fbsql_query will also fail and return FALSE + fbsql_query will also fail and return FALSE if you don't have permission to access the table(s) referenced by the query. @@ -1593,7 +1616,7 @@ mixed fbsql_result - int result + resource result int row mixed @@ -1635,15 +1658,15 @@ fbsql_select_db - FrontBaseデータベースを選択する + Select a FrontBase database 説明 - int fbsql_select_db + resource fbsql_select_db string database_name - int + resource link_identifier @@ -1651,7 +1674,7 @@ - Returns: true on success, false on error. + Returns: TRUE on success, FALSE on error. fbsql_select_db sets the current active @@ -1662,6 +1685,14 @@ called, and use it. + The client contacts FBExec to obtain the port number to use for + the connection to the database. if the database name is a number + the system will use that as a port number and it will not ask + FBExec for the port number. + The FrontBase server can be stared as + FRontBase -FBExec=No -port=<port number> <database name>. + + Every subsequent call to fbsql_query will be made on the active database. @@ -1676,14 +1707,14 @@ fbsql_tablename - 指定したフィールドのテーブル名を得る + Get table name of field 説明 string fbsql_tablename - int result + resource result int i @@ -1694,10 +1725,10 @@ fbsql_num_rows function may be used to determine the number of tables in the result pointer. - <function>fbsql_tablename</function> Example + <function>fbsql_tablename</function> example <?php -fbsql_connect ("localhost:3306"); +fbsql_connect ("localhost", "_SYSTEM", ""); $result = fbsql_list_tables ("wisconsin"); $i = 0; while ($i < fbsql_num_rows ($result)) { @@ -1705,7 +1736,7 @@ echo $tb_names[$i] . "<BR>"; $i++; } -?> +?> @@ -1715,7 +1746,7 @@ fbsql_warnings - FrontBaseの警告を有効または無効にする + Enable or disable FrontBase warnings 説明 @@ -1730,7 +1761,7 @@ - Returns: true if warnings is turned on otherwise false. + Returns TRUE if warnings is turned on otherwise FALSE. fbsql_warnings enables or disables FrontBase Index: phpdoc/ja/functions/math.xml diff -u phpdoc/ja/functions/math.xml:1.17 phpdoc/ja/functions/math.xml:1.18 --- phpdoc/ja/functions/math.xml:1.17 Sat May 5 22:22:49 2001 +++ phpdoc/ja/functions/math.xml Sun May 20 00:43:01 2001 @@ -840,6 +840,24 @@ えられた文字列を使い、小数部の前のドット(".")の代わりに dec_pointで与えられた文字列を使います。 + + 例えば、フランス語表記では通常小数点以下は2桁とし、カンマ(',')を + 小数部の区切り文字、スペースを1000の位毎の区切り文字として使用し + ます。これは、次のように行います。 + + +<?php + $nombre = 1234.56; + // 英語表記 (デフォルト) + $english_format_number = number_format($nombre); + // 1,234.56 + // フランス語表記 + $nombre_format_francais = number_format($nombre, 2, ',', ' '); + // 1 234,56 +?> + + + Index: phpdoc/ja/functions/misc.xml diff -u phpdoc/ja/functions/misc.xml:1.17 phpdoc/ja/functions/misc.xml:1.18 --- phpdoc/ja/functions/misc.xml:1.17 Sun Mar 18 08:36:45 2001 +++ phpdoc/ja/functions/misc.xml Sun May 20 00:43:01 2001 @@ -47,9 +47,9 @@ 接続ステータスのビットフィールドを返します。 - 詳細な説明に関しては、機能 に関する章の - 接続処理 - に関する記述を参照下さい。 + 詳細な説明に関しては、機能 に関す + る章の接続処理 + に関する記述を参照下さい。 @@ -69,10 +69,18 @@ スクリプトがタイムアウトした場合にtrueを返します。 - 詳細な説明に関しては、機能 に関する章の - 接続処理 - に関する記述を参照下さい。 + + 過去の関数 + + この関数は、過去のものであり、4.0.5以降には存在しません。 + + + + 詳細な説明に関しては、機能 に関す + る章の接続処理 + に関する記述を参照下さい。 + @@ -217,8 +225,18 @@ - name で指定した名前の定数が定義されている場合に - true、その他の場合にfalseを返します。 + name で指定した名前の定数が定義されている + 場合にtrue、その他の場合にfalseを返します。 + + 定数のチェック + +<?php +if (defined("CONSTANT")){ // 引用符で括られている必要があります + echo CONSTANT; // + } +?> + + define, @@ -268,7 +286,7 @@ - 関数を使用する <function>die</function> の例 + 関数を使用する<function>die</function>の例 <?php @@ -296,7 +314,7 @@ eval - 文字列を PHP コードとして評価する + 文字列をPHPコードとして評価する 説明 @@ -611,7 +629,8 @@ ignore_user_abort - クライアント接続が断となった時にスクリプトの実行を中断するかどうかを設定する + クライアント接続が断となった時にスクリプトの実行を中断するかどう + かを設定する @@ -852,62 +871,6 @@ - - - serialize - - 値の保存可能な表現を生成する - - - - 説明 - - - string serialize - mixed value - - - - serialize は、valueの - 保存可能なバイトストリーム表現を含む文字列を返します。 - - - 型や構造を失わずにPHPの値を保存または渡す際に有効です。 - - - シリアル化された文字列をPHPの値に戻すには、 - unserializeを使用して下さい。 - serializeは型integer, - double,string,array - (多次元),object - (オブジェクトプロパティはシリアル化されますが、メソッドは失われます) - に対応します。 - - - - <function>serialize</function>の例 - -// $session_data はカレントユーザーのセッション情報を含む多次元配列を -// 保持しています。リクエストの最後にこれをデータベースに保存するために -// serialize() を使用します。 - -$conn = odbc_connect("webdb", "php", "chicken"); -$stmt = odbc_prepare($conn, - "UPDATE sessions SET data = ? WHERE id = ?"); -$sqldata = array(serialize($session_data), $PHP_AUTH_USER); -if (!odbc_execute($stmt, &$sqldata)) { - $stmt = odbc_prepare($conn, - "INSERT INTO sessions (id, data) VALUES(?, ?)"); - if (!odbc_execute($stmt, &$sqldata)) { - /* 何か問題があったようです。Bitch, whine and moan. */ - } -} - - - - - - show_source @@ -978,9 +941,9 @@ 説明 - string uniqid + int uniqid string prefix - boolean + bool lcg @@ -988,11 +951,11 @@ - uniqidは、ミリ秒単位の現在時刻に基づき - 先頭辞(prefix)を付けたユニークなIDを返します。 - いくつかのホスト上で同時にIDを生成させる場合、 - 全く同じミリ秒のIDが生成されるのを防ぐのにprefixが有用です。 - prefixには114文字までの長さを指定することができます。 + uniqidは、ミリ秒単位の現在時刻に基づき先頭辞 + (prefix)を付けたユニークなIDを返します。いくつかのホスト上で同 + 時にIDを生成させる場合、全く同じミリ秒のIDが生成されるのを防ぐの + にprefixが有用です。prefixには114文字まで + の長さを指定することができます。 オプションの lcg パラメータが true の場合、 @@ -1006,14 +969,14 @@ - lcg パラメータは、 - PHP 4またはPHP 3.0.13以降でのみ使用可能です。 + lcg パラメータは、PHP 4またはPHP 3.0.13以 + 降でのみ使用可能です。 - ユニークなIDまたはトークンが必要な場合、そして、 - ネットワーク経由でユーザーにそのトークンを渡そうとする場合、 - 次の例のようにするのが推奨されます。 + ユニークなIDまたはトークンが必要な場合、そして、ネットワーク経由 + でユーザーにそのトークンを渡そうとする場合(例えば、セッションクッ + キー)、次の例のようにするのが推奨されます。 $token = md5 (uniqid ("")); // ランダム要素なし @@ -1074,57 +1037,6 @@ - - - unserialize - 保存用表現から PHP の値を生成する - - - 説明 - - - mixed unserialize - string str - - - - unserialize は、シリアル化された変数 - (serialize を参照) をとり、PHP 変数値に - 戻す変換を行います。変換された値が返されます。その値は、 - integer, double, - string, array , object - とすることが可能です。 - オブジェクトがシリアル化された場合、 - 返り値にそのメソッドは保存されていません。 - - - - <function>unserialize</function>の例 - -// ここで、データベースから $session_data にセッションデータをロード -// するために unserialize() を使用します。 -// この例は、serialize で記述された例を補足するものです。 - -$conn = odbc_connect("webdb", "php", "chicken"); -$stmt = odbc_prepare($conn, "SELECT data FROM sessions WHERE id = ?"); -$sqldata = array($PHP_AUTH_USER); -if (!odbc_execute($stmt, &$sqldata) || !odbc_fetch_into($stmt, &$tmp)) { - // 実行または取得が失敗した場合、空の配列で初期化します - $session_data = array(); -} else { - // $tmp[0] にシリアル化されたデータを保持している必要があります。 - $session_data = unserialize($tmp[0]); - if (!is_array($session_data)) { - // 何か問題があったため、空の配列で初期化します。 - $session_data = array(); - } -} - - - - - - usleep Index: phpdoc/ja/functions/oci8.xml diff -u phpdoc/ja/functions/oci8.xml:1.13 phpdoc/ja/functions/oci8.xml:1.14 --- phpdoc/ja/functions/oci8.xml:1.13 Sat May 5 22:22:49 2001 +++ phpdoc/ja/functions/oci8.xml Sun May 20 00:43:01 2001 @@ -1336,8 +1336,8 @@ var_dump($data); } -OCIFreeCursor ($stmt); -OCIFreeStatement ($curs); +OCIFreeStatement ($stmt); +OCIFreeCursor ($curs); OCILogoff ($conn); ?> Index: phpdoc/ja/functions/pdf.xml diff -u phpdoc/ja/functions/pdf.xml:1.21 phpdoc/ja/functions/pdf.xml:1.22 --- phpdoc/ja/functions/pdf.xml:1.21 Wed Mar 28 05:45:34 2001 +++ phpdoc/ja/functions/pdf.xml Sun May 20 00:43:02 2001 @@ -1987,6 +1987,33 @@ + + + PDF_setcolor + 塗りつぶし色および輪郭色をCMYKで設定する + + + 説明 + + + void PDF_setcolor + int pdf object + string type + string colorspace + double c1 + double c2 + double c3 + double c4 + + + + カレントのカラースペースと色を設定します。 + typeは、"fill", "stroke", "both" のどれか + です。 + + + + pdf_setdash Index: phpdoc/ja/functions/var.xml diff -u phpdoc/ja/functions/var.xml:1.26 phpdoc/ja/functions/var.xml:1.27 --- phpdoc/ja/functions/var.xml:1.26 Fri Apr 27 19:20:55 2001 +++ phpdoc/ja/functions/var.xml Sun May 20 00:43:02 2001 @@ -791,6 +791,11 @@ オブジェクトに関しても同様の表示形式となります。 + print_rは、配列ポインタを終端まで移動するこ + とに注意して下さい。ポインタを最初に戻すために + resetを使用して下さい。 + + print_rvar_dumpと比較してみて下さい。 @@ -817,6 +822,75 @@ + + + serialize + + 値の保存可能な表現を生成する + + + + 説明 + + + string serialize + mixed value + + + + serialize は、valueの + 保存可能なバイトストリーム表現を含む文字列を返します。 + + + 型や構造を失わずにPHPの値を保存または渡す際に有効です。 + + + シリアル化された文字列をPHPの値に戻すには、 + unserializeを使用して下さい。 + serializeは型integer, + double,string,array + (多次元),object + (オブジェクトプロパティはシリアル化されますが、メソッドは失われます) + に対応します。 + + + + PHP 3では、メソッドはシリアル化されたオブジェクトを非シリアル化 + する際に保存されません。PHP 4ではこの制限は取り除かれ、プロパティ + とメソッドの両方を保存します。より詳細な情報については、 + オブジェクトとクラス の + オブジェクトのシリア + ル化の節を参照下さい。 + + + + + <function>serialize</function>の例 + +// $session_data はカレントユーザーのセッション情報を含む多次元配列を +// 保持しています。リクエストの最後にこれをデータベースに保存するために +// serialize() を使用します。 + +$conn = odbc_connect("webdb", "php", "chicken"); +$stmt = odbc_prepare($conn, + "UPDATE sessions SET data = ? WHERE id = ?"); +$sqldata = array(serialize($session_data), $PHP_AUTH_USER); +if (!odbc_execute($stmt, &$sqldata)) { + $stmt = odbc_prepare($conn, + "INSERT INTO sessions (id, data) VALUES(?, ?)"); + if (!odbc_execute($stmt, &$sqldata)) { + /* 何か問題があったようです。Bitch, whine and moan. */ + } +} + + + + + unserializeも参照下さい。 + + + + settype @@ -898,6 +972,69 @@ + + + unserialize + 保存用表現から PHP の値を生成する + + + 説明 + + + mixed unserialize + string str + + + + unserialize は、シリアル化された変数 + (serialize を参照) をとり、PHP 変数値に + 戻す変換を行います。変換された値が返されます。その値は、 + integer, double, + string, array , object + とすることが可能です。オブジェクトがシリアル化された場合、返り値 + にそのメソッドは保存されていません。 + + + + PHP 3では、メソッドはシリアル化されたオブジェクトを非シリアル化 + する際に保存されません。PHP 4ではこの制限は取り除かれ、プロパティ + とメソッドの両方を保存します。より詳細な情報については、 + オブジェクトとクラス の + オブジェクトのシリア + ル化の節を参照下さい。 + + + + + <function>unserialize</function>の例 + +// ここで、データベースから $session_data にセッションデータをロード +// するために unserialize() を使用します。 +// この例は、serialize で記述された例を補足するものです。 + +$conn = odbc_connect("webdb", "php", "chicken"); +$stmt = odbc_prepare($conn, "SELECT data FROM sessions WHERE id = ?"); +$sqldata = array($PHP_AUTH_USER); +if (!odbc_execute($stmt, &$sqldata) || !odbc_fetch_into($stmt, &$tmp)) { + // 実行または取得が失敗した場合、空の配列で初期化します + $session_data = array(); +} else { + // $tmp[0] にシリアル化されたデータを保持している必要があります。 + $session_data = unserialize($tmp[0]); + if (!is_array($session_data)) { + // 何か問題があったため、空の配列で初期化します。 + $session_data = array(); + } +} + + + + + serializeも参照下さい。 + + + + unset Index: phpdoc/ja/functions/xml.xml diff -u phpdoc/ja/functions/xml.xml:1.10 phpdoc/ja/functions/xml.xml:1.11 --- phpdoc/ja/functions/xml.xml:1.10 Thu Jan 4 22:29:05 2001 +++ phpdoc/ja/functions/xml.xml Sun May 20 00:43:02 2001 @@ -396,18 +396,18 @@ } function startElement($parser, $name, $attribs){ - print "&lt;<font color=\"#0000cc\">$name</font>"; + print "&lt;<font color=\"#0000cc\">$name</font>"; if (sizeof($attribs)) { while (list($k, $v) = each($attribs)) { - print " <font color=\"#009900\">$k</font>=\"<font - color=\"#990000\">$v</font>\""; + print " <font color=\"#009900\">$k</font>=\"<font + color=\"#990000\">$v</font>\""; } } print "&gt;"; } function endElement($parser, $name){ - print "&lt;/<font color=\"#0000cc\">$name</font>&gt;"; + print "&lt;/<font color=\"#0000cc\">$name</font>&gt;"; } function characterData($parser, $data){ @@ -432,7 +432,7 @@ function defaultHandler($parser, $data){ if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { - printf('<font color="#aa00aa">%s</font>', htmlspecialchars($data)); + printf('<font color="#aa00aa">%s</font>', htmlspecialchars($data)); } else { printf('<font size="-1">%s</font>', htmlspecialchars($data)); } @@ -1059,7 +1059,7 @@ 外部エンティティ宣言の記述用定義に関しては、 - XML 1.0 仕様の 4.2.2 + XML 1.0 仕様の 4.2.2 節を参照下さい。 @@ -1179,7 +1179,7 @@ > | publicId}> 表記法宣言の定義に関しては、 - XML 1.0 仕様の 4.7 節 + XML 1.0 仕様の 4.7 節 を参照下さい。 Index: phpdoc/ja/language/oop.xml diff -u phpdoc/ja/language/oop.xml:1.7 phpdoc/ja/language/oop.xml:1.8 --- phpdoc/ja/language/oop.xml:1.7 Sat Mar 10 21:56:44 2001 +++ phpdoc/ja/language/oop.xml Sun May 20 00:43:02 2001 @@ -38,11 +38,40 @@ この例は、籠の中の物と籠にアイテムを加えたり除いたりする二つの関数への 連想配列からなる Cart という名前のクラスを定義します。 + + + + 以下の注意書きはPHP 4に関するものです。 + + + + 名前stdClassは、Zendにより内部的に使用され、保 + 存されています。PHPでstdClassという名前のクラ + スを使用することはできません。 + + + + The function names __sleep and + __wakeup are magical in PHP classes. You + cannot have functions with these names in any of your + classes unless you want the magic functionality associated + with them. See below for more information. + + + + PHP reserves all function names starting with __ as magical. + It is recommended that you do not use function names with + __ in PHP unless you want some documented magic functionality. + + + PHP 4では、変数varについては定数による初期化の - みが可能です。定数以外で初期化を行う場合にはコンストラクタを使用 - して下さい。 + みが可能です。定数以外で初期化を行う場合には初期化関数が必要です。 + この初期化関数は、オブジェクトがクラスから構築される際に自動的に + コールされます。このような関数はコンストラクタと呼ばれます。(以下 + 参照) @@ -69,32 +98,96 @@ - クラスは型、つまり、実際の変数の雛型です。 - new 演算子により所望の型の変数を作成する必要があります。 + クラスは型、つまり、実際の変数の雛型です。new演 + 算子により所望の型の変数を作成する必要があります。 -$cart = new Cart; -$cart->add_item("10", 1); + $cart = new Cart; + $cart->add_item("10", 1); + + $another_cart = new Cart; + $another_cart->add_item("0815", 3); - この例は、クラス Cart のオブジェクト $cart を作成します。 - オブジェクトの関数 add_item() が番号10 の物を籠に加えるためにコールされ - ています。 + この例は、クラスCartのオブジェクト $cartおよび$another_cartを作成 + します。$cartオブジェクトの関数 add_item()が商品番号10の商品一つが + カートに追加されています。商品番号0815の商品3つが$another_cartに追 + 加されています。 + - クラスは、他のクラスを拡張することにより作成することができます。 - 拡張または派生クラスは、基底クラスの全ての変数と関数、そして、 - 拡張する際の定義により加えられたものを保持しています。 - この定義は、extends キーワードにより行なうことができます。 - 多重継承はサポートされていません。 + Both, $cart and $another_cart, have functions add_item(), + remove_item() and a variable items. These are distinct + functions and variables. You can think of the objects as + something similar to directories in a filesystem. In a + filesystem you can have two different files README.TXT, as + long as they are in different directories. Just like with + directories where you'll have to type the full pathname in + order to reach each file from the toplevel directory, you + have to specify the complete name of the function you want + to call: In PHP terms, the toplevel directory would be the + global namespace, and the pathname separator would be ->. + Thus, the names $cart->items and $another_cart->items + name two different variables. Note that the variable is + named $cart->items, not $cart->$items, that is, a + variable name in PHP has only a single dollar sign. - + +// correct, single $ +$cart->items = array("10" => 1); + +// invalid, because $cart->$items becomes $cart->"" +$cart->$items = array("10" => 1); + +// correct, but may or may not be what was intended: +// $cart->$myvar becomes $ncart->items +$myvar = 'items'; +$cart->$myvar = array("10" => 1); + + + + + Within a class definition, you do not know under which name the object will + be accessible in your program: At the time the Cart class was + written, it was unknown that the object will be named $cart or + $another_cart later. Thus, you cannot write $cart->items within + the Cart class itself. Instead, in order to be able to access it's own + functions and variables from within a class, one can use the + pseudo-variable $this which can be read as 'my own' or + 'current object'. Thus, '$this->items[$artnr] += $num' can + be read as 'add $num to the $artnr counter of my own items + array' or 'add $num to the $artnr counter of the items array + within the current object'. + + + + + <literal>extends</literal> + + + Often you need classes with similar variables and functions + to another existing class. In fact, it is good practice to + define a generic class which can be used in all your + projects and adapt this class for the needs of each of your + specific projects. To facilitate this, Classes can be + extensions of other classes. The extended or derived class + has all variables and functions of the base class (this is + called 'inheritance' despite the fact that nobody died) and what + you add in the extended definition. It is not possible to + substract from a class, that is, to undefine any existing + functions or variables. An extended class is always dependent + on a single base class, that is, multiple inheritance is + not supported. Classes are extended using the keyword 'extends'. + + + + class Named_Cart extends Cart { var $owner; @@ -107,7 +200,7 @@ この例は、Cart の全ての変数及び関数に加えて変数 $owner と - 関数 $set_owner を保持するクラス Named_Cart を定義しています。 + 関数 set_owner() を保持するクラス Named_Cart を定義しています。 この定義により、名前付きの籠を通常の手段で作成し、籠の保有者を 設定したり得たりすることができます。 名前付きの籠で元の籠クラスの関数を使うことも可能です。 @@ -122,35 +215,31 @@ - - クラスにおける関数の中では、変数 $this はそのオブジェクト自身を意 - 味します。オブジェクトの中では、何らかのクラス変数や関数にアクセス - したい場合に $this->something を使う必要があります。オブジェクトの - 内部または外部の場合、そのオブジェクトのプロパティにアクセスする際 - に $ は不要です。 - - - - -$ncart->owner = "chris"; // $ は不要 + -$ncart->$owner = "chris"; -// $ncart->$owner = $ncart->"" なのでこれは誤り + + <literal>コンストラクタ</literal> -$myvar = 'owner'; -$ncart->$myvar = "chris"; -// $ncart->$myvar = $ncart->ownerなのでこれは有効 - - + + + In PHP 3 and PHP 4 constructors behave differently. The PHP 4 + semantics are strongly preferred. + + - コンストラクタは、クラスの新しいインスタンスを作成する際に - 自動的にコールされるクラス関数です。 - 関数は、クラスと同じ名前を有する際にコンストラクタとなります。 + コンストラクタは、newによりクラスの新しいインス + タンスを作成する際に自動的にコールされるクラス関数です。 + PHP 3では、ある関数が、クラス名と同じ名前を有している場合にコンス + トラクタになりました。PHP 4では、ある関数が、そのコンストラクタが + 定義されているクラスと同じ名前を有している場合にコンストラクタにな + ります。これらの違いは僅かですが、重要な違いがあります。(以下、参 + 照) - + +// Works in PHP 3 and PHP 4. class Auto_Cart extends Cart { function Auto_Cart () { $this->add_item ("10", 1); @@ -162,13 +251,16 @@ この例は、Cart にコンストラクタを加えたクラス Auto_Cart を定義しています。 このコンストラクタは、"new" により新しい Auto_Cart が作成される度に - 籠に 10 番の物を一つ保持するように初期化します。 - コンストラクタは、オプションとして引数をとります。 - これにより、コンストラクタは非常に便利なものとなります。 + 籠に10番の物を一つ保持するように初期化します。コンストラクタは、オ + プションとして引数をとります。これにより、コンストラクタは非常に便 + 利なものとなります。To be able to still use the class + without parameters, all parameters to constructors should be + made optional by providing default values. +// Works in PHP 3 and PHP 4. class Constructor_Cart extends Cart { function Constructor_Cart ($item = "10", $num = 1) { $this->add_item ($item, $num); @@ -184,18 +276,378 @@ $different_cart = new Constructor_Cart ("20", 17); - + - 派生クラスの場合、派生クラスのコンストラクタがコールされた時にも - 親クラスのコンストラクタが自動的にコールされるということはありま - せん。 + In PHP 3, derived classes and constructors have a number of + limitations. The following examples should be read carefully + to understand these limitations. + + + + + +class A { + function A() { + echo "I am the constructor of A.<br>\n"; + } +} + +class B extends A { + function C() { + "I am a regular function.<br>\n"; + } +} + +// no constructor is being called in PHP 3. +$b = new B; + + + + + In PHP 3, no constructor is being called in the above example. + The rule in PHP 3 is: 'A constructor is a function of the same + name as the class.'. The name of the class is B, and there is + no function called B() in class B. Nothing happens. + + + + This is fixed in PHP 4 by introducing another rule: If a class + has no constructor, the constructor of the base class is being + called, if it exists. The above example would have printed + 'I am the constructor of A.<br>' in PHP 4. + + + + +class A { + function A() { + echo "I am the constructor of A.<br>\n"; + } + + function B() { + echo "I am a regular function named B in class A.<br>\n"; + echo "I am not a constructor in A.<br>\n"; + } +} + +class B extends A { + function C() { + echo "I am a regular function.<br>\n"; + } +} + +// This will call B() as a constructor. +$b = new B; + + + + + In PHP 3, the function B() in class A will suddenly become a + constructor in class B, although it was never intended to be. + The rule in PHP 3 is: 'A constructor is a function of the same + name as the class.'. PHP 3 does not care if the function is + being defined in class B, or if it has been inherited. + + + + This is fixed in PHP 4 by modifying the rule to: 'A constructor + is a function of the same name as the class it is being defined + in.'. Thus in PHP 4, the class B would have no constructor function + of its own and the constructor of the base class would have been + called, printing 'I am the constructor of A.<br>'. + + + + + Neither PHP 3 nor PHP 4 call constructors of the base class + automatically from a constructor of a derived class. It is + your responsibility to propagate the call to constructors + upstream where appropriate. + + + + There are no destructors in PHP 3 or PHP 4. You may use + register_shutdown_function instead + to simulate most effects of destructors. + + + + + Destructors are functions that are called automatically + when a variable is destroyed, either with unset + or by simply going out of scope. There are no destructors + in PHP. + - - - コンストラクタの中での参照 + + + <literal>::</literal> + + + + The following is valid for PHP 4 only. + + + + + Sometimes it is useful to refer to functions and variables + in base classes or to refer to functions in classes that + have not yet any instances. The :: operator is being used + for this. + + + + +class A { + function example() { + echo "I am the original function A::example().<br>\n"; + } +} + +class B extends A { + function example() { + echo "I am the redefined function B::example().<br>\n"; + A::example(); + } +} + +// there is no object of class A. +// this will print +// I am the original function A::example().<br> +A::example(); + +// create an object of class B. +$b = new B; + +// this will print +// I am the redefined function B::example().<br> +// I am the original function A::example().<br> +$b->example(); + + + + + The above example calls the function example() in + class A, but there is no object of class A, so that + we cannot write $a->example() or similar. Instead we + call example() as a 'class function', that is, as a + function of the class itself, not any object of that + class. + + + + There are class functions, but there are no class variables. + In fact, there is no object at all at the time of the call. + Thus, a class function may not use any object variables (but + it can use local and global variables), and it may no use + $this at all. + + + + In the above example, class B redefines the function example(). + The original definition in class A is shadowed + and no longer available, unless you are refering specifically + to the implementation of example() in class A using the + ::-operator. Write A::example() to do this (in fact, you + should be writing parent::example(), as shown in the next + section). + + + + In this context, there is a current object and it may + have object variables. Thus, when used from WITHIN an + object function, you may use $this and object variables. + + + + + + <literal>親クラス</literal> + + + You may find yourself writing code that refers to + variables and functions in base classes. This is + particularly true if your derived class is a refinement + or specialisation of code in your base class. + + + + Instead of using the literal name of the base class in your + code, you should be using the special name + parent, which refers to the name of your + base class as given in the extends + declation of your class. By doing this, you avoid using the + name of your base class in more than one place. Should + your inheritance tree change during implementation, the + change is easily made by simply changing the + extends declaration of your class. + + + + +class A { + function example() { + echo "I am A::example() and provide basic functionality.<br>\n"; + } +} + +class B extends A { + function example() { + echo "I am B::example and provide additional functionality().<br>\n"; + parent::example(); + } +} + +$b = new B; + +// This will call B::example(), which will in turn call A::example(). +$b->example(); + + + + + + Serializing objects - objects in sessions + + + + In PHP 3, objects will lose their class association + throughout the process of serialization and unserialization. + The resulting variable is of type object, but has no class + and no methods, thus it is pretty useless (it has become + just like an array with a funny syntax). + + + + + + The following information is valid for PHP 4 only. + + + + + serialize returns a string containing a + byte-stream representation of any value that can be stored in + PHP. unserialize can use this string to + recreate the original variable values. Using serialize to + save an object will save all variables in an object. The + functions in an object will not be saved, only the name of + the class. + + + + In order to be able to unserialize an + object, the class of that object needs to be defined. That + is, if you have an object $a of class A on page1.php and + serialize this, you'll get a string that refers to class A + and contains all values of variabled contained in $a. If + you want to be able to unserialize this on page2.php, + recreating $a of class A, the definition of class A must + be present in page2.php. This can be done for example + by storing the class defintion of class A in an include + file and including this file in both page1.php and page2.php. + + + + +classa.inc: + class A { + var $one = 1; + + function show_one() { + echo $this->one; + } + } + +page1.php: + include("classa.inc"); + + $a = new A; + $s = serialize($a); + // store $s somewhere where page2.php can find it. + $fp = fopen("store", "w"); + echo $s; + fclose($fp); + +page2.php: + // this is needed for the unserialize to work properly. + include("classa.inc"); + + $s = implode("",  <email protected>("store")); + unserialize($s); + + // now use the function show_one of the $a object. + $a->show_one(); + + + + + If you are using sessions and use session_register + to register objects, these objects are serialized automatically + at the end of each PHP page, and are unserialized automatically on + e