`
空洞的世界
  • 浏览: 49296 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
文章列表
很多不太懂正则的朋友,在遇到需要用正则校验数据时,往往是在网上去找很久,结果找来的还是不很符合要求。所以我最近把开发中常用的一些正则表达式整理了一下,包括校验数字、字符、一些特殊的需求等等。给自己留个 ...
$array = array( array('name'=>'手机','brand'=>'诺基亚','price'=>1050), array('name'=>'笔记本电脑','brand'=>'lenovo','price'=>4300), array('name'=>'剃须刀','brand'=>'飞利浦','price'=>3100), array('name'=>'跑步机','brand'=>'三和松石','price'=>4900), array ...
PHP中有一个非常厉害的函数,strtotime()函数,这个函数有一个异常厉害的使用方法,手册上说的有,但是估计在实际应用中能够想到的人不多: 请看下面的列子: 当前时间之后的时间是“+”,之前的时间当然用“-”就可以了! strtotime(”+1 week”) 当前时间一周之后 strtotime(”-1 week”) 当前时间一周之前 strtotime(”+1 months”) 一个月之后 strtotime(”+5 days”) 5天之后 strtotime(”+12 hours”) 12个小时之后 strto ...
<?php function resizeImage($im,$maxwidth,$maxheight,$name,$filetype) { $pic_width = imagesx($im); $pic_height = imagesy($im); if(($maxwidth && $pic_width > $maxwidth) || ($maxheight && $pic_height > $maxheight)) { if($maxwidth && $pic_width>$m ...
jQuery的on()方法可以绑定动态生成元素的事件,但是在实际使用时发现无效。如下HTML: <p> <a>123</a> </p> 使用如下方式,对静态元素有效,但是绑定动态生成的a元素的事件时无效: $('a').on('mouseenter', function(){ ............ }); 需要绑定a的父级元素(此元素必须为静态元素,不是后来动态生成的),然后设定on()方法的selector参数才行: $('p').on('mouseenter', 'a', fu ...
[align=left] $post_data = array(); //普通值 $post_data['t'] = time(); $post_data['t1'] =123; //传递json数组 $post_data_json['baseid'] = "1210"; $post_data_json['email'] = "18651kMdvsjWCOb@mfsa.ru"; $post_data_json['answer'] = "704xklV5"; $post_data_json['platfor ...
在jquery是遍历筛选数组有多种方法与函数了,包括有:grep、each、inArray、map同时也要以遍历json对象哦,下面给各位同学介绍一下具体的操作方法: grep grep()方法用于数组元素过滤筛选 grep(array,callback,invert) array:待过滤数组; callback:处理数组中的每个元素,并过滤元素,该函数中包含两个参数,第一个是当前数组元素的值,一个是当前数组元素的下标,即元素索引值。此函数应返回一个布尔值。另外,此函数可设置为一个字符串,当设置为字符串时,将视为“lambda-form”(缩写形式?),其中 a 代表数组元素,i 代表元素索引 ...
[size=x-small]废话不多说:直接代码,把下面的代码访问以下在本地 <?php $arr = array( array('id' => '3', 'name' => "上海", 'parid' => 4,'lev'=>4), array('id' => '4', 'name' => "上海1", 'parid' => 5,'lev'=>3), array('id' => '5', 'name' => "上海2", 'pari ...
1.在配置文件mail.php 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.163.com', ...
yii2的多语言个yii1几乎类似 1.设置默认语言:在mail.php配置文件加上:'language'=>'zh-CN' 2.多语言切换 html代码 <a href="<?php echo Yii::$app->urlManager->createUrl(['/ebay/user/language','lang'=>'zh-CN']);?>">中文</a> <a href="<?php echo Yii::$app->urlManager->createUrl(['/ ...
[size=x-large][size=large]1.在 console/controllers 文件夹下创建一个把握器 <?php namespace console\controllers; use yii\console\Controller; /** * Test controller */ class TestController extends Controller { public function actionIndex() { echo "runnning success"; ...
    User::find()->all(); 此方法返回所有数据; User::findOne($id); 此方法返回 主键 id=1 的一条数据(举个例子); User::find()->where(['name' => '小伙儿'])->one(); 此方法返回 ['name' => '小伙儿'] 的一条数据; User::find()->where(['name' => '小伙儿'])->all(); 此方法返回 ['name' => '小伙儿'] 的所有数据; User::findBySq ...
要求: 要在订单(Order)视图的gridview中显示出客户(Customer)姓名,并使其具有与其它字段相同的排序和搜索功能。 数据库结构 订单表order含有字段customer_id 与 客户表customer的id字段关联 首先确保在Order Model中包含以下代码: 一定要是get开头的,用的时候,把get去掉 public function getCustomer() { return $this->hasOne(Customer::className(), ['id' => 'customer_id']); } 第一步: 在OrderS ...
注:$c = new CDbCriteria();是ActiveRecord的一种写法,使ActiveRecord更加灵活,而不是手册中DAO(PDO)和Query Builder。 1. criteria常用的sql拼接方式 $criteria = new CDbCriteria; //函数方式 $criteria->addCondition("id=1"); //查询条件 ...
[size=large]1 .Select:  常用几种方法 // find the first row satisfying the specified condition $post=Post::model()->find($condition,$params); // find the row with the specified primary key $post=Post::model()->findByPk($postID,$condition,$params); // find the row with the specified attribute valu ...
Global site tag (gtag.js) - Google Analytics