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

PHP getType函数代码示例

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

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



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

示例1: update

 protected function update($data = array(), $params = array(), $otherTables = false)
 {
     $tables = "";
     if (!empty($otherTables)) {
         foreach ($otherTables as $table) {
             $tables .= "," . $table . " ";
         }
     }
     $values = '';
     foreach ($data as $field => $value) {
         if (getType($value) == 'integer') {
             $values .= $field . "=" . addslashes($value) . ",";
         } else {
             $values .= $field . "='" . addslashes($value) . "',";
         }
     }
     $condition = !empty($params['condition']) ? $params['condition'] : '1=1';
     $sql = "UPDATE " . $this->table . $tables . " SET " . substr($values, 0, -1) . " WHERE " . $condition;
     //echo "<meta charset='UTF-8'>UPDATE ".$this->table.$tables." SET ".substr($values,0,-1)." WHERE ".$condition.'<br>'.'<br>';
     try {
         $request = self::$connexion->prepare($sql);
         $request->execute();
     } catch (Exception $error) {
         die('FAILED UPDATE : ' . $error->getMessage());
     }
 }
开发者ID:hardouinyann,项目名称:EnigmaTIC,代码行数:26,代码来源:model.php


示例2: saveFile

 public function saveFile($url, $file, $name)
 {
     $file_type = getType($file);
     if ($file_type != '') {
         copy($file['tmp_name'], $url . $name . '.' . $file_type);
     }
 }
开发者ID:vicbaporu,项目名称:ITRADE,代码行数:7,代码来源:SaveFiles.php


示例3: CreateResponse

 /**
  * CreateResponse - Response handler to handle API Requests
  * 
  * @param int $apiStatusCode The HTTP Status Code
  * 
  * @return ApiResponse
  */
 public static function CreateResponse($apiStatusCode, $requestResult = [])
 {
     if (getType($requestResult) == "array") {
         $requestResult = json_encode($requestResult);
     }
     $request_result = json_decode($requestResult, true);
     $request_result["records"] = array_key_exists("data", $request_result) ? count($request_result["data"]) : count($request_result);
     $statusType = ApiResponse::$statusMessages[$apiStatusCode]["status_type"];
     $successStatus = $statusType == "success" ? true : false;
     $statusCode = ApiResponse::$statusMessages[$apiStatusCode]["status_code"];
     $response = ["code" => $statusCode, "message" => Response::$statusTexts[$statusCode], "description" => ApiResponse::$statusCodeMessages[$statusCode], "reason" => ApiResponse::$statusMessages[$apiStatusCode]["status_text"], "apistatuscode" => $apiStatusCode];
     $return = ["success" => $successStatus];
     if ($statusType == "success") {
         $return["response"] = $response;
     } elseif ($statusType == "error") {
         $return["error"] = $response;
     }
     if (!empty($requestResult)) {
         $return["result"] = json_decode($requestResult, true);
         $return["date"] = date("Y-m-d");
         $return["time"] = date("H:i:s");
     }
     // Return Result
     return $return;
 }
开发者ID:PipIWYG,项目名称:api-endpoint-host,代码行数:32,代码来源:ApiResponse.php


示例4: convert

 /**
  * Map a PHP data type to ours
  * @param mixed $value Any type of data
  * @throws Exception
  */
 public static function convert($type)
 {
     switch (getType($type)) {
         case 'NULL':
             return Type::NULL;
             break;
         case 'boolean':
             return Type::BOOLEAN;
             break;
         case 'integer':
             return Type::INTEGER;
             break;
         case 'double':
             return Type::FLOAT;
             break;
         case 'string':
             return Type::STRING;
             break;
         case 'array':
             return Type::COLLECTION;
             break;
         case 'object':
             return Type::OBJECT;
             break;
         case 'resource':
             return Type::RESOURCE;
             break;
         case 'unknown type':
             return Type::UNKNOWN;
             break;
     }
 }
开发者ID:g4z,项目名称:poop,代码行数:37,代码来源:Type.php


