Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
e9a5b92d
Commit
e9a5b92d
authored
Sep 09, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added StringHelper::dirname()
parent
347e79a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
StringHelperBase.php
framework/yii/helpers/StringHelperBase.php
+20
-2
No files found.
framework/yii/helpers/StringHelperBase.php
View file @
e9a5b92d
...
...
@@ -47,8 +47,8 @@ class StringHelperBase
/**
* Returns the trailing name component of a path.
* This method
does the same as
the php function `basename()` except that it will
*
always use
\ and / as directory separators, independent of the operating system.
* This method
is similar to
the php function `basename()` except that it will
*
treat both
\ and / as directory separators, independent of the operating system.
* This method was mainly created to work on php namespaces. When working with real
* file paths, php's `basename()` should work fine for you.
* Note: this method is not aware of the actual filesystem, or path components such as "..".
...
...
@@ -70,6 +70,24 @@ class StringHelperBase
}
/**
* Returns parent directory's path.
* This method is similar to `dirname()` except that it will treat
* both \ and / as directory separators, independent of the operating system.
* @param string $path A path string.
* @return string the parent directory's path.
* @see http://www.php.net/manual/en/function.basename.php
*/
public
static
function
dirname
(
$path
)
{
$pos
=
mb_strrpos
(
str_replace
(
'\\'
,
'/'
,
$path
),
'/'
);
if
(
$pos
!==
false
)
{
return
mb_substr
(
$path
,
0
,
$pos
);
}
else
{
return
$path
;
}
}
/**
* Compares two strings or string arrays, and return their differences.
* This is a wrapper of the [phpspec/php-diff](https://packagist.org/packages/phpspec/php-diff) package.
* @param string|array $lines1 the first string or string array to be compared. If it is a string,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment