text
stringlengths
1
254
output
stringlengths
2
255
To release a lock (shared or exclusive), set operation to LOCK_UN (set to 3 prior to PHP 4.0.1).
共有ロック(読み手)ずするには、 operation に LOCK_SH(PHP 4.0.1より前の堎合は1に蚭定したす)をセットしたす。
If you don' t want flock() to block while locking, add LOCK_NB (4 prior to PHP 4.0.1) to operation.
排他的ロック(曞き手)ずするには、 operation にLOCK_EX(PHP 4.0.1より前の堎 合は2に蚭定したす)をセットしたす。
flock() allows you to perform a simple reader / writer model which can be used on virtually every platform (including most Unix derivatives and even Windows).
(共有たたは排他的)ロックを開攟するには、 operation にLOCK_UN(PHP 4.0.1より前の堎 合は3に蚭定したす)をセットしたす。
Returns TRUE on success or FALSE on failure.
ロック䞭に flock() でブロックを行いたくない堎 合は、 operation に LOCK_NB (PHP 4.0.1 より前の堎合は 4 に蚭定したす)を加えたす。
Warning
flock() により、(ほずんどのUNIXやWindowsさえ含む) ほずんど党おのプラットフォヌムで䜿甚可胜な簡易な読み手/曞き手モデ ルが実珟されたす。ロックをブロックモヌドずする堎合(EWOULDBLOCK errno 条件)にオプションの3番目の匕数に TRUE を蚭定したす。
Check your operating system documentation for more details.
flock() は成功時に TRUE 、 (䟋えばロックが確保できなかった堎合等の)゚ラヌ時に FALSE を返したす。
When using a multithreaded server API like ISAPI you may not be able to rely on flock() to protect files against other PHP scripts running in parallel threads of the same server instance!
泚意 flock() は、ファむルポむンタを必芁ずするため、 (fopen() ぞ匕数"w"たたは"w+"を指定しお)曞き蟌 みモヌドでオヌプンするこずにより䞞めるファむルにアクセス保護する 特別なロックファむルを䜿甚する必芁があるかもしれたせん。
Prev
flock() はNFS及び他の倚くのネットワヌクファむ ルシステムでは動䜜したせん。詳现に぀いおはオペレヌティングシステ ムのドキュメントを確認䞋さい。
filetype
いく぀かのオヌペレヌティングシステムで flock() はプロセスレベルで実装されおいたす。ISAPIのようなマルチスレッド 型のサヌバヌAPIを䜿甚しおいる堎合、同じサヌバヌむンスタンスの䞊 列スレッドで実行されおいる他のPHPスクリプトに察しおファむルを保 護する際に flock() を䜿甚するこずはできたせん!
(PHP 3, PHP 4)
(PHP 3, PHP 4)
The return value of floor() is still of type float because the value range of float is usually bigger than that of integer.
必芁に応じお value を䞞めるこずにより、最も 近い最小の敎数の倀を返したす。 floor() の返り倀 は、 float 型のたたずなりたす。これは、 float の範囲は int よりも広いためです。
echo floor( 4.3); / / 4 echo floor(9.999); / / 9
䟋 1 floor() の䟋
Prev
ceil() ず round() も参照䞋 さい。
Prev
(PHP 3, PHP 4)
Flushes the output buffers of PHP and whatever backend PHP is using (CGI, a web server, etc).
PHPおよびPHPが䜿っおいる(CGI, Web サヌバなどの)バック゚ンド の出力バッファをフラッシュしたす。これにより、それたでの党おの 出力がナヌザのブラりザに察しお効率的に出力されたす。
Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.
泚意 flush() は、Webサヌバたたはクラむアント偎のブ ラりザのバッファリングの手法に圱響を䞎えたせん。
Server modules for Apache like mod_gzip may do buffering of their own that will cause flush() to not result in data being sent immediately to the client.
耇数のサヌバ、特に Win32 䞊ではスクリプトからの出力をブラりザに 結果を送信する前にスクリプトが終了するたでバッファに溜めるこずが ありたす。
Netscape, for example, buffers text until it receives an end-of-line or the beginning of a tag, and it won 't render tables until the / table tag of the outermost table is seen.
ブラりザ偎で衚瀺前に入力をバッファリングするこずもあり埗たす。 Netscape では䟋えば改行たたは開始タグを受信するたでテキストはバッ ファリングされ、最も倖偎のテヌブルの /table タグが珟れる たでテヌブルは描画されたせん。
Prev
いく぀かのバヌゞョンのMicrosoft Internet Explorerは、256バむトの 出力を受けおからペヌゞを衚瀺し始めたす。このため、これらのブラり ザにペヌゞを衚瀺させるには、フラッシュする前に䜙分な空癜を送信す る必芁があるかもしれたせん。
Returns the floating point remainder of dividing the dividend (x) by the divisor (y).
(PHP 4 = 4.2.0)
If y is non-zero, r has the same sign as x and a magnitude less than the magnitude of y.
Returns the floating point remainder of dividing the dividend (x) by the divisor (y). The reminder (r) is defined as: x = i * y + r, for some integer i. If y is non-zero, r has the same sign as x and a magnitude less than the magnitude of y.
$x = 5.7; $y = 1.3; $r = fmod($x, $y); / / $r equals 0.5, because 4 * 1.3 + 0.5 = 5.7
䟋 1Using fmod()
Prev
(PHP 4 = 4.3.0)
fnmatch() checks if the passed string would match the given shell wildcard pattern.
fnmatch() checks if the passed string would match the given shell wildcard pattern.
Checking a color name against a shell wildcard pattern.
䟋 1 Checking a color name against a shell wildcard pattern.
See also glob(), ereg(), preg_match() and the unix manpage on fnmatch(3) for flag names (as long as they are not documented here).
See also glob(), ereg(), preg_match() and the unix manpage on fnmatch(3) for flag names (as long as they are not documented here).
(PHP 3, PHP 4)
(PHP 3, PHP 4)
If filename is of the form "scheme: / /.. .", it is assumed to be a URL and PHP will search for a protocol handler (also known as a wrapper) for that scheme.
filename が"http://"(倧文字小文字は区別したせん) で始たっおいる堎合、指定されたサヌバに察するHTTP 1.0コネクションが オヌプンされ、HTTP GETメ゜ッドを甚いおそのペヌゞがリク゚ストされ、 返された応答の本䜓の先頭を指すファむルポむンタが返されたす。 名前に基づく仮想ホストを凊理するために'Host:' ヘッダが、リク゚ストで 送信されたす。
If PHP has decided that filename specifies a local file, then it will try to open a stream on that file.
ファむルポむンタによりレスポンスの 本䜓 のみを 取埗するこずが可胜であるこずに泚意しお䞋さい。この関数を甚いお HTTPレスポンスにアクセスするこずはできたせん。
If you have enabled safe_mode, or open_basedir further restrictions may apply.
PHP 4.0.5 より前のバヌゞョンは、HTTPリダむレクトを凊理したせんでし た。このため、ディレクトリは末尟にスラッシュを含む必芁がありたした。
If it is switched off, PHP will emit a warning and the fopen call will fail.
filename が"ftp://"(倧文字小文字は区別したせん) で始たっおいる堎合、指定されたサヌバに察する FTPコネクションがオヌプンされ、芁求したファむルぞのポむンタが 返されたす。そのサヌバがパッシブ・モヌドFTPをサポヌトしお いない堎合は、この関数は倱敗したす。 ftp経由で読みこみたたは曞きこみのどちらかでファむルオヌプンする こずが可胜です、(しかし、同時に䞡方を行うこずはできたせん。)
mode specifies the type of access you require to the stream.
filename が"php://stdin","php://stdout", "php://stderr"のどれかで始たっおいる堎合、察応するstdioストリヌムが オヌプンされたす。 (この機胜はPHP 3.0.13で導入されたした。これ以前のバヌゞョンでは、 stdioストリヌムにアクセスするために "/dev/stdin"たたは"/dev/fd/0"のようなファむル名を䜿甚する必芁がありたす。)
'r+' - Open for reading and writing; place the file pointer at the beginning of the file.
filename が䞊蚘以倖の堎合、指定された ファむルがファむルシステムよりオヌプンされ、そのオヌプンされた ファむルぞのファむルポむンタが返されたす。
'w' - Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length.
オヌプンに倱敗するず、この関数は FALSE を返したす。
If the file does not exist, attempt to create it.
mode は次のどれかになりたす。
If the file does not exist, attempt to create it.
'r' - 読みこみのみでオヌプンしたす。ファむルポむンタをファむルの 先頭に眮きたす。
If the file does not exist, attempt to create it.
'r+' - 読みこみ・曞きこみ甚にオヌプンしたす。ファむルポむンタを ファむルの先頭に眮きたす。
If the file does not exist, attempt to create it.
'w' - 曞きこみのみでオヌプンしたす。ファむルポむンタをファむルの 先頭に眮き、ファむルサむズをれロにしたす。ファむルが存圚しない 堎合には、䜜成を詊みたす。
This is useful only on systems which differentiate between binary and text files (i.e.
'w+' - 読みこみ・曞きこみ甚でオヌプンしたす。ファむルポむンタを ファむルの先頭に眮き、ファむルサむズをれロにしたす。 ファむルが存圚しない堎合には、䜜成を詊みたす。
If not needed, this will be ignored.
'a' - 曞きこみのみでオヌプンしたす。ファむルポむンタをファむルの 終端に眮きたす。ファむルが存圚しない堎合には、䜜成を詊みたす。
The optional third use_include_path parameter can be set to '1' or TRUE if you want to search for the file in the include_path, too.
'a+' - 読みこみ・曞きこみ甚でオヌプンしたす。ファむルポむンタを ファむルの終端に眮きたす。ファむルが存圚しない堎合には、䜜成を 詊みたす。
If the open fails, the function returns FALSE.
オプションの2番目の匕数を䜿甚しお、これに"1"を蚭定する こずにより、 include_path のファむルの怜玢も行うこずもできたす。
Example 1. fopen() example
䟋 1 fopen() の䟋
If you are experiencing problems with reading and writing to files and you' re using the server module version of PHP, remember to make sure that the files and directories you're using are accessible to the server process.
ファむルの読みこみ・曞きこみ時に問題が発生し、 サヌバヌモゞュヌル版のPHPを䜿甚しおいる堎合、 䜿甚するファむル・ディレクトリがサヌバヌプロセスからアクセス可胜 かどうかを確認しおみおください。
?php $handle = fopen ("c:\\data\\info.txt", "r");?
Windows 環境では、ファむルパスで甚いる党おのバックスラッシュを ゚スケヌプするかフォワヌドスラッシュを䜿甚するこずに泚意しお䞋さい。
Prev
fclose(), fsockopen(), socket_set_timeout(), popen() も参照䞋さい。
Prev
(PHP 3, PHP 4)
Reads to EOF on the given file pointer from the current position and writes the results to the output buffer.
䞎えられたファむルポむンタをEOFたで読み、結果を暙準出力に曞き出し たす。
Otherwise, fpassthru() returns the number of characters read from handle and passed through to the output.
゚ラヌが起こった堎合、 fpassthru() は FALSE を返したす。
You may need to call rewind() You may need to call rewind() to reset the file pointer to the beginning of the file if you have already written data to the file.
ファむルポむンタは有効なものでなければならず、たた fopen(), popen() たたは fsockopen() で正垞にオヌプンされたファむルを指しおいる必芁がありたす。 fpassthru() はファむルを読み終えるず そのファむルをクロヌズしたす残った fp はもはや䜿甚できたせん。
If you just want to dump the contents of a file to the output buffer, without first modifying it or seeking to a particular offset, you may want to use the readfile(), which saves you the fopen() call.
ファむルの内容を暙準出力にダンプしたいだけの堎合、 readfile() を䜿甚するこずが可胜です。 この堎合、 fopen() コヌルは必芁ありたせん。
You are encouraged to use the b flag when dealing with binary files, even if your system does not require it, so that your scripts will be more portable.
泚意 fpassthru() をWindowsシステムのバむナリファむ ルで䜿甚する堎合、 fopen() をコヌルする際に モヌドに b を远加しおバむナリモヌドでファむルを オヌプンするようにしお䞋さい。
Prev
readfile(), fopen(), popen(), fsockopen() も参照䞋さい。
Write a string produced according to the formatting string format to the stream resource specified by handle..
(PHP 5 CVS only)
This applies to fprintf(), sprintf(), and printf().
Write a string produced according to the formatting string format to the stream resource specified by handle..
The default is right-justified; a - character here will make it left-justified.
Each conversion specification consists of a percent sign (%), followed by one or more of these elements, in order:
A type specifier that says what type the argument data should be treated as.
An optional alignment specifier that says if the result should be left-justified or right-justified. The default is right-justified; a - character here will make it left-justified.
c - the argument is treated as an integer, and presented as the character with that ASCII value.
An optional number, a width specifier that says how many characters (minimum) this conversion should result in.
u - the argument is treated as an integer, and presented as an unsigned decimal number.
An optional precision specifier that says how many decimal digits should be displayed for floating-point numbers. This option has no effect for other types than float. (Another function useful for formatting numbers is number_format().)
o - the argument is treated as an integer, and presented as an octal number.
A type specifier that says what type the argument data should be treated as. Possible types:
X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).
See also: printf(), sprintf(), sscanf(), fscanf(), vsprintf(), and number_format().
Example 1. sprintf(): zero-padded integers
䟋 1 sprintf(): zero-padded integers
$money1 = 68.75; $money2 = 54.35; $money = $money1 + $money2; / / echo $money will output "123.1"; $formatted = sprintf("%01.2f", $money); / / echo $formatted will output "123.10 "
䟋 2 sprintf(): formatting currency
(PHP 3, PHP 4)
(PHP 3, PHP 4)
Note that the length parameter is optional and if not specified the entire string will be written.
fputs() は fwrite() の別名で、すべおの面で同䞀です。 length パラメヌタはオプションであり、 指定されない堎合、文字列党䜓が曞かれるこずに泚意しお䞋さい。
fread() reads up to length bytes from the file pointer referenced by handle.
(PHP 3, PHP 4)
?php / / get contents of a file into a string $filename = "/ usr / local / something.txt"; $handle = fopen ($filename, "r"); $contents = fread ($handle, filesize ($filename)); fclose ($handle);?
fread() は fp が指す ファむルポむンタから最高 length バむト 読み蟌みたす。読み蟌みは、 length バむト分 読み蟌たれたか、EOFに達したかのいずれか早い方の事象により䞭止 されたす。
?php $filename = "c:\\files\\somepic.gif"; $handle = fopen ($filename, "rb"); $contents = fread ($handle, filesize ($filename)); fclose ($handle);?
泚意 バむナリずテキストファむルの圢匏が異なるシステム(すなわち Windows)では、 fopen() の mode パラメヌタに'b' を指定しおファむルをオヌプンする必芁がありたす。
Prev
fwrite(), fopen(), fsockopen(), popen(), fgets(), fgetss(), fscanf(), file(), fpassthru() も参照䞋さい。
Prev
(PHP 3, PHP 4)
Converts a date from the French Republican Calendar to a Julian Day Count.
日付けをフランス革呜暊からナリりス積算日に倉換したす。
This more than covers the period when the calendar was in use.
これらのルヌチンは、1から14幎たで(グレゎリりス暊の1792幎9月22日から 1806幎9月22日)日付けのみを倉換したす。 この期間は、フランス革呜暊が䜿甚されおいた期間を十分にカバヌしおいたす。
This function is EXPERIMENTAL.
(PHP 4 = 4.0.4)
Use this function at your own risk.
この関数は、 実隓的 なステヌタスにありたす。これは、この関数の 動䜜、関数名、ここで曞かれおいるこず党おがPHPの将来のバヌゞョンで予告 なく倉曎される可胜性があるこずを意味したす。泚意を喚起するずずもに自分 のリスクでこの関数を䜿甚しお䞋さい。
Prev
この関数は、 珟圚のずころ詳现な情報はありたせん。匕数のリストのみが 蚘述されおいたす。
(PHP 4 = 4.0.1)
(PHP 4 = 4.0.1)
If only two parameters were passed to this function, the values parsed will be returned as an array.
関数 fscanf() は sscanf() に 䌌おいたすが、 handle が指すファむルから入力 を取埗し、指定したフォヌマット format に基 づき解釈を行いたす。この関数のパラメヌタが二぀だけの堎合、凊理さ れた倀は配列ずしお返されたす。他方、オプションのパラメヌタが指定 された堎合、この関数は、代入された倀の数を返したす。オプション匕 数は参照枡しずする必芁がありたす。
The optional parameters must be passed by reference.
䟋 1 fscanf() の䟋
This means that even a tab \t in the format string can match a single space character in the input stream.
䟋 2users.txt
$handle = fopen ("users.txt" ,"r"); while ($userinfo = fscanf ($handle, "%s\t%s\t%s\n")) {list ($name, $profession, $countrycode) = $userinfo; / /... do something with the values} fclose($handle);
fread(), fgets(), fgetss(), sscanf(), printf(), sprintf() も参照䞋さい。
Prev
(PHP 3, PHP 4)
Sets the file position indicator for the file referenced by handle .The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by whence, whose values are defined as follows:
fp が指しおいるファむルのファむル䜍眮識別子 をファむル・ストリヌム䞭の offset バむト目 にセットしたす。新芏䜍眮は、ファむルの先頭からのバむト数で 蚈られたす。これは whence で指定した䜍眮に offset を远加するこずにより埗られたす。 この倀は、以䞋のように定矩されっYり
SEEK_CUR - Set position to current location plus offset.
whence を指定しない堎合、SEEK_SETが指定された ず仮定したす。
If whence is not specified, it is assumed to be SEEK_SET.
成功するず0を返し、そうでなければ-1を返したす。EOFより先の 䜍眮にシヌクしおも゚ラヌずはならないので泚意しお䞋さい。
May not be used on file pointers returned by fopen() if they use the "http: / / "or "ftp: / /" formats.
"http://"たたは"ftp://"フォヌマット指定の fopen () により返されたファむルポむンタに察しおは䜿わないで䞋さい。
The whence argument was added after PHP 4.0.0.
泚意 匕数 whence はPHP 4.0.0以降で远加されたした。
Prev
ftell() および rewind() も参照䞋さい。
Prev
(PHP 3, PHP 4)
For UDP connections, you need to explicitly specify the protocol by prefixing hostname with 'udp: / /'.
泚意 ゜ケット経由でデヌタを読み曞きする際のタむムアりトを蚭定する必芁がある堎合、 fsockopen() の timeout パラメヌタは、 ゜ケットに接続する間のみ適甚されるため、 socket_set_timeout() を䜿甚しおください。
The optional timeout can be used to set a timeout in seconds for the connect system call.
PHP 4.3.0以降、OpenSSLサポヌトを有効にしおコンパむルした堎合、 hostname の前に' ssl:// 'たたは' tls:// 'を付加するこずにより、TCP/IP経由でリモヌトホストに 接続する際にSSLたたはTLSクラむアント接続を䜿甚するこずができたす。
As of PHP 4.3.0, if you have compiled in OpenSSL support, you may prefix the hostname with either 'ssl: / /' or 'tls: / /' to use an SSL or TLS client connection over TCP / IP to connect to the remote host.
fsockopen() は、ファむルポむンタを返したす。 このファむルポむンタは、 (fgets(), fgetss(), fputs(), fclose(), feof() のような) 他のファむル関数で䜿甚可胜です。
If the call fails, it will return FALSE and if the optional errno and errstr arguments are present they will be set to indicate the actual system level error that occurred in the system-level connect() call.
コヌルに倱敗した堎合には FALSE が返され、オプションの匕数 errno および errstr が指定されおいる堎合、システムコヌル connect() で生じた実際のシステムレベル゚ラヌを瀺すように蚭定されたす。 errno は 0 なのに関数が FALSE を返す堎合、 connect() をコヌルする前に゚ラヌを発生したこずを瀺したす。 この堎合、おそらくは゜ケットの初期化に原因がありたす。匕数 errno および errstr は垞に参照枡しであるこずに泚意しおください。
This is most likely due to a problem initializing the socket.
環境によっおはUNIXドメむンたたはオプションの接続タむムアりトは利甚 できたせん。
Depending on the environment, the Unix domain or the optional connect timeout may not be available.
゜ケットはデフォルトでブロックモヌドで開かれたす。 socket_set_blocking() を䜿甚しお、 非ブロックモヌドに切換えるこずができたす。
You can switch it to non-blocking mode by using socket_set_blocking().
䟋 1 fsockopen() の䟋
?php $fp = fsockopen( "udp: / /127.0.0.1", 13, $errno, $errstr); if (!$fp) {echo "ERROR: $errno - $errstr br \n";} else {fwrite($fp ,"\n"); echo fread($fp, 26); fclose($fp);}?
䟋 2UDP接続の䜿甚法
The reason for this is because UDP is a "connectionless" protocol, which means that the operating system does not try to establish a link for the socket until it actually needs to send or receive data.
UDP゜ケットは、リモヌトホストずの接続が確立されおいない堎合でも、 ゚ラヌを発生せずにオヌプンされたように芋えるこずが時々ありたす。 この゚ラヌは、その゜ケットでデヌタを読み曞きした際にのみ明らかに なりたす。この原因は、UDPが"コネクションレス"のプロトコルであり、 実際にデヌタを送受信する必芁が生じるたで、オペレヌションシステムが ゜ケット甚のリンクを確立しようずしないためです。
Prev
泚意 timeout は PHP 3.0.9 でサポヌトされたし た。たた、UDP のサポヌトは PHP 4で远加されたした。
(PHP 4)
(PHP 4)
This function is similar to the stat() function except that it operates on an open file pointer instead of a filename.
ファむルポむンタfpによりオヌプンされたファむルの統蚈情報を取埗し たす。この関数は関数 stat() に䌌おいたすが、 ファ むル名の代わりにオヌプンされたファむルポむンタを指定するずころが 異なりたす。