本文整理汇总了PHP中counter函数的典型用法代码示例。如果您正苦于以下问题:PHP counter函数的具体用法?PHP counter怎么用?PHP counter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了counter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_online_objects
function get_online_objects()
{
$device_browser_list = mmc_array_values(NS_DEVICE_LIST);
time_print('性能分析:取列表:');
if (isset($_GET['debug'])) {
$device_count = mmc_array_length(NS_DEVICE_LIST);
$memcache_obj = new Memcache();
$memcache_obj->connect(MEMC_HOST, MEMC_PORT);
$stats = $memcache_obj->getStats();
$memcache_obj->close();
$dbg_print = '开始时间:' . getDateStyle($stats['time'] - $stats['uptime']);
$dbg_print .= ' 使用内存: ' . bytesToSize($stats['bytes']) . '/' . bytesToSize($stats['limit_maxbytes']);
$dbg_print .= '<br>清理时间:' . getDateStyle(async_timer('/on_timer_online_list.php'));
$dbg_print .= ' 维护设备数: ' . $device_count . ' 活跃设备数: ' . count($device_browser_list);
$xmlStr = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . '/channels-stats');
$channels = json_decode($xmlStr);
$dbg_print .= '<br>推送开始:' . getDateStyle(time() - $channels->uptime) . ' 频道数: ' . $channels->channels;
$dbg_print .= ' 订阅数: ' . $channels->subscribers . ' 消息数: ' . $channels->published_messages;
$dbg_print .= '<br>流程计数: ' . counter() . '<br>';
echo $dbg_print;
}
/******************************************************
预处理:账户绑定列表
******************************************************/
$aDataSet = [];
foreach ($device_browser_list as $browser) {
if (empty($browser)) {
continue;
}
$account = @$browser['bind_account'];
$device = $browser['device'];
$useragent = $browser['UserAgent'];
$ref_obj = $browser['Visiting'] ? parse_url($browser['Visiting']) : null;
$visiting = @$ref_obj['host'];
$is_mobile = $browser['ismobiledevice'] ? 'mobi' : 'desk';
$aDataSet[] = [$account, $browser['region'], $visiting, $browser['browser'], $browser['platform'], $is_mobile, $browser['device_name'], $browser['device']];
}
time_print('整合:');
if (isset($_GET['debug'])) {
echo time_print();
}
return $aDataSet;
}
示例2: counter
<?php
require_once 'config.php';
require_once 'functions.php';
counter(COUNT_IN_BINDING);
/*
$DATA['device']
$DATA['platform']
$DATA['caption']
$DATA['username']
$DATA['nickname']
*/
$DATA = array_merge($_GET, $_POST);
示例3: counter
<?php
require_once 'functions.php';
counter(COUNT_IN_HEARTBEAT);
$DATA = array_merge($_GET, $_POST);
$url = @$DATA['Visiting'];
if (!preg_match('#^http://([a-zA-Z0-9\\-]+\\.)*appgame\\.com/([\\S]+/)?[\\d]+\\.html$#i', $url)) {
exit;
}
CachedHandler::queue('new-access-reporter', $url, function ($items) {
$res = report_remote('http://db.appgame.com/service/spec/appgame.php', ['cmd' => 'event', 'event' => 'new_articles', 'urls' => $items]);
}, 60);
function logfile($obj)
{
file_put_contents('debug.log', gmdate(time()) . ': ' . print_r($obj, true) . "\n", FILE_APPEND);
}
function report_remote($recv_url, $data)
{
$curl_opt = array(CURLOPT_URL => $recv_url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_CONNECTTIMEOUT => 7, CURLOPT_TIMEOUT => 10, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => http_build_query($data));
$ch = curl_init();
curl_setopt_array($ch, $curl_opt);
$res = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err = curl_errno($ch);
curl_close($ch);
return $err || $httpcode !== 200 ? null : $res;
}
示例4: counter
function counter($count_type = 0, $recursive = false)
{
$mem = api_open_mmc();
switch ($count_type) {
case COUNT_ON_HEARTBEAT:
$result = $mem->ns_increment(COUNT_NS, 'COUNT_ON_HEARTBEAT');
break;
case COUNT_IN_HEARTBEAT:
$result = $mem->ns_increment(COUNT_NS, 'COUNT_IN_HEARTBEAT');
break;
case COUNT_ON_ACTIVE:
$result = $mem->ns_increment(COUNT_NS, 'COUNT_ON_ACTIVE');
break;
case COUNT_IN_ACTIVE:
$result = $mem->ns_increment(COUNT_NS, 'COUNT_IN_ACTIVE');
break;
case COUNT_BINDING:
$result = $mem->ns_increment(COUNT_NS, 'COUNT_BINDING');
break;
case COUNT_ON_BINDING:
$result = $mem->ns_increment(COUNT_NS, 'COUNT_ON_BINDING');
break;
case COUNT_IN_BINDING:
$result = $mem->ns_increment(COUNT_NS, 'COUNT_IN_BINDING');
break;
default:
$on_heartbeat = $mem->ns_get(COUNT_NS, 'COUNT_ON_HEARTBEAT');
$in_heartbeat = $mem->ns_get(COUNT_NS, 'COUNT_IN_HEARTBEAT');
$on_active = $mem->ns_get(COUNT_NS, 'COUNT_ON_ACTIVE');
$in_active = $mem->ns_get(COUNT_NS, 'COUNT_IN_ACTIVE');
$binding = $mem->ns_get(COUNT_NS, 'COUNT_BINDING');
$on_binding = $mem->ns_get(COUNT_NS, 'COUNT_ON_BINDING');
$in_binding = $mem->ns_get(COUNT_NS, 'COUNT_IN_BINDING');
$result = "心跳({$on_heartbeat}>{$in_heartbeat}) 活跃({$on_active}>{$in_active}) 绑定({$binding}>{$on_binding}>{$in_binding})";
}
if (!$result && !$recursive) {
$mem->ns_set(COUNT_NS, 'COUNT_ON_HEARTBEAT', 0);
$mem->ns_set(COUNT_NS, 'COUNT_IN_HEARTBEAT', 0);
$mem->ns_set(COUNT_NS, 'COUNT_ON_ACTIVE', 0);
$mem->ns_set(COUNT_NS, 'COUNT_IN_ACTIVE', 0);
$mem->ns_set(COUNT_NS, 'COUNT_BINDING', 0);
$mem->ns_set(COUNT_NS, 'COUNT_ON_BINDING', 0);
$mem->ns_set(COUNT_NS, 'COUNT_IN_BINDING', 0);
return counter($count_type, true);
}
return $result;
}
示例5: shareLink
public function shareLink($id, $data)
{
$segment = $data;
$cats = Category::orderBy('order_type')->get();
$post_details = Post::where('link', $segment)->where('is_approved', 1)->first();
$related = Post::orderByRaw("RAND()")->where('is_approved', 1)->take(2)->get();
if ($post_details) {
counter($segment);
return View::make('single-post')->withRelated($related)->withPost($post_details)->with('cats', $cats);
} else {
return Redirect::route('home');
}
}
示例6: counter
<?php
require 'func.php';
counter();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>What can I do for Wikimedia Commons?</title>
<meta name="keywords" content="Commons,Wikimedia,Community,Uploading,Programming,Editing,Content,Files,Wiki">
<meta name="robots" content="index,follow">
<meta name="description" content="What can I do for Wikimedia Commons?">
<link href="css/bootstrap.min.css" rel="stylesheet">
<style>
body {
padding-top: 60px;
}
footer {
bottom:0;
width:100%;
}
</style>
</head>
<body>
<div class="container">
<div class="jumbotron" style = "text-align:center;">
示例7: viewPost
public function viewPost($id, $data)
{
$segment = $data;
$cats = Category::orderBy('order_type')->get();
$post_details = Post::where('link', $segment)->where('is_approved', 1)->first();
$related = Post::orderByRaw("RAND()")->where('is_approved', 1)->take(2)->get();
if ($post_details) {
if ($publisher = Publisher::find($post_details->publisher_id)) {
$publisher_name = $publisher->name;
$publisher_image = $publisher->image;
} else {
$publisher_name = "";
$publisher_image = "";
}
counter($segment);
return View::make('single-post')->withRelated($related)->with('publisher_image', $publisher_image)->withPost($post_details)->with('cats', $cats);
} else {
return Redirect::back()->with('flash_error', "something went wrong");
}
}
示例8: explode
<?php
$lang = explode('/', explode('?', ltrim($_SERVER['REQUEST_URI'], '/'))[0])[0] ?: 'ru';
if (!preg_match('/^[a-z0-9_]+$/i', $lang) || !file_exists('lang/' . $lang . '.json')) {
header('Location: /');
exit;
}
//--- поехали
include 'counter.php';
$count = counter($lang);
$memcache = new Memcached();
$memcache->addServer('localhost', ini_get('memcache.default_port'));
$memcache->set('count_na_' . $lang, $count, 600);
// записать в memcache
$count = '<span id=counter>' . $count . '</span>';
foreach (json_decode(file_get_contents(__DIR__ . '/lang/' . $lang . '.json'), true) as $var => $val) {
$val = str_replace(['%COUNT%', '%EDITOR_LINK%'], [$count, '/editor/' . $lang . '/'], $val);
$GLOBALS[$var] = $val;
}
header('Content-Type: text/html; charset=utf-8');
?>
<html>
<head>
<title><?php
echo $headpage;
?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body bgcolor=white text=black background=/fon1.jpg>
<?php
示例9: explode
<?php
$lang = explode('/', explode('?', ltrim($_SERVER['REQUEST_URI'], '/'))[0])[1] ?: 'ru';
if (!preg_match('/^[a-z0-9_]+$/i', $lang) || !file_exists('lang/' . $lang . '.json')) {
header('Location: /');
exit;
}
include 'counter.php';
$count = counter('.count.editor');
foreach (json_decode(file_get_contents(__DIR__ . '/lang/' . $lang . '.json'), true) as $var => $val) {
$val = str_replace(['%COUNT%'], [$count], $val);
$GLOBALS[$var] = $val;
}
//--- поехали
print '<div id="custom_link_block" style="display: none;">';
print '<p>ссылка готова: <a href=# id="custom_link_example">нажми</a>';
echo '<SCRIPT language=JavaScript>
function highlight(x){
document.forms[x].elements[0].focus()
document.forms[x].elements[0].select()
}
</SCRIPT>';
echo '<form><center><textarea cols=120 rows=2 style="border: 1px solid #330000; font-size: 14px;" id="custom_link_text"></textarea>';
echo '<font size=-1><br>херассе какая длинная! <a href="javascript:highlight(0)">выделить всю</a><p>хочется видеть эту ссылку короткой и загадочной? <a href=# id="custom_link_tiny">жми сюда</a></font></center></form>';
print "</div>";
?>
<html>
<head>
<title><?php
echo $e_head;
?>
示例10: foreach
}
if (!empty($_POST)) {
$printMethod = $methods[1];
$method = $_POST;
foreach ($method as $item) {
$results .= '<tr><td>' . $item . '</td></tr>';
}
$result = 'Number of submit is: ' . counter();
} else {
if (!empty($_GET)) {
$printMethod = $methods[0];
$method = $_GET;
foreach ($method as $item) {
$results .= '<tr><td>' . $item . '</td></tr>';
}
$result = 'Number of submit is: ' . counter();
} else {
$result = '';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../reset.css">
<link rel="stylesheet" type="text/css" href="../stylesheet.css">
<title>Task 9</title>
</head>
<body>
示例11: counter
<?php
include_once "library/connector.php";
function counter($query, $dbh)
{
$ps = $dbh->prepare($query);
$ps->execute();
$rs = $ps->fetch();
return $rs['jumlah'];
}
$jumlah_hadir = counter("SELECT COUNT(id_rsvp) as `jumlah` FROM rsvp WHERE id_user = " . $_SESSION['user']['id_user'], $dbh);
$jumlah_tidak_hadir = counter("SELECT COUNT(id_rsvp) as `jumlah` FROM rsvp WHERE kehadiran='tidak' AND id_user = " . $_SESSION['user']['id_user'], $dbh);
$jumlah_komentar = counter("SELECT COUNT(id_komentar) as `jumlah` FROM komentar WHERE id_user = " . $_SESSION['user']['id_user'], $dbh);
?>
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">
Dashboard
</h1>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-3 col-md-6">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-book fa-5x"></i>
示例12: counter
echo "</h5>\n </div>\n\n </a>\n <a href='masinos.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-cogs img-responsive' style='font-size: 70px;'></i>\n <h5>Auto remontas ";
counter('masinos');
echo "</h5>\n </div>\n </a>\n </div>\n <div class='row'>\n <a href='grozis.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-scissors img-responsive' style='font-size: 70px;'></i>\n <h5>Grožio Paslaugos ";
counter('grozis');
echo "</h5>\n </div>\n </a>\n <a href='draudimas.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-users img-responsive' style='font-size: 70px;'></i>\n <h5>Draudimo Paslaugos ";
counter('draudimas');
echo "</h5>\n </div>\n </a>\n <a href='valymai.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-recycle img-responsive' style='font-size: 70px;'></i>\n <h5>Valymų Paslaugos ";
counter('valymai');
echo "</h5>\n </div>\n </a>\n <a href='rankdarbiai.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-image img-responsive' style='font-size: 70px;'></i>\n <h5>Rankdarbiai ";
counter('rankdarbiai');
echo "</h5>\n </div>\n </a>\n </div>\n <div class='row'>\n <a href='gyvunai.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-paw img-responsive' style='font-size: 70px;'></i>\n <h5>Gyvūnų Priežiūra ";
counter('gyvunai');
echo "</h5>\n </div>\n </a>\n <a href='it.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-mobile img-responsive' style='font-size: 70px;'></i>\n <h5>it paslaugos ";
counter('it');
echo "</h5>\n </div>\n </a>\n <a href='sveikata.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-plus-square img-responsive' style='font-size: 70px;'></i>\n <h5>sveikatos paslaugos ";
counter('sveikata');
echo "</h5>\n </div>\n </a>\n <a href='buhalterija.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-paperclip img-responsive' style='font-size: 70px;'></i>\n <h5>buhalterinės paslaugos ";
counter('buhalterija');
echo "</h5>\n </div>\n </a>\n </div>\n <div class='row'>\n <a href='fotografija.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-camera img-responsive' style='font-size: 70px;'></i>\n <h5>fotografija ir video ";
counter('fotografija');
echo "</h5>\n </div>\n </a>\n <a href='kalbos.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-language img-responsive' style='font-size: 70px;'></i>\n <h5>kalbų kursai ";
counter('kalbos');
echo "</h5>\n </div>\n </a>\n <a href='teise.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-bank img-responsive' style='font-size: 70px;'></i>\n <h5>teisinės paslaugos ";
counter('teise');
echo "</h5>\n </div>\n </a>\n <a href='telekomunikacijos.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-fax img-responsive' style='font-size: 70px;'></i>\n <h5>telekomunikacijos ";
counter('telekomunikacijos');
echo "</h5>\n </div>\n </a>\n </div>\n <div class='row'>\n <a href='nuoma.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-car img-responsive' style='font-size: 70px;'></i>\n <h5>auto nuoma ";
counter('nuoma');
echo "</h5>\n </div>\n </a>\n <a href='kita.php'>\n <div class='col-md-3 col-sm-6 small-section'>\n <i class='fa fa-credit-card-alt img-responsive' style='font-size: 70px;'></i>\n <h5>kitos paslaugos ";
counter('kita');
echo "</h5>\n </div>\n </a>\n </div>\n </div>\n <div class='col-md-2' style='padding-top: 20px;'>\n <script async src='//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'></script>\n <!-- ad3 -->\n <ins class='adsbygoogle'\n style='display:block'\n data-ad-client='ca-pub-2172217990624096'\n data-ad-slot='7953752161'\n data-ad-format='auto'></ins>\n <script>\n (adsbygoogle = window.adsbygoogle || []).push({});\n </script>\n </div>\n</div>\n";
示例13: foreach
foreach ($wordArray as $item) {
if (strtolower($item) == "true" || strtolower($item) == "false") {
$countArray['num_bool']++;
}
}
//count # of strings - count wordArray length then subtract # of ints and bools
$countArray['num_string'] = count($wordArray) - $countArray['num_numeric'] - $countArray['num_bool'];
/*
//iterate through the array and identify what each item in the array is
foreach($wordArray as $item) {
if(is_int($item)) {
$countArray['num_numeric']++;
//search for bool first instead of string so that "true" and "false" aren't counted as strings
} else if(is_bool($item)) {
$countArray['num_bool']++;
} else if(is_string($item)) {
$countArray['num_string']++;
}
}
*/
echo "<h3># of numbers</h3>";
echo $countArray['num_numeric'] . "<br />";
echo "<h3># of strings</h3>";
echo $countArray['num_string'] . "<br />";
echo "<h3># of booleans</h3>";
echo $countArray['num_bool'];
}
counter($inputString);
?>
示例14: specs_zan
function specs_zan()
{
global $wpdb, $post;
$id = $_POST["um_id"];
$action = $_POST["um_action"];
if ($action == 'like') {
$specs_raters = get_post_meta($id, 'c_like', true);
// 设置cookie防止重复操作
$expire = time() + 99999999;
$domain = $_SERVER['HTTP_HOST'] != 'localhost' ? $_SERVER['HTTP_HOST'] : false;
setcookie('c_like' . $id, $id, $expire, '/', $domain, false);
if (!$specs_raters || !is_numeric($specs_raters)) {
update_post_meta($id, 'c_like', 1);
} else {
update_post_meta($id, 'c_like', $specs_raters + 1);
}
echo get_post_meta($id, 'c_like', true);
}
if ($action == 'dislike') {
$specs_raters = get_post_meta($id, 'c_dislike', true);
$expire = time() + 99999999;
$domain = $_SERVER['HTTP_HOST'] != 'localhost' ? $_SERVER['HTTP_HOST'] : false;
setcookie('c_dislike' . $id, $id, $expire, '/', $domain, false);
if (!$specs_raters || !is_numeric($specs_raters)) {
update_post_meta($id, 'c_dislike', 1);
} else {
update_post_meta($id, 'c_dislike', $specs_raters + 1);
}
echo get_post_meta($id, 'c_dislike', true);
}
if ($action == 'comment_like') {
echo counter($id, COMMENT_META_LIKE);
}
if ($action == 'comment_dislike') {
echo counter($id, COMMENT_META_DISLIKE);
}
die;
}
示例15: counter
function counter($query, $dbh)
{
$ps = $dbh->prepare($query);
$ps->execute();
$rs = $ps->fetch();
return $rs['jumlah'];
}
$jumlah_isian = counter("SELECT COUNT(id_rsvp) as `jumlah` FROM rsvp WHERE id_user = " . $_SESSION['user']['id_user'], $dbh);
$jumlah_hadir = counter("SELECT COUNT(id_rsvp) as `jumlah` FROM rsvp WHERE kehadiran='ya' AND id_user = " . $_SESSION['user']['id_user'], $dbh);
$jumlah_tidak_hadir = counter("SELECT COUNT(id_rsvp) as `jumlah` FROM rsvp WHERE kehadiran='tidak' AND id_user = " . $_SESSION['user']['id_user'], $dbh);
$hadir_acara_1 = counter("SELECT COUNT(id_rsvp) as `jumlah` FROM rsvp WHERE id_acara=1 AND id_user = " . $_SESSION['user']['id_user'], $dbh);
$hadir_acara_2 = counter("SELECT COUNT(id_rsvp) as `jumlah` FROM rsvp WHERE id_acara=2 AND id_user = " . $_SESSION['user']['id_user'], $dbh);
$hadir_acara_3 = counter("SELECT COUNT(id_rsvp) as `jumlah` FROM rsvp WHERE id_acara=3 AND id_user = " . $_SESSION['user']['id_user'], $dbh);
$rombongan_acara_1 = counter("SELECT SUM(jml_rombongan) as `jumlah` FROM rsvp WHERE id_acara=1 AND id_user = " . $_SESSION['user']['id_user'], $dbh);
$rombongan_acara_2 = counter("SELECT SUM(jml_rombongan) as `jumlah` FROM rsvp WHERE id_acara=2 AND id_user = " . $_SESSION['user']['id_user'], $dbh);
$rombongan_acara_3 = counter("SELECT SUM(jml_rombongan) as `jumlah` FROM rsvp WHERE id_acara=3 AND id_user = " . $_SESSION['user']['id_user'], $dbh);
$query = "SELECT * FROM rsvp r, acara a WHERE r.id_acara = a.id_acara AND r.id_user = " . $_SESSION['user']['id_user'] . " ORDER BY r.id_acara DESC";
$ps = $dbh->prepare($query);
$ps->execute();
$rs = $ps->fetchAll();
?>
<div class="row">
<div class="col-md-12">
<h1 class="page-header"> RSVP</h1>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel panel-info">
<div class="panel-heading" align="center">
<h2>Ringkasan Infomasi RSVP</h2>