is_countable

函式
is_countable ( $value )
引數
  • (mixed) $value The value to check.
    Required:
返回值
  • (bool) True if `$value` is countable, false otherwise.
定義位置
相關方法
is_iterableis_front_pagewp_is_writabledisplay_plugins_tabledisabled
引入
4.9.6
棄用
-

is_countable: 這個函式檢查一個變數是否是可數的。如果該變數是可計算的,則返回 true,否則返回 false。在PHP中,如果一個變數是一個陣列或一個實現了Countable介面的物件,它就是可計算的。

PHP 7.3中新增了is_countable()函式的Polyfill。

驗證一個變數的內容是一個陣列或一個實現可計數介面的物件。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function is_countable( $value ) {
return ( is_array( $value )
|| $value instanceof Countable
|| $value instanceof SimpleXMLElement
|| $value instanceof ResourceBundle
);
}
}
function is_countable( $value ) { return ( is_array( $value ) || $value instanceof Countable || $value instanceof SimpleXMLElement || $value instanceof ResourceBundle ); } }
function is_countable( $value ) {
		return ( is_array( $value )
			|| $value instanceof Countable
			|| $value instanceof SimpleXMLElement
			|| $value instanceof ResourceBundle
		);
	}
}

常見問題

FAQs
檢視更多 >