8. Webサーバと組み合わせて実行
(Web Server起動
時にロード済み)
Web Server
run PHP
Script
HTTP Request
Web Server
組み込み型
Web
Server
CGI Protocol
run PHP
Script
HTTP Request
CGI型
起動して実行
Web
Server
FastCGI Protocol
run PHP
Script
HTTP Request
FastCGI型
起動済み
9. PHP 単体で実行
Built-in WebServer
(ex:php –S 127.0.0.1:3000) run PHP
Script
Webサーバと組み合わせずにスタンドアロンで動作
(Built-in Web Server は IO 多重化による、シングルプロセス実装なのでIO が Busy に
なると並列処理できない。もし PHP Script 実行時にクラッシュすると、WebServer も巻
き込んで死ぬのであくまで開発用)
HTTP Request
Command Execution
run PHP
Script
コマンド実行
(ex: php hoge.php)
起動して実行
64. early binding なし
<?php
func(); // Call to undefined function func()
new Cls(); // Class 'Cls' not found
if (1) {
function func() {}
class Cls {}
}
func(); // OK
new Cls(); // OK
定義がトップレベルではないの
で early binding されない
80. 循環参照
$a = new stdClass();
$b = new stdClass();
$a->r = $b;
$b->r = $a;
unset($a);
unset($b);
$a
$b
stdClass(ref:1)
stdClass(ref:1)
$a
$b
stdClass(ref:2) r
stdClass(ref:2) r
$a
$b
stdClass(ref:1) r
stdClass(ref:2) r
$b
stdClass(ref:1) r
stdClass(ref:1) r
解放されない