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

PHP is_resource函数代码示例

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

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



在下文中一共展示了is_resource函数的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: createOutputFile

 public function createOutputFile()
 {
     if (!is_resource($this->getFileStream())) {
         $this->setFileStream(fopen($this->createFileName(), "w+"));
         fwrite($this->getFileStream(), $this->header());
     }
 }
开发者ID:philip,项目名称:phd,代码行数:7,代码来源:BigXHTML.php


示例3: obtenerArreglo

 public function obtenerArreglo($result)
 {
     if (!is_resource($result)) {
         return false;
     }
     return pg_fetch_array($result);
 }
开发者ID:japeto,项目名称:PollSystem,代码行数:7,代码来源:db.class_bodega.php


示例4: testOpeningFileWorks

 public function testOpeningFileWorks()
 {
     $this->assertFalse($this->instance->fileExists('testfile'));
     $this->instance->setFileContents('testfile', 'mmmmm plastic');
     $this->assertTrue($this->instance->fileExists('testfile'));
     $this->assertTrue(is_resource($this->instance->openFile('testfile')));
 }
开发者ID:99designs,项目名称:cabinet,代码行数:7,代码来源:ArrayFileStoreTest.php


示例5: process

 /**
  * Process
  *
  * @param mixed $value
  * @param array $options
  *
  * @return string|null
  */
 public function process($value, array $options = array())
 {
     if ($value === null) {
         return;
     }
     if (!class_exists('\\libphonenumber\\PhoneNumberUtil')) {
         throw new \RuntimeException('Library for phone checking not found');
     }
     if (is_object($value) || is_resource($value) || is_array($value)) {
         $this->throwException($options, 'error');
     }
     try {
         $phone = $this->getPhone($value, $options, $is_toll_free);
     } catch (\libphonenumber\NumberParseException $e) {
         $this->throwException($options, 'error');
     }
     $util = \libphonenumber\PhoneNumberUtil::getInstance();
     if (!$util->isValidNumber($phone)) {
         $this->throwException($options, 'error');
     }
     if ($is_toll_free) {
         return $phone->getNationalNumber();
     }
     return (string) $util->format($phone, $this->getDefaultPhoneFormat($options));
 }
开发者ID:apishka,项目名称:validator,代码行数:33,代码来源:Phone.php


示例6: 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


示例7: listCertificates

 /**
  * Returns all certificates trusted by the user
  *
  * @return \OCP\ICertificate[]
  */
 public function listCertificates()
 {
     if (!$this->config->getSystemValue('installed', false)) {
         return array();
     }
     $path = $this->getPathToCertificates() . 'uploads/';
     if (!$this->view->is_dir($path)) {
         return array();
     }
     $result = array();
     $handle = $this->view->opendir($path);
     if (!is_resource($handle)) {
         return array();
     }
     while (false !== ($file = readdir($handle))) {
         if ($file != '.' && $file != '..') {
             try {
                 $result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
             } catch (\Exception $e) {
             }
         }
     }
     closedir($handle);
     return $result;
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:30,代码来源:CertificateManager.php


示例8: __construct

 /**
  * Constructor
  * @param  resource                  $resource
  * @throws \InvalidArgumentException If invalid resource
  */
 public function __construct($resource)
 {
     if (!is_resource($resource)) {
         throw new \InvalidArgumentException('Cannot create LogWriter. Invalid resource handle.');
     }
     $this->resource = $resource;
 }
开发者ID:karthy86,项目名称:Experiments,代码行数:12,代码来源:LogWriter.php


示例9: prepareData

 /**
  * Serialize the data for storing.
  *
  * Serializes the given $data to a executable PHP code representation 
  * string. This works with objects implementing {@link ezcBaseExportable},
  * arrays and scalar values (int, bool, float, string). The return value is
  * executable PHP code to be stored to disk. The data can be unserialized 
  * using the {@link fetchData()} method.
  * 
  * @param mixed $data
  * @return string
  *
  * @throws ezcCacheInvalidDataException
  *         if the $data can not be serialized (e.g. an object that does not
  *         implement ezcBaseExportable, a resource, ...).
  */
 protected function prepareData($data)
 {
     if (is_object($data) && !$data instanceof ezcBaseExportable || is_resource($data)) {
         throw new ezcCacheInvalidDataException(gettype($data), array('simple', 'array', 'ezcBaseExportable'));
     }
     return "<?php\nreturn " . var_export($data, true) . ";\n?>\n";
 }
开发者ID:mdb-webdev,项目名称:livehelperchat,代码行数:23,代码来源:object.php


示例10: query

 public function query($sql)
 {
     $resource = mysql_query($sql, $this->link);
     if ($resource) {
         if (is_resource($resource)) {
             $i = 0;
             $data = array();
             while ($result = mysql_fetch_assoc($resource)) {
                 $data[$i] = $result;
                 $i++;
             }
             mysql_free_result($resource);
             $query = new stdClass();
             $query->row = isset($data[0]) ? $data[0] : array();
             $query->rows = $data;
             $query->num_rows = $i;
             unset($data);
             return $query;
         } else {
             return true;
         }
     } else {
         trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br />' . $sql);
         exit;
     }
 }
开发者ID:ahmedkato,项目名称:openshift-opencart,代码行数:26,代码来源:sqlite.php


示例11: write

 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if (!is_resource($this->stream)) {
         if (!$this->url) {
             throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
         }
         $this->createDir();
         $this->errorMessage = null;
         set_error_handler(array($this, 'customErrorHandler'));
         $this->stream = fopen($this->url, 'a');
         if ($this->filePermission !== null) {
             @chmod($this->url, $this->filePermission);
         }
         restore_error_handler();
         if (!is_resource($this->stream)) {
             $this->stream = null;
             throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: ' . $this->errorMessage, $this->url));
         }
     }
     if ($this->useLocking) {
         // ignoring errors here, there's not much we can do about them
         flock($this->stream, LOCK_EX);
     }
     fwrite($this->stream, (string) $record['formatted']);
     if ($this->useLocking) {
         flock($this->stream, LOCK_UN);
     }
 }
