Note: is_object(null) returns false
This should actually be part of the input/output specification at the top of this page.
(PHP 4, PHP 5, PHP 7)
is_object — 변수가 객체인지 확인합니다
var
평가할 변수.
var
가 object면 TRUE
를, 아니라면
FALSE
를 반환합니다.
Example #1 is_object() 예제
<?php
// 객체에서 배열을 반환하는
// 간단한 함수를 선언합니다.
fucntion get_students($obj)
{
if(!is_object($obj))
{
return(false);
}
return($obj->students);
}
// 새 클래스를 선언하고
// 값을 채웁니다.
$obj = new stdClass;
$obj->students = Array('Kalle', 'Ross', 'Felipe');
var_dump(get_students(NULL));
var_dump(get_students($obj));
?>
Note: is_object(null) returns false
This should actually be part of the input/output specification at the top of this page.
Unserializes data as returned by the standard PHP serialize() function. If the unserialized object is not an array, it will be converted to one, particularily useful if it returns a __PHP_Incomplete_Class.
<?php
/**
*
* @param string $data Serialized data
*
* @return array Unserialized array
*/
function unserialize2array($data) {
$obj = unserialize($data);
if(is_array($obj)) return $obj;
$arr = array();
foreach($obj as $k=>$v) {
$arr[$k] = $v;
}
unset($arr['__PHP_Incomplete_Class_Name']);
return $arr;
}
?>