PHP 8.4.0 RC4 available for testing

svn_cat

(PECL svn >= 0.1.0)

svn_catReturns the contents of a file in a repository

说明

svn_cat(string $repos_url, int $revision_no = ?): string

Returns the contents of the URL repos_url to a file in the repository, optionally at revision number revision_no.

参数

repos_url

String URL path to item in a repository.

revision_no

Integer revision number of item to retrieve, default is the HEAD revision.

返回值

Returns the string contents of the item from the repository on success, and false on failure.

示例

示例 #1 Basic example

This example retrieves the contents of a file at revision 28:

<?php
$contents
= svn_cat('http://www.example.com/svnroot/calc/gui.c', 28)
?>

注释

警告

此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担。

添加备注

用户贡献的备注 2 notes

up
1
Adam
11 years ago
There is a difference how svn cat works for deleted files. For deleted file commandline `svn cat -r xxx <full_url>` will give error, but 'svn cat <full_url>@xxx` will cat file from the past.
Unfortunately this method will not cat deleted file.
up
0
colm
10 years ago
Just to add to Adam's comment, when retrieving a file contents I found I got the best results using the same revision in both places every time; ie. as follows:

<?php
svn_cat
($url.'@'.$revision, $revision);
?>

The one appended to the URL is the peg revision, and the one in the second paramer is the operative revision.

This seems to cover all the bases.
To Top