示例5: HTMLTemplate

 function HTMLTemplate($name, $replace, $with)
 {
     $loc = $this->templateKey[$name];
     $webRoot = getWebRoot();
     if (getType($replace) == getType($with) && getType($replace) == "array" && count($replace) > 0) {
         if (count($replace) == count($with)) {
             array_unshift($replace, "{webRoot}");
             array_unshift($with, $webRoot);
         } else {
             echo "error: Replace and With arrays are of different lengths.";
         }
     } else {
         $replace = array('{webRoot}');
         $with = array($webRoot);
     }
     if (isset($loc)) {
         $html = file_get_contents($loc);
         if ($html) {
             if ($replace && $with) {
                 $htmlWithVars = str_replace($replace, $with, $html);
             } else {
                 $htmlWithVars = $html;
             }
             echo $htmlWithVars;
         }
     } else {
         // echo header("Location:error.php?num=2");
         echo "error: Missing HTML template of {$name}";
     }
 }
开发者ID:JasonHorsley2,项目名称:Pubbly-2016,代码行数:30,代码来源:HTMLTemplate.php


示例6: setConfigParameter

 /**
  * Sets the name of the config-entry.
  * @param string $strConfig the name of the config-entry.
  * @return Dkplus_Controller_Plugin_Database
  * @throws Zend_Controller_Exception on wrong parameter.
  */
 public function setConfigParameter($strConfig)
 {
     if (!is_string($strConfig)) {
         throw new Zend_Controller_Exception('$strConfig is an ' . getType($strConfig) . ', must be an string');
     }
     $this->_configName = $strConfig;
 }
开发者ID:BackupTheBerlios,项目名称:dkplusengine,代码行数:13,代码来源:Database.php


示例7: validate

 /**
  * 入力チェック処理
  * @param array $data 入力データ
  * @param array &$valid_data 入力チェック後の返却データ
  * @param array $white_list 入力のチェック許可リスト
  */
 public function validate($data, &$valid_data, $white_list = array())
 {
     $errors = array();
     $valid_data = array();
     $isWhiteList = !!count($white_list);
     foreach ($this->validates as $key => $valid) {
         // カラムのホワイトリストチェック
         if ($isWhiteList && !in_array($key, $white_list)) {
             continue;
         }
         foreach ($valid as $mKey => $options) {
             $method = is_array($options) && isset($options['rule']) ? $options['rule'] : $mKey;
             if (!isset($data[$key])) {
                 $data[$key] = null;
             }
             $error = Validate::$method($data[$key], $options, $key, $data, $this);
             if ($error === false) {
                 break;
             }
             if (getType($error) === 'string') {
                 $errors[$key] = $error;
                 break;
             }
         }
         if (isset($data[$key])) {
             $valid_data[$key] = $data[$key];
         }
     }
     return $errors;
 }
开发者ID:nokatsur,项目名称:blog,代码行数:36,代码来源:model.php


示例8: serializeArrayToXml

 protected function serializeArrayToXml(array $array, DOMElement $element)
 {
     foreach ($array as $name => $value) {
         $property = $element->appendChild($element->ownerDocument->createElement('property'));
         $property->setAttribute('key-type', is_string($name) ? 'string' : 'integer');
         $property->setAttribute('key-name', $name);
         switch ($type = gettype($value)) {
             case 'double':
                 $type = 'float';
             case 'integer':
                 // $type has already been set
                 $property->appendChild($element->ownerDocument->createTextNode((string) $value));
                 break;
             case 'boolean':
                 // $type has already been set
                 $property->appendChild($element->ownerDocument->createTextNode($value ? '1' : '0'));
                 break;
             case 'string':
                 $property->appendChild($element->ownerDocument->createCDATASection($value));
                 break;
             case 'array':
                 // $type has been set
                 // recursively serialize the array
                 $this->serializeArrayToXml($value, $property);
                 break;
             default:
                 //@todo
                 throw new Exception('Can not serialize type ' . getType($value) . ' in configuration setting ' . $name);
         }
         $property->setAttribute('value-type', $type);
     }
 }
开发者ID:jou,项目名称:ymc-components,代码行数:32,代码来源:node_configuration.php


