Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

PHP type mixed

The mixed declaration explicitly accepts all PHP values, including null, resources and objects.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

function describe(mixed $value): string

The mixed declaration explicitly accepts all PHP values, including null, resources and objects. It documents an unrestricted input without converting or validating it. Narrow the value before using operations that require a specific type. Combining mixed with another union member is redundant and is rejected.

function describe(mixed $value): string { return is_string($value) ? strtoupper($value) : get_debug_type($value); }
echo json_encode([describe('ab'), describe(null), describe(7)]);
["AB","null","int"]

Examples

<?php
function describe(mixed $value): string { return is_string($value) ? strtoupper($value) : get_debug_type($value); }
echo json_encode([describe('ab'), describe(null), describe(7)]);

Result

["AB","null","int"]

Sources