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


PHP score函数代码示例

本文整理汇总了PHP中score函数的典型用法代码示例。如果您正苦于以下问题:PHP score函数的具体用法?PHP score怎么用?PHP score使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了score函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: vote

function vote()
{
    if ($_SESSION['userid'] == '') {
        echo "0Please login to vote";
        exit;
    }
    $id = sanitize($_POST['id'], "int");
    $sql = "select userid from comments where id = '" . escape($id) . "'";
    $query = mysql_query($sql);
    $comment = mysql_fetch_array($query);
    if ($comment['userid'] == $_SESSION['userid']) {
        echo "0You cannot upvote your own comment";
        exit;
    }
    $sql = "select * from comments_votes where commentid = '" . escape($id) . "' and userid = '" . escape($_SESSION['userid']) . "'";
    $query = mysql_query($sql);
    $result = mysql_fetch_array($query);
    if ($result['id'] > 0) {
        $sql = "delete from comments_votes where commentid = '" . escape($id) . "' and userid = '" . escape($_SESSION['userid']) . "'";
        $query = mysql_query($sql);
        $sql_nest = "update comments set votes = votes-1 where id = '" . escape($id) . "'";
        $query_nest = mysql_query($sql_nest);
        score('c_upvoted_removed', $id, $comment['userid']);
    } else {
        $sql = "insert into comments_votes (commentid,userid) values ('" . escape($id) . "','" . escape($_SESSION['userid']) . "')";
        $query = mysql_query($sql);
        $sql_nest = "update comments set votes = votes+1 where id = '" . escape($id) . "'";
        $query_nest = mysql_query($sql_nest);
        score('c_upvoted', $id, $comment['userid']);
    }
    echo "1";
    exit;
}
开发者ID:bg6aer,项目名称:Qwench,代码行数:33,代码来源:comments.php

示例2: vote

function vote()
{
    if ($_SESSION['userid'] == '') {
        echo "0Please login to vote";
        exit;
    }
    $id = sanitize($_POST['id'], "int");
    $sql = "SELECT userid FROM comments WHERE id = '" . escape($id) . "'";
    $query = mysql_query($sql);
    $comment = mysql_fetch_array($query);
    if ($comment['userid'] == $_SESSION['userid']) {
        echo "0You cannot upvote your own comment";
        exit;
    }
    $sql = "SELECT * FROM comments_votes WHERE commentid = '" . escape($id) . "' AND userid = '" . escape($_SESSION['userid']) . "'";
    $query = mysql_query($sql);
    $result = mysql_fetch_array($query);
    if ($result['id'] > 0) {
        $sql = "DELETE FROM comments_votes WHERE commentid = '" . escape($id) . "' AND userid = '" . escape($_SESSION['userid']) . "'";
        $query = mysql_query($sql);
        $sql_nest = "UPDATE comments SET votes = votes-1 WHERE id = '" . escape($id) . "'";
        $query_nest = mysql_query($sql_nest);
        score('c_upvoted_removed', $id, $comment['userid']);
    } else {
        $sql = "INSERT INTO comments_votes (commentid,userid) VALUES ('" . escape($id) . "','" . escape($_SESSION['userid']) . "')";
        $query = mysql_query($sql);
        $sql_nest = "UPDATE comments SET votes = votes+1 WHERE id = '" . escape($id) . "'";
        $query_nest = mysql_query($sql_nest);
        score('c_upvoted', $id, $comment['userid']);
    }
    echo "1";
    exit;
}
开发者ID:nayanshah,项目名称:Qwench,代码行数:33,代码来源:comments.php

示例3: gradient

