lass Comment { const NAME = 'comment'; const NAME_PUBLISH = 'comment:publish'; } class CommentListen...
PHP将一个数组转换成Xml
<?php $test_array = array ( 'bla' => 'blub', 'foo' => 'bar', 'another_array' => array ( ...
php通过大写字母分割字符串
使用preg_split和表达工来分割: function splitAtUpperCase($s) { return preg_split('/(?=)/', $s, -1, PREG_SPLIT_...

Symfony事件调度器的使用
调度器组件提供允许应用程序通过调度事件并收听事件来相互通信。在使用面向对象开发时,我们把类的职责分配的很单一,程序也因此变得很灵活,其他开发人员可以通过继承来修改其行为。但是这些变更如果要通知其它的开...
twig中使用continue和break
Break {% set break = false %} {% for post in posts if not break %} {{ post.heading }} {% if post.id ...
在twig中使用strpos函数
默认情况: {# returns true #} {{ 1 in }} {{ 'cd' in 'abcde' }} {% if "http://" in "http://baidu.com" %} {...
phalcon控制器方法返回json
Base控制器实现afterExecuteRoute方法: /** * @param Dispatcher $dispatcher */ public function afterExecuteRou...

Vagrant打造PHP开发环境
Vagrant Vagrant允许用户创建和配置轻量级,可重复的和便携式的虚拟软件(VirtualBox、Hyper-V、Docker、VMware、AWS)开发环境。其背后的核心思想在于,在大型软件...
phalcon视图中获取常量
使用函数 constant(): {{ constant("DIRECTORY_SEPARATOR") }} {{ constant("Phalcon\Logger::ERROR") }}
使用PHP计算两个日期之间相隔多少天
面向对象风格: <?php $january = new DateTime('2010-01-01'); $february = new DateTime('2010-02-01'); $int...