php

Zend_Controller_Dispatcher_Exception: Invalid controller specified (error) なエラー

ひょっとして ErrorController.php置いてないんじゃね?

macのphpを入れなおしたら クソハマった話

自宅のmacでもZend_dbを使うため、pdoとか必要になったから 元々入ってるのだと駄目みたいなので、ビルドし直す。 参考 http://d.hatena.ne.jp/boto/20071121/1195657035 2007-11-14 http://d.hatena.ne.jp/hetima/20071028 MacでPostgreSQLをインストールす…

include_pathについて

php

めも 参考 include_pathかset_include_path()か - Shin x blog

Pear::Pagerのfactoryの仕様が変わってるようにみえる

2.4.5だと、factoryに渡すやつでpathを入れなくても 今のページに対してのページャーが出たのに、2.4.7になったら /に対するページャーが出るようになった pathにfalseとか渡したらよくなった $params = array( #略 'path' => false, //2.4.7になったらコレ…

Zend_Dbのjoin

ハマッタ。。 Zend_Db_Table の join でハマる - Memo肝は $this->model->select()->setIntegrityCheck(false)

変数名を変数

php

$hoge = "crimaru"; ${$hoge} = "mogemoge" ; var_dump($crimaru); hashでよいんだけど

trim

php

第2引数に消したい文字を放り込めば消える <hogehoge@fugafuga.moge>から、メルアドだけ取り出したかった。 trim("<hogehoge@fugafuga.moge>","<>"); ( ゚Д゚)ウマー</hogehoge@fugafuga.moge></hogehoge@fugafuga.moge>

issetとempty

php

$a = 1; $b = array(); $c = 0; $d = NULL; $e = ""; var_dump( !isset($a) ); var_dump( empty($a) ); var_dump( !isset($b) ); var_dump( empty($b) ); var_dump( !isset($c) ); var_dump( empty($c) ); var_dump( !isset($d) ); var_dump( empty($d) ); v…

smartyでforみたいなこと

{section name=cnt loop=10} {$smarty.section.cnt.iteration-1}<br> {/section} {section name=cnt loop=10} {$smarty.section.cnt.index}<br> {/section} {section name=cnt start=0 loop=10} {$smarty.section.cnt.index}<br> {/section} 参考 Smartyでfor文みたいな…

pdo_pgsqlのインストール

php

PDOのドライバはインストールしないといけない with-pdo-pgsql をつけてコンパイルhttpdをrestart # /etc/init.d/httpd restart httpd を停止中: [ OK ] httpd を起動中: [Fri Sep 05 13:03:43 2008] [warn] module php5_module is already loaded, skipping…

{html_select_date}でXXXX年XX月XX日ってだしたい

そうかバラせばよかったのか {html_select_date time = "" prefix = "birthday_" start_year = "1920" end_year = "-1" field_order = "Y" field_separator = "" year_empty = "" all_extra = 'class="html_select_date"' }年 {html_select_date time = "" p…

アップロード用ライブラリ

php

ファイルアップロード&画像加工ならお任せ·CLASS.UPLOAD.PHP MOONGIFT

プラグインでカスタムなをつくる

渡すパラメータでつくるarrayをかえたりで、なんでもできる。 呼び側 {custom_hoge_option} プラグイン function smarty_function_custom_hoge_option($params, &$smarty){ require_once $smarty->_get_plugin_filepath('function','html_options'); $option…

プラグインディレクトリは複数していできた

pluginsに突っ込んでいくしかないと思ってた $this->base_dir = "/hoge/fuga/project_root" $this->plugins_dir[] = $this->base_dir . "/inc/Smarty/plugins" ; #default $this->plugins_dir[] = $this->base_dir . "/inc/Smarty/myplugins" ;#自作 でok 参…

PEAR::DBのプレースホルダでlike使うとき

php

http://www.ironhearts.com/diary/archives/000798.html

PHPのmb_encode_mimeheaderは事前にmb_internal_encodingが必要

php

PHPのmb_encode_mimeheaderは事前にmb_internal_encodingが必要 : akiyan.com

スクレイピングやる。

php

Tidy関数を使えるようにする libをいれる yum install libtidy yum install libtidy-devel phpをリコンパイル ./configure --with-apxs2=/usr/sbin/apxs --with-pgsql --enable-mbstring --with-mcrypt --with-gd --with-zlib --with-jpeg-dir --with-png-di…

RSSをごにょる

phpでRSSを生成した外部フィードを読んでごにょごにょごにょ PEAR::XML_Serializer PEAR::XML_RSS 参考 pear http://webtech-walker.com/archive/2007/04/06023523.html http://www.doyouphp.jp/sample/sample_xml_pear_rss.shtml rss RSS 2.0 Notes 跡地 結…

オブジェクトを配列にする

php

rubyのto_a get_object_vars($object); 参考 PHPでオブジェクトを配列に変換するにはget_object_vars – 秋元

ループの回数で処理するしないとか

{if $smarty.section.file.iteration%2 == 0}{/if} rubyだと hoge.each_with_index do |i, count| p count #ループのn回目 end

GD入れてみた

phpで画像の保存 GD使わない //$imageが画像リソース $fp = fopen(IMG_PATH . "hoge.jpg", "wb"); fputs($fp, $image); fclose($fp); GD使う imagejpeg($image, "/home/coek/dev/php/mag_storm/public/mag/image/$filename.jpg"); GD使うために yum install …

ini_set

php

スクリプト内でincludepathをセットしたいとき $path = '/home/crimaru/dev/php/hoge/inc'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); でOS依存なく追加できる。

try catch

php

php5は例外が使える。 http://php.benscom.com/manual/ja/language.exceptions.php でも、失敗はFALSEって奴らが結構多いみたい。 mkdirで失敗してもfalseが返ってくるだけだから。例外を捕捉しない。 try { if( !mkdir('dirname')) { throw new Exception('…

PHPでPOP3

55. PEAR::Net_POP3を使ってPOP3サーバにアクセスしよう | 日経 xTECH(クロステック)

運用時はエラー出したくない

php

運用時はエラーを出したくない 手っ取り早いのは、.htaccessに php_flag display_errors Off書く。 参考 PHPなどでエラーが起きた場合ファイル名などが出てしまうので、… - 人力検索はてな

インストールしたPEAR

php

net_userAgent_mobile βリリースなので-fとかつける pear install -f -o net_userAgent_mobile 参考 Net_UserAgent_Mobile PEAR::Net_UserAgent_Mobile 3G対応携帯判別(ケータイ判別) [dozo dokuwiki.php] db calendar date pager

PHPで簡単なCSRF対策

php

smarty拡張クラスを作る function smarty_function_csrf_token($params, &$o_smarty){ if(session_id() == ""){ session_start(); } $key = session_id(); return "<input type=\"hidden\" name=\"_csrf_token\" value=\"". $key ."\" />"; } で、テンプレートで {csrt_token}で呼ぶと

phpのサニタイズはmagic_quotes_gpcがonだと\\\\\\\\ってなる

php

magic_quotes_gpc = Offにするのが基本みたい。 参考 [PHP4]phpの文字化けとphp.iniの設定 | ごった煮 - tips about programming and building a server

smartyのフィルターと関数のオーバーライド

php

フィルター function __construct(){ #略 $this->register_prefilter('toEUC'); } 関数のオーバーライド displayに処理追加 例えば携帯だったら、SJISで出すみたいな function display($resource_name, $cache_id = null, $compile_id = null) { $content = …

smartyの必須で必須なこと

php

SJISだとエラーになる。 須の2バイト目がダメポ {literal}必須{/literal} 参考 プログラミング/PHP/smarty - Naoebi Wiki