PHP 클래스 yii\helpers\BaseStringHelper

Do not use BaseStringHelper. Use [[StringHelper]] instead.
부터: 2.0
저자: Qiang Xue ([email protected])
저자: Alex Makarov ([email protected])
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 메소드들

메소드 설명
basename ( string $path, string $suffix = '' ) : string Returns the trailing name component of a path.
byteLength ( string $string ) : integer Returns the number of bytes in the given string.
byteSubstr ( string $string, integer $start, integer $length = null ) : string Returns the portion of string specified by the start and length parameters.
countWords ( string $string ) : integer Counts words in a string
dirname ( string $path ) : string Returns parent directory's path.
endsWith ( string $string, string $with, boolean $caseSensitive = true ) : boolean Check if given string ends with specified substring.
explode ( string $string, string $delimiter = ',', mixed $trim = true, boolean $skipEmpty = false ) : array Explodes string into array, optionally trims values and skips empty ones
startsWith ( string $string, string $with, boolean $caseSensitive = true ) : boolean Check if given string starts with specified substring.
truncate ( string $string, integer $length, string $suffix = '...', string $encoding = null, boolean $asHtml = false ) : string Truncates a string to the number of characters specified.
truncateWords ( string $string, integer $count, string $suffix = '...', boolean $asHtml = false ) : string Truncates a string to the number of words specified.

보호된 메소드들

메소드 설명
truncateHtml ( string $string, integer $count, string $suffix, string | boolean $encoding = false ) : string Truncate a string while preserving the HTML.

메소드 상세

basename() 공개 정적인 메소드

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 "..".
또한 보기: http://www.php.net/manual/en/function.basename.php
public static basename ( string $path, string $suffix = '' ) : string
$path string A path string.
$suffix string If the name component ends in suffix this will also be cut off.
리턴 string the trailing name component of the given path.

byteLength() 공개 정적인 메소드

This method ensures the string is treated as a byte array by using mb_strlen().
public static byteLength ( string $string ) : integer
$string string the string being measured for length
리턴 integer the number of bytes in the given string.

byteSubstr() 공개 정적인 메소드

This method ensures the string is treated as a byte array by using mb_substr().
또한 보기: http://www.php.net/manual/en/function.substr.php
public static byteSubstr ( string $string, integer $start, integer $length = null ) : string
$string string the input string. Must be one character or longer.
$start integer the starting position
$length integer the desired portion length. If not specified or `null`, there will be no limit on length i.e. the output will be until the end of the string.
리턴 string the extracted part of string, or FALSE on failure or an empty string.

countWords() 공개 정적인 메소드

Counts words in a string
부터: 2.0.8
public static countWords ( string $string ) : integer
$string string
리턴 integer

dirname() 공개 정적인 메소드

This method is similar to dirname() except that it will treat both \ and / as directory separators, independent of the operating system.
또한 보기: http://www.php.net/manual/en/function.basename.php
public static dirname ( string $path ) : string
$path string A path string.
리턴 string the parent directory's path.

endsWith() 공개 정적인 메소드

Binary and multibyte safe.
public static endsWith ( string $string, string $with, boolean $caseSensitive = true ) : boolean
$string string Input string to check
$with string Part to search inside of the $string.
$caseSensitive boolean Case sensitive search. Default is true. When case sensitive is enabled, $with must exactly match the ending of the string in order to get a true value.
리턴 boolean Returns true if first input ends with second input, false otherwise

explode() 공개 정적인 메소드

Explodes string into array, optionally trims values and skips empty ones
부터: 2.0.4
public static explode ( string $string, string $delimiter = ',', mixed $trim = true, boolean $skipEmpty = false ) : array
$string string String to be exploded.
$delimiter string Delimiter. Default is ','.
$trim mixed Whether to trim each element. Can be: - boolean - to trim normally; - string - custom characters to trim. Will be passed as a second argument to `trim()` function. - callable - will be called for each value instead of trim. Takes the only argument - value.
$skipEmpty boolean Whether to skip empty strings between delimiters. Default is false.
리턴 array

startsWith() 공개 정적인 메소드

Binary and multibyte safe.
public static startsWith ( string $string, string $with, boolean $caseSensitive = true ) : boolean
$string string Input string
$with string Part to search inside the $string
$caseSensitive boolean Case sensitive search. Default is true. When case sensitive is enabled, $with must exactly match the starting of the string in order to get a true value.
리턴 boolean Returns true if first input starts with second input, false otherwise

truncate() 공개 정적인 메소드

Truncates a string to the number of characters specified.
public static truncate ( string $string, integer $length, string $suffix = '...', string $encoding = null, boolean $asHtml = false ) : string
$string string The string to truncate.
$length integer How many characters from original string to include into truncated string.
$suffix string String to append to the end of truncated string.
$encoding string The charset to use, defaults to charset currently used by application.
$asHtml boolean Whether to treat the string being truncated as HTML and preserve proper HTML tags. This parameter is available since version 2.0.1.
리턴 string the truncated string.

truncateHtml() 보호된 정적인 메소드

Truncate a string while preserving the HTML.
부터: 2.0.1
protected static truncateHtml ( string $string, integer $count, string $suffix, string | boolean $encoding = false ) : string
$string string The string to truncate
$count integer
$suffix string String to append to the end of the truncated string.
$encoding string | boolean
리턴 string

truncateWords() 공개 정적인 메소드

Truncates a string to the number of words specified.
public static truncateWords ( string $string, integer $count, string $suffix = '...', boolean $asHtml = false ) : string
$string string The string to truncate.
$count integer How many words from original string to include into truncated string.
$suffix string String to append to the end of truncated string.
$asHtml boolean Whether to treat the string being truncated as HTML and preserve proper HTML tags. This parameter is available since version 2.0.1.
리턴 string the truncated string.