本文整理汇总了PHP中strncasecmp函数的典型用法代码示例。如果您正苦于以下问题:PHP strncasecmp函数的具体用法?PHP strncasecmp怎么用?PHP strncasecmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strncasecmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getTextMode
private static function _getTextMode()
{
if (!function_exists('getText') || strncasecmp(PHP_OS, 'WIN', 3) == 0) {
return self::GETTEXT_MODE_LIBRARY;
}
return self::GETTEXT_MODE_NATIVE;
}
示例2: constructUrl
/**
* Constructs absolute URL from Request object.
* @return string|NULL
*/
public function constructUrl(PresenterRequest $appRequest, Url $refUrl)
{
if ($this->flags & self::ONE_WAY) {
return NULL;
}
$params = $appRequest->getParameters();
// presenter name
$presenter = $appRequest->getPresenterName();
if (strncasecmp($presenter, $this->module, strlen($this->module)) === 0) {
$params[self::PRESENTER_KEY] = substr($presenter, strlen($this->module));
} else {
return NULL;
}
// remove default values; NULL values are retain
foreach ($this->defaults as $key => $value) {
if (isset($params[$key]) && $params[$key] == $value) {
// intentionally ==
unset($params[$key]);
}
}
$url = ($this->flags & self::SECURED ? 'https://' : 'http://') . $refUrl->getAuthority() . $refUrl->getPath();
$sep = ini_get('arg_separator.input');
$query = http_build_query($params, '', $sep ? $sep[0] : '&');
if ($query != '') {
// intentionally ==
$url .= '?' . $query;
}
return $url;
}
示例3: matches
/**
* Match a list of proxies.
*
* @param array $list The list of proxies in front of this service.
*
* @return bool
*/
public function matches(array $list)
{
$list = array_values($list);
// Ensure that we have an indexed array
if ($this->isSizeValid($list)) {
$mismatch = false;
foreach ($this->chain as $i => $search) {
$proxy_url = $list[$i];
if (preg_match('/^\\/.*\\/[ixASUXu]*$/s', $search)) {
if (preg_match($search, $proxy_url)) {
phpCAS::trace("Found regexp " . $search . " matching " . $proxy_url);
} else {
phpCAS::trace("No regexp match " . $search . " != " . $proxy_url);
$mismatch = true;
break;
}
} else {
if (strncasecmp($search, $proxy_url, strlen($search)) == 0) {
phpCAS::trace("Found string " . $search . " matching " . $proxy_url);
} else {
phpCAS::trace("No match " . $search . " != " . $proxy_url);
$mismatch = true;
break;
}
}
}
if (!$mismatch) {
phpCAS::trace("Proxy chain matches");
return true;
}
} else {
phpCAS::trace("Proxy chain skipped: size mismatch");
}
return false;
}
示例4: run
public static function run()
{
if (!Site::init(!empty($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : '')) {
@header('HTTP/1.1 404 Not Found');
exit;
}
$method = Core::getRequestMethod();
if (!in_array($method, array('get', 'put', 'delete', 'post'))) {
@header("HTTP/1.1 501 Not Implemented");
exit;
}
$data = Core::getRequestData();
if (empty($data[$method]) && !in_array($_SERVER['REQUEST_URI'], array($_SERVER['SCRIPT_NAME'], "", "/"))) {
$data[$method] = $_SERVER['REQUEST_URI'];
}
$resource = Core::getResource($data, $method);
$staticFolders = array('/cache/', '/static/', '/uploads/', '/vendor/');
foreach ($staticFolders as $folder) {
if (strncasecmp($resource, $folder, strlen($folder)) === 0) {
@header('HTTP/1.1 404 Not Found');
exit;
}
}
App::set(App::parse($resource));
Core::resource($resource);
Module::init();
$response = Response\Factory::get($resource, $method);
if (empty($response)) {
@header('HTTP/1.1 406 Not Acceptable');
exit;
}
Request::init($response, $data);
echo Request::run($resource, $method);
}
示例5: copyFile
/**
* Copy file.
*
* @param string $source source file path
* @param string $dest destination file path.
* @param bool|null $overwrite whether to overwrite destination file if it already exist.
* @return bool whether the copying operation succeeded.
*/
public static function copyFile($source, $dest, $overwrite = null)
{
if (!is_file($source)) {
Console::stderr("File {$dest} skipped ({$source} not exist)", Console::FG_GREEN);
return true;
}
if (is_file($dest)) {
if (file_get_contents($source) === file_get_contents($dest)) {
Console::stdout("File {$dest} unchanged", Console::FG_GREEN);
return true;
}
Console::stdout("File {$dest} exist, overwrite? [Yes|No|Quit]", Console::FG_YELLOW);
$answer = $overwrite === null ? Console::stdin() : $overwrite;
if (!strncasecmp($answer, 'q', 1) || strncasecmp($answer, 'y', 1) !== 0) {
Console::stdout("Skipped {$dest}", Console::FG_GREEN);
return false;
}
file_put_contents($dest, file_get_contents($source));
Console::stdout("Overwritten {$dest}", Console::FG_GREEN);
return true;
}
if (!is_dir(dirname($dest))) {
@mkdir(dirname($dest), 0777, true);
}
file_put_contents($dest, file_get_contents($source));
Console::stdout("Copied {$source} to {$dest}", Console::FG_GREEN);
return true;
}
示例6: substr_compare
function substr_compare($main_str, $str, $offset, $length = NULL, $case_insensitivity = false)
{
$offset = (int) $offset;
// Throw a warning because the offset is invalid
if ($offset >= strlen($main_str)) {
trigger_error('The start position cannot exceed initial string length.', E_USER_WARNING);
return false;
}
// We are comparing the first n-characters of each string, so let's use the PHP function to do it
if ($offset == 0 && is_int($length) && $case_insensitivity === true) {
return strncasecmp($main_str, $str, $length);
}
// Get the substring that we are comparing
if (is_int($length)) {
$main_substr = substr($main_str, $offset, $length);
$str_substr = substr($str, 0, $length);
} else {
$main_substr = substr($main_str, $offset);
$str_substr = $str;
}
// Return a case-insensitive comparison of the two strings
if ($case_insensitivity === true) {
return strcasecmp($main_substr, $str_substr);
}
// Return a case-sensitive comparison of the two strings
return strcmp($main_substr, $str_substr);
}
示例7: proc
/**
* @brief Widget execution
* Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
* After generating the result, do not print but return it.
*/
function proc($args)
{
// Set a path of the template skin (values of skin, colorset settings)
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
Context::set('colorset', $args->colorset);
// Specify a template file
if (Context::get('is_logged')) {
$tpl_file = 'login_info';
} else {
$tpl_file = 'login_form';
}
// Get the member configuration
$oModuleModel = getModel('module');
$this->member_config = $oModuleModel->getModuleConfig('member');
Context::set('member_config', $this->member_config);
// Set a flag to check if the https connection is made when using SSL and create https url
$ssl_mode = false;
$useSsl = Context::getSslStatus();
if ($useSsl != 'none') {
if (strncasecmp('https://', Context::getRequestUri(), 8) === 0) {
$ssl_mode = true;
}
}
Context::set('ssl_mode', $ssl_mode);
// Compile a template
$oTemplate =& TemplateHandler::getInstance();
return $oTemplate->compile($tpl_path, $tpl_file);
}
示例8: __construct
/**
* Constructor
*
* @param string|RFormatter $format Output format ID, or formatter instance defaults to 'html'
*/
public function __construct($format = 'html')
{
static $didIni = false;
if (!$didIni) {
$didIni = true;
foreach (array_keys(static::$config) as $key) {
$iniVal = get_cfg_var('ref.' . $key);
print_r($iniVal);
if ($iniVal !== false) {
static::$config[$key] = $iniVal;
}
}
}
if ($format instanceof RFormatter) {
$this->fmt = $format;
} else {
$format = __NAMESPACE__ . '\\' . (isset(static::$config['formatters'][$format]) ? static::$config['formatters'][$format] : 'R' . ucfirst($format) . 'Formatter');
if (!class_exists($format, true)) {
throw new \Exception(sprintf('%s class not found', $format));
}
$this->fmt = new $format();
}
if (static::$env) {
return;
}
static::$env = array('is54' => version_compare(PHP_VERSION, '5.4') >= 0, 'is546' => version_compare(PHP_VERSION, '5.4.6') >= 0, 'is56' => version_compare(PHP_VERSION, '5.6') >= 0, 'curlActive' => function_exists('curl_version'), 'mbStr' => function_exists('mb_detect_encoding'), 'supportsDate' => strncasecmp(PHP_OS, 'WIN', 3) !== 0 || version_compare(PHP_VERSION, '5.3.10') >= 0);
}
示例9: findColumns
/**
* Collects the table column metadata.
* @param CDbTableSchema the table metadata
* @return boolean whether the table exists in the database
*/
protected function findColumns($table)
{
$sql = "PRAGMA table_info({$table->rawName})";
$columns = $this->getDbConnection()->createCommand($sql)->queryAll();
if (empty($columns)) {
return false;
}
foreach ($columns as $column) {
$c = $this->createColumn($column);
$table->columns[$c->name] = $c;
if ($c->isPrimaryKey) {
if ($table->primaryKey === null) {
$table->primaryKey = $c->name;
} else {
if (is_string($table->primaryKey)) {
$table->primaryKey = array($table->primaryKey, $c->name);
} else {
$table->primaryKey[] = $c->name;
}
}
}
}
if (is_string($table->primaryKey) && !strncasecmp($table->columns[$table->primaryKey]->dbType, 'int', 3)) {
$table->sequenceName = '';
}
return true;
}
示例10: getBlockCode_ViewImage
function getBlockCode_ViewImage()
{
$sSiteUrl = $this->_aSite['url'];
$aFile = BxDolService::call('photos', 'get_photo_array', array($this->_aSite['photo'], 'file'), 'Search');
$sImage = $aFile['no_image'] ? '' : $aFile['file'];
// BEGIN STW INTEGRATION
if (getParam('bx_sites_account_type') != 'No Automated Screenshots') {
if ($sImage == '') {
$aSTWOptions = array();
bx_sites_import('STW');
$sThumbHTML = getThumbnailHTML($sSiteUrl, $aSTWOptions, false, false);
}
}
// END STW INTEGRATION
$sVote = '';
if (strncasecmp($sSiteUrl, 'http://', 7) != 0 && strncasecmp($sSiteUrl, 'https://', 8) != 0) {
$sSiteUrl = 'http://' . $sSiteUrl;
}
if ($this->_oConfig->isVotesAllowed() && $this->_oSites->oPrivacy->check('rate', $this->_aSite['id'], $this->_oSites->iOwnerId)) {
bx_import('BxTemplVotingView');
$oVotingView = new BxTemplVotingView('bx_sites', $this->_aSite['id']);
if ($oVotingView->isEnabled()) {
$sVote = $oVotingView->getBigVoting();
}
}
$sContent = $this->_oTemplate->parseHtmlByName('view_image.html', array('title' => $this->_aSite['title'], 'site_url' => $sSiteUrl, 'site_url_view' => $this->_aSite['url'], 'bx_if:is_image' => array('condition' => $sThumbHTML == false, 'content' => array('image' => $sImage ? $sImage : $this->_oTemplate->getImageUrl('no-image-thumb.png'))), 'bx_if:is_thumbhtml' => array('condition' => $sThumbHTML != '', 'content' => array('thumbhtml' => $sThumbHTML)), 'vote' => $sVote, 'view_count' => $this->_aSite['views']));
return array($sContent, array(), array(), false);
}
示例11: actionIndex
/**
* Index
*/
public function actionIndex()
{
// define confirm message
$confirmMsg = "\r\n";
$confirmMsg .= "Please confirm:\r\n";
$confirmMsg .= "\r\n";
$confirmMsg .= " From [ {$this->from} ]\r\n";
$confirmMsg .= " To [ {$this->to} ]\r\n";
$confirmMsg .= " Namespace [ {$this->namespace} ]\r\n";
$confirmMsg .= "\r\n";
$confirmMsg .= "(yes|no)";
// confirm copy
$confirm = $this->prompt($confirmMsg, ["required" => true, "default" => "no"]);
// process copy
if (strncasecmp($confirm, "y", 1) === 0) {
// handle aliases and copy files
$fromPath = Yii::getAlias($this->from);
$toPath = Yii::getAlias($this->to);
$this->copyFiles($fromPath, $toPath, $this->namespace);
} else {
echo "\r\n";
echo "--- Copy cancelled! --- \r\n";
echo "\r\n";
echo "You can specify the paths using:\r\n\r\n";
echo " php yii user/copy --from=@vendor/amnah/yii2-user";
echo " --to=@app/modules/user --namespace=app\\\\modules\\\\user";
echo "\r\n";
}
}
示例12: statement
protected function statement($key, $value)
{
if (strncasecmp($key, 'etag', 4) == 0) {
$value = '"' . $value . '"';
}
return sprintf('%s: %s', $key, (string) $value);
}
示例13: handle
public function handle(Event $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->getParameter('request_type')) {
return false;
}
$exception = $event->getParameter('exception');
$request = $event->getParameter('request');
if (null !== $this->logger) {
$this->logger->err(sprintf('%s: %s (uncaught exception)', get_class($exception), $exception->getMessage()));
} else {
error_log(sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine()));
}
$logger = null !== $this->logger ? $this->logger->getDebugLogger() : null;
$attributes = array('_controller' => $this->controller, 'exception' => FlattenException::create($exception), 'logger' => $logger, 'format' => 0 === strncasecmp(PHP_SAPI, 'cli', 3) ? 'txt' : $request->getRequestFormat());
$request = $request->duplicate(null, null, $attributes);
try {
$response = $event->getSubject()->handle($request, HttpKernelInterface::SUB_REQUEST, true);
} catch (\Exception $e) {
if (null !== $this->logger) {
$this->logger->err(sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()));
}
// re-throw the exception as this is a catch-all
throw new \RuntimeException('Exception thrown when handling an exception.', 0, $e);
}
$event->setReturnValue($response);
return true;
}
示例14: test_mimetypes
function test_mimetypes($mimetypes)
{
foreach ($mimetypes as $mimetype) {
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port) ?: 80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
die('Connect failed');
}
file_put_contents(__DIR__ . "/foo.{$mimetype}", '');
$header = <<<HEADER
GET /foo.{$mimetype} HTTP/1.1
Host: {$host}
HEADER;
if (fwrite($fp, $header)) {
while (!feof($fp)) {
$text = fgets($fp);
if (strncasecmp("Content-type:", $text, 13) == 0) {
echo "foo.{$mimetype} => ", $text;
}
}
@unlink(__DIR__ . "/foo.{$mimetype}");
fclose($fp);
}
}
}
示例15: _CreateColumn
protected function _CreateColumn($Name, $Type, $Null, $Default, $KeyType)
{
$Length = '';
$Precision = '';
// Check to see if the type starts with a 'u' for unsigned.
if (is_string($Type) && strncasecmp($Type, 'u', 1) == 0) {
$Type = substr($Type, 1);
$Unsigned = TRUE;
} else {
$Unsigned = FALSE;
}
// Check for a length in the type.
if (is_string($Type) && preg_match('/(\\w+)\\s*\\(\\s*(\\d+)\\s*(?:,\\s*(\\d+)\\s*)?\\)/', $Type, $Matches)) {
$Type = $Matches[1];
$Length = $Matches[2];
if (count($Matches) >= 4) {
$Precision = $Matches[3];
}
}
$Column = new stdClass();
$Column->Name = $Name;
$Column->Type = is_array($Type) ? 'enum' : $Type;
$Column->Length = $Length;
$Column->Precision = $Precision;
$Column->Enum = is_array($Type) ? $Type : FALSE;
$Column->AllowNull = $Null;
$Column->Default = $Default;
$Column->KeyType = $KeyType;
$Column->Unsigned = $Unsigned;
$Column->AutoIncrement = FALSE;
return $Column;
}