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


PHP getType函数代码示例

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


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


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