function gradient($data, $parameters)
{
    $learn_rate = 0.01;
    $hypothesis = hypothesis($parameters[0], $parameters[1]);
    $deriv = deriv($data, $hypothesis);
    $score = score($data, $hypothesis);
    $parameters[0] = $parameters[0] - $learn_rate * $deriv[0];
    $parameters[1] = $parameters[1] - $learn_rate * $deriv[1];
    // Create a new hypothesis to test our score
    $hypothesis = hypothesis($parameters[0], $parameters[1]);
    if ($score < score($data, $hypothesis)) {
        return false;
    }
    return $parameters;
}
开发者ID:esokullu,项目名称:PHPIR,代码行数:15,代码来源:linreg.php

示例4: posts

function posts($post_id = '')
{
    if (empty($post = get_post($post_id))) {
        return;
    }
    // Check the post ID passed to this function
    if (!is_int($post_id)) {
        $post_id = $post->ID;
    }
    // Allow other functions to filter the taxonomies options
    // Weighted taxonomy: array( 'post_tag' => 1 )
    // Unweighted taxonomy: array( 'post_tag' )
    $taxonomies = (array) apply_filters('ubik_related_taxonomies', option('taxonomies'));
    if (empty($taxonomies)) {
        return;
    }
    // Allow other functions to filter the maximum number of results returned
    $max_results = (int) apply_filters('ubik_related_max_results', option('max_results'));
    // Test the taxonomies argument and call the appropriate function
    if (count($taxonomies) > 1) {
        $related = posts_multi($post_id, $taxonomies);
    } else {
        // This part would be straight-forward except that we might receive an array with a single entry; furthermore, this array may or may not be weighted
        $taxonomy = $taxonomies;
        // Copy the original taxonomies argument; we'll need the original for the counts (below)
        if (is_numeric(current($taxonomy))) {
            // Presumably a weighted array
            $taxonomy = array_keys($taxonomy);
        }
        // All we want is the key
        $related = posts_single($post_id, $taxonomy[0]);
    }
    // Nothing found? Time to break out of this...
    if (empty($related) || !is_array($related)) {
        return;
    }
    // Score the results and filter; this allows other functions to hook in and modify counts in creative ways
    // Note 1: this approach automatically removes duplicate post IDs
    // Note 2: if you hook into this function be sure to return a sorted list of results
    $related = score($related, $taxonomies);
    // Trim the array and return the keys (the related post IDs)
    return array_slice($related, 0, $max_results, true);
}
开发者ID:synapticism,项目名称:ubik,代码行数:43,代码来源:related.php

示例5: error_reporting

 *
 * @author	Benoit Asselin <contact(at)ab-d.fr>
 * @version	benchmark.php, 2014-03-12
 * @link	http://www.ab-d.fr
 *
 */
error_reporting(E_ALL);
ini_set('display_error', true);
/**
 * Display result
 * @param string $label [optional]
 */
function score($label = '')
{
    static $microtime_start = null;
    static $test = 0;
    if (null === $microtime_start) {
        // First run
        $microtime_start = microtime(true);
        return;
    }
    $microtime_score = microtime(true) - $microtime_start;
    ++$test;
    echo '<p style="font-family:sans-serif;font-size:1em;">Test #' . $test . ($label ? ' <code style="font-size:1.1em;">' . $label . '</code> ' : '') . '<br />';
    echo '<span style="color:blue;">Time: ' . sprintf('%.8f', $microtime_score) . ' sec</span></p>';
    // Reset
    $microtime_start = microtime(true);
}
// First run
score();
开发者ID:milanchheda,项目名称:php-certification-training,代码行数:30,代码来源:benchmark.php

