Help us understand the problem. What is going on with this article?

smartyからssi呼び出し。テンプレと出力が異文字コード。

More than 5 years have passed since last update.

呼び出し元

test.tpl
{ssi file="../design/ssi/head.html" ssi_enc="SJIS"}

smarty function

function.ssi.php
<?php

/**
 * ssi
 */
function smarty_function_ssi($params, &$smarty)
{

    if (empty($params['file'])) return '';
    if (empty($params['ssi_enc'])) return '';
    if (!file_exists($params['file'])) return '<!-- no file -->';

    $ssi = file_get_contents($params['file']);
    if (false === $ssi) return '';

    /*
    echo "<!--", PHP_EOL;
    echo "******************************", PHP_EOL;
    echo $ssi, PHP_EOL;
    echo "******************************", PHP_EOL;
    echo "-->", PHP_EOL;
    */

    $ret = mb_convert_encoding($ssi, mb_internal_encoding(), $params['ssi_enc']);

    /*
    echo "<!--", PHP_EOL;
    echo "******************************", PHP_EOL;
    echo $ret, PHP_EOL;
    echo "******************************", PHP_EOL;
    echo "-->", PHP_EOL;
    */

    return $ret;
}
mrk461
phpエンジニア / EC / CMS / cakephp(php) / plone(python) / wordpress(php) / movabletype(perl)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away