示例9: __construct

 /**
  * Just set member variables and check the values are correct 
  * 
  * @param int $code The response code
  * @param array of string $message The response message
  * @return void
  */
 public function __construct($code, array $message)
 {
     if (!is_numeric($code)) {
         throw new InvalidArgumentException('SMTP response code must be a ' . 'number, but (' . getType($code) . ')' . $code . ' given.');
     }
     $this->code = $code;
     $this->message = $message;
 }
开发者ID:NorthV,项目名称:nSMTPMailer,代码行数:15,代码来源:Response.php


示例10: typeName

 public static function typeName($arg)
 {
     $t = getType($arg);
     if ($t == "object") {
         return get_class($arg);
     }
     return $t;
 }
开发者ID:lechimp-p,项目名称:php-formlets,代码行数:8,代码来源:Checking.php


示例11: __construct

 /**
  * Schedule generator constructor. Creates schedule sequence for selected objects
  *
  * @param array|Traversable $objects
  */
 public function __construct($objects = [])
 {
     if (!is_array($objects) && !$objects instanceof \Traversable) {
         throw new \InvalidArgumentException(sprintf("Expects an array or Traversable object, '%s' has given", getType($object)));
     }
     foreach ($objects as $object) {
         $this->add($object);
     }
 }
开发者ID:gallna,项目名称:media-library,代码行数:14,代码来源:ScheduleGenerator.php


示例12: toObject

 public static function toObject($arr) 
 {/*{{{*/
     if(gettype($arr) != 'array') return $arr;
     foreach ($arr as $k=>$v)
     {
         if(gettype($v) == 'array' || getType($v) == 'object')
             $arr[$k] = (object) self::toObject($v);
     }
     return (object) $arr;
 }/*}}}*/
开发者ID:sdgdsffdsfff,项目名称:hdf-client,代码行数:10,代码来源:xarray.php


示例13: getBrokenThemeSettings

