php判斷變數型別

2021-10-08 16:14:01 字數 1183 閱讀 3996

<?php

// 其中gettype()函式返回變數的型別,如"boolean"、"integer"、"double"(float型別會返回"double",而非"float")、

"string"、"array"、"object"、"resource"、"null"和"unknown type"等值,表明變數型別

// 標量變數是指那些包含了 integer、float、string 或 boolean的變數,而 array、object 和 resource 則不是標量。

'gettype(): //獲取變數型別

isset(); //變數是否已經宣告

empty(); //變數是否為空

defined(); //常量是否已經定義 define()

array_key_exists(mixed key, array search); //檢查給定的鍵名或索引是否存在於陣列中

is_numeric(mixed var); //檢測變數是 否為數字或數字字串

is_bool(); // 檢測變數是否是布林型

is_float(): // 檢測變數是否是浮點型 和is_double,is_real()都一樣的用法

is_int(): // 檢測變數是否是整數is_integer() 一樣的 用法

is_string(): // 檢測變數是否是字串

is_object(): // 檢測變數是否是乙個物件

is_resource(): // 檢測變數是否是乙個資源

is_array(): // 檢測變數是否是陣列

is_null(): // 檢測變數是否為 null 值是否是null大小寫敏感

is_scalar(): // 檢測變數是否是乙個標量

class_exists(class classname); // 檢測class類是否存在

method_exists(object class, mixed method); // 檢測class類中是否存在某方法method

function_exists(mixed functionname); // 檢測函式是否存在

?>

php判斷變數型別

gettype 函式 gettype 1 返回的是integer is array is系列函式empty 0 0 null false array var var 未定義 以及沒有任何屬性的物件都將被認為是空的 isset 如果 變數 存在 非null 則返回 true is null 檢測傳入值...

php 判斷 設定變數型別

php判斷變數型別常用的函式 gettype settype is array is bool is float is double is integer is null is numeric is object is resource is scalar is string 現在我們來了解一下他們...

php判斷變數型別常用方法

php 判斷變數型別常用的函式主要有下列幾個 gettype is array is bool is float is double is integer is null is numeric is object is resource is scalar 和 is string 現在讓我們了解下他...