CKTIS / PHP
Tipo PHP null
Il tipo ha il solo valore null e può essere dichiarato da solo da PHP 8.2.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
function clear(): nullIl tipo ha il solo valore null e può essere dichiarato da solo da PHP 8.2. Null può rappresentare dati assenti, ma una chiave che contiene null esiste comunque. Nelle impostazioni distingui la presenza della chiave da un valore diverso da null.
function clear(): null { return null; }
$settings = ['quota'=>clear()];
echo json_encode([$settings['quota'], array_key_exists('quota',$settings), isset($settings['quota'])]);
[null,true,false]
Esempi
<?php
function clear(): null { return null; }
$settings = ['quota'=>clear()];
echo json_encode([$settings['quota'], array_key_exists('quota',$settings), isset($settings['quota'])]);
Risultato
[null,true,false]