CKTIS / PHP
Complemento bit a bit (~)
Inverte ogni bit dell’unico operando.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
~$valueInverte ogni bit dell’unico operando. Per un intero usa l’intera larghezza del tipo, quindi ~0 dà −1. Per una stringa inverte i bit di ciascun byte e restituisce una stringa. L’uscita esadecimale mostra anche byte che non costituiscono testo valido.
~$value
[-1,-6,"be"]
Esempi
<?php
echo json_encode([~0, ~5, bin2hex(~"A")]);
Risultato
[-1,-6,"be"]