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


PHP class_exists函数代码示例

本文整理汇总了PHP中class_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP class_exists函数的具体用法?PHP class_exists怎么用?PHP class_exists使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: factory

 /**
  * 工厂, 创建操作各种数据库的对象.
  *
  * @param string|null $db_type 数据库类型, 如果传递 null 或者不传递则默认为 local RThink_Config 的
  *            db_type
  * @param array $options 数据库配置参数
  * @return object 操作相应数据库的对象
  * @throws em_db_exception
  */
 public static function factory($options, $db_type)
 {
     $adapter_name = ucfirst($db_type) . 'Adapter';
     $class_name = 'RThink_Db_' . $adapter_name;
     class_exists($class_name, false) || (require 'RThink/Db/' . $adapter_name . '.php');
     return new $class_name($options);
 }
开发者ID:tomorrowdemo,项目名称:haojiaolexue,代码行数:16,代码来源:Db.php

示例2: __construct

 /**
  * Setup the config based on either the Configure::read() values
  * or the PaypalIpnConfig in config/paypal_ipn_config.php
  *
  * Will attempt to read configuration in the following order:
  *   Configure::read('PaypalIpn')
  *   App::import() of config/paypal_ipn_config.php
  *   App::import() of plugin's config/paypal_ipn_config.php
  */
 function __construct()
 {
     $this->config = Configure::read('PaypalIpn');
     if (empty($this->config)) {
         $importConfig = array('type' => 'File', 'name' => 'PaypalIpn.PaypalIpnConfig', 'file' => CONFIGS . 'paypal_ipn_config.php');
         if (!class_exists('PaypalIpnConfig')) {
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             // Import from paypal plugin configuration
             $importConfig['file'] = 'config' . DS . 'paypal_ipn_config.php';
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             trigger_error(__d('paypal_ipn', 'PaypalIpnConfig: The configuration could not be loaded.', true), E_USER_ERROR);
         }
         if (!PHP5) {
             $config =& new PaypalIpnConfig();
         } else {
             $config = new PaypalIpnConfig();
         }
         $vars = get_object_vars($config);
         foreach ($vars as $property => $configuration) {
             if (strpos($property, 'encryption_') === 0) {
                 $name = substr($property, 11);
                 $this->encryption[$name] = $configuration;
             } else {
                 $this->config[$property] = $configuration;
             }
         }
     }
     parent::__construct();
 }
开发者ID:ranium,项目名称:CakePHP-Paypal-IPN-Plugin,代码行数:42,代码来源:paypal.php

示例3: init

 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
  *
  * @param array $settings array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
 public function init($settings = array())
 {
     if (!class_exists('Memcache')) {
         return false;
     }
     if (!isset($settings['prefix'])) {
         $settings['prefix'] = Inflector::slug(APP_DIR) . '_';
     }
     $settings += array('engine' => 'Memcache', 'servers' => array('127.0.0.1'), 'compress' => false, 'persistent' => true);
     parent::init($settings);
     if ($this->settings['compress']) {
         $this->settings['compress'] = MEMCACHE_COMPRESSED;
     }
     if (is_string($this->settings['servers'])) {
         $this->settings['servers'] = array($this->settings['servers']);
     }
     if (!isset($this->_Memcache)) {
         $return = false;
         $this->_Memcache = new Memcache();
         foreach ($this->settings['servers'] as $server) {
             list($host, $port) = $this->_parseServerString($server);
             if ($this->_Memcache->addServer($host, $port, $this->settings['persistent'])) {
                 $return = true;
             }
         }
         return $return;
     }
     return true;
 }
开发者ID:4Queen,项目名称:php-buildpack,代码行数:38,代码来源:MemcacheEngine.php

