我是新來的PHP,我試圖用PHP創建一個簡單的多語言網站。我在下面提到了我的總代碼,並且我在該en.php,fn.php文件中共有四個文件,index.php,setlocal.php和一個文件夾語言環境。時遇到的文件夾結構這樣的..php多語言網站錯誤問題
----
index.php
setlocal.php
locale
en.php
fn.php
文件碼是..
的index.php
<?php
include_once "setlocal.php";
?>
<!doctype html>
<head>
<title><?php echo $GLOBALS['l']['title1']; ?></title>
</head>
<body>
<ul class="header-nav pull-right">
<li><a href="index.php?lang=en">English</a></li>
<li><a href="index.php?lang=fn">French</a></li>
</ul>
<p><?php echo $GLOBALS['l']['homdes1']; ?></p>
</body>
</html>
setlocal.php
<?php
($language = @$_GET['lang']) or $language = 'en';
$allowed = array('en', 'te');
if(!in_array($language, $allowed)) {
$language = 'en';
}
include "locale/{$language}.php";
$GLOBALS['l'] = '$local';
?>
區域
|
en.php
<?php
$local = array (
'title1' => 'sample english content',
'homdes1' => 'sample english contentsample english contentsample english content');
?>
fn.php
<?php
$local = array (
'title1' => 'sample french content',
'homdes1' => 'sample french contentsample french contentsample french contentsample french contentsample french content');
?>
當我運行它呈現這樣下面的錯誤代碼,請幫我解決這個問題,謝謝。
Warning: Illegal string offset 'homdes1' in D:\madhu_new\korimerla\htdocs\korimerla\php\index.php on line 15
$
三江源這麼多,它的工作的罰款。 – vadlamani