CakeFest 2024: The Official CakePHP Conference

variant_set_type

(PHP 5, PHP 7, PHP 8)

variant_set_typeПриводит вариант к другому типу «по месту»

Описание

variant_set_type(variant $variant, int $type): void

Функция аналогична функции variant_cast() за исключением того, что изменяется сам вариант, а не создаётся новый. Передаваемые функции параметры идентичны параметрам функции variant_cast().

Список параметров

variant

Вариант.

type

Возвращаемые значения

Функция не возвращает значения после выполнения.

Смотрите также

  • variant_cast() - Преобразовывает вариант в новый вариант другого типа
  • variant_get_type() - Получить тип варианта

add a note

User Contributed Notes 1 note

up
0
martin at itmission dot com
14 years ago
In my application I was using ADODB to retrieve data from Microsoft Access. During queries, fields defined as "Date/Time" in Access were being returned to PHP as instances of the Variant class.

For some reason, the variant_date_to_timestamp function returned incorrect timestamps. As a workaround, I used variant_set_type($variant, VT_BSTR) to get a string representation of the date. This can be used for most variant types PHP doesn't handle.
To Top