本文整理汇总了PHP中endsWith函数的典型用法代码示例。如果您正苦于以下问题:PHP endsWith函数的具体用法?PHP endsWith怎么用?PHP endsWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了endsWith函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getstats
function getstats($completed)
{
foreach ($completed as $fname) {
if (endsWith($fname, ".txt")) {
}
}
}
示例2: 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 'empty':
case '(empty)':
return '';
case 'null':
case '(null)':
return;
}
if (startsWith($value, '"') && endsWith($value, '"')) {
return substr($value, 1, -1);
}
return $value;
}
示例3: setup_database
function setup_database($new = false)
{
global $MYSQL_SERVER;
global $MYSQL_USER;
global $MYSQL_PASSWORD;
global $MYSQL_DATABASE;
echo "= DATABASE SETUP =" . PHP_EOL . PHP_EOL;
$conn = mysql_connect($MYSQL_SERVER, $MYSQL_USER, $MYSQL_PASSWORD);
if ($new) {
mysql_query("DROP DATABASE {$MYSQL_DATABASE}");
echo "Database {$database} dropped." . PHP_EOL;
}
mysql_query("CREATE DATABASE IF NOT EXISTS {$MYSQL_DATABASE}") or die(mysql_error());
echo "Database {$MYSQL_DATABASE} created." . PHP_EOL;
mysql_select_db($MYSQL_DATABASE, $conn);
mysql_set_charset("utf8");
if ($new) {
$dir = "database/";
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (!is_dir($file) && !endsWith($file, "_inserts.sql")) {
create_table($file);
}
}
}
}
insert_languages();
echo "Tables for {$MYSQL_DATABASE} created." . PHP_EOL;
}
}
示例4: loadFiles
public static function loadFiles($path)
{
if (endsWith($path, "dashboard")) {
$css = "dashboard.wolf.css";
if (Setting::get("theme") === "fox_theme") {
$css = "dashboard.fox.css";
} else {
if (Setting::get("theme") === "wordpress-3.8") {
$css = "dashboard.wordpress.css";
}
}
$file = PATH_PUBLIC . "wolf/plugins/dashboard/system/css/" . $css;
?>
<link rel="stylesheet" type="text/css" href="<?php
echo $file;
?>
" media="screen" /><?php
Observer::notify("dashboard_load_css");
$file = PATH_PUBLIC . "wolf/plugins/dashboard/system/js/script.dashboard.js";
?>
<script type="text/javascript" language="javascript" src="<?php
echo $file;
?>
"></script><?php
Observer::notify("dashboard_load_js");
}
}
示例5: percentToDecimal
function percentToDecimal($percent)
{
if (endsWith($percent, '%')) {
return rtrim($percent, "%") / 100;
}
return $percent;
}
示例6: setTemplatePath
/**
*
* @param string $template
* @throws \InvalidArgumentException
*/
public function setTemplatePath($template)
{
if (!endsWith($template, ".mustache")) {
throw new \InvalidArgumentException("O arquivo de template do email deve ser do tipo .mustache");
}
$this->template = $template;
}
示例7: _identify
function _identify($str)
{
$msg_identifier = "]8úü";
$server_delivery_identifier = "Œ";
$client_delivery_identifier = "½";
$acc_info_iden = "™½§”";
$last_seen_ident = "H8úü";
$last_seen_ident2 = "{½L‹";
if (startsWith($str, $msg_identifier, 3)) {
if (endsWith($str, $server_delivery_identifier)) {
return 'server_delivery_report';
} else {
if (endsWith($str, $client_delivery_identifier)) {
return 'client_delivery_report';
} else {
return 'msg';
}
}
} else {
if (startsWith($str, $acc_info_iden, 3)) {
return 'account_info';
} else {
if (startsWith($str, $last_seen_ident, 3) && strpos($str, $last_seen_ident2)) {
return 'last_seen';
}
}
}
}
示例8: __construct
function __construct($password = NULL, $host = "127.0.0.1", $port = 10010)
{
$this->socket = stream_socket_client("udp://" . $host . ":" . $port, $errorno, $errorstr);
if (!$this->socket) {
die("Failed to connect, Error #{$errorno}: {$errorstr}");
}
fwrite($this->socket, Bencode::encode(array("q" => "ping")));
// Try to ping it
$returndata = fread($this->socket, $this->buffersize);
if (!endsWith($returndata, "1:q4:ponge")) {
die("{$returndata}");
}
$this->password = $password;
$page = 0;
while (True) {
$request = array("q" => "Admin_availableFunctions", "args" => array("page" => $page));
fwrite($this->socket, Bencode::encode($request));
$result = Bencode::decode(fread($this->socket, $this->buffersize));
foreach ($result['availableFunctions'] as $function => $description) {
$this->functions[$function] = $description;
}
if (isset($result['more'])) {
$page++;
} else {
break;
}
}
}
示例9: add_edge
function add_edge($_previous_as, $_as, $attrs = array())
{
global $edges, $graph;
$edge_array = array($_previous_as => $_as);
if (!array_key_exists(gek($_previous_as, $_as), $edges)) {
$attrs['splines'] = "true";
$edge = array($edge_array, $attrs);
$graph->addEdge($edge_array, $attrs);
$edges[gek($_previous_as, $_as)] = $edge;
} else {
if (array_key_exists('label', $attrs)) {
$e =& $edges[gek($_previous_as, $_as)];
$label_without_star = str_replace("*", "", $attrs['label']);
$labels = explode("\r", $e[1]['label']);
if (!in_array($label_without_star . "*", $labels)) {
$tmp_labels = array();
foreach ($labels as $l) {
if (!startsWith($l, $label_without_star)) {
$labels[] = $l;
}
}
$labels = array_merge(array($attrs['label']), $tmp_labels);
$cmp = function ($a, $b) {
return endsWith($a, "*") ? -1 : 1;
};
usort($labels, $cmp);
$label = escape(implode("\r", $labels));
$e[1]['label'] = $label;
}
}
}
return $edges[gek($_previous_as, $_as)];
}
示例10: getFolderNameFromPath
function getFolderNameFromPath($path)
{
if (endsWith("/", $path)) {
$path = substr($path, 0, -1);
}
return substr($path, strrpos($path, "/") + 1);
}
示例11: __construct
public function __construct(WebRequest $request)
{
parent::__construct($request);
global $IP;
if (strpos($this->mOid, '..') !== false) {
throw new Exception('File path must not contain \'..\'.');
}
if (endsWith($this->mOid, '.js', false)) {
$this->mContentType = AssetsManager::TYPE_JS;
} else {
if (endsWith($this->mOid, '.css', false)) {
$this->mContentType = AssetsManager::TYPE_CSS;
} else {
throw new Exception('Requested file must be .css or .js.');
}
}
$filePath = $IP . '/' . $this->mOid;
if (file_exists($filePath)) {
$this->mContent = file_get_contents($filePath);
} else {
$requestDetails = AssetsManager::getRequestDetails();
Wikia::log(__METHOD__, false, "file '{$filePath}' doesn't exist ({$requestDetails})", true);
throw new Exception('File does not exist');
}
}
示例12: pugpig_validate_file
function pugpig_validate_file($file, $mime)
{
// CHECK UTF-8??
if (!file_exists($file)) {
return "No file";
}
if (FALSE) {
return "File encoding is not UTF-8";
}
// Check XML
if (strpos($mime, 'xml') !== FALSE || endsWith($file, '.xml')) {
$f = file_get_contents($file);
return check_xml_is_valid($f);
}
// Check JSON
if (startsWith($mime, 'application/json') || endsWith($file, '.json')) {
$f = file_get_contents($file);
$json = json_decode($f);
$err = json_last_error();
if ($err == JSON_ERROR_NONE) {
return "";
}
return "Error: {$err}";
}
// Check Manifests
if (startsWith($mime, 'text/cache-manifest') || endsWith($file, '.manifest') || endsWith($file, '.appcache')) {
$f = file_get_contents($file);
if (!startsWith($f, "CACHE MANIFEST")) {
return "Manifest did not start with CACHE Manifest. Instead got:\n{$f}";
}
}
return "";
}
示例13: normalize
private function normalize($path)
{
if (!endsWith($path, '/')) {
$path .= '/';
}
return $path;
}
示例14: validateHtmlTag
function validateHtmlTag($html)
{
$result = array();
$result[] = strpos($html, '<html>');
$result[] = endsWith($html, '</html>');
return $result;
}
示例15: showHeaders
function showHeaders()
{
?>
<html>
<head>
<meta charset="utf-8" />
<?php
$m_data = new application\model\M_Data();
//$array = $m_data->listFolderFiles("assets");
$array = $m_data->directoryToArray("assets", true);
foreach ($array as $key => $value) {
if (endsWith($value, ".js")) {
?>
<script src="<?php
echo base_url($value);
?>
"></script>
<?php
} elseif (endsWith($value, ".css")) {
?>
<link href="<?php
echo base_url($value);
?>
" rel="stylesheet">
<?php
}
}
?>
</head>
<body>
<?php
}