Is there a more effective way to implement a copy protection mechanism in PHP?

One way to implement a more effective copy protection mechanism in PHP is by using encryption and decryption techniques to obfuscate the code. By encrypting the PHP code and decrypting it at runtime, it becomes more difficult for unauthorized users to copy or modify the code.

<?php
function encrypt_code($input, $key) {
    return openssl_encrypt($input, 'AES-256-CBC', $key, 0, '1234567890123456');
}

function decrypt_code($input, $key) {
    return openssl_decrypt($input, 'AES-256-CBC', $key, 0, '1234567890123456');
}

$original_code = file_get_contents('original_code.php');
$encrypted_code = encrypt_code($original_code, 'secret_key');

file_put_contents('protected_code.php', $encrypted_code);

// To decrypt and execute the protected code
$protected_code = file_get_contents('protected_code.php');
$decrypted_code = decrypt_code($protected_code, 'secret_key');

eval($decrypted_code);
?>