我有一个函数,我想传递一个参数,但我希望它默认为0.
是否有可能与PHP类似,例如:
function byMonth(export=0) {
Run Code Online (Sandbox Code Playgroud)
非常感谢
class Form_Accounts_Add extends Zend_Form {
public function init($options=array()) {
$first_name = new Zend_Form_Element_Text('first_name');
$last_name = new Zend_Form_Element_Text('last_name');
$email = new Zend_Form_Element_Text('email');
$password = new Zend_Form_Element_Text('encrypted_password');
$first_name->setRequired(false);
$last_name->setRequired(false);
$email->setRequired(true)->addFilter('StringToLower')->addValidator('NotEmpty', true)->addValidator('EmailAddress');
$password->setRequired(true);
$this->addElements(array($first_name, $last_name, $email, $password));
}
}
Run Code Online (Sandbox Code Playgroud)
如果电子邮件无效,我会收到:$ form-> getErrors('email')的emailAddressInvalidHostname;
我想自定义该错误,是否可能?
我有动态生成的匹配列表.在每个成员之后,我显示一个在其中显示VS的li.然而,div匹配中的最后一个ul li应该是不可见的.我有什么想法可以做到这一点?HTML
<style>
.match {
}
.match ul {
}
.match ul li {
float: left;
margin-right: 50px;
}
.match ul li:last-child {
display: none;
}
</style>
<div class="content">
<div class="match">
<ul>
<li><a href="/wade-barrett/member">Wade Barrett</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/shaemus/member">Shaemus</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/randy-orton/member">Randy Orton</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/john-cena/member">John Cena</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/edge/member">Edge</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/chris-jericho/member">Chris Jericho</a></li>
<li style="">VS</li>
</ul>
<p class="clear"></p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我想知道Zend_Registry是否使用phpMemory,会话或其他方法.
这个问题更让我感到好奇.
Zend_Registry::set('test', array());
Run Code Online (Sandbox Code Playgroud) 我需要视图来重新收集集合并每30秒重新渲染一次.问题是,一旦我更改页面(没有完整页面刷新),setInterval将保留在内存中并在后台保持重新获取.然而,这种观点早已被摧毁.
码:
define(
[
"underscore",
"collection/system/feed",
"view/list",
"text!template/index/system-feed.html"
],
function (_, Collection, ListView, Template) {
return ListView.extend({
el: '<div id="main-inner">',
collection: new Collection(),
loading: true,
client: false,
initialize: function (options) {
this.collection.fetch();
this.collection.on('reset', this.onFetchCollection, this);
var self = this;
setInterval(function() {
self.collection.fetch();
}, 30000);
},
/*collection is returned, so reset the loading symbol and set the posts to the render*/
onFetchCollection: function () {
this.list = this.collection.toJSON();
this.loading = false;
this.render();
},
render: function () {
var html = _.template(Template, …Run Code Online (Sandbox Code Playgroud) 使用mongo查看php页面时出现此错误:"Mongo无法加载"
我的命令行说:
/usr/lib/php5/20100525# php -i | fgrep -i configure
PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20090626
PHP compiled with module API=20100525
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/mongo.so' - /usr/lib/php5/20090626/mongo.so: cannot open shared object file: No such file or directory in Unknown on line 0
Run Code Online (Sandbox Code Playgroud)
所以我确保两个20090626和20100525目录都有mongo.so并重新启动apache但它仍然无法正常工作.我很困惑.我试过没有运气重新安装.
编辑:
我已经确定两个目录都有相同的扩展名,现在我得到了这个:
PHP Warning: PHP Startup: mongo: Unable to …Run Code Online (Sandbox Code Playgroud) 错误
Running "less" task
Running "less:files" (less) task
Verifying property less.files exists in config...OK
Warning: Object #<Object> has no method 'indexOf' Use --force to continue.
Run Code Online (Sandbox Code Playgroud)
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
files: [
{
expand: true,
cwd: 'public/css',
src: ['*.less'],
dest: 'public/css',
ext: '.css'
}
],
options: {
compress: true,
yuicompress: true,
optimization: 2
}
},
watch: {
files: "public/css/*",
tasks: ["less"]
},
});
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-less");
grunt.loadNpmTasks("grunt-contrib-requirejs");
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['less', 'watch']);
};
Run Code Online (Sandbox Code Playgroud)
非常感谢任何帮助,谢谢
我很困惑为什么Zend_DB不接受一个WHERE子句数组- 或者我是不正确的?我做了以下工作:
$all = new ORM_Model_DbTable_Asset();
$wheres = array('id > 0', 'enabled' => 1);
$all = $all->fetchAll(implode(' AND ', $wheres))->toArray();
Run Code Online (Sandbox Code Playgroud)
我希望如何:
$all = new ORM_Model_DbTable_Asset();
$wheres = array('id > 0', 'enabled' => 1);
$all = $all->fetchAll($wheres)->toArray();
Run Code Online (Sandbox Code Playgroud)
有点令人失望,我错过了什么?
我不喜欢将PhpStorm与巨型块一起用作鼠标或键盘光标.我想把它切换成一个简单的单行.我在另一台计算机上的PhpStorm副本看起来不像这样.

任何想法如何禁用它,这是一个简单的单行?
我的页面大约有31个
<ul class="sortableList">
<li>Jargon</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我试图循环每个sortableList并计算该ul中li的数量。
到目前为止,我有
_.each($('.sortableList'), function(info, key) {
console.log($(this).length);
});
Run Code Online (Sandbox Code Playgroud)
但是在控制台中,我得到31 x0。它不计算每个列表中的li。
javascript ×2
php ×2
backbone.js ×1
css ×1
css3 ×1
function ×1
gruntjs ×1
jquery ×1
mongodb ×1
phpstorm ×1
setinterval ×1
ubuntu ×1
zend-form ×1