当前位置: 首页>>代码示例>>PHP>>正文


PHP test::getInstance方法代码示例

本文整理汇总了PHP中test::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP test::getInstance方法的具体用法?PHP test::getInstance怎么用?PHP test::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test的用法示例。


在下文中一共展示了test::getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getInstance

<?php

/********************************************************/
/*****                 @!!@                          ****/
/********************************************************/
/**
 *@FileName : .php
 *@Author   : WangKilin
 *@Email    : wangkilin@126.com
 *@Date     : 
 *@Homepage : http://www.yeaheasy.com
 *@Version  : 0.1
 */
class test
{
    function getInstance($cc)
    {
        echo "hello";
    }
}
if (function_exists('test::getInstance')) {
    test::getInstance();
}
if (is_callable(array('test', 'getInstance'))) {
    test::getInstance('cc');
    echo 'dddd';
}
开发者ID:cwcw,项目名称:cms,代码行数:27,代码来源:test.php

示例2: test

    {
        static $instance2 = null;
        if ($instance2 == null) {
            $instance2 = new test('Singleton2');
        } else {
            echo "Using old class " . $instance2->myname . "\n";
        }
        return $instance2;
    }
    public function __destruct()
    {
        if (defined('SCRIPT_END')) {
            echo "Class " . $this->myname . " destroyed at script end\n";
        } else {
            echo "Class " . $this->myname . " destroyed beforce script end\n";
        }
    }
}
echo "Try static instance inside class :\n";
$getCopyofSingleton = test::getInstance();
$getCopyofSingleton = null;
$getCopyofSingleton =& test::getInstance();
$getCopyofSingleton = null;
$getCopyofSingleton = test::getInstance();
echo "Try static instance inside function :\n";
$getCopyofSingleton2 = test::getInstance2();
$getCopyofSingleton2 = null;
$getCopyofSingleton2 =& test::getInstance2();
$getCopyofSingleton2 = null;
$getCopyofSingleton2 = test::getInstance2();
define('SCRIPT_END', 1);
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:bug32322.php

示例3: getInstance

<?php

final class test
{
    private static $_INSTANCE = null;
    public static function getInstance()
    {
        if (is_null(self::$_INSTANCE)) {
            self::$_INSTANCE = new self();
        }
        return self::$_INSTANCE;
    }
    private function __construct()
    {
    }
    public final function __clone()
    {
        throw new RuntimeException('clone �֎~');
    }
}
$u = test::getInstance();
var_dump($u);
开发者ID:kawazoe-yusuke,项目名称:design-pattern,代码行数:22,代码来源:test.php


注:本文中的test::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。