Php doesn’t have direct functions for AES encryption and decryption like MySql.
These functions will do exactly what the MySql functions do.

Encypt function:

function AES_ENCRYPT($value, $secret)
{
    return rtrim(
        base64_encode(
            mcrypt_encrypt(
                MCRYPT_RIJNDAEL_256,
                $secret, $value,
                MCRYPT_MODE_ECB,
                mcrypt_create_iv(
                    mcrypt_get_iv_size(
                        MCRYPT_RIJNDAEL_256,
                        MCRYPT_MODE_ECB
                    ),
                    MCRYPT_RAND)
                )
            ), "\0"
        );
}

Decrypt function:

function AES_DECRYPT($value, $secret)
{
    return rtrim(
        mcrypt_decrypt(
            MCRYPT_RIJNDAEL_256,
            $secret,
            base64_decode($value),
            MCRYPT_MODE_ECB,
            mcrypt_create_iv(
                mcrypt_get_iv_size(
                    MCRYPT_RIJNDAEL_256,
                    MCRYPT_MODE_ECB
                ),
                MCRYPT_RAND
            )
        ), "\0"
    );
}

These functions use base64_encode, so the hash can be stored in a regular VARCHAR or TEXT type field in MySql unlike the example in this article: Mysql AES_ENCRYPT not working properly.

Usage examples:

$password = "password_for_testing";
$secret = "a_very_difficult_key";
$crypted_hash = AES_ENCRYPT($password, $secret);
$regular_password = AES_DECRYPT($crypted_hash, $secret);
echo AES_DECRYPT(AES_ENCRYPT($password, $secret), $secret);