• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ltrim函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ltrim函数的典型用法代码示例。如果您正苦于以下问题:PHP ltrim函数的具体用法?PHP ltrim怎么用?PHP ltrim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ltrim函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: execute

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $class_name = ltrim($input->getArgument('class_name'), '\\');
        $namespace_root = $input->getArgument('namespace_root_path');
        $match = [];
        preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match);
        if ($match) {
            $root_namespace = $match[1];
            $rest_fqcn = $match[2];
            $proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php';
            $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn;
            $proxy_class_string = $this->proxyBuilder->build($class_name);
            $file_string = <<<EOF
<?php
// @codingStandardsIgnoreFile

/**
 * This file was generated via php core/scripts/generate-proxy-class.php '{$class_name}' "{$namespace_root}".
 */
{{ proxy_class_string }}
EOF;
            $file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string);
            mkdir(dirname($proxy_filename), 0775, TRUE);
            file_put_contents($proxy_filename, $file_string);
            $output->writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename));
        }
    }
开发者ID:318io,项目名称:318-io,代码行数:30,代码来源:GenerateProxyClassCommand.php


示例2: addView

 /**
  * Add a View instance to the Collector
  *
  * @param \Illuminate\View\View $view
  */
 public function addView(View $view)
 {
     $name = $view->getName();
     $path = $view->getPath();
     if (!is_object($path)) {
         if ($path) {
             $path = ltrim(str_replace(base_path(), '', realpath($path)), '/');
         }
         if (substr($path, -10) == '.blade.php') {
             $type = 'blade';
         } else {
             $type = pathinfo($path, PATHINFO_EXTENSION);
         }
     } else {
         $type = get_class($view);
         $path = '';
     }
     if (!$this->collect_data) {
         $params = array_keys($view->getData());
     } else {
         $data = array();
         foreach ($view->getData() as $key => $value) {
             $data[$key] = $this->exporter->exportValue($value);
         }
         $params = $data;
     }
     $this->templates[] = array('name' => $path ? sprintf('%s (%s)', $name, $path) : $name, 'param_count' => count($params), 'params' => $params, 'type' => $type);
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:33,代码来源:ViewCollector.php


示例3: uploads_path

 /**
  * Get the URL to uploads_path folder
  *
  * @param  string  $path
  * @param  bool    $secure
  * @return string
  */
 function uploads_path($upload)
 {
     if (file_exists(public_path() . 'uploads/' . $upload)) {
         return 'no image broh';
     }
     return public_path() . '/uploads/' . ltrim($upload, '/');
 }
开发者ID:benhanks040888,项目名称:rmyrfl,代码行数:14,代码来源:helpers.php


示例4: convertToBytes

 private function convertToBytes($memoryLimit)
 {
     if ('-1' === $memoryLimit) {
         return -1;
     }
     $memoryLimit = strtolower($memoryLimit);
     $max = strtolower(ltrim($memoryLimit, '+'));
     if (0 === strpos($max, '0x')) {
         $max = intval($max, 16);
     } elseif (0 === strpos($max, '0')) {
         $max = intval($max, 8);
     } else {
         $max = intval($max);
     }
     switch (substr($memoryLimit, -1)) {
         case 't':
             $max *= 1024;
         case 'g':
             $max *= 1024;
         case 'm':
             $max *= 1024;
         case 'k':
             $max *= 1024;
     }
     return $max;
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:26,代码来源:MemoryDataCollector.php


示例5: __construct

 public function __construct()
 {
     $logPath = CoreHelper::loadConfig("log_path", "config");
     $logFileExtension = CoreHelper::loadConfig("log_file_extension", "config");
     $logThreshold = CoreHelper::loadConfig("log_threshold", "config");
     $logDateFormat = CoreHelper::loadConfig("log_date_format", "config");
     $logFilePermissions = CoreHelper::loadConfig("log_file_permissions", "config");
     $this->_log_path = $logPath !== '' ? $logPath : APPPATH . 'logs/';
     $this->_file_ext = isset($logFileExtension) && $logFileExtension !== '' ? ltrim($logFileExtension, '.') : 'php';
     file_exists($this->_log_path) || mkdir($this->_log_path, 0755, true);
     if (!is_dir($this->_log_path) || !CoreHelper::isWriteable($this->_log_path)) {
         $this->_enabled = false;
     }
     if (is_numeric($logThreshold)) {
         $this->_threshold = (int) $logThreshold;
     } elseif (is_array($logThreshold)) {
         $this->_threshold = 0;
         $this->_threshold_array = array_flip($logThreshold);
     }
     if (!empty($logDateFormat)) {
         $this->_date_fmt = $logDateFormat;
     }
     if (!empty($logFilePermissions) && is_int($logFilePermissions)) {
         $this->_file_permissions = $logFilePermissions;
     }
 }
开发者ID:ErosZy,项目名称:CSF,代码行数:26,代码来源:CoreLog.php


示例6: load_request

 static function load_request($allow)
 {
     $uri = getRequestURI();
     $parts = explode('?', $uri);
     $uri = $parts[0];
     $path = ltrim(substr($uri, strlen(WEBPATH) + 1), '/');
     if (empty($path)) {
         return $allow;
     } else {
         $rest = strpos($path, '/');
         if ($rest === false) {
             if (strpos($path, '?') === 0) {
                 // only a parameter string
                 return $allow;
             }
             $l = $path;
         } else {
             $l = substr($path, 0, $rest);
         }
     }
     $locale = validateLocale($l, 'seo_locale');
     if ($locale) {
         // set the language cookie and redirect to the "base" url
         zp_setCookie('dynamic_locale', $locale);
         $uri = pathurlencode(preg_replace('|/' . $l . '[/$]|', '/', $uri));
         if (isset($parts[1])) {
             $uri .= '?' . $parts[1];
         }
         header("HTTP/1.0 302 Found");
         header("Status: 302 Found");
         header('Location: ' . $uri);
         exitZP();
     }
     return $allow;
 }
开发者ID:JoniWeiss,项目名称:JoniWebGirl,代码行数:35,代码来源:seo_locale.php


示例7: getFileForPhotoWithScale

 /**
  * getFileForPhotoWithScale function.
  * 
  * @access private
  * @param Models\Photo $photo
  * @param mixed $scale
  * @return [$file, $temp, $mtime]
  */
 private static function getFileForPhotoWithScale(Models\Photo $photo, $scale)
 {
     $extension = $photo->extension;
     $bucket = 'other';
     $path = '';
     if ($scale == 'photo') {
         if ($photo->get('modified')) {
             $path = '/' . $photo->get('id') . '_mod.' . $extension;
         } else {
             $bucket = 'photo';
             $path = rtrim('/' . ltrim($photo->get('path'), '/'), '/') . '/' . $photo->get('filename');
         }
     } elseif ($scale == 'scaled') {
         $thumbSize = Models\Preferences::valueForModuleWithKey('CameraLife', 'scaledsize');
         $path = "/{$photo->get('id')}_{$thumbSize}.{$extension}";
     } elseif ($scale == 'thumbnail') {
         $thumbSize = Models\Preferences::valueForModuleWithKey('CameraLife', 'thumbsize');
         $path = "/{$photo->get('id')}_{$thumbSize}.{$extension}";
     } elseif (is_numeric($scale)) {
         $valid = preg_split('/[, ]+/', Models\Preferences::valueForModuleWithKey('CameraLife', 'optionsizes'));
         if (!in_array($scale, $valid)) {
             throw new \Exception('This image size has not been allowed');
         }
         $path = "/{$photo->get('id')}_{$scale}.{$extension}";
     } else {
         throw new \Exception('Missing or bad size parameter');
     }
     $fileStore = Models\FileStore::fileStoreWithName($bucket);
     list($file, $temp, $mtime) = $fileStore->getFile($path);
     if (!$file) {
         $photo->generateThumbnail();
         list($file, $temp, $mtime) = $fileStore->getFile($path);
     }
     return [$file, $temp, $mtime];
 }
开发者ID:fulldecent,项目名称:cameralife,代码行数:43,代码来源:MediaController.php


示例8: formatVueGridName

 private function formatVueGridName()
 {
     $gridName = preg_split('/(?=[A-Z])/', $this->modelName);
     $gridName = implode('-', $gridName);
     $gridName = ltrim($gridName, '-');
     return $gridName = strtolower($gridName);
 }
开发者ID:evercode1,项目名称:view-maker,代码行数:7,代码来源:FormatsTokens.php


示例9: getFilePath

 /**
  *
  * @param string $value
  * @return string
  */
 protected function getFilePath($value)
 {
     if (null !== $this->rawValue) {
         $value = $this->rawValue;
     }
     return $this->internalBasePath . '/' . ltrim($value, '/');
 }
开发者ID:hummer2k,项目名称:conlayout,代码行数:12,代码来源:CacheBusterFilter.php


示例10: path

/**
 * 组装路径。整理路径包括:
 * <ol>
 * <li>整理目录分隔符为标准形式。</li>
 * <li>连接多段路径,清理多余的目录分隔符。</li>
 * <li>空的或无效的路径段将被忽略。</li>
 * </ol>
 * @param string $_ 可变参数,要组装的路径段。
 * @return string 返回组装后的路径,空路径返回 null。
 * @example path('/www', 'sites', 'www.example.com', 'index.php'); // 结果:/www/sites/www.example.com/index.php
 */
function path($_)
{
    $ps = array();
    $n = func_num_args();
    for ($i = 0; $i < $n; $i++) {
        $p = func_get_arg($i);
        if (is_object($p) && method_exists($p, '__toString')) {
            $p = "{$p}";
        }
        if (!is_scalar($p)) {
            continue;
        }
        $p = str_replace(DSC, DS, $p);
        if ($n > 1) {
            if ($i > 0 && $i + 1 < $n) {
                $p = trim($p, DS);
            } else {
                if ($i === 0) {
                    $p = rtrim($p, DS);
                } else {
                    $p = ltrim($p, DS);
                }
            }
        }
        if (strlen($p) < 1) {
            continue;
        }
        $ps[] = $p;
    }
    return implode(DS, $ps);
}
开发者ID:stonepeng,项目名称:b2c,代码行数:42,代码来源:function.php


示例11: process

	public function process(Vtiger_Request $request)
	{
		$qualifiedModuleName = $request->getModule(false);
		$moduleModel = Settings_Vtiger_CompanyDetails_Model::getInstance();
		$status = false;

		if ($request->get('organizationname')) {
			$saveLogo = $status = true;
			if (!empty($_FILES['logo']['name'])) {
				$logoDetails = $_FILES['logo'];
				$fileType = explode('/', $logoDetails['type']);
				$fileType = $fileType[1];

				if (!$logoDetails['size'] || !in_array($fileType, Settings_Vtiger_CompanyDetails_Model::$logoSupportedFormats)) {
					$saveLogo = false;
				}

				//mime type check 
				$mimeType = Vtiger_Functions::getMimeContentType($logoDetails['tmp_name']);
				$mimeTypeContents = explode('/', $mimeType);
				if (!$logoDetails['size'] || $mimeTypeContents[0] != 'image' || !in_array($mimeTypeContents[1], Settings_Vtiger_CompanyDetails_Model::$logoSupportedFormats)) {
					$saveLogo = false;
				}

				// Check for php code injection
				$imageContents = file_get_contents($_FILES["logo"]["tmp_name"]);
				if (preg_match('/(<\?php?(.*?))/i', $imageContents) == 1) {
					$saveLogo = false;
				}
				if ($saveLogo) {
					$moduleModel->saveLogo();
				}
			} else {
				$saveLogo = true;
			}
			$fields = $moduleModel->getFields();
			foreach ($fields as $fieldName => $fieldType) {
				$fieldValue = $request->get($fieldName);
				if ($fieldName === 'logoname') {
					if (!empty($logoDetails['name'])) {
						$fieldValue = ltrim(basename(" " . $logoDetails['name']));
					} else {
						$fieldValue = $moduleModel->get($fieldName);
					}
				}
				$moduleModel->set($fieldName, $fieldValue);
			}
			$moduleModel->save();
		}

		$reloadUrl = $moduleModel->getIndexViewUrl();
		if ($saveLogo && $status) {
			
		} else if (!$saveLogo) {
			$reloadUrl .= '&error=LBL_INVALID_IMAGE';
		} else {
			$reloadUrl = $moduleModel->getEditViewUrl() . '&error=LBL_FIELDS_INFO_IS_EMPTY';
		}
		header('Location: ' . $reloadUrl);
	}
开发者ID:rubichcube,项目名称:YetiForceCRM,代码行数:60,代码来源:CompanyDetailsSave.php


示例12: getCollectionName

 /**
  * Returns report collection name.
  *
  * @return  string
  */
 protected function getCollectionName()
 {
     if (null !== $this->name) {
         return sprintf('%s/%s', parent::getCollectionName(), ltrim($this->name, '/'));
     }
     return parent::getCollectionName();
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:12,代码来源:Report.php


示例13: getRelativePath

 /**
  * Returns the path relative to the root.
  *
  * @param  string $path
  * @return string
  */
 protected function getRelativePath($path)
 {
     if (0 === strpos($path, App::path())) {
         $path = ltrim(str_replace('\\', '/', substr($path, strlen(App::path()))), '/');
     }
     return $path;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:13,代码来源:InfoHelper.php


示例14: build_query_url

 /**
  * 拼接URL
  * @param $uri 可以传入Controller名称
  * @param string $type
  * @param array $params
  * @param bool $toLower 是否需要将uri换成小写
  * @return string
  */
 public static function build_query_url($uri, $params = array(), $toLower = true, $type = "")
 {
     $class_name = ereg_replace('Controller$', '', $uri);
     $arr = explode("_", $class_name);
     if ($toLower) {
         $uri = strtolower(implode("/", $arr));
     } else {
         $uri = implode("/", $arr);
     }
     if (empty($type) && BASE_URI_PRI) {
         $resUri = "/" . BASE_URI_PRI . "/" . ltrim($uri, "/");
     } elseif (empty($type)) {
         $resUri = "/" . ltrim($uri, "/");
     } else {
         $url_type = APF::get_instance()->get_config("domain_type");
         if ($url_type[$type]) {
             $resUri = "/" . $url_type[$type] . "/" . ltrim($uri, "/");
         } else {
             $resUri = "/" . ltrim($uri, "/");
         }
     }
     if (!empty($params) && is_array($params)) {
         $resUri .= "?" . http_build_query($params);
     }
     $base_domain = APF::get_instance()->get_config('base_domain');
     return self::get_protocol_name() . "://" . $base_domain . $resUri;
 }
开发者ID:emilymwang8,项目名称:cms,代码行数:35,代码来源:Url.php


示例15: CWizardBase

 function CWizardBase($wizardName, $package)
 {
     $this->wizardName = $wizardName;
     $this->package = $package;
     $this->wizardSteps = array();
     $this->currentStepID = null;
     $this->firstStepID = null;
     $this->nextButtonID = "StepNext";
     $this->prevButtonID = "StepPrevious";
     $this->finishButtonID = "StepFinish";
     $this->cancelButtonID = "StepCancel";
     $this->nextStepHiddenID = "NextStepID";
     $this->prevStepHiddenID = "PreviousStepID";
     $this->finishStepHiddenID = "FinishStepID";
     $this->cancelStepHiddenID = "CancelStepID";
     $this->currentStepHiddenID = "CurrentStepID";
     $this->variablePrefix = "__wiz_";
     $this->formName = "__wizard_form";
     $this->formActionScript = "/" . ltrim($_SERVER["REQUEST_URI"], "/");
     $this->returnOutput = false;
     $this->defaultVars = array();
     $this->arTemplates = array();
     $this->defaultTemplate = null;
     $this->useAdminTemplate = true;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:25,代码来源:wizard.php


示例16: cleanData

 private function cleanData($dirtData)
 {
     $dirtData = str_replace("&nbsp;", "", $dirtData);
     $dirtData = ltrim($dirtData);
     $dirtData = rtrim($dirtData);
     return trim($dirtData);
 }
开发者ID:branJakJak,项目名称:aepiaiklayentportal,代码行数:7,代码来源:VicidialCampaignRetriever.php


示例17: itemList

 public function itemList($options = [])
 {
     $session = Yii::$app->session;
     $moduleId = Yii::$app->controller->module->id;
     if (isset($options['sub-directory'])) {
         $session->set($moduleId, ['path' => '/' . ltrim($options['sub-directory'], '/')]);
     }
     //$session->remove($moduleId);
     $dir = $this->routes->uploadDir . $session->get($moduleId)['path'];
     if (is_dir($dir)) {
         //echo $dir;
         $files = \yii\helpers\FileHelper::findFiles($dir, ['recursive' => false]);
         $files_r = [];
         if (!isset($options['show-directory']) || intval($options['show-directory']) === 1) {
             foreach (glob($dir . '/*', GLOB_ONLYDIR) as $filename) {
                 $files_r[] = $filename;
             }
         }
         foreach ($files as $value) {
             $files_r[] = str_replace('\\', '/', $value);
         }
     } else {
         $message = 'Path ' . $session->get($moduleId)['path'] . ' not found!.';
         $session->remove($moduleId);
         throw new \yii\web\HttpException(500, $message);
     }
     return $files_r;
 }
开发者ID:miragesoft,项目名称:yii2-basicfilemanager,代码行数:28,代码来源:FileModel.php


示例18: init

 public function init()
 {
     /** @var Uri $uri */
     $uri = $this->grav['uri'];
     $config = $this->grav['config'];
     $is_admin = false;
     $session_timeout = $config->get('system.session.timeout', 1800);
     $session_path = $config->get('system.session.path', '/' . ltrim($uri->rootUrl(false), '/'));
     // Activate admin if we're inside the admin path.
     if ($config->get('plugins.admin.enabled')) {
         $route = $config->get('plugins.admin.route');
         $base = '/' . trim($route, '/');
         if (substr($uri->route(), 0, strlen($base)) == $base) {
             $session_timeout = $config->get('plugins.admin.session.timeout', 1800);
             $is_admin = true;
         }
     }
     if ($config->get('system.session.enabled') || $is_admin) {
         // Define session service.
         parent::__construct($session_timeout, $session_path);
         $unique_identifier = GRAV_ROOT;
         $this->setName($config->get('system.session.name', 'grav_site') . '-' . substr(md5($unique_identifier), 0, 7) . ($is_admin ? '-admin' : ''));
         $this->start();
         setcookie(session_name(), session_id(), time() + $session_timeout, $session_path);
     }
 }
开发者ID:clee03,项目名称:metal,代码行数:26,代码来源:Session.php


示例19: parseParameters

 private static function parseParameters($text)
 {
     $text = preg_replace('/[\\x{00a0}\\x{200b}]+/u', ' ', $text);
     if (!preg_match_all(static::$argumentsRegex, $text, $matches, PREG_SET_ORDER)) {
         return ltrim($text) ? array(ltrim($text) => null) : array();
     }
     $parameters = array();
     foreach ($matches as $match) {
         if (!empty($match[1])) {
             $parameters[strtolower($match[1])] = stripcslashes($match[2]);
         } elseif (!empty($match[3])) {
             $parameters[strtolower($match[3])] = stripcslashes($match[4]);
         } elseif (!empty($match[5])) {
             $parameters[strtolower($match[5])] = stripcslashes($match[6]);
         } elseif (isset($match[7]) && strlen($match[7])) {
             $parameters[stripcslashes($match[7])] = null;
         } elseif (isset($match[8])) {
             $parameters[stripcslashes($match[8])] = null;
         }
     }
     foreach ($parameters as $key => $value) {
         if (false !== strpos($value, '<') && 1 !== preg_match('/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value)) {
             $parameters[$key] = '';
         }
     }
     return $parameters;
 }
开发者ID:getgrav,项目名称:grav-plugin-shortcode-core,代码行数:27,代码来源:WordpressParser.php


示例20: indexAction

 /**
  * @Request({"path"})
  */
 public function indexAction($path)
 {
     if (!($dir = $this->getPath())) {
         return $this->error(__('Invalid path.'));
     }
     if (!is_dir($dir) || '-' === ($mode = $this->getMode($dir))) {
         throw new ForbiddenException(__('Permission denied.'));
     }
     $data = array_fill_keys(['items'], []);
     $data['mode'] = $mode;
     $finder = App::finder();
     $finder->sort(function ($a, $b) {
         return $b->getRealpath() > $a->getRealpath() ? -1 : 1;
     });
     foreach ($finder->depth(0)->in($dir) as $file) {
         if ('-' === ($mode = $this->getMode($file->getPathname()))) {
             continue;
         }
         $info = ['name' => $file->getFilename(), 'mime' => 'application/' . ($file->isDir() ? 'folder' : 'file'), 'path' => $this->normalizePath($path . '/' . $file->getFilename()), 'url' => ltrim(App::url()->getStatic($file->getPathname(), [], 'base'), '/'), 'writable' => $mode == 'w'];
         if (!$file->isDir()) {
             $info = array_merge($info, ['size' => $this->formatFileSize($file->getSize()), 'lastmodified' => date(\DateTime::ISO8601, $file->getMTime())]);
         }
         $data['items'][] = $info;
     }
     return $data;
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:29,代码来源:FinderController.php



注:本文中的ltrim函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP luna_htmlspecialchars函数代码示例发布时间:2022-05-15
下一篇:
PHP lti_split_custom_parameters函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap