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


PHP strcmp函数代码示例

本文整理汇总了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');
}
开发者ID:CDFLS,项目名称:CWOJ,代码行数:60,代码来源:sourcecode.php

示例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');
         }
     }
 }
开发者ID:dariachechulina,项目名称:LinkStorage,代码行数:27,代码来源:Link_Controller.php

示例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;
 }
开发者ID:TheElk205,项目名称:qualityWeb,代码行数:29,代码来源:QualityApi.php

示例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;
}
开发者ID:JustKiddingCode,项目名称:apvel,代码行数:7,代码来源:lib.php

示例5: compare

function compare($respw, $pw)
{
	if(strcmp($respw, $pw)==0)
		return true;
	else
		return false;
}
开发者ID:rashmibachani,项目名称:Feed-Reader,代码行数:7,代码来源:funx.php

示例6: check_command

function check_command($check_str)
{
    if (strcmp($check_str, "actionTrainees")) {
        return SYMBOL_ERROR;
    }
    return $check_str;
}
开发者ID:ahmatjan,项目名称:iLearn_iSearch_API,代码行数:7,代码来源:Trainees_action.php

示例7: check_command

function check_command($check_str)
{
    if (strcmp($check_str, "read") && strcmp($check_str, "write")) {
        return SYMBOL_ERROR;
    }
    return $check_str;
}
开发者ID:ahmatjan,项目名称:iLearn_iSearch_API,代码行数:7,代码来源:Categories_modify.php

示例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;
 }
开发者ID:DeFi-ManriquezLuis,项目名称:MTLTransfer,代码行数:29,代码来源:login.class.php

示例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);
         }
     }
 }
开发者ID:radmiraal,项目名称:neos-development-collection,代码行数:40,代码来源:PasswordValidator.php

示例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;
 }
开发者ID:kk222hk,项目名称:1dv608-laborations,代码行数:10,代码来源:VenueList.php

示例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);
 }
开发者ID:megabr,项目名称:web3cms,代码行数:25,代码来源:_CHtml.php

示例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;
}
开发者ID:peterbehr,项目名称:peterbehr,代码行数:7,代码来源:functions.php

示例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;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:33,代码来源:navigation.php

示例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;
 }
开发者ID:nicolaisi,项目名称:adei,代码行数:25,代码来源:cachereader.php

示例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;
}
开发者ID:kidexx,项目名称:sitebar,代码行数:7,代码来源:tree.inc.php


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