示例6: display_votes

	/**
	 * display a list of votes
	 *
	 * @param array   $proposals
	 * @param resource $result
	 * @param string  $token     (optional) token of the logged in member for highlighting
	 */
	public static function display_votes(array $proposals, $result, $token="") {
?>
<table class="votes">
<?
		// table head
		if (count($proposals) == 1) {
			$show_scores = false;
?>
<tr><th><?=_("Vote token")?></th><th><?=_("Voting time")?></th><th><?=_("Acceptance")?></th></tr>
<?
		} else {
			$show_scores = true;
?>
<tr><th rowspan="2"><?=_("Vote token")?></th><th rowspan="2"><?=_("Voting time")?></th><?
			foreach ($proposals as $proposal) {
				?><th colspan="2"><?=_("Proposal")?> <?=$proposal->id?></th><?
			}
			?></tr>
<tr><?
			/** @noinspection PhpUnusedLocalVariableInspection */
			foreach ($proposals as $proposal) {
				?><th><?=_("Acceptance")?></th><th><?=_("Score")?></th><?
			}
			?></tr>
<?
		}

		// votes
		$last_token = null;
		while ( $row = DB::fetch_assoc($result) ) {
?>
<tr class="<?=stripes();
			// highlight votes of the logged in member
			if ($token == $row['token']) { ?> self<? }
			// strike through votes, which have been overridden by a later vote
			if ($row['token'] == $last_token) { ?> overridden<? } else $last_token = $row['token'];
			?>"><td><?=$row['token']?></td><?

			if ($row['vote']) {
				?><td class="tdc"><?=date(VOTETIME_FORMAT, strtotime($row['votetime']))?></td><?
				$vote = unserialize($row['vote']);
				foreach ($proposals as $proposal) {
					?><td><?=acceptance($vote[$proposal->id]['acceptance'])?></td><?
					if ($show_scores) {
						?><td class="tdc"><?=score($vote[$proposal->id]['score'])?></td><?
					}
				}
			} else {
				// member did not vote
				?><td class="tdc"></td><?
				/** @noinspection PhpUnusedLocalVariableInspection */
				foreach ($proposals as $proposal) {
					?><td></td><?
					if ($show_scores) {
						?><td class="tdc"></td><?
					}
				}
			}

			?></tr>
<?
		}
?>
</table>
<?
	}
开发者ID:ppschweiz,项目名称:basisentscheid,代码行数:73,代码来源:Issue.php

示例7: die

        die("something is going wrong");
    }
}
if ($_POST['action'] == "bet" and $_POST['bet'] >= 1 and $_POST['bet'] <= 250 and $_SESSION['game'] != 'running') {
    $_SESSION['bet'] = $_POST['bet'];
}
if ($_SESSION['game'] != 'running') {
    $content = "<b>Deine Karten (" . score() . "):</b><br />" . showcards() . "<br /><b>Der Bank ihre Karten (" . bankscore() . "):</b><br />" . showbankcards() . '<br /><a href="?action=new&amp;' . SID . '">[Runde starten!]</a><br /><br /><form method="post" action="?' . SID . '" enctype="multipart/form-data">
	Der Einsatz betr&auml;gt: <input type="text" name="bet" value="' . $_SESSION['bet'] . '" size="4" />
  	<input type="hidden" name="action" value="bet" />
	<input type="hidden" name="ok" value="1" />
	<input type="submit" name="submit" value="&auml;ndern" /></form>Minimum: 1 / Maximum: 250';
} elseif ($_SESSION['card'] == 2) {
    $content = showcards() . "<br /><b>Derzeitige Punkte: " . score() . '</b><br /><a href="?action=hit&amp;' . SID . '">hit</a> / <a href="?action=stand&amp;' . SID . '">stand</a><br />';
} else {
    $content = showcards() . "<br /><b>Derzeitige Punkte: " . score() . '</b><br /><a href="?action=hit&amp;' . SID . '">hit</a> / <a href="?action=stand&amp;' . SID . '">stand</a>';
}
$content = str_replace("%content%", $content, template1());
$content = str_replace("%status%", $_SESSION['game'], $content);
$content = str_replace("%credits%", number_format($ressis['display_gold'], 0, '', '.'), $content);
$content = str_replace("%bet%", $_SESSION['bet'], $content);
mysql_query("UPDATE `ressis` SET `gold` = '" . $_SESSION['credit'] . "' WHERE `omni` = '" . $_SESSION['user']['omni'] . "' LIMIT 1;");
$ressis = ressistand($_SESSION['user']['omni']);
// get playerinfo template and replace tags
$status = template('playerinfo');
$status = tag2value('name', $_SESSION['user']['name'], $status);
$status = tag2value('base', $_SESSION['user']['base'], $status);
$status = tag2value('ubl', $_SESSION['user']['omni'], $status);
$status = tag2value('points', $_SESSION['user']['points'], $status);
echo tag2value('onload', $onload, template('head')) . $status . $ressis['html'] . $content . '</table>' . template('footer');
// debug
开发者ID:o-wars,项目名称:o-wars,代码行数:31,代码来源:cards.php

