PHP 클래스 Ouzo\Utilities\StrSubstitutor

파일 보기 프로젝트 열기: letsdrink/ouzo 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( array $values = [], null | string $default = null ) Creates a substitutor object that uses the given array for placeholders resolution.
replace ( string $string ) : mixed Replaces placeholders {{PLACEHOLDER_NAME}} with their values.

비공개 메소드들

메소드 설명
_replace_vars ( array $match ) : string

메소드 상세

__construct() 공개 메소드

Optionally, substitutor can use the $default when no value is found for a placeholder.
public __construct ( array $values = [], null | string $default = null )
$values array
$default null | string

replace() 공개 메소드

Example: $strSubstitutor = new StrSubstitutor(array('NAME' => 'John', 'SURNAME' => 'Smith')); $substituted = $strSubstitutor->replace('Hi, {{NAME}} {{SURNAME}}'); Result: Hi, John Smith Example: $strSubstitutor = new StrSubstitutor(array(), 'Unknown'); $substituted = $strSubstitutor->replace('Hi, {{NAME}}'); Result: Hi, Unknown
public replace ( string $string ) : mixed
$string string
리턴 mixed