当前位置: 首页>>代码示例>>PHP>>正文


PHP startswith函数代码示例

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


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

示例1: forceproto

function forceproto($url)
{
    if (startswith('//', $url)) {
        $url = proto() . ':' . $url;
    }
    return $url;
}
开发者ID:agnat,项目名称:streaming-website,代码行数:7,代码来源:helper.php

示例2: smarty_cms_prefilter_precompilefunc

function smarty_cms_prefilter_precompilefunc($tpl_output, &$smarty)
{
    $result = explode(':', $smarty->_current_file);
    if (count($result) > 1) {
        if (startswith($result[0], 'tmp_')) {
            $result[0] = 'template';
        }
        switch ($result[0]) {
            case 'stylesheet':
                Events::SendEvent('Core', 'StylesheetPreCompile', array('stylesheet' => &$tpl_output));
                break;
            case "content":
                Events::SendEvent('Core', 'ContentPreCompile', array('content' => &$tpl_output));
                break;
            case "template":
                Events::SendEvent('Core', 'TemplatePreCompile', array('template' => &$tpl_output));
                break;
            case "globalcontent":
                Events::SendEvent('Core', 'GlobalContentPreCompile', array('global_content' => &$tpl_output));
                break;
            default:
                break;
        }
    }
    Events::SendEvent('Core', 'SmartyPreCompile', array('content' => &$tpl_output));
    return $tpl_output;
}
开发者ID:aldrymaulana,项目名称:cmsdepdagri,代码行数:27,代码来源:prefilter.precompilefunc.php

示例3: callHistory

/**
 * an easy to read backtrace (uses debug_backtrace())
 * @todo longest common string should only go until / or \
 */
function callHistory()
{
    $arr = debug_backtrace();
    // find out which is the basic path each files are sharing
    // this is done to keep readability
    $base = false;
    foreach ($arr as $v) {
        if (!isset($v['file']) || !$v['file']) {
            continue;
        }
        if ($base === false) {
            $base = $v['file'];
        }
        while (!startswith($base, $v['file'])) {
            $base = substr($base, 0, -1);
        }
    }
    $ret = array(array('basepath' => $base));
    foreach ($arr as $v) {
        if (isset($v['file']) && $v['file']) {
            $ret[] = array('file' => substr($v['file'], strlen($base)), 'line' => $v['line']);
        }
    }
    return $ret;
}
开发者ID:balrok,项目名称:aiajaya,代码行数:29,代码来源:debug.php

示例4: getMinName

 /**
  * 
  * @param String $fieldname
  * @return String nom d'attribut réduit comme 'joueur_name' => 'name'
  */
 private function getMinName($fieldname)
 {
     if (startswith($fieldname, $this->table_name . '_')) {
         return substr($fieldname, strlen($this->table_name) + 1);
     } else {
         return $fieldname;
     }
 }
开发者ID:laiello,项目名称:ascn,代码行数:13,代码来源:DBItem.php

示例5: test

 public function test($time = '')
 {
     if (!$time) {
         $time = time();
     }
     $mod = cms_utils::get_module('FrontEndUsers');
     $lastrun = $mod->GetPreference('forcelogout_lastrun');
     $times = $mod->GetPreference('forcelogout_times');
     // like: 18:30,20:30,08:00, etc.
     if ($times == '') {
         return FALSE;
     }
     $tmp = array();
     $times = explode(',', $times);
     for ($i = 0; $i < count($times); $i++) {
         $t_h = '';
         $t_m = '';
         if (startswith($times[$i], '*')) {
             list($junk, $minutes) = explode('/', $times[$i], 2);
             $minutes = (int) $minutes;
             $minutes = max($minutes, 1);
             // minumum 2 minutes
             $minutes = min($minutes, 180);
             // maximum 180 minutes.
             for ($i = 0; $i < 60 * 24; $i += $minutes) {
                 $t_h = (int) ($i / 60);
                 $t_m = (int) ($i % 60);
                 $tmp[] = mktime((int) $t_h, (int) $t_m, 0, (int) date('m', $time), (int) date('d', $time), (int) date('Y', $time));
             }
         } else {
             list($t_h, $t_m) = explode(':', trim($times[$i]), 2);
         }
     }
     rsort($tmp);
     $fi = '';
     $ft = '';
     // find the closest entry.
     $db = cmsms()->GetDb();
     for ($i = 0; $i < count($tmp); $i++) {
         if ($time > $tmp[$i]) {
             break;
         }
         // nothing to do..
         $dt = $tmp[$i] - $time;
         if ($ft == '' || $dt < $ft - $time) {
             $fi = $i;
             $ft = $tmp[$i];
         }
     }
     if ($ft != '' && $fi != '' && $time - $ft < 60) {
         // we found something that can execute.
         $_SESSION[get_class() . '_runtime'] = $tmp[$i];
         return TRUE;
     }
     return FALSE;
 }
开发者ID:aldrymaulana,项目名称:cmsdepdagri,代码行数:56,代码来源:class.FEUForcedLogoutTask.php

示例6: getOldParams