示例8: vote

function vote()
{
    if ($_SESSION['userid'] == '') {
        echo "0" . _("Please login to vote");
        exit;
    }
    $id = sanitize($_POST['id'], "int");
    $vote = sanitize($_POST['vote'], "string");
    if ($vote == 'plus') {
        $vote = '+1';
    } else {
        $vote = '-1';
    }
    $sql = "select questions.userid,questions_votes.id qvid,questions_votes.vote qvvote from questions left join questions_votes on (questions.id = questions_votes.questionid and questions_votes.userid =  '" . escape($_SESSION['userid']) . "') where questions.id = '" . escape($id) . "'";
    $query = mysql_query($sql);
    $question = mysql_fetch_array($query);
    if ($question['userid'] == $_SESSION['userid']) {
        echo "0" . _("You cannot up/down vote your own question");
        exit;
    }
    if ($question['qvid'] > 0) {
        if ($question['qvvote'] == 1 && $vote == '+1') {
            $vote = "-1";
            score('q_upvoted_removed', $id, $question['userid']);
        } else {
            if ($question['qvvote'] == 1 && $vote == '-1') {
                $vote = "-2";
                score('q_upvoted_removed', $id, $question['userid']);
                score('q_downvoter', $id);
                score('q_downvoted', $id, $question['userid']);
            } else {
                if ($question['qvvote'] == -1 && $vote == '-1') {
                    $vote = "+1";
                    score('q_downvoter_removed', $id);
                    score('q_downvoted_removed', $id, $question['userid']);
                } else {
                    if ($question['qvvote'] == -1 && $vote == '+1') {
                        $vote = "+2";
                        score('q_downvoter_removed', $id);
                        score('q_downvoted_removed', $id, $question['userid']);
                        score('q_upvoted', $id, $question['userid']);
                    } else {
                        if ($question['qvvote'] == 0) {
                            if ($vote == 1) {
                                score('q_upvoted', $id, $question['userid']);
                            } else {
                                score('q_downvoter', $id);
                                score('q_downvoted', $id, $question['userid']);
                            }
                        }
                    }
                }
            }
        }
        $sql = "update questions_votes set vote = vote" . escape($vote) . " where id = '" . $question['qvid'] . "'";
        $query = mysql_query($sql);
    } else {
        $sql = "insert into questions_votes (questionid,userid,vote) values ('" . escape($id) . "','" . escape($_SESSION['userid']) . "','" . escape($vote) . "')";
        $query = mysql_query($sql);
        if ($vote == 1) {
            score('q_upvoted', $id, $question['userid']);
        } else {
            score('q_downvoter', $id);
            score('q_downvoted', $id, $question['userid']);
        }
    }
    $sql_nest = "update questions set votes = votes" . escape($vote) . " where id = '" . escape($id) . "'";
    $query_nest = mysql_query($sql_nest);
    echo "1" . _("Thankyou for voting");
    exit;
}
开发者ID:jerome42,项目名称:Qwench,代码行数:71,代码来源:questions.php

