• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP method_exists函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __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


示例2: __get

 public function __get($name)
 {
     $method = 'get' . ucfirst($name);
     if (method_exists($this, $method)) {
         return $this->{$method}();
     }
 }
开发者ID:Antoine07,项目名称:AppFromScratch,代码行数:7,代码来源:Product.php


示例3: setValue

 /**
  * Sets selected items (by keys).
  * @param  array
  * @return self
  */
 public function setValue($values)
 {
     if (is_scalar($values) || $values === NULL) {
         $values = (array) $values;
     } elseif (!is_array($values)) {
         throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name));
     }
     $flip = [];
     foreach ($values as $value) {
         if (!is_scalar($value) && !method_exists($value, '__toString')) {
             throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name));
         }
         $flip[(string) $value] = TRUE;
     }
     $values = array_keys($flip);
     if ($this->checkAllowedValues && ($diff = array_diff($values, array_keys($this->items)))) {
         $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) {
             return var_export($s, TRUE);
         }, array_keys($this->items))), 70, '...');
         $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'";
         throw new Nette\InvalidArgumentException("Value{$vals} are out of allowed set [{$set}] in field '{$this->name}'.");
     }
     $this->value = $values;
     return $this;
 }
开发者ID:jjanekk,项目名称:forms,代码行数:30,代码来源:MultiChoiceControl.php


示例4: load

 public function load(TemplateReferenceInterface $template)
 {
     if (method_exists($this, $method = 'get' . ucfirst($template->get('name')) . 'Template')) {
         return new StringStorage($this->{$method}());
     }
     return false;
 }
开发者ID:symfony,项目名称:symfony,代码行数:7,代码来源:CacheLoaderTest.php


示例5: pipe

 /**
  * Add middleware to the pipe-line. Please note that middleware's will
  * be called in the order they are added.
  *
  * A middleware CAN implement the Middleware Interface, but MUST be
  * callable. A middleware WILL be called with three parameters:
  * Request, Response and Next.
  *
  * @throws \RuntimeException when adding middleware to the stack to late
  * @param callable $middleware
  */
 public function pipe(callable $middleware)
 {
     // Check if the pipeline is locked
     if ($this->locked) {
         throw new \RuntimeException('Middleware can’t be added once the stack is dequeuing');
     }
     // Inject the dependency injection container
     if (method_exists($middleware, 'setContainer') && $this->container !== null) {
         $middleware->setContainer($this->container);
     }
     // Force serializers to register mime types
     if ($middleware instanceof SerializerMiddleware) {
         $middleware->registerMimeTypes();
     }
     // Add the middleware to the queue
     $this->queue->enqueue($middleware);
     // Check if middleware should be added to the error queue
     if (!$this->errorQueueLocked) {
         $this->errorQueue->enqueue($middleware);
         // Check if we should lock the error queue
         if ($middleware instanceof ErrorMiddleware) {
             $this->errorQueueLocked = true;
         }
     }
 }
开发者ID:phapi,项目名称:pipeline,代码行数:36,代码来源:Pipeline.php


示例6: validateString

 /**
  * validate a string
  *
  * @param mixed $str the value to evaluate as a string
  *
  * @throws \InvalidArgumentException if the submitted data can not be converted to string
  *
  * @return string
  */
 protected function validateString($str)
 {
     if (is_object($str) && method_exists($str, '__toString') || is_string($str)) {
         return trim($str);
     }
     throw new InvalidArgumentException('The data received is not OR can not be converted into a string');
 }
开发者ID:KorvinSzanto,项目名称:uri,代码行数:16,代码来源:ImmutableComponentTrait.php


示例7: __call

 public function __call($func, $args)
 {
     $connectionObj = $this->connections[$this->defaultConnection];
     if (method_exists($connectionObj, $func)) {
         call_user_func_array([$connectionObj, $func], $args);
     }
 }
