includeとかrequireでreturnが取れるなんて・・・!!!(via 上鍵さん

$ cat config.php
<?php
return array(
    'test' => array(
        'adapter'  => 'mysql',
        'database' => 'iitaidake_test',
        'username' => 'iitaidake',
        'password' => 'unk_test',
        'host'     => 'localhost',
        'socket'   => '/var/run/mysqld/mysqld.sock',
        'encoding' => 'utf8'
    ),
    'production' => array(
        'adapter'  => 'mysql',
        'database' => 'iitaidake',
        'username' => 'iitaidake',
        'password' => 'unk',
        'host'     => 'localhost',
        'socket'   => '/var/run/mysqld/mysqld.sock',
        'encoding' => 'utf8'
    )   
);

$ php -r 'print_r(include "config.php");'
Array
(
    [test] => Array
        (   
            [adapter] => mysql
            [database] => iitaidake_test
            [username] => iitaidake
            [password] => unk_test
            [host] => localhost
            [socket] => /var/run/mysqld/mysqld.sock
            [encoding] => utf8
        )

    [production] => Array
        (  
            [adapter] => mysql
            [database] => iitaidake
            [username] => iitaidake
            [password] => unk
            [host] => localhost
            [socket] => /var/run/mysqld/mysqld.sock
            [encoding] => utf8
        )
)

こういう設定ファイルとか良くない!?

・・・・・・・・・。

それじゃ、あれだ、

$ cat foo.php
<?php
class Foo {}
return new Foo;

$ php -r 'print_r(include "foo.php");'
foo Object
(
)

こういうクラスとか、すげー便利じゃない?

・・・・・・・・・・・・。

Comments


Option