本文整理汇总了PHP中strcmp函数的典型用法代码示例。如果您正苦于以下问题:PHP strcmp函数的具体用法?PHP strcmp怎么用?PHP strcmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strcmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sc_check_priv
function sc_check_priv($prob_id, $opened, $user)
{
if (!function_exists('check_priv')) {
require __DIR__ . '/privilege.php';
}
if (isset($_SESSION['user'])) {
if (strcmp($user, $_SESSION['user']) == 0 || check_priv(PRIV_SOURCE)) {
return TRUE;
}
}
require __DIR__ . '/../conf/database.php';
if (!defined('PROB_HAS_TEX')) {
require __DIR__ . '/../lib/problem_flags.php';
}
if ($opened) {
$row = mysqli_fetch_row(mysqli_query($con, "select has_tex from problem where problem_id={$prob_id}"));
if (!$row) {
return _('There\'s no such problem');
}
$prob_flag = $row[0];
if ($prob_flag & PROB_IS_HIDE && !check_priv(PRIV_INSIDER)) {
return _('Looks like you can\'t access this page');
}
if ($prob_flag & PROB_DISABLE_OPENSOURCE) {
return _('This solution is not open-source');
} else {
if ($prob_flag & PROB_SOLVED_OPENSOURCE) {
if (isset($_SESSION['user'])) {
$query = 'select min(result) from solution where user_id=\'' . $_SESSION['user'] . "' and problem_id={$prob_id} group by problem_id";
$user_status = mysqli_query($con, $query);
$row = mysqli_fetch_row($user_status);
if ($row && $row[0] == 0) {
return TRUE;
}
}
return _('You can\'t see me before solving it');
} else {
if (isset($_SESSION['user'])) {
$res = mysqli_query($con, "SELECT contest.contest_id,co.contest_id from contest\n RIGHT JOIN (select contest_id from contest_status where user_id='" . $_SESSION['user'] . "' and leave_time is NULL) as cs on (contest.contest_id=cs.contest_id)\n LEFT JOIN (select contest_id from contest_problem where problem_id={$prob_id}) as cp on (contest.contest_id=cp.contest_id)\n LEFT JOIN (select contest_id from contest_owner where user_id='" . $_SESSION['user'] . "') as co on (contest.contest_id=co.contest_id)\n where NOW()>start_time and NOW()<end_time and contest.hide_source_code");
$num = mysqli_num_rows($res);
if ($num > 0) {
$accessible = false;
while ($row = mysqli_fetch_row($res)) {
if (!is_null($row[1])) {
$accessible = true;
}
}
if ($accessible) {
return TRUE;
} else {
return _('You can\'t see me before the contest ends');
}
}
return TRUE;
}
}
}
}
return _('Looks like you can\'t access this page');
}
示例2: action_edit
function action_edit($lid)
{
$model = $this->model;
$model->get_link_by_id($lid);
if (!isset($_POST['edit'])) {
$this->view = new Main_View(array(CONTENT => 'Edit_Link', 'edit_data' => $model));
$this->view->render();
}
if (isset($_POST['edit'])) {
if (isset($_POST['check']) && strcmp($_POST['check'], 'on') == 0) {
$privacy_status = 'private';
} else {
$privacy_status = 'public';
}
$model->set_title($_POST['title']);
$model->set_link($_POST['link']);
$model->set_description($_POST['description']);
$model->set_privacy_status($privacy_status);
$is_saved = $model->save();
if (!$is_saved) {
$this->view = new Main_View(array(CONTENT => 'Edit_Link', 'edit_data' => $model));
$this->view->render();
} else {
header('Location: /Link/show_my');
}
}
}
示例3: getQualityWithId
/**
* @param $id The Quality ID to analyse
* @return \QualityInfo the object corresponding to the ID
*/
public function getQualityWithId($id)
{
$json = getCall($this->basePath . "/" . $id);
$quality = QualityInfo::create($json);
if (strcmp($quality->status, "FINISHED") == 0) {
$stepsize = 100;
for ($rep = 0; $rep < count($quality->results); $rep++) {
$psnr = QualityPSNR::create("{}");
$psnr->setID($quality->results[$rep]->id);
$psnr->setStatus($quality->status);
$psnr->initvalues();
for ($i = 0; $i < $quality->numberOfFrames; $i += $stepsize + 1) {
$json = getCall($this->basePath . "/" . $id . "/psnr/" . $quality->results[$rep]->id . "/" . $i . "/" . ($i + $stepsize));
$partPSNR = QualityPartResult::create($json);
//var_dump($partPSNR);
for ($ii = 0; $ii < count($partPSNR->values); $ii++) {
$psnr->addValue($partPSNR->values[$ii]);
}
}
$quality->addPSNRValues($psnr);
}
}
//var_dump($quality);
return $quality;
}
示例4: endsWith
function endsWith($haystack, $needle, $case = true)
{
if ($case) {
return strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
}
return strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
}
示例5: compare
function compare($respw, $pw)
{
if(strcmp($respw, $pw)==0)
return true;
else
return false;
}
示例6: check_command
function check_command($check_str)
{
if (strcmp($check_str, "actionTrainees")) {
return SYMBOL_ERROR;
}
return $check_str;
}
示例7: check_command
function check_command($check_str)
{
if (strcmp($check_str, "read") && strcmp($check_str, "write")) {
return SYMBOL_ERROR;
}
return $check_str;
}
示例8: handleLanguageChange
/**
* Set the cultureKey for the login page and get the list of languages
* @return string The loaded cultureKey
*/
public function handleLanguageChange()
{
$cultureKey = $this->modx->getOption('cultureKey', $_REQUEST, 'en');
if ($cultureKey) {
$cultureKey = $this->modx->sanitizeString($cultureKey);
$this->modx->setOption('cultureKey', $cultureKey);
$this->modx->setOption('manager_language', $cultureKey);
}
$this->setPlaceholder('cultureKey', $cultureKey);
$languages = $this->modx->lexicon->getLanguageList('core');
$list = array();
foreach ($languages as $language) {
$selected = $language == $cultureKey ? ' selected="selected"' : '';
$list[] = '<option value="' . $language . '"' . $selected . '>' . $language . '</option>';
}
$this->setPlaceholder('languages', implode("\n", $list));
$this->modx->lexicon->load('login');
$languageString = $this->modx->lexicon('login_language');
if (empty($languageString) || strcmp($languageString, 'login_language') == 0) {
$this->modx->lexicon->load('en:core:login');
$languageString = $this->modx->lexicon('login_language', array(), 'en');
}
$this->setPlaceholder('language_str', $languageString);
return $cultureKey;
}
示例9: isValid
/**
* Returns TRUE, if the given property ($value) is a valid array consistent of two equal passwords and their length
* is between 'minimum' (defaults to 0 if not specified) and 'maximum' (defaults to infinite if not specified)
* to be specified in the validation options.
*
* If at least one error occurred, the result is FALSE.
*
* @param mixed $value The value that should be validated
* @return void
* @throws \TYPO3\Flow\Validation\Exception\InvalidSubjectException
*/
protected function isValid($value)
{
if (!is_array($value)) {
throw new \TYPO3\Flow\Validation\Exception\InvalidSubjectException('The given value was not an array.', 1324641197);
}
$password = trim(strval(array_shift($value)));
$repeatPassword = trim(strval(array_shift($value)));
$passwordNotEmptyValidator = new \TYPO3\Flow\Validation\Validator\NotEmptyValidator();
$passwordNotEmptyValidatorResult = $passwordNotEmptyValidator->validate($password);
$repeatPasswordNotEmptyValidator = new \TYPO3\Flow\Validation\Validator\NotEmptyValidator();
$repeatPasswordNotEmptyValidatorResult = $repeatPasswordNotEmptyValidator->validate($repeatPassword);
if ($passwordNotEmptyValidatorResult->hasErrors() === TRUE && $repeatPasswordNotEmptyValidatorResult->hasErrors() === TRUE) {
if (!isset($this->options['allowEmpty']) || isset($this->options['allowEmpty']) && intval($this->options['allowEmpty']) === 0) {
$this->addError('The given password was empty.', 1324641097);
}
return;
}
if (strcmp($password, $repeatPassword) !== 0) {
$this->addError('The passwords did not match.', 1324640997);
return;
}
$stringLengthValidator = new \TYPO3\Flow\Validation\Validator\StringLengthValidator(array('minimum' => $this->options['minimum'], 'maximum' => $this->options['maximum']));
$stringLengthValidatorResult = $stringLengthValidator->validate($password);
if ($stringLengthValidatorResult->hasErrors() === TRUE) {
foreach ($stringLengthValidatorResult->getErrors() as $error) {
$this->result->addError($error);
}
}
}
示例10: getVenuesSortedByLocation
/**
* @return array of \app\model\Venue sorted alphabetically by location
*/
public function getVenuesSortedByLocation()
{
usort($this->venues, function ($venueA, $venueB) {
return strcmp($venueA->getLocation(), $venueB->getLocation());
});
return $this->venues;
}
示例11: radioButtonList
public static function radioButtonList($name, $select, $data, $htmlOptions = array())
{
$template = isset($htmlOptions['template']) ? $htmlOptions['template'] : '{input} {label}';
$separator = isset($htmlOptions['separator']) ? $htmlOptions['separator'] : "<br/>\n";
unset($htmlOptions['template'], $htmlOptions['separator']);
$labelOptions = isset($htmlOptions['labelOptions']) ? $htmlOptions['labelOptions'] : array();
unset($htmlOptions['labelOptions']);
$items = array();
$baseID = self::getIdByName($name);
$id = 0;
$hasJqueryUIScreenshot = strpos($template, '{jqueryUIScreenshot}') !== false;
//+
foreach ($data as $value => $label) {
$jqueryUIScreenshot = $hasJqueryUIScreenshot ? self::image(Yii::app()->request->baseUrl . '/static/css/ui/' . $value . '/screenshot.png', $label, array('height' => 105, 'title' => $label)) : '';
//+
$checked = !strcmp($value, $select);
$htmlOptions['value'] = $value;
$htmlOptions['id'] = $baseID . '_' . $id++;
$option = self::radioButton($name, $checked, $htmlOptions);
$label = self::label($label, $htmlOptions['id'], $labelOptions);
$items[] = strtr($template, array('{input}' => $option, '{label}' => $label, '{jqueryUIScreenshot}' => $jqueryUIScreenshot));
//!
}
return implode($separator, $items);
}
示例12: cmp_date
function cmp_date($a, $b)
{
if ($a['date'] == $b['date']) {
return strcmp($a['post']->post_title, $b['post']->post_title);
}
return $a['date'] > $b['date'] ? -1 : 1;
}
示例13: getNavigation
/**
* @return array
*/
public function getNavigation()
{
//$this->setActiveElements();
$return = [];
foreach ($this->pages as $block => $blockPages) {
if (is_array($blockPages) && count($blockPages) > 0 && $blockPages[0] instanceof rex_be_page_main) {
uasort($blockPages, function (rex_be_page_main $a, rex_be_page_main $b) {
$a_prio = (int) $a->getPrio();
$b_prio = (int) $b->getPrio();
if ($a_prio == $b_prio || $a_prio <= 0 && $b_prio <= 0) {
return strcmp($a->getTitle(), $b->getTitle());
}
if ($a_prio <= 0) {
return 1;
}
if ($b_prio <= 0) {
return -1;
}
return $a_prio > $b_prio ? 1 : -1;
});
}
$n = $this->_getNavigation($blockPages);
if (count($n) > 0) {
$fragment = new rex_fragment();
$fragment->setVar('navigation', $n, false);
$return[] = ['navigation' => $n, 'headline' => ['title' => $this->getHeadline($block)]];
}
}
return $return;
}
示例14: GetGroupInfo
function GetGroupInfo(LOGGROUP $grp = NULL, $flags = 0)
{
$groups = array();
$res = $this->cache->ListCachedGroups();
foreach ($res as $gid) {
if ($grp && strcmp($grp->gid, $gid)) {
continue;
}
$groups[$gid] = array('gid' => $gid, 'name' => $gid);
if ($flags & REQUEST::NEED_INFO) {
$postfix = $this->cache->GetCachePostfix($gid);
$info = $this->cache->GetCacheInfo($postfix, $flags & REQUEST::FLAG_MASK);
if (!$info) {
throw new ADEIException(translate("The CACHE for group (%s) is empty", $grp->gid));
}
foreach ($info as $key => &$value) {
$groups[$gid][$key] = $value;
}
if ($flags & REQUEST::NEED_ITEMINFO) {
$groups[$gid]['items'] = $this->cache->GetCacheItemList($postfix);
}
}
}
return $grp ? $groups[$grp->gid] : $groups;
}
示例15: SB_trOrderCmp
function SB_trOrderCmp(&$a, &$b)
{
if ($a->order == $b->order) {
return strcmp($a->name, $b->name);
}
return $a->order > $b->order ? 1 : -1;
}