开发者ID:jimbojsb,项目名称:dolphin,代码行数:7,代码来源:ConnectionManager.php


示例8: createLinks

 /**
  * Create the links for resources in the resource root
  * @return array the links, name => config
  */
 protected function createLinks()
 {
     $app = \Yii::app();
     /* @var \Restyii\Web\Application $app */
     $controller = $this->getController();
     $module = $controller->getModule();
     if (!$module) {
         $module = $app;
     }
     $controllers = $app->getSchema()->getControllerInstances($module);
     /* @var \Restyii\Controller\Base[]|\CController[] $controllers */
     $links = array('self' => array('title' => $module->name, 'href' => trim($app->getBaseUrl(), '/') . '/'));
     foreach ($controllers as $id => $controller) {
         if ($id === $module->defaultController) {
             continue;
         }
         $links[$id] = array('title' => method_exists($controller, 'classLabel') ? $controller->classLabel(true) : String::pluralize(String::humanize(substr(get_class($controller), 0, -10))), 'href' => $controller->createUrl('search'));
         if (method_exists($controller, 'classDescription')) {
             $links[$id]['description'] = $controller->classDescription();
         }
         if (isset($controller->modelClass)) {
             $links[$id]['profile'] = array($controller->modelClass);
         }
     }
     return $links;
 }
开发者ID:codemix,项目名称:restyii,代码行数:30,代码来源:Index.php