开发者ID:saj696,项目名称:pipe,代码行数:31,代码来源:StreamHandler.php


示例12: __destruct

 public function __destruct()
 {
     if (\is_resource($this->filePointer)) {
         $this->writeLocationTable();
         \fclose($this->filePointer);
     }
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:7,代码来源:RegionLoader__64bit.php


示例13: 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


示例14: realFilesize

function realFilesize($filename)
{
    $fp = fopen($filename, 'r');
    $return = false;
    if (is_resource($fp)) {
        if (PHP_INT_SIZE < 8) {
            if (0 === fseek($fp, 0, SEEK_END)) {
                $return = 0.0;
                $step = 0x7fffffff;
                while ($step > 0) {
                    if (0 === fseek($fp, -$step, SEEK_CUR)) {
                        $return += floatval($step);
                    } else {
                        $step >>= 1;
                    }
                }
            }
        } else {
            if (0 === fseek($fp, 0, SEEK_END)) {
                $return = ftell($fp);
            }
        }
    }
    return $return;
}
开发者ID:GvarimAZA,项目名称:website,代码行数:25,代码来源:functions.php


示例15: query

 private static function query($q, $params = array())
 {
     if (self::$link === NULL) {
         self::connect();
     }
     self::$numQuerys++;
     $q .= self::$order;
     $q .= self::$limit;
     self::$order = '';
     self::$limit = '';
     self::$sql = $q;
     self::$result = mysql_query($q, self::$link);
     if (!self::$result) {
         return false;
     } else {
         if (!is_resource(self::$result)) {
             return true;
         }
     }
     $rset = array();
     while ($row = mysql_fetch_assoc(self::$result)) {
         $rset[] = $row;
     }
     return $rset;
 }
开发者ID:42Khane,项目名称:Steam-Grid,代码行数:25,代码来源:mysql.php


示例16: __construct

 /**
  * Constructor method
  *
  * @param string|resource $input is either a stream or a filename
  * @param int $size see $_FILES['size'] from PHP
  * @param int $errorStatus see $_FILES['error']
  * @param string $clientFilename the original filename handed over from the client
  * @param string $clientMediaType the media type (optional)
  *
  * @throws \InvalidArgumentException
  */
 public function __construct($input, $size, $errorStatus, $clientFilename = null, $clientMediaType = null)
 {
     if (is_string($input)) {
         $this->file = $input;
     }
     if (is_resource($input)) {
         $this->stream = new Stream($input);
     } elseif ($input instanceof StreamInterface) {
         $this->stream = $input;
     }
     if (!$this->file && !$this->stream) {
         throw new \InvalidArgumentException('The input given was not a valid stream or file.', 1436717301);
     }
     if (!is_int($size)) {
         throw new \InvalidArgumentException('The size provided for an uploaded file must be an integer.', 1436717302);
     }
     $this->size = $size;
     if (!is_int($errorStatus) || 0 > $errorStatus || 8 < $errorStatus) {
         throw new \InvalidArgumentException('Invalid error status for an uploaded file. See UPLOAD_ERR_* constant in PHP.', 1436717303);
     }
     $this->error = $errorStatus;
     if ($clientFilename !== null && !is_string($clientFilename)) {
         throw new \InvalidArgumentException('Invalid client filename provided for an uploaded file.', 1436717304);
     }
     $this->clientFilename = $clientFilename;
     if ($clientMediaType !== null && !is_string($clientMediaType)) {
         throw new \InvalidArgumentException('Invalid client media type provided for an uploaded file.', 1436717305);
     }
     $this->clientMediaType = $clientMediaType;
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:41,代码来源:UploadedFile.php


示例17: __construct

 /**
  * constructor
  *
  * If no file pointer given it will fall back to STDOUT.
  *
  * @param   resource  $out  optional
  * @throws  InvalidArgumentException
  */
 public function __construct($out = STDOUT)
 {
     if (is_resource($out) === false || get_resource_type($out) !== 'stream') {
         throw new InvalidArgumentException('Given filepointer is not a resource of type stream');
     }
     $this->out = $out;
 }
开发者ID:clickalicious,项目名称:doozr,代码行数:15,代码来源:vfsStreamPrintVisitor.php


示例18: query

 public function query($sql)
 {
     if ($this->link) {
         $resource = mysql_query($sql, $this->link);
         if ($resource) {
             if (is_resource($resource)) {
                 $i = 0;
                 $data = array();
                 while ($result = mysql_fetch_assoc($resource)) {
                     $data[$i] = $result;
                     $i++;
                 }
                 mysql_free_result($resource);
                 $query = new \stdClass();
                 $query->row = isset($data[0]) ? $data[0] : array();
                 $query->rows = $data;
                 $query->num_rows = $i;
                 unset($data);
                 return $query;
             } else {
                 return true;
             }
         } else {
             $trace = debug_backtrace();
             trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br /> Error in: <b>' . $trace[1]['file'] . '</b> line <b>' . $trace[1]['line'] . '</b><br />' . $sql);
         }
     }
 }
开发者ID:honeynatividad,项目名称:mircatu,代码行数:28,代码来源:mysql.php


示例19: execute

function execute($cmd, &$output, &$error, &$returnCode)
{
    $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
    $process = proc_open($cmd, $descriptorspec, $pipes);
    if (!is_resource($process)) {
        throw new RuntimeException("Unable to execute the command. [{$cmd}]");
    }
    stream_set_blocking($pipes[1], false);
    stream_set_blocking($pipes[2], false);
    $output = $error = '';
    foreach ($pipes as $key => $pipe) {
        while (!feof($pipe)) {
            if (!($line = fread($pipe, 128))) {
                continue;
            }
            if (1 == $key) {
                $output .= $line;
                // stdout
            } else {
                $error .= $line;
                // stderr
            }
        }
        fclose($pipe);
    }
    $returnCode = proc_close($process);
}
开发者ID:sangda,项目名称:php-svn-hook,代码行数:27,代码来源:svn_pre_commit_hookTest.php


示例20: build_image

 /** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height.
  * Returns FALSE on failure. The only one parameter $image can be an instance of this class,
  * a GD resource, an array(width, height) or path to image file.
  * @param mixed $image
  * @return array */
 protected function build_image($image)
 {
     if ($image instanceof gd) {
         $width = $image->get_width();
         $height = $image->get_height();
         $image = $image->get_image();
     } elseif (is_resource($image) && get_resource_type($image) == "gd") {
         $width = @imagesx($image);
         $height = @imagesy($image);
     } elseif (is_array($image)) {
         list($key, $width) = each($image);
         list($key, $height) = each($image);
         $image = imagecreatetruecolor($width, $height);
     } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) {
         $image = $type == IMAGETYPE_GIF ? @imagecreatefromgif($image) : ($type == IMAGETYPE_WBMP ? @imagecreatefromwbmp($image) : ($type == IMAGETYPE_JPEG ? @imagecreatefromjpeg($image) : ($type == IMAGETYPE_JPEG2000 ? @imagecreatefromjpeg($image) : ($type == IMAGETYPE_PNG ? imagecreatefrompng($image) : ($type == IMAGETYPE_XBM ? @imagecreatefromxbm($image) : false)))));
         if ($type == IMAGETYPE_PNG) {
             imagealphablending($image, false);
         }
     }
     $return = is_resource($image) && get_resource_type($image) == "gd" && isset($width) && isset($height) && preg_match('/^[1-9][0-9]*$/', $width) !== false && preg_match('/^[1-9][0-9]*$/', $height) !== false ? array($image, $width, $height) : false;
     if ($return !== false && isset($type)) {
         $this->type = $type;
     }
     return $return;
 }
开发者ID:Evrika,项目名称:Vidal,代码行数:30,代码来源:class_gd.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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