function getBrokenThemeSettings($id)
{
    $themeSettings = WikiFactory::getVarByName('wgOasisThemeSettings', $id);
    if (!is_object($themeSettings) || empty($themeSettings->cv_value)) {
        return null;
    }
    $themeSettingsArray = unserialize($themeSettings->cv_value);
    $backgroundImage = $themeSettingsArray['background-image'];
    return getType($backgroundImage) !== 'string' || $backgroundImage === 'false' ? $themeSettingsArray : null;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:10,代码来源:fixThemeDesignerBGImage.php


示例14: debug

 protected function debug($arrayToDebug = array(), $array_name = false)
 {
     $title = !empty($array_name) ? $array_name : "";
     if (getType($arrayToDebug) == "array") {
         ksort($arrayToDebug);
     }
     echo "<meta charset='UTF-8'>\n                  <h1 style='margin-bottom:-35px!important;position:relative;z-index:9999!important;'>" . $title . "</h1>\n                  <pre style='margin:50px!important;background-color:#AEAEAE!important;border:solid 2px red!important;z-index:9999!important;position:relative;'>";
     print_r($arrayToDebug);
     echo "</pre><br>";
 }
开发者ID:hardouinyann,项目名称:EnigmaTIC,代码行数:10,代码来源:controller.php


示例15: extract

 /**
  * @param array|ModelInterface $dataOrModel
  * @param HydratorInterface $hydrator
  * @return array
  */
 public function extract($dataOrModel, HydratorInterface $hydrator = null)
 {
     if (is_array($dataOrModel)) {
         return $dataOrModel;
     }
     if (!$dataOrModel instanceof ModelInterface) {
         throw new \InvalidArgumentException('Model object needs to implement ModelInterface  got: ' . getType($dataOrModel));
     }
     $hydrator = $hydrator ?: $this->getHydrator();
     return $hydrator->extract($dataOrModel);
 }
开发者ID:uthando-cms,项目名称:uthando-common,代码行数:16,代码来源:ModelAwareTrait.php


示例16: createCorrectScalarType

 /**
  * Create a new scalar based on type of original matrix
  *
  * @param \Chippyash\Math\Matrix\NumericMatrix $originalMatrix
  * @param scalar $scalar
  * @return Chippyash\Type\Interfaces\NumericTypeInterface
  *
  */
 protected function createCorrectScalarType(NumericMatrix $originalMatrix, $scalar)
 {
     if ($scalar instanceof NumericTypeInterface) {
         if ($originalMatrix instanceof RationalMatrix) {
             return $scalar->asRational();
         }
         if ($originalMatrix instanceof ComplexMatrix) {
             return $scalar->asComplex();
         }
         return $scalar;
     }
     if ($originalMatrix instanceof ComplexMatrix) {
         if (is_numeric($scalar)) {
             return ComplexTypeFactory::create($scalar, 0);
         }
         if (is_string($scalar)) {
             try {
                 return RationalTypeFactory::create($scalar)->asComplex();
             } catch (\Exception $e) {
                 //do nothing
             }
         }
         if (is_bool($scalar)) {
             return ComplexTypeFactory::create($scalar ? 1 : 0, 0);
         }
         return ComplexTypeFactory::create($scalar);
     }
     if ($originalMatrix instanceof RationalMatrix) {
         if (is_bool($scalar)) {
             $scalar = $scalar ? 1 : 0;
         }
         return RationalTypeFactory::create($scalar);
     }
     //handling for NumericMatrix
     if (is_int($scalar)) {
         return TypeFactory::createInt($scalar);
     } elseif (is_float($scalar)) {
         return TypeFactory::createRational($scalar);
     } elseif (is_bool($scalar)) {
         return TypeFactory::createInt($scalar ? 1 : 0);
     } elseif (is_string($scalar)) {
         try {
             return TypeFactory::createRational($scalar);
         } catch (\InvalidArgumentException $e) {
             try {
                 return ComplexTypeFactory::create($scalar);
             } catch (\InvalidArgumentException $e) {
                 //do nothing
             }
         }
     }
     throw new ComputationException('Scalar parameter is not a supported type for numeric matrices: ' . getType($scalar));
 }
开发者ID:chippyash,项目名称:math-matrix,代码行数:61,代码来源:CreateCorrectScalarType.php


示例17: parse

 public static function parse($e)
 {
     if (gettype($e) != 'array') {
         return;
     }
     foreach ($e as $k => $v) {
         if (gettype($v) == 'array' || getType($v) == 'object') {
             $e[$k] = self::parse($v);
         }
     }
     return (object) $e;
 }
开发者ID:js-wei,项目名称:Wechat,代码行数:12,代码来源:Array2Object.class.php


示例18: arrayToObject

function arrayToObject($e)
{
    if (gettype($e) != 'array') {
        return;
    }
    foreach ($e as $k => $v) {
        if (gettype($v) == 'array' || getType($v) == 'object') {
            $e[$k] = (object) arrayToObject($v);
        }
    }
    return (object) $e;
}
开发者ID:oyoy8629,项目名称:yii-core,代码行数:12,代码来源:ArrayToObject.php


示例19: serialiseArray

 function serialiseArray($parent, $array, $tagName = null)
 {
     if (is_array($array)) {
         foreach ($array as $key => $val) {
             $attr = null;
             if (!is_int($key)) {
                 $attr = array('name' => $key, 'type' => getType($val));
             }
             $key = get_class($val) != null ? get_class($val) : is_int($key) ? gettype($val) : $key;
             $this->serialiseValue($parent, $val, $key, $attr);
         }
     }
 }
开发者ID:sixones,项目名称:expose,代码行数:13,代码来源:serialiser.php


示例20: validateData

 /**
  * Pass in a value and get the validated value back
  *
  * @param mixed $value
  * @return mixed
  * @throws ValidationException
  */
 public function validateData($value)
 {
     if ($this->getType() != getType($value)) {
         if ($this->getRequired()) {
             throw new \ClassyLlama\AvaTax\Framework\Interaction\MetaData\ValidationException(__('The value you passed in is not an object.'));
         }
         $value = null;
     }
     $class = $this->getClass();
     if (!is_null($value) && !$value instanceof $class) {
         throw new \ClassyLlama\AvaTax\Framework\Interaction\MetaData\ValidationException(__('The object you passed in is of type %1 and is required to be of type %2.', [get_class($value), $class]));
     }
     return $value;
 }
开发者ID:classyllama,项目名称:ClassyLlama_AvaTax,代码行数:21,代码来源:ObjectType.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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