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

PHP get_resource_type函数代码示例

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

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



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

示例1: getExceptionTraceAsString

 /**
  * @param \Exception $exception
  * @return string
  * @todo Fix this to get full stack trace
  */
 public static function getExceptionTraceAsString(\Exception $exception)
 {
     $ret = "";
     $count = 0;
     foreach ($exception->getTrace() as $trace) {
         $args = "";
         if (isset($trace['args'])) {
             $args = array();
             foreach ($trace['args'] as $arg) {
                 if (is_string($arg)) {
                     $args[] = "'" . $arg . "'";
                 } elseif (is_array($arg)) {
                     $args[] = "Array";
                 } elseif (is_null($arg)) {
                     $args[] = 'NULL';
                 } elseif (is_bool($arg)) {
                     $args[] = $arg ? "true" : "false";
                 } elseif (is_object($arg)) {
                     $args[] = get_class($arg);
                 } elseif (is_resource($arg)) {
                     $args[] = get_resource_type($arg);
                 } else {
                     $args[] = $arg;
                 }
             }
             $args = join(", ", $args);
         }
         $ret .= sprintf("#%s %s(%s): %s(%s)\n", $count, isset($trace['file']) ? $trace['file'] : 'unknown file', isset($trace['line']) ? $trace['line'] : 'unknown line', isset($trace['class']) ? $trace['class'] . $trace['type'] . $trace['function'] : $trace['function'], $args);
         $count++;
     }
     return $ret;
 }
开发者ID:jakubpas,项目名称:error-exception,代码行数:37,代码来源:Handler.php