function getOldParams($post)
{
    $old_params = array();
    foreach ($post as $key => $value) {
        if (startswith($key, 'old_')) {
            $old_params[] = substr($key, 4);
        }
    }
    return $old_params;
}
开发者ID:pulse-project,项目名称:pulse,代码行数:10,代码来源:launch.php

示例7: smarty_cms_prefilter_precompilefunc

function smarty_cms_prefilter_precompilefunc($tpl_output, &$smarty)
{
    global $gCms;
    $result = explode(':', $smarty->_current_file);
    if (count($result) > 1) {
        if (startswith($result[0], 'tmp_')) {
            $result[0] = 'template';
        }
        switch ($result[0]) {
            case "content":
                // 				foreach($gCms->modules as $key=>$value)
                // 				{
                // 					if ($gCms->modules[$key]['installed'] == true &&
                // 						$gCms->modules[$key]['active'] == true)
                // 					{
                // 						$gCms->modules[$key]['object']->ContentPreCompile($tpl_output);
                // 					}
                // 				}
                Events::SendEvent('Core', 'ContentPreCompile', array('content' => &$tpl_output));
                break;
            case "template":
                // 				foreach($gCms->modules as $key=>$value)
                // 				{
                // 					if ($gCms->modules[$key]['installed'] == true &&
                // 						$gCms->modules[$key]['active'] == true)
                // 					{
                // 						$gCms->modules[$key]['object']->TemplatePreCompile($tpl_output);
                // 					}
                // 				}
                Events::SendEvent('Core', 'TemplatePreCompile', array('template' => &$tpl_output));
                break;
            case "globalcontent":
                // 				foreach($gCms->modules as $key=>$value)
                // 				{
                // 					if ($gCms->modules[$key]['installed'] == true &&
                // 						$gCms->modules[$key]['active'] == true)
                // 					{
                // 						$gCms->modules[$key]['object']->GlobalContentPreCompile($tpl_output);
                // 					}
                // 				}
                Events::SendEvent('Core', 'GlobalContentPreCompile', array('global_content' => &$tpl_output));
                break;
            default:
                break;
        }
    }
    foreach ($gCms->modules as $key => $value) {
        if ($gCms->modules[$key]['installed'] == true && $gCms->modules[$key]['active'] == true) {
            $gCms->modules[$key]['object']->SmartyPreCompile($tpl_output);
        }
    }
    Events::SendEvent('Core', 'SmartyPreCompile', array('content' => &$tpl_output));
    return $tpl_output;
}
开发者ID:rasomu,项目名称:chuza,代码行数:54,代码来源:prefilter.precompilefunc.php

示例8: findPage

 /**
  * Reproducing renderPage() if hell, to avoid regression.
  *
  * This highlights how bad this needs to be rewrite,
  * but let's focus on plugins for now.
  *
  * @param string $query    $_SERVER['QUERY_STRING'].
  * @param array  $get      $_SERVER['GET'].
  * @param bool   $loggedIn true if authenticated user.
  *
  * @return self::page found.
  */
 public static function findPage($query, $get, $loggedIn)
 {
     $loggedIn = $loggedIn === true ? true : false;
     if (empty($query) && !isset($get['edit_link']) && !isset($get['post'])) {
         return self::$PAGE_LINKLIST;
     }
     if (startswith($query, 'do=' . self::$PAGE_LOGIN) && $loggedIn === false) {
         return self::$PAGE_LOGIN;
     }
     if (startswith($query, 'do=' . self::$PAGE_PICWALL)) {
         return self::$PAGE_PICWALL;
     }
     if (startswith($query, 'do=' . self::$PAGE_TAGCLOUD)) {
         return self::$PAGE_TAGCLOUD;
     }
     if (startswith($query, 'do=' . self::$PAGE_OPENSEARCH)) {
         return self::$PAGE_OPENSEARCH;
     }
     if (startsWith($query, 'do=' . self::$PAGE_DAILY)) {
         return self::$PAGE_DAILY;
     }
     // At this point, only loggedin pages.
     if (!$loggedIn) {
         return self::$PAGE_LINKLIST;
     }
     if (startswith($query, 'do=' . self::$PAGE_TOOLS)) {
         return self::$PAGE_TOOLS;
     }
     if (startswith($query, 'do=' . self::$PAGE_CHANGEPASSWORD)) {
         return self::$PAGE_CHANGEPASSWORD;
     }
     if (startswith($query, 'do=' . self::$PAGE_CONFIGURE)) {
         return self::$PAGE_CONFIGURE;
     }
     if (startswith($query, 'do=' . self::$PAGE_CHANGETAG)) {
         return self::$PAGE_CHANGETAG;
     }
     if (startswith($query, 'do=' . self::$PAGE_ADDLINK)) {
         return self::$PAGE_ADDLINK;
     }
     if (isset($get['edit_link']) || isset($get['post'])) {
         return self::$PAGE_EDITLINK;
     }
     if (startswith($query, 'do=' . self::$PAGE_EXPORT)) {
         return self::$PAGE_EXPORT;
     }
     if (startswith($query, 'do=' . self::$PAGE_IMPORT)) {
         return self::$PAGE_IMPORT;
     }
     return self::$PAGE_LINKLIST;
 }