示例9: parse

 static function parse($args)
 {
     $method = strtolower(@$args[1]);
     $string = @$args[0];
     if (empty($string)) {
         return false;
     }
     if (!method_exists('kirbytext', $method)) {
         return $string;
     }
     $replace = array('(', ')');
     $string = str_replace($replace, '', $string);
     $attr = array_merge(self::$tags, self::$attr);
     $search = preg_split('!(' . implode('|', $attr) . '):!i', $string, false, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     $result = array();
     $num = 0;
     foreach ($search as $key) {
         if (!isset($search[$num + 1])) {
             break;
         }
         $key = trim($search[$num]);
         $value = trim($search[$num + 1]);
         $result[$key] = $value;
         $num = $num + 2;
     }
     return self::$method($result);
 }
开发者ID:robeam,项目名称:kirbycms,代码行数:27,代码来源:kirbytext.php


示例10: __construct

 /**
  * Make a new experiment with given variants
  *
  * @since 0.1.0
  *
  * @param array $variants
  * @param int|string $id Experiment (group) ID
  * @param \MaBandit\MaBandit $bandit MaBandit object
  */
 public function __construct(array $variants, $id, \MaBandit\MaBandit $bandit)
 {
     $this->experiment = $bandit->createExperiment((string) $id, $variants);
     if (method_exists($bandit->getPersistor(), 'save_levers')) {
         $bandit->getPersistor()->batchSave($this->experiment->getLevers(), $id);
     }
 }
开发者ID:Ingothq,项目名称:multiarmedbandit,代码行数:16,代码来源:CreateExperiment.php


示例11: displayLayout

	function displayLayout($layout=null, $tpl = null) {
		if ($layout) $this->setLayout ($layout);
		$viewName = ucfirst($this->getName ());
		$layoutName = ucfirst($this->getLayout ());

		KUNENA_PROFILER ? $this->profiler->start("display {$viewName}/{$layoutName}") : null;

		if (isset($this->common)) {
			if ($this->config->board_offline && ! $this->me->isAdmin ()) {
				// Forum is offline
				$this->common->header = JText::_('COM_KUNENA_FORUM_IS_OFFLINE');
				$this->common->body = $this->config->offline_message;
				$this->common->display('default');
				KUNENA_PROFILER ? $this->profiler->start("display {$viewName}/{$layoutName}") : null;
				return;
			} elseif ($this->config->regonly && ! $this->me->exists()) {
				// Forum is for registered users only
				$this->common->header = JText::_('COM_KUNENA_LOGIN_NOTIFICATION');
				$this->common->body = JText::_('COM_KUNENA_LOGIN_FORUM');
				$this->common->display('default');
				KUNENA_PROFILER ? $this->profiler->start("display {$viewName}/{$layoutName}") : null;
				return;
			}
		}

		$this->assignRef ( 'state', $this->get ( 'State' ) );
		$layoutFunction = 'display'.$layoutName;
		if (method_exists($this, $layoutFunction)) {
			$contents = $this->$layoutFunction ($tpl);
		} else {
			$contents = $this->display($tpl);
		}
		KUNENA_PROFILER ? $this->profiler->stop("display {$viewName}/{$layoutName}") : null;
		return $contents;
	}
开发者ID:rich20,项目名称:Kunena,代码行数:35,代码来源:view.php


示例12: testGenerator

 public function testGenerator()
 {
     /** @var OpsWay\Test2\Solid\I $generator */
     $generator = OpsWay\Test2\Solid\Factory::create('i');
     $generator->generate();
     $this->assertFileExists($file = __DIR__ . '/../../test/I/IGeometric.php');
     include $file;
     $this->assertTrue(interface_exists('IGeometric'));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/IAngular.php');
     include $file;
     $this->assertTrue(interface_exists('IAngular'));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/ISquarable.php');
     include $file;
     $this->assertTrue(interface_exists('ISquarable'));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/Square.php');
     include $file;
     $this->assertTrue(class_exists('Square'));
     $this->assertTrue(in_array('IGeometric', class_implements('Square')));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/Circle.php');
     include $file;
     $this->assertTrue(class_exists('Circle'));
     $this->assertTrue(in_array('IGeometric', class_implements('Circle')));
     $this->assertTrue(method_exists('IGeometric', 'square'));
     $this->assertTrue(method_exists('ISquarable', 'square'));
     $this->assertTrue(method_exists('IAngular', 'countAngles'));
 }
开发者ID:kokareff,项目名称:hr-test-2,代码行数:26,代码来源:Test_Generator_I.php


示例13: __construct

 /**
  * Constructor.
  *
  * @param callable|object $classLoader Passing an object is @deprecated since version 2.5 and support for it will be removed in 3.0
  */
 public function __construct($classLoader)
 {
     $this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile');
     if ($this->wasFinder) {
         @trigger_error('The ' . __METHOD__ . ' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
         $this->classLoader = array($classLoader, 'loadClass');
         $this->isFinder = true;
     } else {
         $this->classLoader = $classLoader;
         $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile');
     }
     if (!isset(self::$caseCheck)) {
         $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), DIRECTORY_SEPARATOR);
         $i = strrpos($file, DIRECTORY_SEPARATOR);
         $dir = substr($file, 0, 1 + $i);
         $file = substr($file, 1 + $i);
         $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
         $test = realpath($dir . $test);
         if (false === $test || false === $i) {
             // filesystem is case sensitive
             self::$caseCheck = 0;
         } elseif (substr($test, -strlen($file)) === $file) {
             // filesystem is case insensitive and realpath() normalizes the case of characters
             self::$caseCheck = 1;
         } elseif (false !== stripos(PHP_OS, 'darwin')) {
             // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters
             self::$caseCheck = 2;
         } else {
             // filesystem case checks failed, fallback to disabling them
             self::$caseCheck = 0;
         }
     }
 }
开发者ID:phantsang,项目名称:8csfOIjOaJSlDG2Y3x992O,代码行数:38,代码来源:DebugClassLoader.php


示例14: render

 /**
  * Render captcha
  *
  * @param string $content
  *
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     if (!method_exists($element, 'getCaptcha')) {
         return $content;
     }
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $placement = $this->getPlacement();
     $separator = $this->getSeparator();
     /** @var \Zend_Captcha_Adapter $captcha */
     $captcha = $element->getCaptcha();
     $markup = '<label>' . $captcha->render($view) . '</label>';
     switch ($placement) {
         case 'PREPEND':
             $content = $markup . $separator . $content;
             break;
         case 'APPEND':
         default:
             $content = $content . $separator . $markup;
             break;
     }
     return $content;
 }
