First, to do PKCS#5 padding on the input you need to improvise:
// source: http://php.net/manual/en/ref.mcrypt.php#69782
function pkcs5_pad($text, $blocksize)
{
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
Then select your algorithm and generate the IV:
$alg = MCRYPT_RIJNDAEL_128; // AES
$mode = MCRYPT_MODE_ECB; // not recommended unless used with OTP
$iv_size = mcrypt_get_iv_size($alg, $mode);
$block_size = mcrypt_get_block_size($alg, $mode);
$iv = mcrypt_create_iv($iv_size, MCRYPT_DEV_URANDOM); // pull from /dev/urandom
Initialize your encryption key:
$key = "This is a very secret key";
Apply padding to the input and encrypt it
$input = pkcs5_pad($input, $block_size);
$crypttext = mcrypt_encrypt($alg, $key, $input, $mode, $iv);