示例2: __construct

 /**
  * Class Constructor
  *
  * @param array|string|resource $streamOrUrl Stream or URL to open as a stream
  * @param string|null $mode Mode, only applicable if a URL is given
  * @return void
  * @throws Zend_Log_Exception
  */
 public function __construct($streamOrUrl, $mode = null)
 {
     // Setting the default
     if (null === $mode) {
         $mode = 'a';
     }
     if (is_resource($streamOrUrl)) {
         if (get_resource_type($streamOrUrl) != 'stream') {
             // require_once 'Zend/Log/Exception.php';
             throw new Zend_Log_Exception('Resource is not a stream');
         }
         if ($mode != 'a') {
             // require_once 'Zend/Log/Exception.php';
             throw new Zend_Log_Exception('Mode cannot be changed on existing streams');
         }
         $this->_stream = $streamOrUrl;
     } else {
         if (is_array($streamOrUrl) && isset($streamOrUrl['stream'])) {
             $streamOrUrl = $streamOrUrl['stream'];
         }
         if (!($this->_stream = @fopen($streamOrUrl, $mode, false))) {
             // require_once 'Zend/Log/Exception.php';
             $msg = "\"{$streamOrUrl}\" cannot be opened with mode \"{$mode}\"";
             throw new Zend_Log_Exception($msg);
         }
     }
     $this->_formatter = new Zend_Log_Formatter_Simple();
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:36,代码来源:Stream.php


示例3: printParams

 public static function printParams($params, $glue = ',')
 {
     $res = '';
     if (count($params)) {
         foreach ($params as $val) {
             if (is_string($val)) {
                 $val = sprintf('\'%s\'', $val);
             } else {
                 if (is_int($val) || is_float($val)) {
                     null;
                 } else {
                     if (is_bool($val)) {
                         $val = $val ? 'true' : 'false';
                     } else {
                         if (is_array($val)) {
                             $val = sprintf('array:%s', json_encode($val, JSON_UNESCAPED_UNICODE));
                         } else {
                             if (is_object($val)) {
                                 $val = sprintf('[object]%s:%s', get_class($val), json_encode($val, JSON_UNESCAPED_UNICODE));
                             } else {
                                 if (is_resource($val)) {
                                     $val = sprintf('[resource]%s', get_resource_type($val));
                                 } else {
                                     $val = 'other';
                                 }
                             }
                         }
                     }
                 }
             }
             $res .= $glue . ' ' . strval($val);
         }
     }
     return substr($res, 2);
 }
开发者ID:hzh123,项目名称:my_yaf,代码行数:35,代码来源:String.php


示例4: varToString

 private function varToString($var)
 {
     if (is_object($var)) {
         return sprintf('Object(%s)', get_class($var));
     }
     if (is_array($var)) {
         $a = array();
         foreach ($var as $k => $v) {
             $a[] = sprintf('%s => %s', $k, $this->varToString($v));
         }
         return sprintf('Array(%s)', implode(', ', $a));
     }
     if (is_resource($var)) {
         return sprintf('Resource(%s)', get_resource_type($var));
     }
     if (null === $var) {
         return 'null';
     }
     if (false === $var) {
         return 'false';
     }
     if (true === $var) {
         return 'true';
     }
     return (string) $var;
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:26,代码来源:FilterControllerEvent.php


示例5: Open

 function Open($ArchFile, $UseIncludePath = false)
 {
     // Open the zip archive
     if (!isset($this->Meth8Ok)) {
         $this->__construct();
     }
     // for PHP 4 compatibility
     $this->Close();
     // close handle and init info
     $this->Error = false;
     $this->ArchIsNew = false;
     $this->ArchIsStream = is_resource($ArchFile) && get_resource_type($ArchFile) == 'stream';
     if ($this->ArchIsStream) {
         $this->ArchFile = 'from_stream.zip';
         $this->ArchHnd = $ArchFile;
     } else {
         // open the file
         $this->ArchFile = $ArchFile;
         $this->ArchHnd = fopen($ArchFile, 'rb', $UseIncludePath);
     }
     $ok = !($this->ArchHnd === false);
     if ($ok) {
         $ok = $this->CentralDirRead();
     }
     return $ok;
 }
开发者ID:seblangis,项目名称:DocxMerge,代码行数:26,代码来源:TbsZip.php


示例6: serializeValue

 public static function serializeValue($value)
 {
     if ($value === null) {
         return 'null';
     } elseif ($value === false) {
         return 'false';
     } elseif ($value === true) {
         return 'true';
     } elseif (is_float($value) && (int) $value == $value) {
         return $value . '.0';
     } elseif (is_object($value) || gettype($value) == 'object') {
         return 'Object ' . get_class($value);
     } elseif (is_resource($value)) {
         return 'Resource ' . get_resource_type($value);
     } elseif (is_array($value)) {
         return 'Array of length ' . count($value);
     } elseif (is_integer($value)) {
         return (int) $value;
     } else {
         $value = (string) $value;
         if (function_exists('mb_convert_encoding')) {
             $value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
         }
         return $value;
     }
 }
开发者ID:dparks-seattletimes,项目名称:openworldstudios,代码行数:26,代码来源:Serializer.php


示例7: emit

 public function emit($cycle, $r = null)
 {
     $writer = $cycle->writer() ? $cycle->writer() : $cycle();
     if ($r) {
         if (is_callable($r)) {
             $r = $r();
         }
         if (is_resource($r) and get_resource_type($r) == 'stream') {
             //flush header
             $writer();
             $stream = $cycle->response()->getBody()->detach();
             stream_copy_to_stream($r, $stream);
             $cycle->response()->getBody()->attach($stream);
         } elseif (is_array($r) or $r instanceof \Traversable or $r instanceof \Generator) {
             foreach ($r as $part) {
                 $writer($part);
             }
         } else {
             $writer((string) $r);
         }
     } else {
         //flush if not
         $writer();
     }
 }
开发者ID:chuchiy,项目名称:phpex,代码行数:25,代码来源:Pex.php


示例8: spy

function spy($x)
{
    switch (1) {
        case is_string($x):
            return '"' . $x . '"';
        case is_numeric($x):
            return $x;
        case is_null($x):
            return 'NULL';
        case is_bool($x):
            return $x ? 'TRUE' : 'FALSE';
        case is_resource($x):
            return '(' . get_resource_type($x) . ')' . "{$x}";
        case is_object($x):
            return get_class($x);
        case is_array($x):
            break;
        case is_scalar($x):
        default:
            return "{$x}";
    }
    switch (count($x)) {
        case 0:
            return '[]';
        case 1:
            return '[' . spy(array_first_key($x)) . ' => ' . spy(array_pop($x)) . ']';
        case 2:
            return '[' . spy(array_first_key($x)) . ' => ' . spy(array_shift($x)) . ', ' . spy(array_last_key($x)) . ' => ' . spy(array_pop($x)) . ']';
        default:
            return '[' . spy(array_first_key($x)) . ' => ' . spy(array_shift($x)) . ', ..., ' . spy(array_last_key($x)) . ' => ' . spy(array_pop($x)) . ']';
    }
    trigger_error('Something terrible has happened.');
}
开发者ID:bonniebo421,项目名称:rockhall,代码行数:33,代码来源:functions.php


示例9: __construct

 /**
  * Constructor...
  *
  * @param Resource $result The SQLite result resource
  */
 public function __construct($result)
 {
     if (!is_resource($result) || get_resource_type($result) != 'sqlite result') {
         throw new \r8\Exception\Argument(0, "Result Resource", "Must be a SQLite Result resource");
     }
     $this->result = $result;
 }
开发者ID:Nycto,项目名称:Round-Eights,代码行数:12,代码来源:Result.php


示例10: __construct

 /**
  * Creates a new stream.
  *
  * @param stream $stream
  */
 public function __construct($stream)
 {
     if (!is_resource($stream) || get_resource_type($stream) !== 'stream') {
         throw new \RuntimeException(self::class . '::__construct($stream) expects a stream as the first argument!');
     }
     $this->stream = $stream;
 }
开发者ID:crystalplanet,项目名称:redshift,代码行数:12,代码来源:Stream.php


示例11: setTimeout

 public function setTimeout($timeout)
 {
     $this->options['timeout'] = $timeout;
     if ($this->socket && get_resource_type($this->socket) === 'stream') {
         stream_set_timeout($this->socket, $timeout);
     }
 }
开发者ID:sjw-github,项目名称:lib,代码行数:7,代码来源:base2.php


示例12: __construct

 public function __construct($value, $class = '')
 {
     $this->class = $class;
     $this->value = $value;
     switch (gettype($value)) {
         case 'object':
             $this->type = self::TYPE_OBJECT;
             $this->class = get_class($value);
             $this->cut = -1;
             break;
         case 'array':
             $this->type = self::TYPE_ARRAY;
             $this->class = self::ARRAY_ASSOC;
             $this->cut = $this->value = count($value);
             break;
         case 'resource':
         case 'unknown type':
             $this->type = self::TYPE_RESOURCE;
             $this->class = @get_resource_type($value);
             $this->cut = -1;
             break;
         case 'string':
             if ('' === $class) {
                 $this->type = self::TYPE_STRING;
                 $this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY;
                 $this->cut = self::STRING_BINARY === $this->class ? strlen($value) : (function_exists('iconv_strlen') ? iconv_strlen($value, 'UTF-8') : -1);
                 $this->value = '';
             }
             break;
     }
 }
开发者ID:vomasmic,项目名称:symfony,代码行数:31,代码来源:CasterStub.php


示例13: __construct

 /**
  * The constructor
  * @param resource $socket a valid socket resource
  * @throws \InvalidArgumentException
  */
 public function __construct($socket)
 {
     if (!is_resource($socket) && strtolower(@get_resource_type($socket)) != 'socket') {
         throw new \InvalidArgumentException('Socket resource is required!');
     }
     $this->socket = $socket;
 }
开发者ID:KevenLibcast,项目名称:WorkerPool,代码行数:12,代码来源:SimpleSocket.php


示例14: __construct

 function __construct()
 {
     /**
      * The constructor can either be called with an existing database handle
      * or a set of four parameters to use with mysqli_[p]connect():
      *
      * $db = new DB_MySQL($my_existing_mysqli_link_handle);
      *
      * or
      *
      * $db = new DB_MySQL("localhost", "my_db", "db_user", "db_password");
      *
      */
     switch (func_num_args()) {
         case 1:
             $h = func_get_arg(0);
             // Make sure what we got really is a mysql link
             assert(is_resource($h));
             $t = get_resource_type($h);
             if ($t == "mysql link") {
                 $this->isPersistent = false;
             } elseif ($t == "mysql link persistent") {
                 $this->isPersistent = true;
             } else {
                 trigger_error(__CLASS__ . "::" . __FUNCTION__ . "() Passed handle isn't a mysql connection - it's a {$t} resource!", E_USER_ERROR);
             }
             $this->Handle = $t;
             return;
         case 4:
             list($this->Server, $this->Database, $this->Username, $this->Password) = func_get_args();
             break;
         default:
             trigger_error(__CLASS__ . "::" . __FUNCTION__ . "() called with " . func_num_args() . " arguments - it should be called with either 1 (a mysql connection handle) or 4 (the server, db_name, user, and password to connect with)", E_USER_ERROR);
     }
 }
开发者ID:acdha,项目名称:impphp,代码行数:35,代码来源:DB_MySQL.php


示例15: is_ref

 public static function is_ref(&$arg1, &$arg2)
 {
     if (!self::is_same($arg1, $arg2)) {
         return false;
     }
     $same = false;
     if (is_array($arg1)) {
         do {
             $key = uniqid("is_ref_", true);
         } while (array_key_exists($key, $arg1));
         if (array_key_exists($key, $arg2)) {
             return false;
         }
         $data = uniqid('is_ref_data_', true);
         $arg1[$key] =& $data;
         if (array_key_exists($key, $arg2)) {
             if ($arg2[$key] === $data) {
                 $same = true;
             }
         }
         unset($arg1[$key]);
     } elseif (is_object($arg1)) {
         if (get_class($arg1) !== get_class($arg2)) {
             return false;
         }
         $obj1 = array_keys(get_object_vars($arg1));
         $obj2 = array_keys(get_object_vars($arg2));
         do {
             $key = uniqid('is_ref_', true);
         } while (in_array($key, $obj1));
         if (in_array($key, $obj2)) {
             return false;
         }
         $data = uniqid('is_ref_data_', true);
         $arg1->{$key} =& $data;
         if (isset($arg2->{$key})) {
             if ($arg2->{$key} === $data) {
                 $same = true;
             }
         }
         unset($arg1->{$key});
     } elseif (is_resource($arg1)) {
         if (get_resource_type($arg1) !== get_resource_type($arg2)) {
             return false;
         }
         return (string) $arg1 === (string) $arg2;
     } else {
         if ($arg1 !== $arg2) {
             return false;
         }
         do {
             $key = uniqid('is_ref_', true);
         } while ($key === $arg1);
         $tmp = $arg1;
         $arg1 = $key;
         $same = $arg1 === $arg2;
         $arg1 = $tmp;
     }
     return $same;
 }
开发者ID:xpence,项目名称:portfolio,代码行数:60,代码来源:XLib.php


示例16: __construct

 /**
  * @since 1.0
  *
  * @param resource $handle
  */
 public function __construct($handle)
 {
     if (get_resource_type($handle) !== 'curl') {
         throw new InvalidArgumentException("Expected a cURL resource type");
     }
     $this->handle = $handle;
 }
开发者ID:JeroenDeDauw,项目名称:http-request,代码行数:12,代码来源:CurlRequest.php


示例17: flatten

 /**
  * Normalize all non-scalar data types (except null) in a string value
  *
  * @param mixed $value
  * @return mixed
  */
 protected function flatten($value)
 {
     if (is_scalar($value) || null === $value) {
         return $value;
     }
     // better readable JSON
     static $jsonFlags;
     if ($jsonFlags === null) {
         $jsonFlags = 0;
         $jsonFlags |= defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0;
         $jsonFlags |= defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0;
     }
     if ($value instanceof \DateTime) {
         $value = $value->format($this->getDateTimeFormat());
     } elseif ($value instanceof \Traversable) {
         $value = json_encode(iterator_to_array($value), $jsonFlags);
     } elseif (is_array($value)) {
         $value = json_encode($value, $jsonFlags);
     } elseif (is_object($value) && !method_exists($value, '__toString')) {
         $value = sprintf('object(%s) %s', get_class($value), json_encode($value));
     } elseif (is_resource($value)) {
         $value = sprintf('resource(%s)', get_resource_type($value));
     } elseif (!is_object($value)) {
         $value = gettype($value);
     }
     return (string) $value;
 }
开发者ID:phPoirot,项目名称:Logger,代码行数:33,代码来源:AbstractFormatter.php


示例18: is_myresource

function is_myresource($o, $onlyres = false)
{
    if (extension_loaded('mysql')) {
        if (!is_resource($o)) {
            return false;
        }
        $cname = get_resource_type($o);
        if ($cname != 'mysql link' && $cname != 'mysql result') {
            return false;
        }
        if ($onlyres && $cname != 'mysql result') {
            return false;
        }
        unset($cname);
        return true;
    }
    if (!is_object($o)) {
        return false;
    }
    $cname = get_class($o);
    if ($cname != 'mysqli' && $cname != 'mysqli_result') {
        return false;
    }
    if ($onlyres && $cname != 'mysqli_result') {
        return false;
    }
    unset($cname);
    return true;
}
开发者ID:OOPS-ORG-PHP,项目名称:mysql-extension-wrapper,代码行数:29,代码来源:mysql-wrapper.php


示例19: initialize

 /**
  * Initialize
  *
  * @param  resource $pgsql
  * @return void
  * @throws Exception\RuntimeException for invalid or missing postgresql connection
  */
 public function initialize($pgsql)
 {
     if (!is_resource($pgsql) || get_resource_type($pgsql) !== 'pgsql link') {
         throw new Exception\RuntimeException(sprintf('%s: Invalid or missing postgresql connection; received "%s"', __METHOD__, get_resource_type($pgsql)));
     }
     $this->pgsql = $pgsql;
 }
开发者ID:idwsdta,项目名称:INIT-frame,代码行数:14,代码来源:Statement.php


示例20: isImageResource

 /**
  * @access      protected
  * @param       resource    image resource
  * @return      bool
  */
 protected function isImageResource($imageResource)
 {
     if (is_resource($imageResource) && get_resource_type($imageResource) == 'gd') {
         return true;
     }
     return false;
 }
开发者ID:naucon,项目名称:image,代码行数:12,代码来源:ImageWriter.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_resource_types函数代码示例发布时间:2022-05-15
下一篇:
PHP get_resource_path函数代码示例发布时间: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