示例4: __call

 public function __call($s_method_name, $arr_arguments)
 {
     if (!method_exists($this, $s_method_name)) {
         // если еще не имлементировали
         $s_match = "";
         $s_method_prefix = '';
         $s_method_base = '';
         $arr_matches = array();
         $bSucc = preg_match("/[A-Z_]/", $s_method_name, $arr_matches);
         if ($bSucc) {
             $s_match = $arr_matches[0];
             $i_match = strpos($s_method_name, $s_match);
             $s_method_prefix = substr($s_method_name, 0, $i_match) . "/";
             $s_method_base = substr($s_method_name, 0, $i_match + ($s_match === "_" ? 1 : 0));
         }
         $s_class_enter = "__" . $s_method_name;
         // метод, общий для всех режимов
         if (!class_exists($s_class_enter)) {
             $s_entermethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . ".lib.php";
             $this->__loadLib($s_entermethod_lib);
             $this->__implement($s_class_enter);
         }
         $s_class_mode = "__" . $s_method_name . "_";
         // метод, выбираемый в зависимости от режима
         if (!class_exists($s_class_mode)) {
             $s_modemethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . "_" . cmsController::getInstance()->getCurrentMode() . ".lib.php";
             $this->__loadLib($s_modemethod_lib);
             $this->__implement($s_class_mode);
         }
     }
     return parent::__call($s_method_name, $arr_arguments);
 }
开发者ID:tomoonshine,项目名称:postsms,代码行数:32,代码来源:class+из+content.php

示例5: create

 /**
  * Factory method that creates a cache object based on configuration
  * @param $name Name of definitions handled by cache
  * @param $config Instance of HTMLPurifier_Config
  */
 public function create($type, $config)
 {
     $method = $config->get('Cache', 'DefinitionImpl');
     if ($method === null) {
         return new HTMLPurifier_DefinitionCache_Null($type);
     }
     if (!empty($this->caches[$method][$type])) {
         return $this->caches[$method][$type];
     }
     if (isset($this->implementations[$method]) && class_exists($class = $this->implementations[$method], false)) {
         $cache = new $class($type);
     } else {
         if ($method != 'Serializer') {
             trigger_error("Unrecognized DefinitionCache {$method}, using Serializer instead", E_USER_WARNING);
         }
         $cache = new HTMLPurifier_DefinitionCache_Serializer($type);
     }
     foreach ($this->decorators as $decorator) {
         $new_cache = $decorator->decorate($cache);
         // prevent infinite recursion in PHP 4
         unset($cache);
         $cache = $new_cache;
     }
     $this->caches[$method][$type] = $cache;
     return $this->caches[$method][$type];
 }
开发者ID:seclabx,项目名称:xlabas,代码行数:31,代码来源:DefinitionCacheFactory.php

