{"version":"1.0","url":"https://drambuie.hatenadiary.org/entry/20040216/p1","width":"100%","author_url":"https://blog.hatena.ne.jp/drambuie/","provider_url":"https://hatena.blog","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fdrambuie.hatenadiary.org%2Fentry%2F20040216%2Fp1\" title=\"PHP singleton - drambuie\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","description":"\u666e\u901a\u306b\u3084\u308b\u306a\u3089 class MyClass { /** * \u3053\u306e\u30af\u30e9\u30b9\u306e\u5358\u4e00\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u8fd4\u5374\u3057\u307e\u3059\u3002 */ function &getInstance() { static $singleton; if (!isset($singleton)) { $singleton = new MyClass; } return $singleton; } } $instance =& MyClass::getInstance(); \u4ee5\u4e0b\u3067\u306f$GLOBALS\u3092\u4f7f\u3063\u3066\u30af\u30e9\u30b9\u306b\u9759\u7684\u5909\u6570\u3092\u5b9f\u73fe\u3059\u308b\u65b9\u6cd5\u3082\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u3002 phpPatterns() - Singleton Pattern http://www\u2026","categories":[],"blog_url":"https://drambuie.hatenadiary.org/","provider_name":"Hatena Blog","type":"rich","author_name":"drambuie","published":"2004-02-16 00:00:00","height":"190","image_url":null,"title":"PHP singleton","blog_title":"drambuie\u306e\u65e5\u8a18"}