いちいち空チェックをやってた。
たとえばページ番号なんかをpageパラメータから取得するときに
$page = $this->getRequest()->getParam('page', 1);
とかやれば、pageパラメータにデフォルトで1が入る。まぁ普通にソース見てもいいし、ドキュメントにも書いてあるので、
とりあえず、API Documentationは一通り見ようと思った。
・Zend Framework API Documentation
基本的には技術メモです。
$page = $this->getRequest()->getParam('page', 1);
とかやれば、pageパラメータにデフォルトで1が入る。$adapter->addValidator('MimeType', false, array('image/gif', 'image/png', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/x-png')); // jpg, png, gif
こんなんとか、$adapter->addValidator('IsImage', false);
こんなんとかを使ってMimeTypeのチェックをしようと思ったが、なぜかうまくいかない。} else if (!(class_exists('finfo', false))) {
$ php -i | grep fileinfo (何も出ない)
$ sudo yum install php-devel ..... Installed: php-devel.x86_64 0:5.2.10-1.el5.centos Complete!
$ sudo pecl install fileinfo ..... Build process completed successfully Installing '/usr/lib64/php/modules/fileinfo.so' install ok: channel://pear.php.net/Fileinfo-1.0.4
$ sudo vim /etc/php.d/fileinfo.ini extension=fileinfo.so
$ sudo /etc/init.d/httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ]
$ php -i | grep fileinfo /etc/php.d/fileinfo.ini, fileinfo fileinfo support => enabled
$('#password').keypress(function (e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
// sumit action
}
});
var hash = {a:'hoge', b:'piyo', c:'huga'}
if (hash[a]) {
//exsist a
}
これだけでいいらしい。
$ sudo pear install --force services_twitter ..... Starting to download Net_URL2-0.3.1.tgz (8,488 bytes) ...done: 8,488 bytes install ok: channel://pear.php.net/Net_URL2-0.3.1 install ok: channel://pear.php.net/HTTP_Request2-0.5.2 install ok: channel://pear.php.net/Services_Twitter-0.6.2
$ sudo pear install HTTP_OAuth-0.1.18 ..... downloading HTTP_OAuth-0.1.18.tgz ... Starting to download HTTP_OAuth-0.1.18.tgz (51,237 bytes) .............done: 51,237 bytes install ok: channel://pear.php.net/HTTP_OAuth-0.1.18
require_once 'Services/Twitter.php';
require_once 'HTTP/OAuth/Consumer.php';
try {
$twitter = new Services_Twitter();
$oauth = new HTTP_OAuth_Consumer(
'メモったconsumer_key',
'メモったconsumer_secret',
'メモったauth_token',
'メモったtoken_secret'
);
$twitter->setOAuth($oauth);
$msg = $twitter->statuses->update("OAuth経由でTwitterに投稿するよ。");
} catch (Services_Twitter_Exception $e) {
echo $e->getMessage();
}
require_once("Zend/Log.php");
require_once("Zend/Log/Writer/Stream.php");
require_once("Zend/Log/Filter/Priority.php");
require_once("Zend/Log/Formatter/Simple.php");
// output format
$time = date('Y/m/d H:i:s');
$format = "{$time} %priorityName% (%priority%): %message%" . PHP_EOL;
$formatter = new Zend_Log_Formatter_Simple($format);
$writer = new Zend_Log_Writer_Stream('/****/****/****/logs/error_log'); // set log file path
$writer->setFormatter($formatter);
// setting log level
$filter = new Zend_Log_Filter_Priority(Zend_Log::DEBUG);
$log = new Zend_Log();
$log->addWriter($writer);
$log->addFilter($filter);
// write log
$log->debug('hogehoge');
PHP Fatal error: Class 'DOMDocument' not found in /****/app/zf/library/Zend/Gdata/App/Base.php on line 210
$ sudo yum install php-xml