<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ものぐさ備忘録 &#187; PHP</title>
	<atom:link href="http://www.ginriki.net/wd/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ginriki.net/wd</link>
	<description>ソフトウェア関係の話を中心とした備忘録的日記</description>
	<lastBuildDate>Sun, 11 Jul 2010 15:48:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>FlashPlayer10で外部swfのロードに失敗する件</title>
		<link>http://www.ginriki.net/wd/2008/11/05/46/</link>
		<comments>http://www.ginriki.net/wd/2008/11/05/46/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 07:25:15 +0000</pubDate>
		<dc:creator>ginriki</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.gikogeek.net/wd/?p=46</guid>
		<description><![CDATA[2008/10にFlashPlayer10が正式リリースされました。
Flashの動作に若干変更が加えられたようで、バイト先のWebサイトで今まで正常動作していたFlashがFlashPlayer10では動かないという問 [...]]]></description>
			<content:encoded><![CDATA[<p>2008/10にFlashPlayer10が<a href='http://www.itmedia.co.jp/news/articles/0810/15/news067.html'>正式リリース</a>されました。</p>
<p>Flashの動作に若干変更が加えられたようで、バイト先のWebサイトで今まで正常動作していたFlashがFlashPlayer10では動かないという問題が起きました。</p>
<p>挙動を調べてみると、MovieClipLoader.loadClipで外部swfのロードに失敗してます。</p>
<p>外部swfとして指定するURLは実際にはPHPファイルを指しており、GETパラメータを変えることで<br />
PHPファイルが出力するswfデータが変わるようになってます。</p>
<p>どうも、PHPファイルがswfデータを出力する際に指定してるHTTPレスポンスヘッダが良くないようなので、調べてみるとContent-disposition 指定がswfロードに失敗する原因でした。</p>
<p>そこで、下記のようにContent-dispositionの指定をコメントアウトしたら、FlashPlayer10でも<br />
外部swfのロードに成功しました。</p>
<div class="igBar"><span id="lphp-2"><a href="#" onclick="javascript:showPlainTxt('php-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-2">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#FF9933; font-style:italic;">//...略</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#FF9933; font-style:italic;">// header(&quot;Content-disposition: attachment;filename=&quot; . $filename);</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <a href="http://www.php.net/header"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Content-type: application/x-shockwave-flash"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <a href="http://www.php.net/header"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Content-length: "</span> . <a href="http://www.php.net/filesize"><span style="color:#000066;">filesize</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$filepath</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <a href="http://www.php.net/readfile"><span style="color:#000066;">readfile</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$filepath</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Content-dispositionの仕様はRFCで規定されています。その内容については、<a href='http://www.studyinghttp.net/header#Content-Disposition'>こちら</a>によくまとめられています。<br />
以下、一部引用</p>
<pre>
Content-Disposition レスポンスヘッダフィールドは、ユーザがその内容を
ファイルに保存したい場合にオリジンサーバが既定のファイル名を提案する事を
意味するように勧告されている。
</pre>
<p>Adobe的には、Flashでロードするswfコンテンツに、ファイルを保存する場合に指定するフィールドを指定するなってことなんでしょうかねえ。</p>
<h4>その他FlashPlayer10の問題</h4>
<p>FlashPlayer10になって、バージョン番号が１桁から２桁に増えたため、<br />
バージョンチェックを適当に行うJavascriptを書いているサイトなどでは、<br />
FlashPlayer10をFlashPlayer1と勘違いして、Flashが表示されない問題が起きてるようです。<br />
<a href='http://bakera.jp/ebi/topic/3302'>http://bakera.jp/ebi/topic/3302</a></p>
<p>・・・なんとなく２０００年問題を思い出しました。</p>
<h4>追記</h4>
<p>Adobe公式の<a href='http://www.adobe.com/devnet/flashplayer/articles/fplayer10_security_changes_02.html#head32'>FlashPlayer10におけるセキュリティ上の変更点解説</a>の中で、<br />
Content-Disposition: attachment 指定されたswfに対する挙動を変えた理由が書いてありました。</p>
<p>不特定の人がファイルをアップロード/ダウンロードできるアップローダサイト等で、<br />
信頼できないユーザによってアップロードされたswfが、そのサイトドメイン上で実行される危険性を<br />
なくすためだそうです。</p>
<p>画像やxmlファイルなどは、Content-Disposition: attachmentがHTMLレスポンスヘッダに<br />
ついていても、今までと同様に動作するそうです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ginriki.net/wd/2008/11/05/46/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PhpDocumentorによるドキュメント自動生成</title>
		<link>http://www.ginriki.net/wd/2008/10/29/45/</link>
		<comments>http://www.ginriki.net/wd/2008/10/29/45/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 09:01:45 +0000</pubDate>
		<dc:creator>ginriki</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[PhpDocumentor]]></category>

		<guid isPermaLink="false">http://www.gikogeek.net/wd/?p=45</guid>
		<description><![CDATA[バイト先のWebアプリケーション用ソースコードの量が増えてきたので、
そろそろドキュメント生成ツールでも使おうということで、そのメモ。
バイト先では、PHP &#038; symfonyフレームワークで書いてるんで、
ド [...]]]></description>
			<content:encoded><![CDATA[<p>バイト先のWebアプリケーション用ソースコードの量が増えてきたので、<br />
そろそろドキュメント生成ツールでも使おうということで、そのメモ。</p>
<p>バイト先では、PHP &#038; symfonyフレームワークで書いてるんで、<br />
ドキュメント生成ツールにはPhpDocumentor<sup>1</sup>を使います。</p>
<p>インストールはPEARを使えば楽勝。</p>
<pre>
 $ pear install PhpDocumentor
</pre>
<p>で、ドキュンメントの生成にはphpdocコマンドを使います。</p>
<pre>
 $ phpdoc -d apps,lib -t doc/phpdoc
</pre>
<p>これで、appsとlibディレクトリ以下すべてのphpファイルをHTMLドキュメント化して、<br />
doc/phpdoc以下に吐き出してくれます。</p>
<p>ただ、デフォルトで生成するHTMLには、charset=iso-8859-1が指定されているため、<br />
日本語コメントは文字化けしてしまいます。</p>
<p>対処法としては、HTML内にcharset指定のないHTMLドキュメントを生成するのが楽です<sup>2</sup>。</p>
<pre>
 $ phpdoc -d apps,lib -t doc/phpdoc -o HTML:Smarty:PHP
</pre>
<p>この場合、デフォルトで生成したHTMLとはレイアウトが変わってしまいます。<br />
デフォルトレイアウトが好きな方は、下記サイトを参考にテンプレートを書き換えてください。<br />
<a href='http://je-pu-pu.jp/blog/archives/2006/04/phpdocumentor.html'>http://je-pu-pu.jp/blog/archives/2006/04/phpdocumentor.html</a></p>
<h4>参考文献</h4>
<ul>
<li><a href='http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.pkg.html'>ソースコードに記述できるタグの説明</a></li>
<li><a href='http://fullmetal.dip.jp/pukiwiki/index.php?memo%2FPhpDocumentor%2Fhelp'>phpdocコマンドオプション説明の日本語訳</a></li>
</ul>
<ol class="footnotes"><li id="footnote_0_45" class="footnote">現バージョンは1.4.2です</li><li id="footnote_1_45" class="footnote">とはいえ、webサーバのDefaultCharsetが間違っていたり、ブラウザの文字コード自動判定が失敗した場合は、文字化けが起きるので注意</li></ol>]]></content:encoded>
			<wfw:commentRss>http://www.ginriki.net/wd/2008/10/29/45/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Interactive ShellによるPHP対話入力補完</title>
		<link>http://www.ginriki.net/wd/2008/09/24/40/</link>
		<comments>http://www.ginriki.net/wd/2008/09/24/40/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 18:39:59 +0000</pubDate>
		<dc:creator>ginriki</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[interactive mode]]></category>
		<category><![CDATA[インタラクティブモード]]></category>

		<guid isPermaLink="false">http://www.gikogeek.net/wd/?p=40</guid>
		<description><![CDATA[この前の記事の続き。
rubyには、irbっていうinteractive modeあります。
irb実行中に、 require 'irb/completion' すると、TABでメソッド名等の補完ができるようになって大変 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gikogeek.net/wd/2008/09/08/10/">この前の記事</a>の続き。</p>
<p>rubyには、irbっていうinteractive modeあります。<br />
irb実行中に、 require 'irb/completion' すると、TABでメソッド名等の補完ができるようになって大変便利です。</p>
<p>PHPのinteractive modeでも同じことができないかなと思い、<br />
探してみたところ、PHP5.1 から標準で導入されてることがわかりました<sup>1</sup>。</p>
<p>ただし、--with-readline付きでＰＨＰをコンパイルした場合に限ります。<sup>2</sup></p>
<p>yumでインストールしたPHPは、--with-readlineが付いてないので、<sup>3</sup><br />
PHP-cliだけソースコードからもう一度コンパイルしてみました。</p>
<p>環境は、CentOS 5.1です。</p>
<pre>
$ wget http://jp2.php.net/get/php-5.2.6.tar.gz/from/jp.php.net/mirror
$ tar xzvf php-5.2.6.tar.gz
$ cd php-5.2.6/
$ yum install libxml2-devel
$ yum install readline-devel
$ ./configure --prefix=~/local --disable-cgi --with-readline
$ make
$ make install
$ ~/local/bin/php -a
Interactive shell

php &gt; get_class  [TAB]
get_class          get_class_methods  get_class_vars
php &gt; get_class
</pre>
<p>うむ、便利だ。</p>
<ol class="footnotes"><li id="footnote_0_40" class="footnote">補完機能付きのinteractive modeは、Interactive Shellっていう名称が付いてます。</li><li id="footnote_1_40" class="footnote">なんで、readlineを動的リンクするだけで使えるようにしてないんだー</li><li id="footnote_2_40" class="footnote">少なくとも、CentOS 5.1のyumでインストールしたPHPは--with-readlineはついてませんでした。</li></ol>]]></content:encoded>
			<wfw:commentRss>http://www.ginriki.net/wd/2008/09/24/40/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHPインタラクティブモードの便利な使い方</title>
		<link>http://www.ginriki.net/wd/2008/09/08/10/</link>
		<comments>http://www.ginriki.net/wd/2008/09/08/10/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 17:28:44 +0000</pubDate>
		<dc:creator>ginriki</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[interactive mode]]></category>
		<category><![CDATA[LL]]></category>
		<category><![CDATA[インタラクティブモード]]></category>

		<guid isPermaLink="false">http://www.gikogeek.net/wd/?p=10</guid>
		<description><![CDATA[ブログに書くネタは結構あるんだけど、整理してから書こうとするとなかなか書けない・・・。
しょうがないんで、ネタは小出しに書くことにしよう。
PHPで何かのライブラリのオブジェクトを使う際、どんなメソッドがある]]></description>
			<content:encoded><![CDATA[<p>ブログに書くネタは結構あるんだけど、整理してから書こうとするとなかなか書けない・・・。</p>
<p>しょうがないんで、ネタは小出しに書くことにしよう。</p>
<p>PHPで何かのライブラリのオブジェクトを使う際、どんなメソッドがあるのかよくわからにことが多々あります。リファレンスを見りゃいいんですが、それが面倒な時は、PHP (CLI)のインタラクティブモードを使うと便利です。</p>
<p>インタラクティブモードの場合、statementが完成するたびに(セミコロンで区切られるたびに）処理が実行されるようです。</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showPlainTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$ php -a</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$methods</span> = <a href="http://www.php.net/get_class_methods"><span style="color:#000066;">get_class_methods</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">new</span> XMLReader<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/print_r"><span style="color:#000066;">print_r</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$methods</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/array"><span style="color:#000066;">Array</span></a></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> =&gt; close</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> =&gt; getAttribute</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">...</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">24</span><span style="color:#006600; font-weight:bold;">&#93;</span> =&gt; expand</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#40;</span>Windowsだと Ctrl-Zで終了<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$ </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>インタラクティブモードで、よく利用する関数は以下　（全部、リフレクション系関数）、</p>
<ul>
<li>get_class_methods( mixed $class_name )  [クラスのメソッドを配列として返す]</li>
<li>get_object_vars ( object $object ) [オブジェクトのプロパティを配列として返す]</li>
<li>get_declared_classes(void) [定義済のクラスの名前を配列として返す]</li>
<li>get_defined_functions(void) [定義済の関数の名前を配列として返す]</li>
<li>get_defined_vars(void) [定義済の変数の名前を配列として返す]</li>
<li>get_loaded_extensions(void) [コンパイル/ロードされている全てのモジュールの名前を配列として返す]</li>
<li>get_extension_funcs ( string $module_name ) [あるモジュールの関数名を配列として返す]</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ginriki.net/wd/2008/09/08/10/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ブラウザキャッシュの無効/有効</title>
		<link>http://www.ginriki.net/wd/2008/07/14/8/</link>
		<comments>http://www.ginriki.net/wd/2008/07/14/8/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 16:50:28 +0000</pubDate>
		<dc:creator>ginriki</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[http]]></category>

		<guid isPermaLink="false">http://www.gikogeek.net/wd/?p=8</guid>
		<description><![CDATA[ブラウザキャッシュは意識して設定しないと簡単に無効になったり有効になったりしてしまいます。
必ず無効にしたい or 必ず有効にしたいというポリシーがあるなら、きちんとした設定が必要です。
・ブラウザキャッシュを]]></description>
			<content:encoded><![CDATA[<p>ブラウザキャッシュは意識して設定しないと簡単に無効になったり有効になったりしてしまいます。<br />
必ず無効にしたい or 必ず有効にしたいというポリシーがあるなら、きちんとした設定が必要です。</p>
<p><strong>・ブラウザキャッシュを無効する方法</strong><br />
<a href="http://blog.knockoutmarch.com/2008/02/06/2323.html">http://blog.knockoutmarch.com/2008/02/06/2323.html</a><br />
より引用</p>
<div class="igBar"><span id="lhtml-7"><a href="#" onclick="javascript:showPlainTxt('html-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-7">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- メタタグに以下を記述。 --&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">"Pragma"</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">"no-cache"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">"Cache-Control"</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">"no-store"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">"Cache-Control"</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">"no-cache"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">"Expires"</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">"-1"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- また、body内に以下を記述。 (for safari) --&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/iframe.html"><span style="color: #000000; font-weight: bold;">&lt;iframe</span></a> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">"height:0px;width:0px;visibility:hidden"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"about:blank"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; this frame prevents back forward cache</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/iframe&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>・ブラウザキャッシュを有効にする方法</strong></p>
<p>そもそも、あるリンクをクリックした後のブラウザキャッシュ挙動には2パターンあることに注意<br />
1. キャッシュしてあるコンテンツが新しくなっていないかwebサーバに問い合わせる。新しくなってなければキャッシュを使う。 (Last-Modified &#038; If-Modified-Since &#038; 304 status)</p>
<p>2. webサーバに問い合わせず、キャッシュをそのまま使う (Expires or Cache-Control: max-age)</p>
<p>しかも、ブラウザによってhttpレスポンス/リクエストヘッダのLast-Modified, Expiresなどの解釈や優先順位が違うことに注意。<br />
<a href="http://labs.cybozu.co.jp/blog/kazuho/archives/2006/02/utilizing_cache.php">http://labs.cybozu.co.jp/blog/kazuho/archives/2006/02/utilizing_cache.php</a><br />
<a href="http://fdays.blogspot.com/2007/11/ie6cache-controlcache.html">http://fdays.blogspot.com/2007/11/ie6cache-controlcache.html</a></p>
<p>以上を踏まえると、PHPコンテンツに対して、ブラウザキャッシュを上記2番の方法で一定時間有効にしたいときは下記のようにしとけば良さそう ( $interval 秒だけキャッシュを有効にしたいとする）</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showPlainTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"Expires: "</span> . <a href="http://www.php.net/gmdate"><span style="color:#000066;">gmdate</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"D, d M Y H:i:s"</span>, <a href="http://www.php.net/time"><span style="color:#000066;">time</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#0000FF;">$interval</span> <span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">" GMT"</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"Cache-Control: max-age="</span> . <span style="color:#0000FF;">$interval</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#FF0000;">"Pragma: cache"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">// no-cache以外にすればＯＫ </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>キャッシュを無効にしたい場合も、有効にしたい場合も、同じようなhttpリクエスト項目を複数指定する必要があるのがだるい・・・</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ginriki.net/wd/2008/07/14/8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>レンタルサーバsakuraにsymfonyをインストール</title>
		<link>http://www.ginriki.net/wd/2008/07/13/7/</link>
		<comments>http://www.ginriki.net/wd/2008/07/13/7/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 09:57:24 +0000</pubDate>
		<dc:creator>ginriki</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.gikogeek.net/wd/?p=7</guid>
		<description><![CDATA[私はレンタルサーバとしてsakuraを使ってます。
PHPフレームワークのsymfonyをsakura上で動かしたかったので、インストール方法を探ってみたところ、すでにやってる方がいらっしゃったのでサクッとインストールで [...]]]></description>
			<content:encoded><![CDATA[<p>私はレンタルサーバとしてsakuraを使ってます。</p>
<p>PHPフレームワークの<a title="symfony" href="http://www.symfony-project.org/">symfony</a>をsakura上で動かしたかったので、インストール方法を探ってみたところ、すでにやってる方がいらっしゃったのでサクッとインストールできました。</p>
<p><a href="http://ueblog.natural-wave.com/2008/06/15/sakura-symfony/">http://ueblog.natural-wave.com/2008/06/15/sakura-symfony/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ginriki.net/wd/2008/07/13/7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPはリファレンスカウントGCを使っているというお話</title>
		<link>http://www.ginriki.net/wd/2008/03/20/35/</link>
		<comments>http://www.ginriki.net/wd/2008/03/20/35/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 16:45:15 +0000</pubDate>
		<dc:creator>ginriki</dc:creator>
				<category><![CDATA[GC]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.gikogeek.net/wd/?p=35</guid>
		<description><![CDATA[
バイト先でHyper Estraierを使った全文検索機能を実装する機会がありました。
そこで、EstraierPureライブラリを使って、PHPスクリプトを通じてHyper Estraierにテキストのインデックスを [...]]]></description>
			<content:encoded><![CDATA[<div class="section">
<p>バイト先で<a href="http://hyperestraier.sourceforge.net/index.ja.html" target="_blank">Hyper Estraier</a>を使った全文検索機能を実装する機会がありました。</p>
<p>そこで、<a href="http://page2.xrea.jp/#EstraierPure" target="_blank">EstraierPure</a>ライブラリを使って、PHPスクリプトを通じて<a href="http://hyperestraier.sourceforge.net/index.ja.html" target="_blank">Hyper Estraier</a>にテキストのインデックスを作成させるようにしたのですが、複数のテキストファイルをインデックス化する途中で下記PHPエラーが出てPHPプロセスが終了しました。</p>
<blockquote>
<p>PHP Fatal error:  Allowed memory size of 8388608 bytes exhausted (tried to allocate 22423 bytes) in /var/lib/Services/HyperEstraier/Utility.php on line 278</p>
</blockquote>
<p>なんかメモリが足りなくなっとるらしい。</p>
<p>また、インデックス化に失敗したテキストファイルから実行再開すると、そのテキストのインデックス化に成功した後、別のテキストファイルをインデックス化する時に同様のエラーが出てプロセスが終了します。</p>
<p>以上の結果からメモリリークの疑いが強いのですが、<a href="http://page2.xrea.jp/#EstraierPure" target="_blank">EstraierPure</a>は100％PHPコードなので、PHPのメモリ管理に原因がありそうです。</p>
<p>ということで、PHPのメモリ管理方法を調べてみたところ、リファレンスカウント方式のGCだと判明しました<span class="footnote"><a href="/gikogeek/#f1" name="fn1" title="PHPカンファレンス2007 「PHPの今とこれから 2007」:http://www.php.gr.jp/seminar/20070901/data/phpcon070901a.ppt">*1</a></span>。今までTracing GC系だと思ってたよ・・・</p>
<p>現在、PHPのリファレンスカウントGCは循環参照しているオブジェクトは解放できません。おそらく、<a href="http://page2.xrea.jp/#EstraierPure" target="_blank">EstraierPure</a>の中で循環参照があって、そのオブジェクトが解放されずにリークし、最終的にメモリが足りなくなるのでしょう。</p>
<p>PHP6からは、Pythonでも使われているCycle Collector<span class="footnote"><a href="/gikogeek/#f2" name="fn2" title="Cycle Collectorアルゴリズムの論文: http://www.research.ibm.com/people/d/dfb/papers/Bacon01Concurrent.pdf">*2</a></span>が実装されるそうなので<span class="footnote"><a href="/gikogeek/#f3" name="fn3" title="PHPカンファレンス2007 「PHPの今とこれから 2007」:http://www.php.gr.jp/seminar/20070901/data/phpcon070901a.ppt">*3</a></span>、今回の問題もPHP6を使えば解消します。</p>
<p>ってまだPHP6は正式リリースされてないし、今更PHP5から変えられるかーっていう状況。PHP5.3でもCycle Collectorが導入されるといいなあ。・・・結局リリース待ちなわけだけど。</p>
</div>
<div class="footnote">
<p class="footnote"><a href="/gikogeek/#fn1" name="f1">*1</a>：PHPカンファレンス2007 「PHPの今とこれから 2007」:<a href="http://www.php.gr.jp/seminar/20070901/data/phpcon070901a.ppt" target="_blank">http://www.php.gr.jp/seminar/20070901/data/phpcon070901a.ppt</a></p>
<p class="footnote"><a href="/gikogeek/#fn2" name="f2">*2</a>：Cycle Collectorアルゴリズムの論文: <a href="http://www.research.ibm.com/people/d/dfb/papers/Bacon01Concurrent.pdf" target="_blank">http://www.research.ibm.com/people/d/dfb/papers/Bacon01Concurrent.pdf</a></p>
<p class="footnote"><a href="/gikogeek/#fn3" name="f3">*3</a>：PHPカンファレンス2007 「PHPの今とこれから 2007」:<a href="http://www.php.gr.jp/seminar/20070901/data/phpcon070901a.ppt" target="_blank">http://www.php.gr.jp/seminar/20070901/data/phpcon070901a.ppt</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ginriki.net/wd/2008/03/20/35/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
