PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

xdiff_string_rabdiff> <xdiff_string_patch_binary
Last updated: Fri, 04 Jul 2008

view this page in

xdiff_string_patch

(PECL xdiff:0.2-1.4)

xdiff_string_patch — 文字列に unified diff 形式のパッチを適用する

説明

string xdiff_string_patch ( string $str , string $patch [, int $flags [, string &$error ]] )

ある文字列に、unified 形式のパッチ文字列 patch を適用します。

パラメータ

str

元の文字列。

patch

unified 形式のパッチ文字列。

flags

flagsXDIFF_PATCH_NORMAL (デフォルト。通常のパッチ) あるいは XDIFF_PATCH_REVERSE (逆パッチ) のいずれかです。

error

これを指定すると、パッチを拒否された部分がここに保存されます。

返り値

パッチ適用後の文字列、あるいはエラー時に FALSE を返します。

例1 xdiff_string_patch() の例

以下のコードは、ある記事に対して変更を適用します。

<?php
$old_article 
file_get_contents('./old_article.txt');
$diff $_SERVER['patch']; /* だれかが html フォームからパッチを投稿したとしましょう */

$errors '';

$new_article xdiff_string_patch($old_article$diffXDIFF_PATCH_NORMAL$errors);
if (
is_string($new_article)) {
    echo 
"新しい記事:\n";
    echo 
$new_article;
}

if (
strlen($errors)) {
    echo 
"Rejects: \n";
    echo 
$errors;
}

?>



add a note add a note User Contributed Notes
xdiff_string_patch
There are no user contributed notes for this page.

xdiff_string_rabdiff> <xdiff_string_patch_binary
Last updated: Fri, 04 Jul 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites