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


PHP beginsWith函数代码示例

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


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

示例1: get

 function get()
 {
     global $g_mv_tests, $g_log_id;
     if (isset($_SESSION["_mv_" . $this->test])) {
         return $_SESSION["_mv_" . $this->test]["var"];
     }
     if (beginsWith($this->test, "man")) {
         return 0;
     }
     $r = array_filter($g_mv_tests, function ($c) {
         return $c["test"] == $this->test && $c["goal"] == $this->goal;
     });
     // reindex array
     $r = array_values($r);
     if (count($r) == 0) {
         internal_error("No variants found for test: " . $this->test . " ,goal: " . $this->goal);
     }
     if ($r[0]["completed"] != null) {
         $res = $r[0];
     } else {
         // assign the user randomly
         shuffle($r);
         $res = $r[0];
     }
     $_SESSION["_mv_" . $this->test] = ["var" => $res["variation"], "start_log_id" => $g_log_id];
     return $res["variation"];
 }
开发者ID:sdrinf,项目名称:cog,代码行数:27,代码来源:cog_variants.php

示例2: getContent

 private function getContent($url)
 {
     if (beginsWith(URL\takeDomain($url), 'blockchain.info') && beginsWith(URL\takePath($url), '/q/addressbalance/')) {
         return $this->addressBalanceRequest(withoutPrefix(URL\takePath($url), '/q/addressbalance/'));
     } else {
         if ($url == 'http://blockchain.info/q/addressbalance/peanuts') {
             return 'Checksum does not validate';
         } else {
             if (beginsWith($url, 'http://blockchain.info/tobtc?currency=USD')) {
                 return '0.00778083';
             } else {
                 if ($url == 'http://api.easyjquery.com/ips/?ip=99.99.99.99') {
                     return '{"Country": "US"}';
                 } else {
                     if ($url == 'https://freegeoip.net/json/99.99.99.99') {
                         return '{"ip":"99.99.99.99","country_code":"US","country_name":"United States",' . '"region_code":"","region_name":"","city":"","zipcode":"","latitude":38,' . '"longitude":-97,"metro_code":"","areacode":""}';
                     } else {
                         if ($url == 'https://freegeoip.net/json/175.156.249.231') {
                             return "404 page not found";
                         } else {
                             throw new Exception("Mock 'get' function couldn't handle following URL: {$url}");
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:JustAHappyKid,项目名称:bitcoin-chipin,代码行数:28,代码来源:http-client.php

示例3: add_js

 public function add_js($file, $module_name)
 {
     if (beginsWith($file, 'http://') || beginsWith($file, 'https://') || beginsWith($file, '//')) {
         $this->js[] = $file;
     } else {
         $this->js[] = get_url('/' . PATH_TO_MODULES . '/' . $module_name . '/' . $file);
     }
 }
开发者ID:nodefortytwo,项目名称:engagement,代码行数:8,代码来源:template.class.php

示例4: map

 function map($url)
 {
     foreach ($this->urlmaps as $k => $v) {
         // add regex prefix, and suffix
         if (!beginsWith($k, "^")) {
             $k = "^" . $k;
         }
         if (!endsWith($k, "\$")) {
             $k = $k . "\$";
         }
         if (ereg($k, $url, $this->regparams)) {
             return $v;
         }
     }
     return null;
 }
开发者ID:sdrinf,项目名称:cog,代码行数:16,代码来源:cog_webhandler.php

示例5: load

 public function load($db_row = array())
 {
     if (!empty($db_row)) {
         $this->id = $db_row['id'];
         return $this->load_from_id($db_row);
     }
     if (is_int((int) $this->id) && (int) $this->id > 0) {
         $this->id = (int) $this->id;
         return $this->load_from_id();
     } else {
         if (beginsWith($this->id, 'http')) {
             return $this->load_from_url();
         } else {
             return $this->load_from_name();
         }
     }
 }
开发者ID:nodefortytwo,项目名称:engagement,代码行数:17,代码来源:engagement.page.class.php

示例6: testSignupProcess

 function testSignupProcess()
 {
     $this->createHomepageWidgets();
     $this->get('/');
     $this->clickLink("//a[contains(@href, 'signup')]");
     $this->get('/account/signup');
     $this->followRedirects(true);
     $this->submitForm($this->getForm(), array('username' => 'sammy', 'email' => 'sam@test.com', 'password1' => 'luckystars', 'password2' => 'luckystars', 'memorydealers-updates' => 'on'));
     $u = User::loadFromUsername('sammy');
     assertEqual('sam@test.com', $u->email);
     $subscriptions = current(DB\simpleSelect('subscriptions', 'user_id = ?', array($u->id)));
     assertFalse(empty($subscriptions), 'Expected to find record in subscriptions table for user');
     assertTrue($subscriptions['chipin'] == false || $subscriptions['chipin'] == 0);
     assertTrue($subscriptions['memorydealers'] == true || $subscriptions['memorydealers'] == 1);
     $this->logout();
     $this->login('sammy', 'luckystars');
     $this->get('/dashboard/');
     assertTrue(beginsWith($this->getCurrentPath(), '/dashboard'));
 }
开发者ID:JustAHappyKid,项目名称:bitcoin-chipin,代码行数:19,代码来源:signup.php

示例7: getBalanceInSatoshis

function getBalanceInSatoshis($address)
{
    $client = new HttpClient();
    $response = $client->get(balanceLookupURL($address));
    if ($response->statusCode == 200 && isInteger($response->content)) {
        return intval($response->content);
    } else {
        $e = strtolower($response->content);
        preg_match('@<title>(.*)</title>@', $response->content, $matches);
        $title = at($matches, 1);
        if ($e == 'checksum does not validate' || beginsWith($e, 'illegal character') || in_array($e, array('input to short', 'input too short'))) {
            throw new InvalidAddress("{$address} appears to be an invalid Bitcoin address");
        } else {
            if (contains($e, 'cloudflare') && !empty($title)) {
                throw new NetworkError("CloudFlare-reported problem at blockchain.info: " . withoutPrefix($title, "blockchain.info | "));
            } else {
                if (contains(strtolower($title), 'under maintenance')) {
                    throw new NetworkError("Blockchain.info appears to be under maintenance");
                } else {
                    if (contains($e, "maximum concurrent requests reached")) {
                        throw new NetworkError("Maximum concurrent requests to Blockchain.info reached");
                    } else {
                        if (!empty($title)) {
                            throw new NetworkError("Unknown error when attempting to check address-balance " . "for ({$address}) via blockchain.info: {$title}");
                        } else {
                            if (trim($e) == '') {
                                throw new NetworkError("Blockchain.info returned empty/content-less response");
                            } else {
                                if ($e == 'lock wait timeout exceeded; try restarting transaction') {
                                    throw new NetworkError("Blockchain.info responded with error message about lock timeout");
                                } else {
                                    throw new \Exception("Unexpected result received from blockchain.info when " . "attempting to get balance of address {$address}: {$response->content}");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:JustAHappyKid,项目名称:bitcoin-chipin,代码行数:41,代码来源:blockchain-dot-info.php

示例8: file

################### doxygen errors in .doxygen-files  ##########################
if ($user == "all" && in_array("doxygen_errors", $tests)) {
    $file = file("{$bin_path}/doc/doxygen/doxygen-error.log");
    foreach ($file as $line) {
        $line = trim($line);
        if (ereg("(.*/[a-zA-Z0-9_]+\\.doxygen):[0-9]+:", $line, $parts)) {
            realOutput("Doxygen errors in '" . $parts[1] . "'", $user, "");
            print "  See 'OpenMS/doc/doxygen/doxygen-error.log'\n";
        }
    }
}
########################### warnings TOPP test  #################################
if (in_array("topp_output", $tests)) {
    $file_warnings = array();
    foreach ($test_log as $name => $warnings) {
        if (beginsWith($name, "TOPP_")) {
            $name = substr($name, 5);
            $name = substr($name, 0, strpos($name, '_'));
            $topp_file = "src/topp/" . $name . ".cpp";
            if (in_array($topp_file, $files_todo)) {
                if (!isset($file_warnings[$topp_file])) {
                    $file_warnings[$topp_file] = array();
                }
                $file_warnings[$topp_file] = array_merge($file_warnings[$topp_file], $warnings);
            }
        }
    }
    //print errors/warnings bundled for each TOPP tool
    foreach ($file_warnings as $file => $warnings) {
        realOutput("Error/warnings in TOPP tool test of '{$file}'", $user, $file);
        $warnings = array_unique($warnings);
开发者ID:gitter-badger,项目名称:OpenMS,代码行数:31,代码来源:checker.php

示例9: count

             $tagfound[$tags[$j]] = 1;
         }
         // server side index
         if (array_key_exists($tags[$j], $idx)) {
             $idx[$tags[$j]][] = count($geo);
         } else {
             $idx[$tags[$j]] = array(count($geo));
         }
     }
 }
 // filter the tags hstore
 if ($row[1] !== null) {
     $hstore = json_decode('{' . str_replace('"=>"', '":"', $row[1]) . '}', true);
     foreach ($hstore as $j => $val) {
         //if( beginsWith($j,'name:') ||  beginsWith($j,'tiger:')  ||  beginsWith($j,'nist:') ) continue;
         if (beginsWith($j, 'tiger:') || beginsWith($j, 'nist:')) {
             continue;
         }
         $type[$j] = $val;
         if (array_key_exists($j, $tagfound)) {
             $tagfound[$j]++;
         } else {
             $tagfound[$j] = 1;
         }
         // server side index
         if (array_key_exists($j, $idx)) {
             $idx[$j][] = count($geo);
         } else {
             $idx[$j] = array(count($geo));
         }
     }
开发者ID:nicolas-raoul,项目名称:wikiminiatlas,代码行数:31,代码来源:jsontile_dev.php

示例10: getPathInfo

 /**
  * Get the path info, which is everything that follows the application
  * node in the URL. (without query info).
  * The returned pathinfo will not start or end with '/'.
  *
  * @return String
  */
 public static function getPathInfo()
 {
     $appRoot = self::getAppRoot();
     // Get the URL path (everything until the '?')
     $path = MapUtil::get($_SERVER, 'CONTEXT_PREFIX');
     // CONTEXT_PREFIX is aparently new to apache 2.3.13
     // If undefined, fall back to previous method. This one, though, is known
     // to have a problem when the URL is root. ('/').
     if ($path === null || $path === "") {
         $path = isset($_SERVER['SCRIPT_URL']) ? $_SERVER['SCRIPT_URL'] : $_SERVER['PHP_SELF'];
     }
     $pathInfo = substr($path, strlen($appRoot));
     if (beginsWith($pathInfo, '/')) {
         $pathInfo = substr($pathInfo, 1);
     }
     if (endsWith($pathInfo, '/')) {
         $pathInfo = substr($pathInfo, 0, -1);
     }
     return $pathInfo;
 }
开发者ID:fruition-sciences,项目名称:phpfw,代码行数:27,代码来源:Application.php

示例11: CalculateObjectDescriptionForAssociation

 protected function CalculateObjectDescriptionForAssociation($strAssociationTableName, $strTableName, $strReferencedTableName, $blnPluralize)
 {
     // Strip Prefixes (if applicable)
     $strTableName = $this->StripPrefixFromTable($strTableName);
     $strAssociationTableName = $this->StripPrefixFromTable($strAssociationTableName);
     $strReferencedTableName = $this->StripPrefixFromTable($strReferencedTableName);
     // Starting Point
     $strToReturn = QConvertNotation::CamelCaseFromUnderscore($strReferencedTableName);
     if ($blnPluralize) {
         $strToReturn = $this->Pluralize($strToReturn);
     }
     // Let's start with strAssociationTableName
     // Rip out trailing "_assn" if applicable
     $strAssociationTableName = str_replace($this->strAssociationTableSuffix, '', $strAssociationTableName);
     // remove instances of the table names in the association table name
     $strTableName2 = str_replace('_', '', $strTableName);
     // remove underscores if they are there
     $strReferencedTableName2 = str_replace('_', '', $strReferencedTableName);
     // remove underscores if they are there
     if (beginsWith($strAssociationTableName, $strTableName . '_')) {
         $strAssociationTableName = trimOffFront($strTableName . '_', $strAssociationTableName);
     } elseif (beginsWith($strAssociationTableName, $strTableName2 . '_')) {
         $strAssociationTableName = trimOffFront($strTableName2 . '_', $strAssociationTableName);
     } elseif (beginsWith($strAssociationTableName, $strReferencedTableName . '_')) {
         $strAssociationTableName = trimOffFront($strReferencedTableName . '_', $strAssociationTableName);
     } elseif (beginsWith($strAssociationTableName, $strReferencedTableName2 . '_')) {
         $strAssociationTableName = trimOffFront($strReferencedTableName2 . '_', $strAssociationTableName);
     } elseif ($strAssociationTableName == $strTableName || $strAssociationTableName == $strTableName2 || $strAssociationTableName == $strReferencedTableName || $strAssociationTableName == $strReferencedTableName2) {
         $strAssociationTableName = "";
     }
     if (endsWith($strAssociationTableName, '_' . $strTableName)) {
         $strAssociationTableName = trimOffEnd('_' . $strTableName, $strAssociationTableName);
     } elseif (endsWith($strAssociationTableName, '_' . $strTableName2)) {
         $strAssociationTableName = trimOffEnd('_' . $strTableName2, $strAssociationTableName);
     } elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName)) {
         $strAssociationTableName = trimOffEnd('_' . $strReferencedTableName, $strAssociationTableName);
     } elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName2)) {
         $strAssociationTableName = trimOffEnd('_' . $strReferencedTableName2, $strAssociationTableName);
     } elseif ($strAssociationTableName == $strTableName || $strAssociationTableName == $strTableName2 || $strAssociationTableName == $strReferencedTableName || $strAssociationTableName == $strReferencedTableName2) {
         $strAssociationTableName = "";
     }
     // Change any double "__" to single "_"
     $strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
     $strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
     $strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
     // If we have nothing left or just a single "_" in AssociationTableName, return "Starting Point"
     if ($strAssociationTableName == "_" || $strAssociationTableName == "") {
         return sprintf("%s%s%s", $this->strAssociatedObjectPrefix, $strToReturn, $this->strAssociatedObjectSuffix);
     }
     // Otherwise, add "As" and the predicate
     return sprintf("%s%sAs%s%s", $this->strAssociatedObjectPrefix, $strToReturn, QConvertNotation::CamelCaseFromUnderscore($strAssociationTableName), $this->strAssociatedObjectSuffix);
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:52,代码来源:QCodeGenBase.class.php

示例12: CKAN

    if (strtolower(substr($txt, 0, strlen($begin))) == strtolower($begin)) {
        return true;
    }
    return false;
}
//error_reporting(0);
?>
<html>
<head>
<title>AODS Link-updater</title>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
</head>
<body>

    <?php 
$count = 0;
$ckan = new CKAN("");
$ckan->getDatasets();
foreach ($ckan->datasets as $key => $set) {
    foreach ($set->res_url as $i => $url) {
        if (beginsWith($url, "http://os.amsterdam")) {
            $ckan->changeResource($set->name, $i, str_replace("http://os.amsterdam", "http://ois.amsterdam", $url), $set->res_description[$i]);
        }
    }
}
?>
  
</body>
</html>

开发者ID:AmsterdamData,项目名称:CKAN,代码行数:29,代码来源:updateoislinks.php

示例13: substr

     }
 } else {
     $monobook['nsclass'] = 'mediawiki ns-1 ltr';
     /* Special page */
     $monobook['content_actions']['nstab-main']['wiki'] = ':' . substr($ID, strlen($monobook['discussion-location']));
     $monobook['content_actions']['nstab-main']['text'] = $lang['monobook_article'];
     $monobook['content_actions']['nstab-main']['accesskey'] = 'v';
     if ($monobook['discussion'] == 1) {
         $monobook['content_actions']['talk']['class'] = "selected";
         $monobook['content_actions']['talk']['wiki'] = ':' . $ID;
         //Etienne : Discussion, not found in the lang.php files
         //$monobook['content_actions']['talk']['text'] = "Discussion";
         $monobook['content_actions']['talk']['text'] = $lang['monobook_discussion'];
     }
 }
 if (beginsWith($ID, "wiki:user:")) {
     $monobook['nsclass'] = 'mediawiki ns-1 ltr';
     /* Special page */
     $monobook['content_actions']['nstab-main']['text'] = $lang['monobook_userpage'];
     $monobook['content_actions']['nstab-main']['accesskey'] = 'v';
 }
 /* Now the edit button... */
 if ($ACT == "edit") {
     $monobook['content_actions']['edit']['class'] = "selected";
 }
 $monobook['content_actions']['edit']['href'] = DOKU_BASE . DOKU_SCRIPT . "?id=" . $ID . "&amp;do=edit&amp;rev=" . $_REQUEST['rev'];
 $monobook['content_actions']['edit']['accesskey'] = 'e';
 if ($INFO['writable']) {
     if ($INFO['exists']) {
         $monobook['content_actions']['edit']['text'] = $lang['btn_edit'];
         $monobook['content_actions']['edit']['accesskey'] = 'e';
开发者ID:BackupTheBerlios,项目名称:openaqua-svn,代码行数:31,代码来源:context.php

示例14: parseSQLFile

function parseSQLFile($filename, &$tables, &$edges)
{
    //init
    $tables = array();
    $edges = array();
    //parse file
    $file = file($filename);
    for ($i = 0; $i < count($file); ++$i) {
        $line = trim($file[$i]);
        //node
        if (beginsWith($line, "CREATE TABLE")) {
            $parts = explode(" ", $line);
            $current_table = $parts[2];
            $tables[$current_table] = array();
            $j = $i + 1;
            $line = trim($file[$j]);
            //table
            while (!beginsWith($line, "CREATE TABLE") && !beginsWith($line, "ALTER TABLE") && $line != "") {
                //primary key
                if (beginsWith($line, "PRIMARY KEY")) {
                    $parts = explode(" ", $line);
                    $tables[$current_table][rp($parts[3])][] = "P";
                } elseif (beginsWith($line, "KEY")) {
                    $parts = explode(" ", $line);
                    $tables[$current_table][rp($parts[2])][] = "I";
                } else {
                    $parts = explode(" ", $line);
                    if ($parts[0] != ")") {
                        $tables[$current_table][$parts[0]] = array();
                    }
                }
                ++$j;
                $line = trim($file[$j]);
            }
        } elseif (beginsWith($line, "ALTER TABLE")) {
            $parts = explode("`", $line);
            $from = $parts[1];
            $j = $i + 1;
            while (beginsWith(trim($file[$j]), "ADD CONSTRAINT")) {
                $parts = explode(" ", $file[$j]);
                $to = $parts[9];
                $tables[$from][rp($parts[7])][] = "F";
                $edges[] = array($from, $to);
                ++$j;
            }
        }
    }
}
开发者ID:gitter-badger,项目名称:OpenMS,代码行数:48,代码来源:sql2graph.php

示例15: varsToSearch

function varsToSearch($prefix, $vars)
{
    $search = array();
    foreach ($vars as $key => $value) {
        if (beginsWith($key, $prefix) && $value != "") {
            $key = substr($key, strlen($prefix));
            $subkeyarray = false;
            if (endsWith($key, '_lower')) {
                $key = substr($key, 0, strlen($key) - strlen('_lower'));
                $subkey = 'lower';
            } else {
                if (endsWith($key, '_upper')) {
                    $key = substr($key, 0, strlen($key) - strlen('_upper'));
                    $subkey = 'upper';
                } else {
                    if (endsWith($key, '_list')) {
                        $keyvalue = explode('__', substr($key, 0, strlen($key) - strlen('_list')));
                        $key = $keyvalue[0];
                        $value = $keyvalue[1];
                        $subkey = 'list';
                        $subkeyarray = true;
                    } else {
                        if (endsWith($key, '_multimatch')) {
                            $key = substr($key, 0, strlen($key) - strlen('_multimatch'));
                            if (empty($value)) {
                                $value = array();
                            } else {
                                $value = explode(",", $value);
                            }
                            $subkey = 'list';
                        } else {
                            $subkey = 'value';
                        }
                    }
                }
            }
            if (!isset($search[$key])) {
                $search[$key] = array();
            }
            if ($subkeyarray) {
                if (!isset($search[$key][$subkey])) {
                    $search[$key][$subkey] = array();
                }
                $search[$key][$subkey][] = $value;
            } else {
                $search[$key][$subkey] = $value;
            }
        }
    }
    return $search;
}
开发者ID:redhog,项目名称:DemoWave,代码行数:51,代码来源:utils.php


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