本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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();
示例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>
<?
}
示例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&' . SID . '">[Runde starten!]</a><br /><br /><form method="post" action="?' . SID . '" enctype="multipart/form-data">
Der Einsatz beträ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="ändern" /></form>Minimum: 1 / Maximum: 250';
} elseif ($_SESSION['card'] == 2) {
$content = showcards() . "<br /><b>Derzeitige Punkte: " . score() . '</b><br /><a href="?action=hit&' . SID . '">hit</a> / <a href="?action=stand&' . SID . '">stand</a><br />';
} else {
$content = showcards() . "<br /><b>Derzeitige Punkte: " . score() . '</b><br /><a href="?action=hit&' . SID . '">hit</a> / <a href="?action=stand&' . 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
示例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;
}
示例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);
}
示例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('<?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('<?php print');
# TEST 5 - Winner!
for ($i = 0; $i < 10000; $i++) {
echo $i;
}
score('<?= ?>');
示例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>
示例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;
}
示例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('[ .. ]');
示例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;
}
}
}
示例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