here is an example basically from the manual.
<?php
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$key = "This is a very secret key";
$text = "Meet me at 11 o'clock behind the monument.";
echo strlen($text) . "\n";
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB , $iv );
echo strlen($crypttext) . "\n";
echo rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256 , $key ,$crypttext , MCRYPT_MODE_ECB ,$iv) , "\x0" );
?>