What makes Unit Test so difficult the revolution from global variable to singleton to registry to dependency injection. “One of the hallmarks of testability is a loose coupling of classes, allowing you to isolate a single class and test it completely” —- http://code.google.com/p/google-singleton-detector/wiki/WhySingletonsAreControversial * unit test could prevent writing code with too many dependencies, in [...]
Archives for PHP
Netbeans 折叠代码
最近在修改公司老早之前的代码,里面的function大多长达一百多行,看起来超级痛苦。如果可以吧方法里的一些部分折叠起来会看的清楚些。netbeans 默认是可以折叠(folding) function的,如果需要自定义的折叠一部分代码可以在代码里写入下面的标签 //<editor-fold desc=” read report info from database”> … 这里是需要折叠隐藏的代码 //</editor-fold> 如此,就可以把当前不需要特别注意的代码折叠起来了。
zend framework中的Request 对象 的
Request是zend framework中很重要的一个对象。 getParam 可以取得客户传来的参数,取数据的顺序为 1. GET 2. POST 3. COOKIE 4. SERVER 5. ENV
exception in zend_db_table
I just met the following exception, when i was trying to implement a model: Message: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound It is because the refcolumns doesn’t exists ( i made this by a typo) , see the following code: protected $_referenceMap = array ( ‘Institute’ => array( ‘columns’ => array(“exchange_institution_id”), ‘refTableClass’ => [...]
命令行查看PHP的参数
phpinfo()是个经常用来查看php配置的命令。每次查看都要创建一个PHP的文件,再在里面呼叫这个方法。 今天发现了一个PHP的命令行参数 -i ,通过输入这个参数就可以在命令行里看当前的php的配置了。 在命令行里输入: php -i |less 看看你的php的参数是什么
using php interactive shell
php has a interactive shell. Just input php -a in your shell. $ php -a Interactive shell php > $a=array(“name”=>”ting”); php > $a[]=3; php > print_r($a); Array ( [name] => ting [0] => 3 ) php > Another way to try your script is using: php -f yourPHP.php $name = “ting”; if($name == “ting){ print [...]
在fpdf中输入欧元的符号 €
用eclipse编辑的时候,文档的编码是utf8的,可以输入€。但是pdf输出确是乱码。 解决的方法是: define(‘EURO’, chr(128)); $ust = $summer * 0.19.EURO;
Smarty中变量的使用
if the variable is an hash array, then use . {$aHashArray.key1} if the variable is an object, then use -> {$anObject->pro1}