示例9: base64_decode

        echo PHP_EOL;
    }
}
$enc = 'http://gist.github.com/tqbf/3132752/raw/cecdb818e3ee4f5dda6f0847bfd90a83edb87e73/gistfile1.txt';
$enc = base64_decode(file_get_contents($enc));
for ($keysize = 2; $keysize <= 40; $keysize++) {
    $blockA = substr($enc, 0, $keysize);
    $blockB = substr($enc, $keysize, $keysize);
    $blockC = substr($enc, $keysize * 2, $keysize);
    $blockD = substr($enc, $keysize * 3, $keysize);
    $lenA = strlen($blockA);
    $lenB = strlen($blockB);
    $lenC = strlen($blockC);
    $lenD = strlen($blockD);
    if ($lenA != $lenB || $lenB != $lenC || $lenC != $lenD) {
        die('Block sizes differ.');
    }
    printf("(Keysize = %d)\t%.2f\n", $keysize, hamdist($blockA, $blockB) / $keysize + hamdist($blockC, $blockD) / $keysize);
}
$keysize = 5;
$enc_blocks = str_split($enc, $keysize);
for ($i = 0; $i < $keysize; $i++) {
    foreach ($enc_blocks as $block) {
        $bytes[] = bin2hex(substr($block, $i, 1));
    }
    $string = implode('', $bytes);
    $unique = array_unique(array_filter($bytes));
    printf("\n\n-- Block %d --\n0x%s\n\n", $i + 1, $string);
    score($string, $unique, $keysize, ' eta', 'bin2hex');
    unset($bytes);
}
开发者ID:jjc224,项目名称:Matasano,代码行数:31,代码来源:6.php

示例10: score

<?php

include '../benchmark.php';
# TEST 1
for ($i = 0; $i < 10000; $i++) {
    echo $i;
}
score('echo');
# TEST 2
for ($i = 0; $i < 10000; $i++) {
    echo $i;
}
score('&lt;?php echo');
# TEST 3
for ($i = 0; $i < 10000; $i++) {
    print $i;
}
score('print');
# TEST 3
for ($i = 0; $i < 10000; $i++) {
    print $i;
}
score('&lt;?php print');
# TEST 5 - Winner!
for ($i = 0; $i < 10000; $i++) {
    echo $i;
}
score('&lt;?= ?&gt;');
开发者ID:milanchheda,项目名称:php-certification-training,代码行数:28,代码来源:echo_print.php

示例11: score

    <p>

        <?php 
/**
 * If you can't find a function you need in PHP, you can create it!
 * Let's modify our previous exercise to print the score for every name.
 */
// Create a function to clean the name and
// print out the person's name and their "score"
function score($name)
{
    $name = ucwords(strtolower(trim($name)));
    $explodedNames = explode(" ", $name);
    $score = stripos($name, "a") * strlen($explodedNames[count($explodedNames) - 1]) / str_word_count($name);
    echo "{$name} = {$score} </br>";
}
$names = ['JASON hunter', ' eRic Schwartz', 'mark zuckerburg '];
// Add a couple extra names to the $names array
array_push($names, "  Bob ArK");
array_push($names, "JAcoB foArD");
sort($names);
// loop through our names and call our function
foreach ($names as $name) {
    echo score($name);
}
?>

    </p>

    </body>
</html>
开发者ID:jacobfoard,项目名称:Curriculum,代码行数:31,代码来源:2_user_defined_functions.php

示例12: insert_tags

 /**
  * Inserta un tag
  * @param array $values valores a insertar
  * @return void 
  */
 function insert_tags($values)
 {
     $values = split(',', $values);
     $this->load->helper('inflector');
     foreach ($values as $value) {
         $value = trim($value);
         $tmp['name'] = $value;
         $tmp['slug'] = score($value);
         $this_tag = $this->_check_insert($tmp);
         if ($this_tag == FALSE) {
             $id = $this->_insertar($tmp);
             $tags[] = $this->term_taxonomy->insertar_tag($id);
         } else {
             $tags[] = $this_tag;
         }
     }
     return $tags;
 }
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:23,代码来源:terms.php

示例13: score