开发者ID:ErwanLeroux,项目名称:Shaarli,代码行数:63,代码来源:Router.php

示例9: list_templates

/**
 * List all available templates.
 * @return An array {path, name, current} where path is the template path, name is the template name and current is true if this is the current template, false otherwise.
 */
function list_templates()
{
    global $config;
    $paths = array_filter(scandir(TPL_DIR), function ($item) {
        return is_dir(TPL_DIR . $item) && !startswith($item, '.');
    });
    $names = array_map('ucfirst', $paths);
    $templates = array();
    foreach ($paths as $key => $path) {
        $path .= '/';
        $templates[] = array('path' => $path, 'name' => $names[$key], 'current' => $path == $config->template);
    }
    return $templates;
}
开发者ID:qwertygc,项目名称:Freeder,代码行数:18,代码来源:functions.php

示例10: check_samples

function check_samples($uri)
{
    if (startswith($uri, "http://example.org/")) {
        $filename = substr($uri, 19);
    } else {
        return false;
    }
    $sample_map = unserialize(sample_map);
    foreach ($sample_map as $mapkey => $mapvalue) {
        if (startswith($filename, $mapkey)) {
            return_cached($mapvalue, "samples");
        }
    }
}
开发者ID:nicholascar,项目名称:rdfjs_tools,代码行数:14,代码来源:proxy.php

示例11: fromString

 /**
  * Create a new dataref object from a string
  * @param string $str Input string of the format __DataRef::key1val::key2val::key3val::key4val
  * @return DataRef
  */
 public static function fromString($str)
 {
     if (!startswith($str, '__DataRef::')) {
         throw new \Exception('String provided is not a valid dataref');
     }
     $parts = explode('::', $str);
     if (count($parts) < 2 || count($parts) > 5) {
         throw new \Exception('String provided is not a valid dataref');
     }
     $obj = new self();
     for ($i = 1; $i < count($parts); $i++) {
         $key = 'key' . $i;
         $obj->{$key} = $parts[$i];
     }
     return $obj;
 }
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:21,代码来源:class.DataRef.php

示例12: GetCachePath

 public static function GetCachePath($mod)
 {
     // Récupérer et traiter la préférence du dossier
     $cache_path = $mod->GetPreference("cache_path");
     // Si la préférence commence par un "/" alors l'enlever
     if (startswith($cache_path, DIRECTORY_SEPARATOR)) {
         $cache_path = substr($cache_path, 1);
     }
     // Si la préférence termine par un "/" alors l'enlever
     if (endswith($cache_path, DIRECTORY_SEPARATOR)) {
         $cache_path = substr($cache_path, -1, 1);
     }
     // Ajouter à la préférence le chemin complet
     $config = $mod->GetConfig();
     $cache_path = $config['root_path'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . $cache_path;
     return $cache_path;
 }
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:17,代码来源:class.te_base.php

示例13: load_keys

function load_keys($list)
{
    $c = file_get_contents($list);
    $lines = explode("\n", $c);
    $result = [];
    foreach ($lines as $line) {
        $line = trim($line);
        if (substr($line, -1) == "\r") {
            $line = substr($line, 0, strlen($line) - 1);
        }
        if (startswith($line, "0.0.0.0 ")) {
            $line = substr($line, 8);
            $result[strupto($line, ' ')] = true;
        }
    }
    return $result;
}
开发者ID:jacquesmattheij,项目名称:remoteresources,代码行数:17,代码来源:process.php

示例14: GetTagParams

 public static function GetTagParams($wholetag)
 {
     $matches = array();
     $result = preg_match_all(AC_BLOCK_PARAM_PATTERN, $wholetag, $matches);
     $params = array();
     for ($i = 0; $i < count($matches[1]); $i++) {
         if (startswith($matches[2][$i], '\'')) {
             $matches[2][$i] = trim($matches[2][$i], '\'');
         } else {
             if (startswith($matches[2][$i], '"')) {
                 $matches[2][$i] = trim($matches[2][$i], '"');
             }
         }
         $params[strtolower($matches[1][$i])] = $matches[2][$i];
     }
     return $params;
 }
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:17,代码来源:class.acContentBlockManager.php

示例15: ordercontent_get_node_rec

 function ordercontent_get_node_rec($str, $prefix = 'page_')
 {
     $gCms = cmsms();
     $tree = $gCms->GetHierarchyManager();
     if (!is_numeric($str) && startswith($str, $prefix)) {
         $str = substr($str, strlen($prefix));
     }
     $id = (int) $str;
     $tmp = $tree->find_by_tag('id', $id);
     $content = '';
     if ($tmp) {
         $content = $tmp->getContent(false, true, true);
         if ($content) {
             $rec = aray();
             $rec['id'] = (int) $str;
         }
     }
 }
开发者ID:RTR-ITF,项目名称:usse-cms,代码行数:18,代码来源:ordercontent.php


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