本文整理汇总了PHP中rtrim函数的典型用法代码示例。如果您正苦于以下问题:PHP rtrim函数的具体用法?PHP rtrim怎么用?PHP rtrim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtrim函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dump
function dump($var, $echo = true, $label = null, $strict = true)
{
$label = $label === null ? '' : rtrim($label) . ' ';
if (!$strict) {
if (ini_get('html_errors')) {
$output = print_r($var, true);
$output = "<pre>" . $label . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
} else {
$output = $label . " : " . print_r($var, true);
}
} else {
ob_start();
var_dump($var);
$output = ob_get_clean();
if (!extension_loaded('xdebug')) {
$output = preg_replace("/\\]\\=\\>\n(\\s+)/m", "] => ", $output);
$output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES, "GB2312") . '</pre>';
}
}
if ($echo) {
echo $output;
return null;
} else {
return $output;
}
}
示例2: save
/**
* Save an uploaded file to a new location.
*
* @param mixed name of $_FILE input or array of upload data
* @param string new filename
* @param string new directory
* @param integer chmod mask
* @return string full path to new file
*/
public static function save($file, $filename = NULL, $directory = NULL, $chmod = 0755)
{
// Load file data from FILES if not passed as array
$file = is_array($file) ? $file : $_FILES[$file];
if ($filename === NULL) {
// Use the default filename, with a timestamp pre-pended
$filename = time() . $file['name'];
}
// Remove spaces from the filename
$filename = preg_replace('/\\s+/', '_', $filename);
if ($directory === NULL) {
// Use the pre-configured upload directory
$directory = WWW_ROOT . 'files/';
}
// Make sure the directory ends with a slash
$directory = rtrim($directory, '/') . '/';
if (!is_dir($directory)) {
// Create the upload directory
mkdir($directory, 0777, TRUE);
}
//if ( ! is_writable($directory))
//throw new exception;
if (is_uploaded_file($file['tmp_name']) and move_uploaded_file($file['tmp_name'], $filename = $directory . $filename)) {
if ($chmod !== FALSE) {
// Set permissions on filename
chmod($filename, $chmod);
}
//$all_file_name = array(FILE_INFO => $filename);
// Return new file path
return $filename;
}
return FALSE;
}
示例3: convert_uudecode
function convert_uudecode($string)
{
// Sanity check
if (!is_scalar($string)) {
user_error('convert_uuencode() expects parameter 1 to be string, ' . gettype($string) . ' given', E_USER_WARNING);
return false;
}
if (strlen($string) < 8) {
user_error('convert_uuencode() The given parameter is not a valid uuencoded string', E_USER_WARNING);
return false;
}
$decoded = '';
foreach (explode("\n", $string) as $line) {
$c = count($bytes = unpack('c*', substr(trim($line), 1)));
while ($c % 4) {
$bytes[++$c] = 0;
}
foreach (array_chunk($bytes, 4) as $b) {
$b0 = $b[0] == 0x60 ? 0 : $b[0] - 0x20;
$b1 = $b[1] == 0x60 ? 0 : $b[1] - 0x20;
$b2 = $b[2] == 0x60 ? 0 : $b[2] - 0x20;
$b3 = $b[3] == 0x60 ? 0 : $b[3] - 0x20;
$b0 <<= 2;
$b0 |= $b1 >> 4 & 0x3;
$b1 <<= 4;
$b1 |= $b2 >> 2 & 0xf;
$b2 <<= 6;
$b2 |= $b3 & 0x3f;
$decoded .= pack('c*', $b0, $b1, $b2);
}
}
return rtrim($decoded, "");
}
示例4: setUp
public function setUp()
{
$_SERVER['REDIRECT_STATUS'] = "200";
$_SERVER['HTTP_HOST'] = "slim";
$_SERVER['HTTP_CONNECTION'] = "keep-alive";
$_SERVER['HTTP_CACHE_CONTROL'] = "max-age=0";
$_SERVER['HTTP_ACCEPT'] = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$_SERVER['HTTP_USER_AGENT'] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3";
$_SERVER['HTTP_ACCEPT_ENCODING'] = "gzip,deflate,sdch";
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en-US,en;q=0.8";
$_SERVER['HTTP_ACCEPT_CHARSET'] = "ISO-8859-1,utf-8;q=0.7,*;q=0.3";
$_SERVER['PATH'] = "/usr/bin:/bin:/usr/sbin:/sbin";
$_SERVER['SERVER_SIGNATURE'] = "";
$_SERVER['SERVER_SOFTWARE'] = "Apache";
$_SERVER['SERVER_NAME'] = "slim";
$_SERVER['SERVER_ADDR'] = "127.0.0.1";
$_SERVER['SERVER_PORT'] = "80";
$_SERVER['REMOTE_ADDR'] = "127.0.0.1";
$_SERVER['DOCUMENT_ROOT'] = rtrim(dirname(__FILE__), '/');
$_SERVER['SERVER_ADMIN'] = "you@example.com";
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
$_SERVER['REMOTE_PORT'] = "55426";
$_SERVER['REDIRECT_URL'] = "/";
$_SERVER['GATEWAY_INTERFACE'] = "CGI/1.1";
$_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1";
$_SERVER['REQUEST_METHOD'] = "GET";
$_SERVER['QUERY_STRING'] = "";
$_SERVER['REQUEST_URI'] = "/";
$_SERVER['SCRIPT_NAME'] = basename(__FILE__);
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
$_SERVER['REQUEST_TIME'] = "1285647051";
$_SERVER['argv'] = array();
$_SERVER['argc'] = 0;
}
示例5: run
public static function run()
{
foreach (glob(app_path() . '/Http/Controllers/*.php') as $filename) {
$file_parts = explode('/', $filename);
$file = array_pop($file_parts);
$file = rtrim($file, '.php');
if ($file == 'Controller') {
continue;
}
$controllerName = 'App\\Http\\Controllers\\' . $file;
$controller = new $controllerName();
if (isset($controller->exclude) && $controller->exclude === true) {
continue;
}
$methods = [];
$reflector = new \ReflectionClass($controller);
foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $rMethod) {
// check whether method is explicitly defined in this class
if ($rMethod->getDeclaringClass()->getName() == $reflector->getName()) {
$methods[] = $rMethod->getName();
}
}
\Route::resource(strtolower(str_replace('Controller', '', $file)), $file, ['only' => $methods]);
}
}
示例6: __construct
/**
* Constructor
*
* @param string $name
* @param string $rname
* @param integer $ttl
* @param string $class
*/
function __construct($name, $value, $ttl = false, $class = "IN")
{
parent::__construct();
$this->Type = "TXT";
// Name
if (($this->Validator->MatchesPattern($name, self::PAT_NON_FDQN) ||
$name == "@" ||
$name === "" ||
$this->Validator->IsDomain($name)) && !$this->Validator->IsIPAddress(rtrim($name, "."))
)
$this->Name = $name;
else
{
self::RaiseWarning("'{$name}' is not a valid name for TXT record");
$this->Error = true;
}
if (strlen($value) > 255)
{
self::RaiseWarning("TXT record value cannot be longer than 65536 bytes");
$this->Error = true;
}
else
$this->Value = $value;
$this->TTL = $ttl;
$this->Class = $class;
}
示例7: index
/**
* [index 管理员列表]
* @return [type] [description]
*/
public function index()
{
if (IS_AJAX) {
$draw = I('draw', 1, 'intval');
//排序设置
$mycolumns = I('mycolumns', '');
$myorder = I('order', '');
if (empty($myorder) || empty($mycolumns)) {
$order = 'id desc';
} else {
foreach ($myorder as $key => $v) {
$order .= $mycolumns[$v['column']] . ' ' . $v['dir'] . ' ,';
}
$order = rtrim($order, ',');
}
$db = D('UsersView');
$lists = $db->where(true)->order($order)->select();
foreach ($lists as $key => $v) {
$lists[$key]['loginTime'] = $v['loginTime'] ? date('Y/m/d H:i:s', $v['loginTime']) : '';
$lists[$key]['loginIp'] = $v['loginIp'] ? long2ip($v['loginIp']) : '';
if ($v['status']) {
$lists[$key]['status'] = '正常';
} else {
$lists[$key]['status'] = '禁用';
}
}
$result['draw'] = $draw;
$result['recordsTotal'] = $db->where(true)->count();
$result['recordsFiltered'] = $result['recordsTotal'];
$result['data'] = $lists;
$this->ajaxReturn($result);
} else {
$this->display();
}
}
示例8: generateClass
/**
* Generate Class
*
* @param string $className
* @return string
* @throws \Magento\Framework\Exception
* @throws \InvalidArgumentException
*/
public function generateClass($className)
{
// check if source class a generated entity
$entity = null;
$entityName = null;
foreach ($this->_generatedEntities as $entityType => $generatorClass) {
$entitySuffix = ucfirst($entityType);
// if $className string ends on $entitySuffix substring
if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) {
$entity = $entityType;
$entityName = rtrim(substr($className, 0, -1 * strlen($entitySuffix)), \Magento\Framework\Autoload\IncludePath::NS_SEPARATOR);
break;
}
}
if (!$entity || !$entityName) {
return self::GENERATION_ERROR;
}
// check if file already exists
$autoloader = $this->_autoloader;
if ($autoloader::getFile($className)) {
return self::GENERATION_SKIP;
}
if (!isset($this->_generatedEntities[$entity])) {
throw new \InvalidArgumentException('Unknown generation entity.');
}
$generatorClass = $this->_generatedEntities[$entity];
$generator = new $generatorClass($entityName, $className, $this->_ioObject);
if (!$generator->generate()) {
$errors = $generator->getErrors();
throw new \Magento\Framework\Exception(implode(' ', $errors));
}
return self::GENERATION_SUCCESS;
}
示例9: getFullClassName
/**
* getFullClassName()
*
* @param string $localClassName
* @param string $classContextName
*/
public function getFullClassName($localClassName, $classContextName = null)
{
// find the ApplicationDirectory OR ModuleDirectory
$currentResource = $this->_resource;
do {
$resourceName = $currentResource->getName();
if ($resourceName == 'ApplicationDirectory' || $resourceName == 'ModuleDirectory') {
$containingResource = $currentResource;
break;
}
} while ($currentResource instanceof Zend_Tool_Project_Profile_Resource && ($currentResource = $currentResource->getParentResource()));
$fullClassName = '';
// go find the proper prefix
if (isset($containingResource)) {
if ($containingResource->getName() == 'ApplicationDirectory') {
$prefix = $containingResource->getAttribute('classNamePrefix');
$fullClassName = $prefix;
} elseif ($containingResource->getName() == 'ModuleDirectory') {
$filter = new Zend_Filter_Word_DashToCamelCase();
$prefix = $filter->filter(ucfirst($containingResource->getAttribute('moduleName'))) . '_';
$fullClassName = $prefix;
}
}
if ($classContextName) {
$fullClassName .= rtrim($classContextName, '_') . '_';
}
$fullClassName .= $localClassName;
return $fullClassName;
}
示例10: init
/**
* 地图
*/
public function init()
{
$siteconfigs = $this->siteconfigs;
$seo_title = $siteconfigs['sitename'];
$seo_keywords = $siteconfigs['seo_keywords'];
$seo_description = $siteconfigs['seo_description'];
$categorys = get_cache('category', 'content');
$hotcity = hotcity(0);
$category_result = $this->db->get_list('category', array('modelid' => 3), '*', 0, 1000);
$city = substr(rtrim($_SERVER["REQUEST_URI"], '/'), 5);
if ($city == '') {
$city = 'beijing';
}
foreach ($categorys as $cid => $rs) {
if ($rs['catdir'] == $city) {
$cityid = $cid;
set_cookie('cityname', $rs['name'], SYS_TIME + 86400 * 7);
set_cookie('cityid', $cityid, SYS_TIME + 86400 * 7);
$cityname = $rs['name'];
break;
}
}
$page = max(intval($GLOBALS['page']), 1);
$urlrule = 'javascript:change_pagemap({$page});';
include T('content', 'map', TPLID);
}
示例11: execute
/**
* Save settings.
*/
function execute()
{
$plugin =& $this->plugin;
$journalId = $this->journalId;
$plugin->updateSetting($journalId, 'phpmvUrl', rtrim($this->getData('phpmvUrl'), "/"), 'string');
$plugin->updateSetting($journalId, 'phpmvSiteId', $this->getData('phpmvSiteId'), 'int');
}
示例12: __construct
/**
* Initializes the Jsb2 object.
*
* @param string $filename Path to manifest file
* @param string $baseURL Base URL for HTML output
* @param array $filter Which packages schould NOT be returned
*/
public function __construct($filename, $baseURL = "", $filter = array())
{
$manifest = $this->getManifest($filename);
$this->baseURL = rtrim($baseURL, '/') . '/';
$this->basePath = dirname($filename) . '/';
$this->registeredPackages = $this->getPackages($manifest, $filter);
}
示例13: PMA_transformation_getOptions
/**
* Set of functions used with the relation and pdf feature
*/
function PMA_transformation_getOptions($string)
{
$transform_options = array();
/* Parse options */
for ($nextToken = strtok($string, ','); $nextToken !== false; $nextToken = strtok(',')) {
$trimmed = trim($nextToken);
if ($trimmed[0] == '\'' && $trimmed[strlen($trimmed) - 1] == '\'') {
$transform_options[] = substr($trimmed, 1, -1);
} else {
if ($trimmed[0] == '\'') {
$trimmed = ltrim($nextToken);
while ($nextToken !== false) {
$nextToken = strtok(',');
$trimmed .= $nextToken;
$rtrimmed = rtrim($trimmed);
if ($rtrimmed[strlen($rtrimmed) - 1] == '\'') {
break;
}
}
$transform_options[] = substr($rtrimmed, 1, -1);
} else {
$transform_options[] = $nextToken;
}
}
}
// strip possible slashes to behave like documentation says
$result = array();
foreach ($transform_options as $val) {
$result[] = stripslashes($val);
}
return $result;
}
示例14: populate
public function populate($where, $preserve = false)
{
$attach = ' WHERE ';
$params = array();
foreach ($where as $key => $value) {
$attach .= $key . ' = ? AND ';
$params[] = $value;
}
$attach = rtrim($attach, 'AND ');
$this->individualWhereClausule = $attach;
$this->iwc_values = $params;
if ($preserve) {
$oldQ = $this->lastQuery;
}
$this->lastQuery = array('query' => 'SELECT * FROM ' . self::tablename() . $attach . ' LIMIT 1', 'values' => $params);
$query = $this->makeQuery(!$preserve);
if ($preserve) {
$this->lastQuery = $oldQ;
}
$values = $query->fetch(PDO::FETCH_ASSOC);
if (is_array($values)) {
foreach ($values as $key => $value) {
$this->{$key} = $value;
}
} else {
$this->void = true;
}
}
示例15: processRequest
public function processRequest()
{
// No CSRF for SendGrid.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$request = $this->getRequest();
$user = $request->getUser();
$raw_headers = $request->getStr('headers');
$raw_headers = explode("\n", rtrim($raw_headers));
$raw_dict = array();
foreach (array_filter($raw_headers) as $header) {
list($name, $value) = explode(':', $header, 2);
$raw_dict[$name] = ltrim($value);
}
$headers = array('to' => $request->getStr('to'), 'from' => $request->getStr('from'), 'subject' => $request->getStr('subject')) + $raw_dict;
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders($headers);
$received->setBodies(array('text' => $request->getStr('text'), 'html' => $request->getStr('from')));
$file_phids = array();
foreach ($_FILES as $file_raw) {
try {
$file = PhabricatorFile::newFromPHPUpload($file_raw, array('authorPHID' => $user->getPHID()));
$file_phids[] = $file->getPHID();
} catch (Exception $ex) {
phlog($ex);
}
}
$received->setAttachments($file_phids);
$received->save();
$received->processReceivedMail();
$response = new AphrontWebpageResponse();
$response->setContent("Got it! Thanks, SendGrid!\n");
return $response;
}