Note: is_object(null) returns false
This should actually be part of the input/output specification at the top of this page.
PHP.mk документација
is_object
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Патека
function.is-object.php
Локална патека за оваа страница.
Извор
php.net/manual/en
Оригиналниот HTML се реупотребува и локално се стилизира.
Режим
Прокси + превод во позадина
Кодовите, табелите и белешките остануваат читливи во истиот тек.
Референца
function.is-object.php
is_object
Референца за `function.is-object.php` со подобрена типографија и навигација.
is_object
(PHP 4, PHP 5, PHP 7, PHP 8)
is_object — Проверува дали променливата е објект
Параметри
value-
Променливата што се оценува.
Вратени вредности
Патеката до PHP скриптата што треба да се провери. true if value е object,
false otherwise.
Дневник на промени
| Верзија | = NULL |
|---|---|
| 7.2.0 |
is_object() сега враќа true за десериализирани објекти без дефиниција на класа (класа на __PHP_Incomplete_Class). Претходно
false .
|
Примери
Пример #1 is_object() example
<?php
// Declare a simple function to return an
// array from our object
function get_students($obj)
{
if (!is_object($obj)) {
return false;
}
return $obj->students;
}
// Declare a new class instance and fill up
// some values
$obj = new stdClass();
$obj->students = array('Kalle', 'Ross', 'Felipe');
var_dump(get_students(null));
var_dump(get_students($obj));
?>Види Исто така
- is_bool() - Дознајте дали променливата е булова
- is_int() - Дознајте дали променливата е цел број
- is_float() - Дознајте дали типот на променливата е float
- is_string() - Finds whether a variable is a scalar
- is_array() - Пронајдете дали променлива е низа
Белешки од корисници 3 белешки
peter dot nagel at portavita dot nl ¶
пред 15 години
mark at not4you dot com ¶
пред 14 години
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;
}
?>
monique at nijboer dot it ¶
пред 1 година
I would expect a reference to is_a() function here.
if you would test if an object is of an specific type use is_a()
https://www.php.net/manual/en/function.is-a.php