score('array()');
# TEST 2
for ($i = 0; $i < 10000; $i++) {
    $tmp_array = array();
    $tmp_array[] = '1';
    $tmp_array[] = '2';
    $tmp_array[] = '3';
    $tmp_array[] = 'a';
    $tmp_array[] = 'b';
    $tmp_array[] = 'c';
}
score('[]..');
# TEST 3
for ($i = 0; $i < 10000; $i++) {
    $tmp_array = array();
    $x = 0;
    $tmp_array[$x++] = '1';
    $tmp_array[$x++] = '2';
    $tmp_array[$x++] = '3';
    $tmp_array[$x++] = 'a';
    $tmp_array[$x++] = 'b';
    $tmp_array[$x++] = 'c';
}
score('[$x]..');
# TEST 4 - Winner!
for ($i = 0; $i < 10000; $i++) {
    // PHP 5.4+
    $tmp_array = ['1', '2', '3', 'a', 'b', 'c'];
}
score('[ .. ]');
开发者ID:milanchheda,项目名称:php-certification-training,代码行数:30,代码来源:array.php

示例14: _upload

 /**
  * Sube un archivo
  * @param boolean $ie6 es Internet Explorer 6
  * @return array 
  */
 function _upload($ie = NULL)
 {
     $tmp['allowed_types'] = 'doc|pdf';
     $tmp['encrypt_name'] = TRUE;
     $this->load->model('options');
     $tmp['upload_path'] = $this->options->get_('upload_path') . date('/Y/m/');
     $values['guid'] = $this->options->get_('upload_url_path') . date('/Y/m/');
     $this->load->library('upload', $tmp);
     if (!$this->upload->do_upload('Filedata')) {
         $error = array('error' => $this->upload->display_errors(), 'upload_data' => $this->upload->data());
         return NULL;
     } else {
         $doc = $this->upload->data();
         //debe insertar en un post, la imagen, ver wp_post id=18
         $this->load->model('post');
         $this->load->model('postmeta');
         $this->load->helper('inflector');
         $values['post_author'] = $this->input->post('id');
         $values['post_title'] = score(ereg_replace($doc['file_ext'], '', $doc['file_name']));
         $values['post_name'] = $values['post_title'];
         $values['post_mime_type'] = 'application/' . ereg_replace('\\.', '', $doc['file_ext']);
         $values['guid'] = $values['guid'] . $doc['file_name'];
         $the_doc = $this->post->insert_attach($values);
         $meta['_wp_attached_file'] = date('Y/m/') . $doc['file_name'];
         $meta['_wp_attachment_metadata'] = 'a:0{}';
         $this->postmeta->insertar($meta, $the_doc);
         if ($this->_is_ie6() == TRUE or $ie != NULL) {
             return $the_doc;
         } else {
             echo $the_doc;
         }
     }
 }
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:38,代码来源:audios.php

示例15: score

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require 'C:\\wamp\\www\\malaria_camp\\config\\connect.php';
require 'C:\\wamp\\www\\malaria_camp\\config\\constants.php';
if (isset($_GET['nav']) && isset($_GET['type']) && isset($_GET['question_id'])) {
    $next = 'Next';
    $prev = 'Prev';
    $nav = $_GET['nav'];
    (int) ($question_id = (int) $_GET['question_id']);
    $player_type = $_GET['type'];
    if ($nav === $next) {
        $aws = (int) $_GET['answer_id'];
        score($question_id, $aws);
        //score answer
        //then go to the next queston
        if (canDoNext($player_type, $question_id)) {
            $question_id = $question_id + 1;
            $ques = getoneQuestion($question_id, $player_type);
            $opts = getAnswerOpt($ques);
            echo json_encode(laodQueston($ques, $opts, $player_type));
        } else {
            echo json_encode(checkIfSabinusOrKoi((int) $_SESSION['result']));
        }
    } else {
        if ($nav === $prev) {
            $question_id = $question_id - 1;
            removeScore($question_id);
            //remove scored answer
开发者ID:uchechukwudim,项目名称:testandtreatmalaria,代码行数:31,代码来源:getQuestions.php


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