示例6: addComplexType

 /**
  * Add a complex type by recursivly using all the class properties fetched via Reflection.
  *
  * @param  string $type Name of the class to be specified
  * @return string XSD Type for the given PHP type
  */
 public function addComplexType($type)
 {
     if (!class_exists($type)) {
         throw new \Zend\Soap\WSDL\Exception(sprintf('Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type));
     }
     $dom = $this->getContext()->toDomDocument();
     $class = new \ReflectionClass($type);
     $complexType = $dom->createElement('xsd:complexType');
     $complexType->setAttribute('name', $type);
     $all = $dom->createElement('xsd:all');
     foreach ($class->getProperties() as $property) {
         if ($property->isPublic() && preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) {
             /**
              * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
              * node for describing other classes used as attribute types for current class
              */
             $element = $dom->createElement('xsd:element');
             $element->setAttribute('name', $property->getName());
             $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
             $all->appendChild($element);
         }
     }
     $complexType->appendChild($all);
     $this->getContext()->getSchema()->appendChild($complexType);
     $this->getContext()->addType($type);
     return "tns:{$type}";
 }
开发者ID:hjr3,项目名称:zf2,代码行数:33,代码来源:DefaultComplexType.php

示例7: tearDown

 /**
  * Run after the test.
  *
  * @return void
  */
 public function tearDown()
 {
     if (class_exists('Mockery')) {
         Mockery::close();
     }
     Container::getInstance()->flush();
 }
开发者ID:thirteen,项目名称:testbench,代码行数:12,代码来源:TestCase.php

示例8: plgAcymailingContentplugin

 function plgAcymailingContentplugin(&$subject, $config)
 {
     parent::__construct($subject, $config);
     if (!isset($this->params)) {
         $plugin = JPluginHelper::getPlugin('acymailing', 'contentplugin');
         $this->params = new acyParameter($plugin->params);
     }
     $this->paramsContent = JComponentHelper::getParams('com_content');
     JPluginHelper::importPlugin('content');
     $this->dispatcherContent = JDispatcher::getInstance();
     $excludedHandlers = array('plgContentEmailCloak', 'pluginImageShow');
     $excludedNames = array('system' => array('SEOGenerator', 'SEOSimple'), 'content' => array('webeecomment', 'highslide', 'smartresizer', 'phocagallery'));
     $excludedType = array_keys($excludedNames);
     if (!ACYMAILING_J16) {
         foreach ($this->dispatcherContent->_observers as $id => $observer) {
             if (is_array($observer) and in_array($observer['handler'], $excludedHandlers)) {
                 $this->dispatcherContent->_observers[$id]['event'] = '';
             } elseif (is_object($observer)) {
                 if (in_array($observer->_type, $excludedType) and in_array($observer->_name, $excludedNames[$observer->_type])) {
                     $this->dispatcherContent->_observers[$id] = null;
                 }
             }
         }
     }
     if (!class_exists('JSite')) {
         include_once ACYMAILING_ROOT . 'includes' . DS . 'application.php';
     }
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:28,代码来源:contentplugin.php

示例9: output

 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     //$inner = $data->parseVariables($this->rawOutput(), false);
     $tmp = new Pagemill_Stream(true);
     foreach ($this->children() as $child) {
         $child->process($data, $tmp);
     }
     $inner = html_entity_decode($tmp->peek(), ENT_COMPAT, 'UTF-8');
     $data->set('value', $inner);
     $use = $data->parseVariables($this->getAttribute('use'));
     if ($use) {
         // Use the requested editor if available
         if (class_exists($use)) {
             if (is_subclass_of($use, __CLASS__)) {
                 $sub = new $use($this->name(), $this->attributes(), $this, $this->docType());
                 $sub->output($data, $stream);
                 return;
             } else {
                 trigger_error("Requested editor class '{$cls}' does not appear to be an editor subclass.");
             }
         } else {
             trigger_error("Requested editor class '{$cls}' does not exist.");
         }
     }
     if (TYPEF_DEFAULT_EDITOR != '') {
         // Use the requested editor if available
         $use = TYPEF_DEFAULT_EDITOR;
         if (class_exists($use)) {
             if (is_subclass_of($use, __CLASS__)) {
                 $sub = new $use($this->name(), $this->attributes(), $this, $this->docType());
                 $sub->output($data, $stream);
                 return;
             } else {
                 trigger_error("Configured editor class '{$use}' does not appear to be an editor subclass.");
             }
         } else {
             trigger_error("Configured editor class '{$use}' does not exist.");
         }
     }
     // Use CKEditor if available
     if (class_exists('Typeframe_Tag_Editor_CkEditor')) {
         $sub = new Typeframe_Tag_Editor_CkEditor($this->name(), $this->attributes(), $this, $this->docType());
         $sub->process($data, $stream);
         return;
     }
     // No editor available. Use a plain textarea.
     $attribs = '';
     foreach ($this->attributes() as $k => $v) {
         if ($k != 'use') {
             $attribs .= " {$k}=\"" . $data->parseVariables($v) . "\"";
         }
     }
     if (!$this->getAttribute('cols')) {
         $attribs .= ' cols="80"';
     }
     if (!$this->getAttribute('rows')) {
         $attribs .= ' rows="25"';
     }
     $stream->puts("<textarea{$attribs}>" . $inner . "</textarea>");
 }
开发者ID:ssrsfs,项目名称:blg,代码行数:60,代码来源:Editor.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     if (!class_exists('Imagick')) {
         $this->markTestSkipped('Imagick is not installed');
     }
 }
开发者ID:noorafree,项目名称:makmakan,代码行数:7,代码来源:ImagineTest.php

示例11: DOMImplementation

 /**
  * Create a new XML document.
  * If $url is set, the DOCTYPE definition is treated as a PUBLIC
  * definition; $dtd should contain the ID, and $url should contain the
  * URL. Otherwise, $dtd should be the DTD name.
  */
 function &createDocument($type, $dtd, $url = null)
 {
     $version = '1.0';
     if (class_exists('DOMImplementation')) {
         // Use the new (PHP 5.x) DOM
         $impl =& new DOMImplementation();
         // only generate a DOCTYPE if type is non-empty
         if ($type != '') {
             $domdtd = $impl->createDocumentType($type, isset($url) ? $dtd : '', isset($url) ? $url : $dtd);
             $doc = $impl->createDocument($version, '', $domdtd);
         } else {
             $doc = $impl->createDocument($version, '');
         }
         // ensure we are outputting UTF-8
         $doc->encoding = 'UTF-8';
     } else {
         // Use the XMLNode class
         $doc =& new XMLNode();
         $doc->setAttribute('version', $version);
         $doc->setAttribute('type', $type);
         $doc->setAttribute('dtd', $dtd);
         $doc->setAttribute('url', $url);
     }
     return $doc;
 }
开发者ID:LiteratimBi,项目名称:jupitertfn,代码行数:31,代码来源:XMLCustomWriter.inc.php

示例12: factory

 /**
  * create a new adapter switch IDp name or ID
  *
  * @param string  $id      The id or name of the IDp
  * @param array   $params  (optional) required parameters by the adapter 
  */
 function factory($id, $params = NULL)
 {
     Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::factory( {$id} )");
     # init the adapter config and params
     $this->id = $id;
     $this->params = $params;
     $this->id = $this->getProviderCiId($this->id);
     $this->config = $this->getConfigById($this->id);
     # check the IDp id
     if (!$this->id) {
         throw new Exception("No provider ID specified.", 2);
     }
     # check the IDp config
     if (!$this->config) {
         throw new Exception("Unknown Provider ID, check your configuration file.", 3);
     }
     # check the IDp adapter is enabled
     if (!$this->config["enabled"]) {
         throw new Exception("The provider '{$this->id}' is not enabled.", 3);
     }
     # include the adapter wrapper
     if (isset($this->config["wrapper"]) && is_array($this->config["wrapper"])) {
         require_once $this->config["wrapper"]["path"];
         if (!class_exists($this->config["wrapper"]["class"])) {
             throw new Exception("Unable to load the adapter class.", 3);
         }
         $this->wrapper = $this->config["wrapper"]["class"];
     } else {
         require_once Hybrid_Auth::$config["path_providers"] . $this->id . ".php";
         $this->wrapper = "Hybrid_Providers_" . $this->id;
     }
     # create the adapter instance, and pass the current params and config
     $this->adapter = new $this->wrapper($this->id, $this->config, $this->params);
     return $this;
 }
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:41,代码来源:Provider_Adapter.php

示例13: getModelForBean

 public function getModelForBean(OODBBean $bean)
 {
     $model = $bean->getMeta("type");
     $prefix = $this->defaultNamespace;
     $typeMap = $this->typeMap;
     if (isset($typeMap[$model])) {
         $modelName = $typeMap[$model];
     } else {
         if (strpos($model, '_') !== FALSE) {
             $modelParts = explode('_', $model);
             $modelName = '';
             foreach ($modelParts as $part) {
                 $modelName .= ucfirst($part);
             }
             $modelName = $prefix . $modelName;
             if (!class_exists($modelName)) {
                 //second try
                 $modelName = $prefix . ucfirst($model);
                 if (!class_exists($modelName)) {
                     return NULL;
                 }
             }
         } else {
             $modelName = $prefix . ucfirst($model);
             if (!class_exists($modelName)) {
                 return NULL;
             }
         }
     }
     $obj = self::factory($modelName);
     $obj->loadBean($bean);
     return $obj;
 }
开发者ID:MhmdLab,项目名称:redbean-slim,代码行数:33,代码来源:RedBeanHelper.php

示例14: create

 private static function create($str, $type)
 {
     if (!class_exists($type)) {
         throw new PPP_Token_UnrecognizedTokenException($type);
     }
     return new $type($str);
 }
开发者ID:russpos,项目名称:ppp,代码行数:7,代码来源:tokens.php

示例15: controller_render

function controller_render($name, $action)
{
    if (!$name) {
        $name = 'default';
    }
    $name = strtolower($name);
    $ret = preg_match('/(^[a-z][a-z]*?[a-z]$)/', $name);
    if ($ret <= 0) {
        return '控制器名称非法' . $ret . $name;
    }
    $path = _ROOT . 'controller/' . $name . '.php';
    if (!file_exists($path)) {
        return '控制器不存在';
    }
    include_once $path;
    $classname = $name . 'Controller';
    if (!class_exists($classname)) {
        return '控制器声明不完全';
    }
    $o = new $classname();
    if (!method_exists($o, 'render')) {
        return '控制器未继承BaseController::Render';
    }
    define('BASE_CONTROLLER', $name);
    return call_user_method('render', $o, $action);
}
开发者ID:jjvein,项目名称:my_php_framework,代码行数:26,代码来源:controller.php


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