本文整理汇总了PHP中mb_strrchr函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_strrchr函数的具体用法?PHP mb_strrchr怎么用?PHP mb_strrchr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_strrchr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($https = false)
{
$root = mb_strrchr($_SERVER['PHP_SELF'], '/', true);
if (isset($_SERVER['HTTPS']) || $https) {
$prefix = 'https://';
} else {
$prefix = 'http://';
}
$this->setBaseUri($prefix . $_SERVER['HTTP_HOST'] . $root);
$aPageParams = explode('/', $_SERVER['QUERY_STRING'], 2048);
$this->setPage(array_shift($aPageParams));
$tmpParamsObj = new stdClass();
while (count($aPageParams)) {
$sKey = strip_tags(rawurldecode(array_shift($aPageParams)));
$sValue = strip_tags(rawurldecode(array_shift($aPageParams)));
if (empty($sKey)) {
continue;
}
if (strstr($sValue, ',')) {
$sValue = explode(',', $sValue, 2048);
}
$tmpParamsObj->{$sKey} = $sValue;
}
$this->setPageParams($tmpParamsObj);
}
示例2: uploadFile
/**
* Copy an image uploaded with HTML form to the specified directory.
* In view scripts one should use something like <img src="{$fileBaseDir}/{@return}"/>
*
* @param string $paramName Parameter name as it passed by a form.
* @param string $fileBaseDir A base directory constant for the file (should be used in view scripts as prefix before $filePath from DB table).
* @return string New file's name.
* @throws CException
*/
public static function uploadFile($paramName, $fileBaseDir)
{
if(empty($_FILES[AutoAdmin::INPUT_PREFIX]['tmp_name'][$paramName]) || !empty($_FILES[AutoAdmin::INPUT_PREFIX]['error'][$paramName]))
throw new AAException(Yii::t('AutoAdmin.errors', 'An error occured with uploading of the file for field "{field}"', array('{field}'=>$paramName)));
$uploadedFileName =& $_FILES[AutoAdmin::INPUT_PREFIX]['name'][$paramName];
$newfname = '';
$toDir = self::srcToPath($fileBaseDir);
$newfname = mb_strtolower(mb_substr($uploadedFileName, 0, mb_strrpos($uploadedFileName, '.')));
$newfname = AAHelperText::translite($newfname);
$newfname = str_replace(' ', '_', $newfname);
$newfname = preg_replace('/[^a-z\-\_0-9]/ui', '', $newfname);
if(mb_strlen($newfname)>60)
$newfname = mb_substr($newfname, 0, 60);
$ext = mb_substr(mb_strrchr($uploadedFileName, '.'), 1);
if(!is_dir($toDir))
{
if(!mkdir($toDir, 0777, true))
throw new AAException(Yii::t('AutoAdmin.errors', 'The directory "{dirname}" cannot be created', array('{dirname}'=>$toDir)));
}
while(file_exists($toDir.DIRECTORY_SEPARATOR.$newfname.'.'.$ext))
$newfname .= '_'.rand(0, 9);
$newfname .= ".{$ext}";
if(!copy($_FILES[AutoAdmin::INPUT_PREFIX]['tmp_name'][$paramName], $toDir.DIRECTORY_SEPARATOR.$newfname))
throw new AAException(Yii::t('AutoAdmin.errors', 'The file ({filename}) cannot be copied', array('{filename}'=>$newfname)));
return $newfname;
}
示例3: copyImage
function copyImage($var, $uploadDir='/i/other')
{
$newFileName = '';
$newFileName = mb_strtolower(mb_substr($_FILES[$var]['name'], 0, mb_strrpos($_FILES[$var]['name'], '.')));
$newFileName = AAHelperText::translite($newFileName);
$newFileName = str_replace(' ', '_', $newFileName);
$newFileName = preg_replace('/[^a-z\-\_0-9]/ui', '', $newFileName);
if(mb_strlen($newFileName)>60)
$newFileName = mb_substr($newFileName, 0, 60);
$ext = mb_strrchr($_FILES[$var]['name'], '.');
$newFileName .= $ext;
$fileLinkDir = $uploadDir;
$targetPath = Yii::app()->basePath.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.Yii::app()->modules['autoadmin']['wwwDirName'].str_replace('/', DIRECTORY_SEPARATOR, $uploadDir);
if(!is_dir($targetPath))
{
if(!mkdir($targetPath))
throw new CHttpException(406, "Указанная в настройках директория [{$fileLinkDir}] не существует и не может быть создана.");
}
$targetPath .= DIRECTORY_SEPARATOR.$newFileName;
if(!copy($_FILES[$var]['tmp_name'], $targetPath))
throw new CHttpException(406, "Файл невозможно сохранить в указанной в настройках директории [{$fileLinkDir}]. Вероятнее всего, проблемы с правами.");
if(!getimagesize($targetPath))
{
throw new CHttpException(406, "Загружаемый файл не является изображением допустимого формата.");
}
return $fileLinkDir.'/'.$newFileName;
}
示例4: strrchr
/**
* Метод возвращает последнее вхождение символа в строке
*
* @param string $string
* @param string $charset
* @return string
*
* @version 0.1 21.08.2011
* @since 0.1
* @author webmaxx <webmaxx@webmaxx.name>
*/
public function strrchr($string, $charset = 'UTF-8')
{
if ($this->_functionExists('mb_strrchr')) {
return mb_strrchr($string, $charset);
} else {
return strrchr($string);
}
}
示例5: PMA_languageName
/**
* Returns language name
*
* @param string $tmplang Language code
*
* @return string
*/
function PMA_languageName($tmplang)
{
$lang_name = ucfirst(mb_substr(mb_strrchr($tmplang[0], '|'), 1));
// Include native name if non empty
if (!empty($tmplang[2])) {
$lang_name = $tmplang[2] . ' - ' . $lang_name;
}
return $lang_name;
}
示例6: buildDescription2
protected function buildDescription2($data)
{
if (!$this->ga_description2) {
$text = "{KEYWORD:{$data}}";
if (strlen($text) > 35) {
if (mb_strlen($data, 'utf-8') > 25) {
$tmp = mb_substr($data, 0, 25, 'utf-8');
$tmp2 = mb_strrchr($tmp, ' ', true, 'utf-8');
$text = "{KEYWORD:" . mb_substr($data, 0, mb_strlen($tmp2, 'utf-8'), 'utf-8') . "}";
}
}
$this->setDescription2($text);
}
}
示例7: createCommand
/**
* Creates a DB command that can be used to execute this query.
*
* @param Connection $db the DB connection used to create the DB command.
* If null, the DB connection returned by [[modelClass]] will be used.
*
* @return Command the created DB command instance.
*/
public function createCommand($db = null)
{
/** @type ActiveRecord $modelClass */
$modelClass = $this->modelClass;
if ($db === null) {
$db = $modelClass::getDb();
}
if ($this->from === null) {
$this->from = $modelClass::modelName();
}
if ($this->searchModel === null) {
$this->searchModel = mb_substr(mb_strrchr($this->modelClass, '\\'), 1) . 'Search';
}
return parent::createCommand($db);
}
示例8: printValue
public function printValue()
{
if($this->value)
{
$ext = mb_substr(mb_strrchr($this->value, '.'), 1);
if(!$ext)
$ext = '';
$spanOptions = array('class'=>'file'.($ext ? " ext-{$ext}" : ''));
if(in_array($ext, array('jpg', 'gif', 'png')))
return CHtml::link($this->value, "{$this->options['directoryPath']}/{$this->value}", $spanOptions);
else
return CHtml::tag('span', $spanOptions, $this->value);
}
else
return null;
}
示例9: find
function find($needle, $ignoreCase = false, $reverse = false)
{
if ($ignoreCase) {
if ($reverse) {
$this->__invar = mb_strrichr($this->__invar, $needle);
} else {
$this->__invar = mb_stristr($this->__invar, $needle);
}
} else {
if ($reverse) {
$this->__invar = mb_strrchr($this->__invar, $needle);
} else {
$this->__invar = mb_strstr($this->__invar, $needle);
}
}
return $this;
}
示例10: buildHeadline
protected function buildHeadline($data, $params)
{
if (mb_strlen($data, 'utf-8') > 25) {
if (mb_strlen($data, 'utf-8') > 35) {
$tmp = mb_substr($data, 0, 35, 'utf-8');
$tmp2 = mb_strrchr($tmp, ' ', true, 'utf-8');
$tmp2 = preg_replace("![0-9 ]+\$!", "", $tmp2);
} else {
$tmp2 = $data;
}
$this->setDescription1($tmp2);
$this->setDescription2(mb_substr($text, mb_strlen($tmp2, 'utf-8')), 35, 'utf-8');
$text = 'מחפשים ' . $params[0]['l_make'] . " " . $params[0]['l_model'];
$this->setHeadline($text . "?");
} else {
$this->setHeadline($data);
}
}
示例11: buildHeadline
protected function buildHeadline($data, $params)
{
if (mb_strlen($data, 'utf-8') > 25) {
if (mb_strlen($data, 'utf-8') > 35) {
$tmp = mb_substr($data, 0, 35, 'utf-8');
$tmp2 = mb_strrchr($tmp, ' ', true, 'utf-8');
$tmp2 = preg_replace("![0-9 ]+\$!", "", $tmp2);
} else {
$tmp2 = $data;
}
$this->setDescription1($tmp2);
$this->setDescription2(mb_substr($text, mb_strlen($tmp2, 'utf-8')), 35, 'utf-8');
$text = 'מחפשים ' . $params['l_assetType'];
if (mb_strlen($text . ($params['l_geo_city'] ? " ב" . $params['l_geo_city'] : ""), 'utf-8') < 26) {
$text .= $params['l_geo_city'] ? " ב" . $params['l_geo_city'] : "";
}
$this->setHeadline($text . "?");
} else {
$this->setHeadline($data);
}
}
示例12: PortalNotesFiles
function PortalNotesFiles($file, &$PortalNotesFilesError)
{
global $PortalNotesFilesPath;
if (!$file || !is_uploaded_file($file['tmp_name'])) {
//no file uploaded
$PortalNotesFilesError = _('File not uploaded');
}
//Check the post_max_size & php_value upload_max_filesize values in the php.ini file
//extensions white list
$white_list = array('.doc', '.docx', '.txt', '.pdf', '.xls', '.xlsx', '.csv', '.jpg', '.jpeg', '.png', '.gif', '.zip', '.ppt', '.pptx', '.mp3', '.wav', '.avi', '.mp4', '.ogg');
if (!in_array(mb_strtolower(mb_strrchr($file['name'], '.')), $white_list)) {
$PortalNotesFilesError = _('Unauthorized file attached extension') . ': ' . mb_strtolower(mb_strrchr($file['name'], '.'));
}
if ($file['size'] > 10240000) {
// file size must be < 10Mb
$PortalNotesFilesError = _('File attached size') . ' > 10Mb: ' . $file['size'] / 1024 / 1024 . 'Mb';
}
//if current sYear folder doesnt exist, create it!
if (!is_dir($PortalNotesFilesPath)) {
if (!mkdir($PortalNotesFilesPath)) {
$PortalNotesFilesError = _('Folder not created') . ': ' . $PortalNotesFilesPath;
}
}
if (!is_writable($PortalNotesFilesPath)) {
$PortalNotesFilesError = _('Folder not writable') . ': ' . $PortalNotesFilesPath;
}
//see PHP user rights
if (!empty($PortalNotesFilesError)) {
return '';
}
//store file
$file_name = str_replace(' ', '_', trim($file['name']));
//sanitize name
$file_name = no_accents($file_name);
$new_file = $PortalNotesFilesPath . $file_name;
if (move_uploaded_file($file['tmp_name'], $new_file)) {
return $new_file;
}
return '';
}
示例13: __invoke
/**
* File extension.
*
* @since 150424 Initial release.
*
* @param string $path A filesystem path.
*
* @return string File extension; or empty string.
*/
public function __invoke(string $path) : string
{
if (!$path) {
return '';
// Not possible.
}
if (mb_substr($path, -1) === '/') {
return '';
// Directory.
}
if (!($basename = basename($path))) {
return '';
// Nothing.
}
if (!($ext = mb_strrchr($basename, '.'))) {
return '';
// Nothing.
}
$ext = $this->c::mbLTrim($ext, '.');
$ext = mb_strtolower($ext);
return $ext;
}
示例14: whoCalledMe
public static function whoCalledMe($deep = 1, $back = 0)
{
ob_start();
debug_print_backtrace();
$infos = ob_get_contents();
ob_end_clean();
$id = '#' . ++$deep;
$entry = str_replace(mb_strstr($infos, $id), "", $infos);
if (!$entry) {
$entry = $infos;
}
$it_was_me = mb_strrchr(mb_strrchr($entry, '#'), '/');
$it_was_me = explode(':', mb_substr($it_was_me, 1, -2));
if (!empty($it_was_me[0])) {
return $it_was_me;
} else {
if ($back > 0) {
return self::whoCalledMe(++$deep, --$back);
} else {
return array();
}
}
}
示例15: ext
/**
* Get the extension.
*
* @access public
* @param string $file
* @return string
* @static
*/
public static function ext($file)
{
return mb_strtolower(trim(mb_strrchr($file, '.'), '.'));
}