开发者ID:tavy315,项目名称:twitter-bootstrap-zend-form-decorator,代码行数:33,代码来源:Captcha.php


示例15: processAPI

 public function processAPI()
 {
     if (method_exists($this, $this->endpoint)) {
         return $this->_response($this->{$this->endpoint}($this->args));
     }
     return $this->_response("No Endpoint: {$this->endpoint}", 404);
 }
开发者ID:paul-arockiyam,项目名称:PHP-REST-API,代码行数:7,代码来源:API.class.php


示例16: act

 /**
  * All handlers must implement act() to conform to handler API.
  * This is the default implementation of act(), which attempts
  * to call a class member method of $this->act_$action().  Any
  * subclass is welcome to override this default implementation.
  *
  * @param string $action the action that was in the URL rule
  */
 public function act($action)
 {
     if (null === $this->handler_vars) {
         $this->handler_vars = new SuperGlobal(array());
     }
     $this->action = $action;
     $action_method = 'act_' . $action;
     $before_action_method = 'before_' . $action_method;
     $after_action_method = 'after_' . $action_method;
     if (method_exists($this, $action_method)) {
         if (method_exists($this, $before_action_method)) {
             $this->{$before_action_method}();
         }
         /**
          * Plugin action to allow plugins to execute before a certain
          * action is triggered
          *
          * @see ActionHandler::$action
          * @action before_act_{$action}
          */
         Plugins::act($before_action_method, $this);
         $this->{$action_method}();
         /**
          * Plugin action to allow plugins to execute after a certain
          * action is triggered
          *
          * @see ActionHandler::$action
          * @action before_act_{$action}
          */
         Plugins::act($after_action_method);
         if (method_exists($this, $after_action_method)) {
             $this->{$after_action_method}();
         }
     }
 }
开发者ID:anupom,项目名称:my-blog,代码行数:43,代码来源:actionhandler.php


示例17: makeApiCall

 /**
  * Execute API Call
  *
  * @param   string $apiCall    API Call
  * @param   string $method     Http Method
  * @param   array  $parameters API call parameters
  *
  * @return array
  */
 public static function makeApiCall($apiCall, $method = 'GET', $parameters = array())
 {
     self::getHttp();
     $apiEndpoint = NenoSettings::get('api_server_url');
     $licenseCode = NenoSettings::get('license_code');
     $response = null;
     $responseStatus = false;
     if (!empty($apiEndpoint) && !empty($licenseCode)) {
         $method = strtolower($method);
         if (method_exists(self::$httpClient, $method)) {
             if ($method === 'get') {
                 if (!empty($parameters)) {
                     $query = implode('/', $parameters);
                     $apiCall = $apiCall . '/' . $query;
                 }
                 $apiResponse = self::$httpClient->{$method}($apiEndpoint . $apiCall, array('Authorization' => $licenseCode));
             } else {
                 $apiResponse = self::$httpClient->{$method}($apiEndpoint . $apiCall, json_encode($parameters), array('Content-Type' => 'application/json', 'Authorization' => $licenseCode));
             }
             /* @var $apiResponse JHttpResponse */
             $data = $apiResponse->body;
             if ($apiResponse->headers['Content-Type'] === 'application/json') {
                 $data = json_decode($data, true);
             }
             $response = $data;
             if ($apiResponse->code == 200) {
                 $responseStatus = true;
             }
         }
     }
     return array($responseStatus, $response);
 }
开发者ID:andresmaeso,项目名称:neno,代码行数:41,代码来源:api.php


