Magento 1.8 – Difference Between htmlEscape and escapeHtml Functions

magento-1.8

I've just been updating a Magento site, and I see one change in the base template files is that htmlEscape has become escapeHtml throughout. Is there any difference between these two functions?

Is it, as I suspect, that Magento are gradually getting rid of htmlEscape and we should no longer use it?

Best Answer

The answer is found in the class where it is defined: app/code/core/Mage/Core/Block/Abstract.php

So it seems that some time after version CE 1.4.0.0-rc1 they decided that htmlEscape should be renamed to escapeHtml.

#File: app/code/core/Mage/Core/Block/Abstract.php
/**
 * @deprecated after 1.4.0.0-rc1
 * @see self::escapeHtml()
 */
public function htmlEscape($data, $allowedTags = null)
{
    return $this->escapeHtml($data, $allowedTags);
}

/**
 * Escape html entities
 *
 * @param   mixed $data
 * @param   array $allowedTags
 * @return  string
 */
public function escapeHtml($data, $allowedTags = null)
{
    return $this->helper('core')->escapeHtml($data, $allowedTags);
}