How can you encrypt a word in Java using bitwise operations and decrypt it in PHP?

To encrypt a word in Java using bitwise operations, you can XOR each character of the word with a key to generate a cipher text. To decrypt it in PHP, you need to perform the same XOR operation using the same key to retrieve the original word.

<?php

function decryptWord($encryptedWord, $key) {
    $decryptedWord = '';
    for ($i = 0; $i < strlen($encryptedWord); $i++) {
        $decryptedWord .= chr(ord($encryptedWord[$i]) ^ $key);
    }
    return $decryptedWord;
}

$encryptedWord = "encrypted_word_here";
$key = 42;

$decryptedWord = decryptWord($encryptedWord, $key);
echo $decryptedWord;

?>