PHP crypt字符串

I try to crypt the sso ticket on my flash game.

var flashvars = {
"sso.ticket" : "<?PHP echo TicketRefresh($user['username']); ?>" };

This is the part of the code i've tried to encrypt it

function encrypt($pure_string, $encryption_key) {
$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $encryption_key,
utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv);
return $encrypted_string;
}

<?php
define("ENCRYPTION_KEY", "!@#$%^&*");
$string = TicketRefresh($user['username']);
$encrypted = encrypt($string, ENCRYPTION_KEY);
?>

var flashvars = {
"sso.ticket" : "<?PHP echo $encrypted; ?>" };

I am a beginner and I don't know what is wrong with it, thank you for your help.

Encrypt is not a PHP function

crypt is one, that should be used with a salt for more security:

$encrypted = crypt($string, $longSalt);

I recommend you to use a $longSalt of random characters of 10 or more characters