本文整理汇总了PHP中str_ends_with函数的典型用法代码示例。如果您正苦于以下问题:PHP str_ends_with函数的具体用法?PHP str_ends_with怎么用?PHP str_ends_with使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_ends_with函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: env
/**
* Gets the value of an environment variable. Supports boolean, empty and null.
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
function env($key, $default = null)
{
$value = getenv($key);
if ($value === false) {
return value($default);
}
switch (strtolower($value)) {
case 'true':
case '(true)':
return true;
case 'false':
case '(false)':
return false;
case 'null':
case '(null)':
return null;
case 'empty':
case '(empty)':
return '';
}
if (str_starts_with($value, '"') && str_ends_with($value, '"')) {
return substr($value, 1, -1);
}
return $value;
}
开发者ID:strongsquirrel,项目名称:yii2-dotenv-app,代码行数:33,代码来源:env.php
示例2: ui
/**
* Loads the given jQuery UI components JS files.
*
* You can indicate the name of the JS files to include as follow:
*
* ```php
* $this->jQuery->ui('mouse', 'droppable', 'widget', ...);
* ```
*
* You can provide an array of options for HtmlHelper::script() as follow:
*
* ```php
* $this->jQuery->ui('mouse', 'droppable', ['block' => 'true'], 'widget', ...);
* ```
*
* If no component is given, all components (concatenated as a single JS file)
* will be loaded at once.
*
* @return mixed String of `<script />` tags or null if block is specified in
* options or if $once is true and the file has been included before
*/
public function ui()
{
$args = func_get_args();
$files = [];
$options = [];
$out = '';
foreach ($args as $file) {
if (is_array($file)) {
$options = $file;
continue;
}
$file = 'Jquery.ui/' . strtolower($file);
if (!str_ends_with($file, '.js')) {
$file .= '.js';
}
if ($file != 'Jquery.ui/core.js') {
$files[] = $file;
}
}
if (empty($files)) {
$files[] = Configure::read('debug') ? 'Jquery.jquery-ui.js' : 'Jquery.jquery-ui.min.js';
} else {
array_unshift($files, 'Jquery.ui/core.js');
}
foreach ($files as $file) {
$out .= (string) $this->_View->Html->script($file, $options);
}
if (empty($out)) {
return null;
}
return $out;
}
开发者ID:quickapps-plugins,项目名称:jquery,代码行数:53,代码来源:JqueryHelper.php
示例3: search
/**
* Execute search
*
* @param void
* @return null
*/
function search()
{
if (active_project() && !logged_user()->isProjectUser(active_project())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
$pageType = array_var($_GET, 'page_type');
$search_for = array_var($_GET, 'search_for');
$objectManagers = array("ProjectWebpages", "ProjectMessages", "MailContents", "ProjectFiles", "ProjectMilestones", "ProjectTasks", "ProjectEvents");
$objectTypes = array(lang('webpages'), lang('messages'), lang('emails'), lang('files'), lang('milestones'), lang('tasks'), lang('events'));
$iconTypes = array('webpage', 'message', 'email', 'file', 'milestone', 'task', 'event');
if (user_config_option('show_file_revisions_search')) {
array_splice($objectManagers, 4, 0, 'ProjectFileRevisions');
array_splice($objectTypes, 4, 0, lang('file contents'));
array_splice($iconTypes, 4, 0, 'file');
}
$search_results = array();
$timeBegin = microtime(true);
if (trim($search_for) == '') {
$search_results = null;
$pagination = null;
} else {
$search_results = $this->searchWorkspaces($search_for, $search_results, 5);
$search_results = $this->searchUsers($search_for, $search_results, 5);
$search_results = $this->searchContacts($search_for, $search_results, 5);
if (array_var($_GET, 'search_all_projects') != "true" && active_project() instanceof Project) {
$projects = active_project()->getAllSubWorkspacesCSV(true);
} else {
$projects = null;
}
$c = 0;
foreach ($objectManagers as $om) {
$user_id = $om == "MailContents" ? logged_user()->getId() : 0;
$results = SearchableObjects::searchByType($search_for, $projects, $om, true, 5, 1, null, $user_id);
if (count($results[0]) > 0) {
$sr = array();
$sr['result'] = $results[0];
$sr['pagination'] = $results[1];
$sr['type'] = $objectTypes[$c];
$sr['icontype'] = $iconTypes[$c];
$sr['manager'] = $om;
$search_results[] = $sr;
}
$c++;
}
}
// if
$timeEnd = microtime(true);
if (str_starts_with($search_for, '"') && str_ends_with($search_for, '"')) {
$search_for = str_replace('"', '', $search_for);
}
tpl_assign('search_string', $search_for);
tpl_assign('search_results', $search_results);
tpl_assign('time', $timeEnd - $timeBegin);
ajx_set_no_toolbar(true);
ajx_replace(true);
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:65,代码来源:SearchController.class.php
示例4: testStrEndsWith
/**
* test str_ends_with
*/
public function testStrEndsWith()
{
$this->assertTrue(str_ends_with('foobar', 'bar'));
$this->assertTrue(str_ends_with('foobar', 'foobar'));
$this->assertFalse(str_ends_with('foobar', 'qux'));
$this->assertFalse(str_ends_with('foobar', 'foo'));
$this->assertFalse(str_ends_with('foobar', 'oba'));
$this->assertFalse(str_ends_with('foobar', 'quxfoobar'));
}
开发者ID:sachsy,项目名称:php-functions,代码行数:12,代码来源:StringFunctionsTest.php
示例5: test_email
/**
* Test Mailer
*
* @param void
* @return null
*/
function test_email()
{
$email_data = $this->request->post('email');
if (!is_array($email_data)) {
$email_data = array('recipient' => $this->logged_user->getEmail(), 'subject' => lang('activeCollab - test email'), 'message' => lang("<p>Hi,</p>\n\n<p>Purpose of this message is to test whether activeCollab can send emails or not</p>"));
}
// if
$this->smarty->assign('email_data', $email_data);
if ($this->request->isSubmitted()) {
$errors = new ValidationErrors();
$subject = trim(array_var($email_data, 'subject'));
$message = trim(array_var($email_data, 'message'));
$recipient = trim(array_var($email_data, 'recipient'));
if ($subject == '') {
$errors->addError(lang('Message subject is required'), 'subject');
}
// if
if ($message == '') {
$errors->addError(lang('Message body is required'), 'message');
}
// if
if (is_valid_email($recipient)) {
$recipient_name = null;
$recipient_email = $recipient;
} else {
if (($pos = strpos($recipient, '<')) !== false && str_ends_with($recipient, '>')) {
$recipient_name = trim(substr($recipient, 0, $pos));
$recipient_email = trim(substr($recipient, $pos + 1, strlen($recipient) - $pos - 2));
if (!is_valid_email($recipient_email)) {
$errors->addError(lang('Invalid email address'), 'recipient');
}
// if
} else {
$errors->addError(lang('Invalid recipient'), 'recipient');
}
// if
}
// if
if ($errors->hasErrors()) {
$this->smarty->assign('errors', $errors);
$this->render();
}
// if
$mailer =& ApplicationMailer::mailer();
$email_message = new Swift_Message($subject, $message, 'text/html', EMAIL_ENCODING, EMAIL_CHARSET);
if ($mailer->send($email_message, new Swift_Address($recipient_email, $recipient_name), $this->logged_user->getEmail())) {
flash_success('Test email has been sent, check your inbox');
} else {
flash_error('Failed to send out test email');
}
// if
$this->redirectTo('admin_tools_test_email');
}
// if
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:61,代码来源:SystemToolsController.class.php
示例6: __construct
public function __construct()
{
parent::__construct();
$documentRoot = $this->getConfig("DocumentRootConnect");
if (str_ends_with($documentRoot, "/")) {
$documentRoot = substr($documentRoot, 0, -1);
}
$this->templatesDirectory = $_SERVER["DOCUMENT_ROOT"] . $documentRoot . DIRECTORY_SEPARATOR . $this->getConfig("TemplatesDirectory");
$this->cacheDirectory = $_SERVER["DOCUMENT_ROOT"] . $documentRoot . DIRECTORY_SEPARATOR . $this->getConfig("CacheDirectory");
$this->baseDirectory = $_SERVER["DOCUMENT_ROOT"] . $documentRoot;
}
开发者ID:famoser,项目名称:php-frame,代码行数:11,代码来源:RuntimeService.php
示例7: url_trimAndClean
function url_trimAndClean($url)
{
$url = trim($url);
if (str_starts_with($url, '/')) {
$url = substr($url, 1);
}
if (str_ends_with($url, '/')) {
$url = substr($url, 0, strlen($url) - 1);
}
$url = strtolower($url);
return $url;
}
开发者ID:GrapheneProject,项目名称:Graphene,代码行数:12,代码来源:utils.php
示例8: smarty_function_permission_name
/**
* Render verbose permission name
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_permission_name($params, &$smarty)
{
$name = array_var($params, 'name', 'unknown');
if (str_ends_with($name, '_add')) {
return lang('Add');
} elseif (str_ends_with($name, '_manage')) {
return lang('Edit and Delete');
} else {
return $name;
}
// if
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:19,代码来源:function.permission_name.php
示例9: _awaitingPlugins
/**
* Look for plugin/themes awaiting for installation and sets a flash message
* with instructions about how to proceed.
*
* @param string $type Possible values `plugin` (default) or `theme`, defaults
* to "plugin"
* @return void
*/
protected function _awaitingPlugins($type = 'plugin')
{
$type = !in_array($type, ['plugin', 'theme']) ? 'plugin' : $type;
$ignoreThemes = $type === 'plugin';
$plugins = Plugin::scan($ignoreThemes);
foreach ($plugins as $name => $path) {
if (Plugin::exists($name) || $type == 'theme' && !str_ends_with($name, 'Theme')) {
unset($plugins[$name]);
}
}
if (!empty($plugins)) {
$this->Flash->set(__d('system', '{0} are awaiting for installation', $type == 'plugin' ? __d('system', 'Some plugins') : __d('system', 'Some themes')), ['element' => 'System.stashed_plugins', 'params' => compact('plugins')]);
}
}
开发者ID:quickapps-plugins,项目名称:system,代码行数:22,代码来源:AppController.php
示例10: getSubscriberComments
static function getSubscriberComments($workspace = null, $tag = null, $orderBy = 'created_on', $orderDir = "DESC", $start = 0, $limit = 20)
{
$oc = new ObjectController();
$queries = $oc->getDashboardObjectQueries($workspace, $tag, false, false, $orderBy);
$query = '';
if (!is_array($queries)) {
return array();
}
foreach ($queries as $name => $q) {
if (str_ends_with($name, "Comments")) {
if ($query == '') {
$query = $q;
} else {
$query .= " \n UNION \n" . $q;
}
}
}
$query .= " ORDER BY `order_value` ";
if ($orderDir != "ASC" && $orderDir != "DESC") {
$orderDir = "DESC";
}
$query .= " " . $orderDir . " ";
$query .= " LIMIT " . $start . "," . $limit . " ";
$res = DB::execute($query);
$comments = array();
if (!$res) {
return $comments;
}
$rows = $res->fetchAll();
if (!is_array($rows)) {
return $comments;
}
foreach ($rows as $row) {
$manager = $row['object_manager_value'];
$id = $row['oid'];
if ($id && $manager) {
$comment = get_object_by_manager_and_id($id, $manager);
$object = $comment->getObject();
if ($object instanceof ProjectDataObject && $object->isSubscriber(logged_user())) {
$comments[] = $comment;
}
}
}
return $comments;
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:45,代码来源:Comments.class.php
示例11: format_value_to_print_task
function format_value_to_print_task($value, $type, $textWrapper = '', $dateformat = 'Y-m-d')
{
switch ($type) {
case DATA_TYPE_STRING:
if (preg_match(EMAIL_FORMAT, strip_tags($value))) {
$formatted = $value;
} else {
$formatted = $textWrapper . clean($value) . $textWrapper;
}
break;
case DATA_TYPE_INTEGER:
$formatted = clean($value);
break;
case DATA_TYPE_BOOLEAN:
$formatted = $value == 1 ? lang('yes') : lang('no');
break;
case DATA_TYPE_DATE:
if ($value != 0) {
if (str_ends_with($value, "00:00:00")) {
$dateformat .= " H:i:s";
}
$dtVal = DateTimeValueLib::dateFromFormatAndString($dateformat, $value);
$formatted = format_date($dtVal, null, 0);
} else {
$formatted = '';
}
break;
case DATA_TYPE_DATETIME:
if ($value != 0) {
$dtVal = DateTimeValueLib::dateFromFormatAndString("{$dateformat} H:i:s", $value);
$formatted = format_date($dtVal, null, 0);
} else {
$formatted = '';
}
break;
default:
$formatted = $value;
}
if ($formatted == '') {
$formatted = '--';
}
return $formatted;
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:43,代码来源:total_task_times.php
示例12: matches
private function matches($needle, $action)
{
if (array_key_exists($needle . '_' . $action, self::$cache['matches'])) {
return self::$cache['matches'][$needle . '_' . $action];
}
self::$cache['matches'][$needle . '_' . $action] = false;
$tneedle = strtoupper($needle);
$taction = strtoupper($action);
if (str_ends_with($tneedle, '.*') && str_starts_with($taction, substr($tneedle, 0, strlen($tneedle - 1)))) {
self::$cache['matches'][$needle . '_' . $action] = true;
} else {
if ($tneedle === $taction) {
self::$cache['matches'][$needle . '_' . $action] = true;
} else {
self::$cache['matches'][$needle . '_' . $action] = false;
}
}
return self::$cache['matches'][$needle . '_' . $action];
}
开发者ID:GrapheneProject,项目名称:Graphene,代码行数:19,代码来源:acl.ACL_CHECK.php
示例13: dirToArray
function dirToArray($dir, $fix = "", &$first = true)
{
$handle = opendir($dir);
while (($file = readdir($handle)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
dirToArray($dir . DIRECTORY_SEPARATOR . $file, $fix . $file . "/", $first);
} elseif (!str_ends_with($file, ".php") && !str_ends_with($file, ".md5") && !str_ends_with($file, ".dat") && !str_starts_with($file, "installer")) {
if ($first) {
$first = false;
} else {
print "\r\n";
}
print $fix . $file;
}
}
closedir($handle);
}
开发者ID:GoldenGnu,项目名称:jeveassets,代码行数:20,代码来源:list.php
示例14: substr
function &loadTheme($name)
{
if (str_ends_with($this->themesDir, '/')) {
$this->themesDir = substr($this->themesDir, 0, strlen($this->themesDir) - 1);
}
$themeDir = $this->themesDir . '/' . $name . '/';
if (is_dir($themeDir)) {
$themeContext = file_exists($themeDir . '/theme-context.yml') ? $themeDir . '/theme-context.yml' : null;
if ($themeContext) {
AppContext::load($themeContext);
}
$bootstrap = file_exists($themeDir . '/bootstrap' . EXT) ? $themeDir . '/bootstrap' . EXT : null;
if ($bootstrap) {
include $bootstrap;
}
$theme =& new Theme($name, $themeDir);
return $theme;
}
show_error('ThemeManager', 'Specified theme doesn\'t exist: ' . $name);
}
开发者ID:qlixes,项目名称:springphp,代码行数:20,代码来源:ThemeManager.php
示例15: upload
/**
* Uploads a ZIP package to the server.
*
* @return bool True on success
*/
public function upload()
{
if (!isset($this->_package['tmp_name']) || !is_readable($this->_package['tmp_name'])) {
$this->_error(__d('installer', 'Invalid package.'));
return false;
} elseif (!isset($this->_package['name']) || !str_ends_with(strtolower($this->_package['name']), '.zip')) {
$this->_error(__d('installer', 'Invalid package format, it is not a ZIP package.'));
return false;
} else {
$dst = normalizePath(TMP . $this->_package['name']);
if (is_readable($dst)) {
$file = new File($dst);
$file->delete();
}
if (move_uploaded_file($this->_package['tmp_name'], $dst)) {
$this->_dst = $dst;
return true;
}
}
$this->_error(__d('installer', 'Package could not be uploaded, please check write permissions on /tmp directory.'));
return false;
}
开发者ID:quickapps-plugins,项目名称:installer,代码行数:27,代码来源:PackageUploader.php
示例16: make
/**
* Compile template and generate
*
* @param string $path
* @param string $template Path to template
* @param $finalPath
*
* @return bool
*/
public function make($path, $template, &$finalPath)
{
$this->name = basename($path, '.php');
$this->path = $this->getPath($path);
$template = $this->getTemplate($template, $this->name);
// check for migration by same name but new date, I'm tired of deleting these files
$filename = basename($this->path, '');
$name = strtolower($this->name) . '.php';
$fileExists = false;
if ($filename !== $name && str_ends_with($filename, $name)) {
// must have a date prefix, we should check if a file by the same name exists and append .new to this one
if ($handle = opendir($basepath = dirname($path))) {
while (false !== ($entry = readdir($handle))) {
if (fnmatch('*_' . $name, $entry, FNM_PERIOD)) {
if ($this->options('overwrite')) {
// delete the sucker
unlink($basepath . '/' . $entry);
} else {
$fileExists = true;
}
}
if (!$this->options('overwrite') && fnmatch('*_' . $name . '.new', $entry, FNM_PERIOD)) {
// delete the sucker
unlink($basepath . '/' . $entry);
}
}
closedir($handle);
}
}
if ($this->options('overwrite') || !$fileExists && !$this->file->exists($this->path)) {
$finalPath = $this->path;
return $this->file->put($this->path, $template) !== false;
} else {
// put it as .new, and delete previous .new
$finalPath = $this->path . ".new";
return $this->file->put($this->path . ".new", $template);
}
}
开发者ID:vsch,项目名称:generators,代码行数:47,代码来源:Generator.php
示例17: format_filesize
/**
* Format filesize
*
* @access public
* @param integer $in_bytes Site in bytes
* @return string
*/
function format_filesize($in_bytes)
{
$units = array('TB' => 1099511627776.0, 'GB' => 1073741824, 'MB' => 1048576, 'KB' => 1024);
// array
// Loop units bigger than byte
foreach ($units as $current_unit => $unit_min_value) {
if ($in_bytes > $unit_min_value) {
$formated_number = number_format($in_bytes / $unit_min_value, 2);
while (str_ends_with($formated_number, '0')) {
$formated_number = substr($formated_number, 0, strlen($formated_number) - 1);
// remove zeros from the end
}
if (str_ends_with($formated_number, '.')) {
$formated_number = substr($formated_number, 0, strlen($formated_number) - 1);
// remove dot from the end
}
return $formated_number . $current_unit;
}
// if
}
// foreach
// Bytes?
return $in_bytes . 'bytes';
}
开发者ID:469306621,项目名称:Languages,代码行数:31,代码来源:format.php
示例18: init
public static function init()
{
$url = OPTIONS::website("url_page_pattern");
$pattern = str_replace(array("%content_slug%", "%content_lang%?/", "%content_lang%"), array("[any]", '([a-z]+/)?', '([a-z]+)'), $url);
URL::route('^' . $pattern . '$', function () use($url) {
$url = str_replace("?", "", $url);
$returns = func_get_args();
$counter = 0;
foreach (explode("/", $url) as $i => $v) {
if (str_starts_with($v, "%") && str_ends_with($v, "%")) {
$col = substr($v, 1, strlen($v) - 2);
$returns[$col] = $returns[$counter];
unset($returns[$counter]);
$counter++;
}
}
$data = self::get_page($returns);
if ($data !== false) {
self::$current = $data;
} else {
URL::routed(false);
}
});
}
开发者ID:double-web,项目名称:drawline,代码行数:24,代码来源:include_content.php
示例19: simple_pattern_match
function simple_pattern_match($patterns, $str)
{
if (!is_array($patterns)) {
$patterns = array($patterns);
}
foreach ($patterns as $pattern) {
if ($pattern == $str || "*" == $pattern) {
return true;
}
if ($pattern == null || $str == null) {
return false;
}
if (str_starts_with($pattern, "*") && str_starts_with($pattern, "*") && strpos($str, substr($pattern, 1, strlen($pattern - 1))) != -1) {
return true;
}
if (str_starts_with($pattern, "*") && str_ends_with($str, substr($pattern, 1, strlen($pattern)))) {
return true;
}
if (str_ends_with($pattern, "*") && str_starts_with($str, substr($pattern, 0, strlen($pattern - 1)))) {
return true;
}
}
return false;
}
开发者ID:qlixes,项目名称:springphp,代码行数:24,代码来源:patterns.php
示例20: loadScripts
/**
* Load all scripts from /scripts folder
*
* @param void
* @return null
*/
private function loadScripts()
{
$script_path = UPGRADER_PATH . '/scripts';
$d = dir($script_path);
$scripts = array();
while (($entry = $d->read()) !== false) {
if ($entry == '.' || $entry == '..') {
continue;
}
// if
$file_path = $script_path . '/' . $entry;
if (is_readable($file_path) && str_ends_with($file_path, '.class.php')) {
include_once $file_path;
$script_class = substr($entry, 0, strlen($entry) - 10);
$script = new $script_class($this->getOutput());
if ($script instanceof $script_class) {
$script->setUpgrader($this);
$scripts[] = $script;
}
// if
}
// if
}
// while
$d->close();
if (count($scripts)) {
usort($scripts, 'compare_scripts_by_version_to');
$this->scripts = $scripts;
}
// if
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:37,代码来源:ScriptUpgrader.class.php
注:本文中的str_ends_with函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论