摘要:Yii2 Working with Relational Data at ActiveDataProvidernamespace common\models;use Yii;use yii\base\Model;use yii\data\ActiveDataProvider;use common\m...
阅读全文
摘要:Friendly file size string 1 public static function bytesToSize($bytes) 2 { 3 if ($bytes 0) { 8 return sprintf("%02d:%02d:%02d", $...
阅读全文
摘要:多个Yii项目,共享cookie登录方式,修改main.php多个项目:每个项目均有不同的子域名。'components'=>array( 'user'=>array( // enable cookie-based authentication 'allowAutoLogin'=>true, 'stateKeyPrefix' => 'Enter your state key prefix here', ), 'session'=>array( 'cookiePa
阅读全文
摘要:一群猴子排成一圈,按1,2,...,n依次编号。然后从第1只开始数,数到第m只,把它踢出圈,从它后面再开始数,再数到第m只,在把它踢出去...,如此不停的进行下去,直到最后只剩下一只猴子为止,那只猴子就叫做大王。要求编程模拟此过程,输入m、n,输出最后那个大王的编号。$s = 0;$n = 9;$m = 3;for($i=1;$i<=$n;$i++) { $s = ($s+$m)%$i;}echo $s+1 . "<br />";It's amazing. but why?
阅读全文
摘要:1 <?php 2 /** 3 * @file IPHitsLimit.php 4 * @version 1.0 5 * @author guoxiaosong <> 6 * @date 2012-11-14 7 * @brief Limit ip frequency. 8 */ 9 class IPHitsLimit 10 { 11 const INDEX_DAY = 0; 12 const INDEX_HOUR = 1; 13 const INDEX_MINUTE = 2; 14 const INDE...
阅读全文
摘要:$this->createTable('{{test}}', array( 'id' => 'pk', ), 'ENGINE=InnoDB DEFAULT CHARSET=utf8');
阅读全文
摘要:Let's see the snippets first.jQuery$.ajax({ 'url': 'http://aptana-local/testobject/test1.php', 'dataType': 'json', "success": function(data){ alert(data); console.log(data); console.log(typeof data); }});PHP (test1.php)echo $this->_sendResponse($arr);
阅读全文
摘要:Just a snippet 1 class KPEnv 2 { 3 /** 4 * @param string $env 5 * @return boolean. 6 */ 7 public static function isValidEnv($env) 8 { 9 return in_array($env, array('dev', 'staging', 'live'));10 }11 12 /**13 * @param string $env14 * @return boo...
阅读全文