本文整理汇总了PHP中Path::split方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::split方法的具体用法?PHP Path::split怎么用?PHP Path::split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::split方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: real
public static function real($path)
{
$path = Path::split($path);
$newpath = array();
while (list(, $v) = each($path)) {
switch ($v) {
case '.':
continue;
case '..':
array_pop($newpath);
continue;
default:
$newpath[] = $v;
}
}
return Path::join($newpath);
}
示例2: searchFiles
function searchFiles($path, $name, $content)
{
if ($name === '' && $content === '') {
throw new NameException();
}
$parent = $this->rootFolder;
if ($parent->isProxy) {
if ($parent->canSearch) {
return $parent->searchFiles($path, $name, $content);
}
return [];
}
$splitPaths = Path::split($path);
$passedFolders = [];
while ($splitPaths) {
$folderName = array_shift($splitPaths);
$passedFolders[] = $folderName;
$item = $parent->get($folderName);
if (!$item) {
throw new FolderNotFoundException(Path::join($passedFolders));
} else {
if ($item instanceof File) {
throw new NotAFolderException($path);
} elseif ($item->isProxy) {
if ($item->canSearch) {
$files = $item->searchFiles(Path::join($splitPaths), $name, $content);
foreach ($files as &$file) {
$file['path'] = Path::join([$path, $file['path']]);
}
return $files;
}
throw new NotAFolderException(Path::join($passedFolders));
}
}
$parent = $item;
}
$files = $parent->searchFiles($name, $content);
foreach ($files as &$file) {
$file['path'] = Path::join([$path, $file['path']]);
}
return $files;
}
示例3: searchFiles
function searchFiles($path, $name, $content)
{
$splitPaths = Path::split($path);
$this->chdir($splitPaths);
$files = $this->searchFilesRecursive($name, $content, []);
foreach ($files as &$file) {
$file['path'] = Path::join([$path, $file['path']]);
}
return $files;
}
示例4: remove
function remove($path)
{
$this->sessionSuspend();
try {
$ftp = $this->getConnection();
$splitPaths = Path::split($path);
$name = array_pop($splitPaths);
$this->chdir($ftp, $splitPaths);
if (ftp_is_dir($ftp, $name)) {
include_once __DIR__ . '/../fns/ftp_rrmdir.php';
$ok = ftp_rrmdir($ftp, $name);
if (!$ok) {
throw new ReadWriteException($path);
}
} elseif (ftp_is_file($ftp, $name)) {
$ok = @ftp_delete($ftp, $name);
if (!$ok) {
throw new ReadWriteException($path);
}
} else {
throw new FileNotFoundException($path);
}
} catch (Exception $e) {
$this->sessionResume();
throw $e;
}
$this->sessionResume();
}
示例5: foreach
$items = $index['items'];
if ($items) {
foreach ($items as $item) {
$name = $href = $item['name'];
$type = $item['type'];
if ($type == 'parent-folder') {
$href = '..';
$name = '.. Parent Folder';
} elseif ($type == 'folder') {
$href .= '/';
$name .= '/';
}
$html .= '<div>' . '<a href="' . htmlspecialchars($href) . '">' . htmlspecialchars($name) . '</a>' . '</div>';
}
} else {
$html .= '<div style="color: #474740">Folder is empty.</div>';
}
$html .= '</body>' . '</html>';
echo $html;
} else {
$splitPath = Path::split($path);
$folderName = array_pop($splitPath);
redirect("{$folderName}/");
}
}
} catch (FolderNotFoundException $e) {
header('HTTP/1.1 404 Not Found');
echo '<!DOCTYPE html>' . '<html>' . '<head>' . '<title>404 Not Found</title>' . '</head>' . '<body>' . '<h1>404 Not Found</h1>' . '</body>' . '</html>';
} catch (FileSystemException $e) {
$e->echoClientJson();
}