Cake\View\Helper\HtmlHelper::charset PHP Method

charset() public method

Returns a charset META-tag.
public charset ( string | null $charset = null ) : string
$charset string | null The character set to be used in the meta tag. If empty, The App.encoding value will be used. Example: "utf-8".
return string A meta tag containing the specified character set.
    public function charset($charset = null)
    {
        if (empty($charset)) {
            $charset = strtolower(Configure::read('App.encoding'));
        }
        return $this->formatTemplate('charset', ['charset' => !empty($charset) ? $charset : 'utf-8']);
    }

Usage Example

Example #1
0
 /**
  * Returns a charset META-tag.
  *
  * @param null $charset
  * @return string
  */
 public function charset($charset = null)
 {
     return parent::charset($charset) . $this->Document->eol;
 }