text
stringlengths 1
254
| output
stringlengths 2
255
|
---|---|
Otherwise, since no-pattern is not present, theOtherwise, since no-pattern is not present, the subpattern matches nothing.
|
単語の境界は、検索対象文字列において、現在の文字および前の文字が 両方は \w または \W にマッチし ない(すなわち、片方は \w にマッチして、もう片方 は \W にマッチする)か、または、最初のまたは最後 の文字が \w にマッチするならば、それぞれ、文字 列の始めまたは終わりの位置です。
|
Without the use of recursion, the best that can be done is to use a patternWithout the use of recursion, the best that can be done is to use a pattern that matches up to some fixed depth of nesting.
|
文字クラスの外側では、パターンの中のドットは非出力文字を含む (デフォルトでは)改行以外の対象の全ての1文字にマッチします。 PCRE_DOTALL オプショ ンを設定した場合、ドットは改行にもマッチします。ドットの処理は、 ハット記号およびドル記号とは完全に独立しています。共通な点は共に 改行文字を含むことだけです。 ドットは、文字クラスの中では特別な意味を持ちません。
|
This takes at least two parameters - - the first is the level of the error, the second is the format string for the error message (as in a standard printf() call), and any following arguments are the parameters for the format string.
|
内部関数からエラーを出力するには、 php3_error() を コールする必要があります。この関数は、少なくとも 2 つの引数をとります。 1 番目の引数はエラーのレベル、2 番目の引数はエラーメッセージの (通常の printf() と同じ形式の)フォーマット文字列、 以降の引数はフォーマット文字列で使用するパラメータです。 エラーレベルは次のようになります。
|
For example, trying to access the value of a variable which has not been set, or calling stat() on a file that doesn't exist.
|
デフォルトで通知(NOTICE)は表示されません。 これは、スクリプト実行時に何かエラーが発生したが、 通常のスクリプト実行を継続できることを示します。 例えば、値が設定されていない変数にアクセスしようとした場合や、 存在しないファイルについて stat() をコールした場合 です。
|
These indicate a problem that should have been trapped by the script before the call was made.
|
警告(WARNING) はデフォルトで出力されますがスクリプトの実行を 中断しません。 このエラーは、コール前にスクリプトにより取り除いておくべき 問題があることを示します。 例えば、無効な正規表現で ereg() をコールした場合です。
|
Errors are also printed by default, and execution of the script is halted after the function returns.
|
エラーもデフォルトで出力されます。 関数からリターンした後、スクリプトの実行は中止されます。 このエラーは、メモリ確保に関する問題等の回復不可能なエラーが 発生したことを示します。
|
Parse errors should only be generated by the parser.
|
パーサエラーは、パーサにより生成されます。ここで表示されるコードは、 あくまでも補完的なものです。
|
This is like an E_ERROR, except it is generated by the core of PHP.
|
PHP のコアにより生成される点を除いて、E_ERROR と同じです。 関数は、このタイプのエラーを生成しません。
|
This is like an E_WARNING, except it is generated by the core of PHP.
|
PHP のコアにより生成される点を除いて、E_WARNING と同じです。 関数は、このタイプのエラーを生成しません。
|
This is like an E_ERROR, except it is generated by the Zend Scripting Engine.
|
E_ERRORに似ていますが、Zendスクリプトエンジンにより生成されたもの であるというところが異なります。関数は、この型のエラーを生成しません。
|
This is like an E_WARNING, except it is generated by the Zend Scripting Engine.
|
E_WARNINGに似ていますが、Zendスクリプトエンジンにより生成されたもの であるというところが異なります。関数は、この型のエラーを生成しません。
|
This is like an E_ERROR, except it is generated in PHP code by using the PHP function trigger_error().
|
E_ERRORに似ていますが、PHP関数 trigger_error() を使用することによりPHPコード内で生成されたものであるというところが 異なります。関数はこの型のエラーを生成しません。
|
This is like an E_WARNING, except it is generated by using the PHP function trigger_error().
|
E_WARNINGに似ていますが、PHP関数 trigger_error() を使用することによりPHPコード内で生成されたものであるというところが 異なります。関数はこの型のエラーを生成しません。
|
This is like an E_NOTICE, except it is generated by using the PHP function trigger_error().
|
E_NOTICEに似ていますが、PHP関数 trigger_error() を使用することによりPHPコード内で生成されたものであるというところが 異なります。関数はこの型のエラーを生成しません。
|
void php3_foo( INTERNAL_FUNCTION_PARAMETERS) {}
|
全ての関数は次のような形式です。
|
So, if your function takes two arguments, you would do something like the following at the top of your function:
|
引数は常にpval型です。この型は、実際の引数の型をメンバーとする unionを有しています。 関数が二つの引数を取る場合、関数の最初に次のような処理を 行なうことになります。
|
Fetching function arguments
|
例 E-1引数の取得
|
If you change the string of a parameter which already IS_STRING or IS_ARRAY you should run pval_destructor on it first.
|
また、パラメータを IS_STRING に変更する場合、 estrdup() された文字列と文字列の長さを最初に割り付けた後で始めて 型を IS_STRING に変更することが可能であることに注意して下さい。 すでに IS_STRING または IS_ARRAY であるパラメータの文字列を 変更する場合、最初に pval_destructor を実行する必要があります。
|
If your function can take either 2 or 3 arguments, use the following:
|
関数は、可変の数の引数をとることができます。 ある関数が 2 つまたは 3 つの引数のどちらかをとる場合、 次のようにしてください。
|
Variable function arguments
|
例 E-2可変引数
|
The type of each argument is stored in the pval type field.
|
各引数の型は pval 型フィールドに保存されます。 この型は、次のどれかとすることができます。
|
Table E-1.
|
表 E-1PHP 内部の型
|
IS_STRING
|
ある型の引数を得たが、他の型で使用したい場合、または、 その引数を強制的にある型で使用したい場合、 次の変換関数のどれかを使用することができます。
|
Double-precision floating point
|
これらの関数は、全てその場で変換されます。 値は全く返されません。
|
IS_ARRAY
|
実引数は、結合体に保持されます。 メンバーは、次のようになります。
|
IS_USER_FUNCTION
|
IS_STRING: arg1- value.str.val
|
IS_INTERNAL_FUNCTION
|
IS_LONG: arg1- value.lval
|
IS_CLASS
|
IS_DOUBLE: arg1- value.dval
|
IS_STRING: arg1 - value.str.val
|
"-DDEBUG" でコンパイルした場合、PHP 3は、指定したスクリプトの実行が 終了した際に、emalloc() および estrdup() で確保したが efree() でまだ開放されていない全メモリーのリストを 表示します。
|
IS_DOUBLE: arg1 - value.dval
|
シンボルテーブルに変数を設定することを容易にするために 以下のようなマクロが用意されています。
|
Any memory needed by a function should be allocated with either emalloc() or estrdup().
|
SET_VAR_STRING(name,value)
|
These are memory handling abstraction functions that look and smell like the normal malloc() and strdup() functions.
|
SET_VAR_DOUBLE(name,value)
|
Memory should be freed with efree().
|
SET_VAR_LONG(name,value)
|
When you assign a string to a variable which is returned to the parser you need to make sure you first allocate the memory with either emalloc() or estrdup().
|
SET_VAR_STRINGを使用する場合は注意が必要です。 value は、メモリ管理コードが後にこのポインタについて free を 行おうとするため、手動で malloc を行う必要があります。 静的に確保されたメモリーを SET_VAR_STRING に渡してはなりません。
|
For any temporary / permanent memory you need in your functions / library you should use the three emalloc(), estrdup(), and efree() functions.
|
PHP 3.0 のシンボルテーブルは、ハッシュテーブルとして実装されています。 いつなんどきでも symbol_table は 'main' シンボルテーブルへの ポインターであり、active_symbol_table は現在アクティブな シンボルテーブルを指しています。(この二つは実行開始時には同じですが、 関数の中にいる時には異なっています。)
|
Anything you emalloc() or estrdup() you have to efree() at some point or another, unless it's supposed to stick around until the end of the program; otherwise, there will be a memory leak.
|
次の例は 'active_symbol_table' を使用します。 'main' シンボルテーブルを使用したい場合には、 これを symbol_table で置きかえる必要があります。 また、以下に説明するように同じ関数を配列にも適用することができます。
|
The meaning of "the functions behave exactly like their counterparts" is: if you efree() something which was not emalloc()'ed nor estrdup() 'ed you might get a segmentation fault.
|
例 E-3$foo がシンボルテーブルに存在するかどうかを調べる
|
So please take care and free all of your wasted memory.
|
例 E-4シンボルテーブルにある変数のサイズの調べ方
|
If you compile with "-DDEBUG", PHP will print out a list of all memory that was allocated using emalloc() and estrdup() but never freed with efree() when it is done running the specified script.
|
シンボルテーブルに配列を新規に定義したい場合、 次のようにする必要があります。
|
SET_VAR_STRING( name,value)
|
まず、hash_exists() または hash_find() を用いて その配列の存在や、適切に開放されているかどうかを 確認する方が良いでしょう。
|
SET_VAR_LONG( name,value)
|
次に、その配列を次のように初期化します。
|
Be careful with SET_VAR_STRING.
|
例 E-5新規の配列の初期化
|
Do not pass statically allocated memory into a SET_VAR_STRING.
|
以下に新しいエントリをこの配列に加える例を示します。
|
Symbol tables in PHP are implemented as hash tables.
|
例 E-6新規配列にエントリを加える
|
The following examples use 'active_symbol_table'.
|
hash_next_index_insert() は、PHP 2.0 の "$foo[] = bar;" とほぼ同じロジックを用いています。
|
Also, the same functions may be applied to arrays, as explained below.
|
関数から配列を返す構成とする場合、 以下のようにするだけで配列の初期化を行うことができます。
|
Checking whether $foo exists in a symbol table
|
続いて、ヘルパー関数を用いて値を付加します。
|
Example E-4.
|
もちろん、付加が配列の初期化直後に行われない場合には、 配列をまず確認する必要があることでしょう。
|
hash_find( active_symbol_table ,"foo",sizeof("foo"), pvalue); check(pvalue.type);
|
hash_find は pval ポインタへのポインタを受け取り、 pval ポインタではないことに注意して下さい。
|
First, you may want to check whether it exists and abort appropriately, using hash_exists() or hash_find().
|
ほとんど全てのハッシュ関数は、SUCCESSまたはFAILUREを返します。 (ただし、論理値を返す hash_exists() を除きます。)
|
Example E-5.
|
関数からの返り値を作成することを容易にするための 複数のマクロが利用可能です。
|
pval arr; if (array_init (arr) == FAILURE) {failed...}; hash_update(active_symbol_table ,"foo",sizeof("foo"), arr,sizeof(pval),NULL);
|
RETURN_* マクロは、全て返り値をセットし関数から戻ります。
|
if (array_init(return_value) == FAILURE) {failed...;}
|
RETURN_LONG(l)
|
add_next_index_long( return_value,long_value); add_next_index_double(return_value,double_value); add_next_index_string(return_value,estrdup(string_value));
|
RETURN_STRING(s,dup) dupが TRUE の場合、文字列をコピーします。
|
pval *arr; if (hash_find(active_symbol_table ,"foo",sizeof("foo") ,(void **) arr)==FAILURE) {can't find...} else {use arr - value.ht...}
|
RETURN_STRINGL(s,l,dup) 指定された長さ(l)の文字列(s)を返します。
|
Note that hash_find receives a pointer to a pval pointer, and not a pval pointer.
|
RETURN_DOUBLE(d)
|
A number of macros are available to make returning values from a function easier.
|
RETVAL_* マクロは返り値をセットしますが、関数から戻りません。
|
RETURN_STRING( s,dup) If dup is TRUE, duplicates the string
|
RETVAL_LONG(l)
|
RETURN_DOUBLE( d)
|
RETVAL_STRING(s,dup) dup が TRUE の場合、文字列をコピーします。
|
RETVAL_FALSE
|
RETVAL_STRINGL(s,l,dup) 指定された長さ (l) の文字列 (s) を返します。
|
RETVAL_LONG( l)
|
RETVAL_DOUBLE(d)
|
RETVAL_STRINGL( s,l,dup) Return string (s) specifying length (l).
|
上記の文字列マクロは、全て 's' 引数に estrdup() を行います。 このため、マクロをコールした後、引数を安全に開放することができます。 他の選択肢としては、静的に確保されたメモリを使用することもできます。
|
The string macros above will all estrdup() the passed's' argument, so you can safely free the argument after calling the macro, or alternatively use statically allocated memory.
|
関数が論理値として成功/エラーの応答を返す場合、 それぞれ RETURN_TRUE および RETURN_FALSE を使用するようにして下さい。
|
If your function returns boolean success / error responses, always use RETURN_TRUE and RETURN_FALSE respectively.
|
関数はオブジェクトや配列といった複雑なデータ型を返すことも可能です。
|
Returning an object:
|
オブジェクトを返すには、次のようにします。
|
Fill it up with values.
|
object_init(return_value) をコールします。
|
Possibly, register functions for this object.
|
オブジェクトを値で埋めます。この際に用いる関数の一覧を 以下に示します。
|
Its type should be IS_OBJECT, and it' s basically a regular hash table (i.e., you can use regular hash functions on .value.ht).
|
可能ならば、このオブジェクト用の関数を登録します。 オブジェクトから値を得るために、関数は、active_symbol_table から "this" を取得する必要があります。 "this" の型は、IS_OBJECT である必要が あります。これは、基本的に通常のハッシュテーブルです。 (すなわち、.value.ht に通常のハッシュ関数が使用可能です) 実際の関数の登録は、次のようにして実行できます。
|
add_method( return_value, function_name, function_ptr);
|
オブジェクトを操作するための関数を以下に示します。
|
add_property_long( return_value, property_name, l) - Add a property named'property_name', of type long, equal to'l '
|
add_property_long( return_value, property_name, l) - long 型で '1' という値を有する 'property_name' という名前のプロパティを追加します
|
add_property_string( return_value, property_name, str) - Same, only adds a string
|
add_property_double( return_value, property_name, d) - 同じですが、倍精度実数を加えるところが違います。
|
Returning an array:
|
add_property_string( return_value, property_name, str) - 同じですが、文字列を加えるところが違います。
|
Fill it up with values.
|
add_property_stringl( return_value, property_name, str, l) - 同じですが、長さ 'l' の文字列を加えるところが違います。
|
The functions available for this purpose are listed below.
|
配列を返すには次のようにします。
|
The functions used to populate an array are:
|
array_init(return_value) をコールします。
|
add_assoc_double( return_value,key,d)
|
配列を値で埋めます。この用途に用いる関数の一覧を以下に示します。
|
add_assoc_stringl( return_value,key,str,length,duplicate) specify the string length
|
配列を用いるための関数は次のようなものです。
|
add_index_double( return_value,index,d)
|
add_assoc_long(return_value,key,l) - キー が 'key' のエントリと long 値 'l' を加えます。
|
add_index_string( return_value,index,str)
|
add_assoc_double(return_value,key,d)
|
add_index_stringl( return_value,index,str,length) - specify the string length
|
add_assoc_string(return_value,key,str,duplicate)
|
add_next_index_double( return_value,d)
|
add_assoc_stringl(return_value,key,str,length,duplicate) 文字列の長さを指定します。
|
add_next_index_stringl( return_value,str,length) - specify the string length
|
add_index_long(return_value,index,l) - 索引が 'index' となるエントリに long 値 'l' を加えます。
|
PHP has a standard way of dealing with various types of resources.
|
add_index_double(return_value,index,d)
|
This replaces all of the local linked lists in PHP 2.0.
|
add_index_string(return_value,index,str)
|
php3_list_insert( ptr, type) - returns the'id 'of the newly inserted resource
|
add_index_stringl(return_value,index,str,length) - 文字列長さを指定します。
|
php3_list_find( id,*type) - returns the pointer of the resource with the specified id, updates'type 'to the resource's type
|
add_next_index_long(return_value,l) - 次にアクセスされる配列エントリと long 値 'l' を加えます。
|
Typical list code would look like this:
|
add_next_index_double(return_value,d)
|
Adding a new resource
|
add_next_index_string(return_value,str)
|
Example E-8.
|
add_next_index_stringl(return_value,str,length) - 文字列長さを指定します。
|
Deleting an existing resource
|
利用可能な関数:
|
pval *resource_id; RESOURCE *resource; int type; convert_to_long(resource_id); php3_list_delete(resource_id - value.lval);
|
php3_list_insert(ptr, type) - 新規に挿入されたリソースの 'id' を返します。
|
PHP has a standard way of storing persistent resources (i.e., resources that are kept in between hits).
|
php3_list_delete(id) - id で指定されたリソースを削除します。
|
The functions you should look at are:
|
php3_list_find(id,*type) - 指定した id が指すリソースへのポインタを 返し、type にそのリソースの型を代入します。
|
php3_mysql_connect()
|
典型的なコードは、次のようになります。
|
The general idea of persistence modules is this:
|
例 E-7新規リソースの追加
|
Code all of your module to work with the regular resource list mentioned in section (9).
|
例 E-8既存のリソースの使用法
|
Code extra connect functions that check if the resource already exists in the persistent resource list.
|
例 E-9既存のリソースの削除
|
LE_MYSQL_LINK for non-persistent link and LE_MYSQL_PLINK for a persistent link).
|
持続的モジュールの一般的な考えは次のようなものです。
|
The very same interface exists for the regular resource list and the persistent resource list, only 'list' is replaced with'plist ':
|
セクション (9) に記載された標準リソースリストと共に 動作するモジュール全体をコーディングします。
|
However, it 's more than likely that these functions would prove to be useless for you when trying to implement a persistent module.
|
mysql.c を読むと、より複雑な接続関数を除いてはモジュールの他の部分を 変更する必要がないということが分かるでしょう。
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.