代码在windows下正常,但在linux下报错
<?php
mb_internal_encoding("Shift_JIS");//テストデータ
$com = new StdClass;$com->label = "あいうえお";
$author = "著者";
$text = "テキストXMLテスト";
$c_author = "五十音図";
// XMLの作成
$dom = new DOMDocument('1.0','Shift_JIS');header("Content-Type: text/plain");$item = $dom->appendChild($dom->createElement('item'));
$title = $item->appendChild($dom->createElement('title'));
$title->appendChild($dom->createtextNode($com->label));
$auth = $item->appendChild($dom->createElement('author'));
$auth->appendChild($dom->createtextNode($author));
$comment = $item->appendChild($dom->createElement('comment'));
$c_auth = $comment->appendChild($dom->createElement('c_author'));
$c_auth->appendChild($dom->createtextNode($c_author));
$c_text = $comment->appendChild($dom->createElement('c_message'));
$c_text->appendChild($dom->createtextNode($text));// 出力
echo $dom->saveXML();----------------------------
DOMDocument::saveXML() unkown encoding Shift_JIS
<?php
mb_internal_encoding("Shift_JIS");//テストデータ
$com = new StdClass;$com->label = "あいうえお";
$author = "著者";
$text = "テキストXMLテスト";
$c_author = "五十音図";
// XMLの作成
$dom = new DOMDocument('1.0','Shift_JIS');header("Content-Type: text/plain");$item = $dom->appendChild($dom->createElement('item'));
$title = $item->appendChild($dom->createElement('title'));
$title->appendChild($dom->createtextNode($com->label));
$auth = $item->appendChild($dom->createElement('author'));
$auth->appendChild($dom->createtextNode($author));
$comment = $item->appendChild($dom->createElement('comment'));
$c_auth = $comment->appendChild($dom->createElement('c_author'));
$c_auth->appendChild($dom->createtextNode($c_author));
$c_text = $comment->appendChild($dom->createElement('c_message'));
$c_text->appendChild($dom->createtextNode($text));// 出力
echo $dom->saveXML();----------------------------
DOMDocument::saveXML() unkown encoding Shift_JIS
header("Content-Type: text/plain");
到
header("Content-Type: application/xml");
是否你的Linux没有安装日文字符集,
是否你的Linux没有安装日文字符集, 同意 6 楼