示例18: success

 public function success($response)
 {
     $pq = phpQuery::newDocument($response);
     foreach ($this->calls as $k => $r) {
         // check if method exists
         if (!method_exists(get_class($pq), $r['method'])) {
             throw new Exception("Method '{$r['method']}' not implemented in phpQuery, sorry...");
             // execute method
         } else {
             $pq = call_user_func_array(array($pq, $r['method']), $r['arguments']);
         }
     }
     if (!isset($this->options['dataType'])) {
         $this->options['dataType'] = '';
     }
     switch (strtolower($this->options['dataType'])) {
         case 'json':
             if ($pq instanceof PHPQUERYOBJECT) {
                 $results = array();
                 foreach ($pq as $node) {
                     $results[] = pq($node)->htmlOuter();
                 }
                 print phpQuery::toJSON($results);
             } else {
                 print phpQuery::toJSON($pq);
             }
             break;
         default:
             print $pq;
     }
     // output results
 }
开发者ID:AloneFallen,项目名称:phpquery,代码行数:32,代码来源:jQueryServer.php


示例19: __construct

 /**
  * Constructor
  * 
  * @param  Adapter $adapter
  * @param  array $data 
  * @return void
  */
 public function __construct($adapter, $data = null)
 {
     if (!$adapter instanceof Zend_Cloud_Infrastructure_Adapter) {
         #require_once 'Zend/Cloud/Infrastructure/Exception.php';
         throw new Zend_Cloud_Infrastructure_Exception("You must pass a Zend_Cloud_Infrastructure_Adapter instance");
     }
     if (is_object($data)) {
         if (method_exists($data, 'toArray')) {
             $data = $data->toArray();
         } elseif ($data instanceof Traversable) {
             $data = iterator_to_array($data);
         }
     }
     if (empty($data) || !is_array($data)) {
         #require_once 'Zend/Cloud/Infrastructure/Exception.php';
         throw new Zend_Cloud_Infrastructure_Exception("You must pass an array of parameters");
     }
     foreach ($this->attributeRequired as $key) {
         if (empty($data[$key])) {
             #require_once 'Zend/Cloud/Infrastructure/Exception.php';
             throw new Zend_Cloud_Infrastructure_Exception(sprintf('The param "%s" is a required param for %s', $key, __CLASS__));
         }
     }
     $this->adapter = $adapter;
     $this->attributes = $data;
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:33,代码来源:Instance.php


示例20: getClass

 /**
  * @param string $class_name
  */
 protected function getClass($class_name, $subclass_of = 'Cyan\\Framework\\Controller', array $arguments = [], \Closure $newInstance = null)
 {
     $required_traits = ['Cyan\\Framework\\TraitSingleton'];
     $reflection_class = new ReflectionClass($class_name);
     foreach ($required_traits as $required_trait) {
         if (!in_array($required_trait, $reflection_class->getTraitNames())) {
             throw new TraitException(sprintf('%s class must use %s', $class_name, $required_trait));
         }
     }
     if (!is_subclass_of($class_name, $subclass_of)) {
         throw new TraitException(sprintf('%s class must be a instance of %s', $class_name, $subclass_of));
     }
     if (is_callable($newInstance)) {
         $instance = call_user_func_array($newInstance, $arguments);
     } else {
         $instance = !empty($arguments) ? call_user_func_array([$class_name, 'getInstance'], $arguments) : $class_name::getInstance();
     }
     if ($this->hasContainer('application')) {
         if (!$instance->hasContainer('application')) {
             $instance->setContainer('application', $this->getContainer('application'));
         }
         if (!$instance->hasContainer('factory_plugin')) {
             $instance->setContainer('factory_plugin', $this->getContainer('application')->getContainer('factory_plugin'));
         }
     }
     if (is_callable([$instance, 'initialize']) || method_exists($instance, 'initialize')) {
         $instance->initialize();
     }
     return $instance;
 }
开发者ID:cyan-framework,项目名称:cms,代码行数:33,代码来源:class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP method_is函数代码示例发布时间:2022-05-15
下一篇:
PHP method函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap