本文整理汇总了PHP中String::startsWith方法的典型用法代码示例。如果您正苦于以下问题:PHP String::startsWith方法的具体用法?PHP String::startsWith怎么用?PHP String::startsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::startsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: analyze
public function analyze()
{
$report = null;
$mail = (string) $this->m_mail;
$desc = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w+'), 2 => array('pipe', 'w+'));
$pipes = [];
$pid = @proc_open(self::CMD_BIN . ' ' . escapeshellarg(self::CMD_ARG), $desc, $pipes);
if (false !== $pid) {
@fwrite($pipes[0], $mail);
@fclose($pipes[0]);
$report = stream_get_contents($pipes[1]);
@proc_close($pid);
}
if (null === $report) {
return;
}
$lines = explode("\n", $report);
$lines = array_reverse($lines);
$score = $lines[count($lines) - 1];
$chunks = explode('/', $score);
$this->m_score = (double) reset($chunks);
$this->m_scoreThreshold = (double) end($chunks);
$this->m_tests = [];
foreach ($lines as $line) {
if (String::startsWith($line, '---')) {
break;
}
$matches = [];
preg_match('/([-+\\d.\\d]+)\\s+(\\w*)\\s+([\\s\\S]*)/', $line, $matches);
if (isset($matches[3])) {
$this->m_tests[$matches[2]] = array((double) $matches[1], $matches[3]);
}
}
}
示例2: Response
static function Response($ex, $app)
{
if ($ex instanceof RequestBodyException) {
$app->response->status(400);
return json_encode(array("RequestBodyException:" . $ex->getMessage()));
} else {
if ($ex instanceof RecordNotFoundException) {
$app->response->status(404);
return json_encode(array("RecordNotFoundException:" . $ex->getMessage()));
} else {
if ($ex instanceof RecordDuplicatedException) {
$app->response->status(409);
return json_encode(array("RecordDuplicatedException:" . $ex->getMessage()));
} else {
if (String::startsWith($ex->getMessage(), "SQLSTATE[23000]")) {
$app->response->status(400);
return json_encode(array("Duplicated record."));
} else {
$app->response->status(500);
//var_dump($ex->getMessage());
return json_encode(array($ex->getMessage()));
//return json_encode(array($ex->__toString()));
}
}
}
}
}
示例3: testStartswith
/**
* startsWith test.
* @return void
*/
public function testStartswith()
{
$this->assertTrue(String::startsWith('123', NULL), "String::startsWith('123', NULL)");
$this->assertTrue(String::startsWith('123', ''), "String::startsWith('123', '')");
$this->assertTrue(String::startsWith('123', '1'), "String::startsWith('123', '1')");
$this->assertFalse(String::startsWith('123', '2'), "String::startsWith('123', '2')");
$this->assertTrue(String::startsWith('123', '123'), "String::startsWith('123', '123')");
$this->assertFalse(String::startsWith('123', '1234'), "String::startsWith('123', '1234')");
}
示例4: getAppNames
/**
* getAppNames
* Devuelve una lista de los nombres de las apps
* existentes en la instalacion de Yupp (lee el filesystem).
*/
public static function getAppNames()
{
$appNames = array();
$dir = dir('./apps');
while (false !== ($app = $dir->read())) {
if (!String::startsWith($app, ".") && $app !== "core" && is_dir('./apps/' . $app)) {
$appNames[] = $app;
}
}
return $appNames;
}
示例5: telephone
/**
* Format telephone number according to known SK and CZ specifics
* @param string $telephone
* @return string
*/
public static function telephone($telephone)
{
if (NStrings::startsWith($telephone, '02')) {
return self::format($telephone, array(2, 1, 2, 2, 2));
} elseif (String::startsWith($telephone, '0')) {
return self::format($telephone, array(3, 1, 2, 2, 2));
} elseif (strlen($telephone) === 10) {
return self::format($telephone, array(3, 1, 2, 2, 2));
} elseif (strlen($telephone) === 9) {
return self::format($telephone, array(3, 3, 3));
} else {
return self::format($telephone, array(1, 2, 2, 2));
}
}
示例6: absolutizeUrl
/**
* Make relative url absolute
* @param string image url
* @param string single or double quote
* @param string absolute css file path
* @param string source path
* @return string
*/
public static function absolutizeUrl($url, $quote, $cssFile, $sourcePath)
{
// is already absolute
if (preg_match("/^([a-z]+:\\/)?\\//", $url)) {
return $url;
}
$docroot = realpath(WWW_DIR);
$basePath = rtrim(Environment::getVariable("baseUri"), '/');
// inside document root
if (String::startsWith($cssFile, $docroot)) {
$path = $basePath . substr(dirname($cssFile), strlen($docroot)) . DIRECTORY_SEPARATOR . $url;
// outside document root
} else {
$path = $basePath . substr($sourcePath, strlen($docroot)) . DIRECTORY_SEPARATOR . $url;
}
$path = self::cannonicalizePath($path);
return $quote === '"' ? addslashes($path) : $path;
}
示例7: getBasePath
public function getBasePath()
{
if (!String::startsWith('/', $this->glob)) {
return '';
}
$pos = 0;
$arr = str_split($this->glob);
$size = count($arr);
for ($i = 0; $i < $size; $i++) {
if ($arr[$i] == '*') {
break;
} else {
if ($arr[$i] == '/') {
$pos = $i;
}
}
}
return substr($this->glob, 0, $pos + 1);
}
示例8: getModelRecursive
/**
* Auxiliar recursiva para getModel()
*/
private function getModelRecursive($dir)
{
$res = array();
$d = dir($dir);
while (false !== ($entry = $d->read())) {
if (!String::startsWith($entry, '.')) {
if (is_file($dir . '/' . $entry)) {
$res[] = $entry;
} else {
if (is_dir($dir . '/' . $entry)) {
$res_recur = $this->getModelRecursive($dir . '/' . $entry);
//$res = array_merge($res, $res_recur);
$res[$entry] = $res_recur;
}
}
}
}
$d->close();
return $res;
}
示例9: getModelClassesRecursive
/**
* Esta devuelve los nombres de las clases dentro del directorio y sigue recorriendo recursivamente.
* FIXME: En realidad es una operacion general, tal vez deberia ser parte de FileSystem.
*/
private static function getModelClassesRecursive($dir)
{
$res = array();
//$entries = FileSystem::getFileNames( $dir ); // subdirs y files
$d = dir($dir);
while (false !== ($entry = $d->read())) {
//echo "$entry<br/>";
if (!String::startsWith($entry, ".")) {
if (is_file("{$dir}/{$entry}")) {
$res[] = $entry;
} else {
if (is_dir("{$dir}/{$entry}")) {
$res_recur = self::getModelClassesRecursive("{$dir}/{$entry}");
$res = array_merge($res, $res_recur);
}
}
}
}
$d->close();
return $res;
}
示例10: flush
*/
//var_dump($app->request->headers);
/*echo $_SERVER['REQUEST_METHOD'] . "<br>";
echo $_SERVER['REQUEST_URI'] . "<br>";
if (String::startsWith($_SERVER['REQUEST_URI'], "/Producer/LoginName/") === FALSE)
{
echo "NOT startwith<br>";
}
else
{
echo "startwith:[" . (String::startsWith($_SERVER['REQUEST_URI'], "/Producer/LoginName/") !== TRUE ) . "]<br>";
}
flush();*/
//Check UserSessionId in header for all URIs(except for register and login pages).
if ($_SERVER['REQUEST_METHOD'] == "POST" && !String::startsWith($_SERVER['REQUEST_URI'], "/Producer/BasicInfo/") && ($_SERVER['REQUEST_METHOD'] == "POST" && !String::startsWith($_SERVER['REQUEST_URI'], "/Consumer/BasicInfo/")) && ($_SERVER['REQUEST_METHOD'] == "GET" && !String::startsWith($_SERVER['REQUEST_URI'], "/Producer/LoginName/")) && ($_SERVER['REQUEST_METHOD'] == "GET" && !String::startsWith($_SERVER['REQUEST_URI'], "/Consumer/LoginName/"))) {
//echo "TRAP<BR>";
if (!isset($app->request->headers["UserSessionId"])) {
//echo "HTTP/1.1 403 Forbidden\r\n";
header("HTTP/1.1 403 Forbidden");
return;
}
}
//echo "PASS<BR>";
//flush();
//header("HTTP/1.1 200 OK");
//return;
//ProducerTest::Test1();
$app->run();
//echo '===0<br>\r\n';
//flush();
示例11: WordHandler
<?php
include_once "libPalabras.php";
include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php';
$handler = new WordHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]);
$handler->conn();
if (!isset($_SESSION["usr"])) {
header('Location: index.php');
}
if (isset($_POST["crear"])) {
$crearReforma = array("tipo" => "INSERT", "campos" => array("id" => $handler->getMaxTabla("id", "cte_reformas"), "acrónimo" => $_POST["acrónimo"], "nombre" => $_POST["nombre"], "descripción" => $_POST["descripción"], "fecha" => date("Y:m:d")), "tabla" => "cte_reformas");
$handler->query($crearReforma);
} elseif (isset($_POST["ref_id"])) {
foreach ($_POST as $clave => $campo) {
$str = new String($clave);
if ($str->startsWith("af_")) {
$str->remove_prefix("af_");
$num = $str->get();
$handler->setWordID($_POST["pal_id_" . $num]);
$handler->getDatosPalabra();
$handler->reformarPalabra($_POST["pal_" . $num], $_POST["ref_id"]);
}
}
}
$handler->shutdown();
session_start();
header('Location: ' . $_SESSION["urlVuelta"]);
示例12: startsWith
/**
* @test
*/
public function startsWith()
{
$this->assertTrue(String::startsWith('Foo', 'Foo'));
$this->assertTrue(String::startsWith('Foo123', 'Foo'));
$this->assertFalse(String::startsWith(' Foo123', 'Foo'));
}
示例13: isAbsolute
/**
* @param string $path
* @return bool
*/
public static function isAbsolute($path)
{
return String::startsWith('/', $path);
}
示例14: dir
<?php
$m = Model::getInstance();
$app = $m->get('app');
?>
<html>
<head>
</head>
<body>
<h1>Aplicacion: <?php
echo $app;
?>
</h1>
<h2>Controladores:</h2>
<?php
$app_dir = dir("./apps/" . $app . "/controllers");
$suffix = "Controller.class.php";
$prefix = "apps." . $app . ".controllers.";
echo "<ul>";
while (false !== ($controller = $app_dir->read())) {
if (!String::startsWith($controller, ".")) {
$controller = substr($controller, strlen($prefix), -strlen($suffix));
$logic_controller = String::firstToLower($controller);
echo '<li>[ <a href="' . Helpers::url(array("app" => $app, "controller" => $logic_controller, "action" => "index")) . '">' . $controller . '</a> ]</li>';
}
}
echo "</ul>";
?>
</body>
</html>
示例15: elseif
}
} elseif ($str->startsWith("edit_raíz_")) {
$str->remove_prefix("edit_raíz_");
$nums = explode("_", $str->get());
$args = array("id" => (int) $nums[1], "raíz" => $_POST["raíz_" . $nums[0] . '_' . $nums[1]]);
$tipo = "raíz";
}
if ($args !== NULL) {
$handler->editarEtimologia($tipo, $args);
}
}
break;
case "significados":
foreach ($_POST as $clave => $campo) {
$str = new String($clave);
if ($str->startsWith("edit_")) {
$str->remove_prefix("edit_");
$num = $str->get();
$handler->editarSignificado((int) $_POST["sign_id_" . $num], $_POST["sign_tipo_" . $num], $_POST["sign_" . $num]);
} elseif ($str->startsWith("elim_")) {
$str->remove_prefix("elim_");
$num = $str->get();
$handler->eliminarSignificado((int) $_POST["sign_id_" . $num]);
} elseif ($str->equals("new_sign_creat")) {
$handler->annadirSignificado($_POST['new_sign_tipo'], $_POST['new_sign']);
}
}
break;
}
$handler->shutdown();
header('Location: palabra.php?id=' . $_SESSION["id"] . '&edicion=true');