簡體   English   中英

用於gettext和poedit的php文件不起作用

[英]php files for gettext and poedit doesn't work

poedit和.po文件的創建都可以正常工作。 問題是我的PHP文件一直向我發送消息錯誤:

致命錯誤:無法在第12行的C:\\ xampp \\ htdocs \\ gettextdemo \\ demo.php中重新聲明_()

這是php文件的代碼

<?php /* Date de création: 2014-03-16 */ ?>
<html>
<body>
<?php
require_once("lib/streams.php");
require_once("lib/gettext.php"); 
$locle_lang = $_GET['lang'];
$locale_file = new FileReader("locale/$locle_lang/LC_MESSAGES/messages.mo");
$locale_fetch = new gettext_reader($locale_file);
function _($text)   
{
global $locale_fetch; 
return $locale_fetch->translate($text);
}
?> 
<h1><?php echo _("The best place in the world to get some text") ?> </h1> <p>
<?php echo _("the greatest son fo the bayou") ?> </p>
</body>
</html>

對不起,我找不到錯誤

謝謝

函數_是gettext中的保留函數。 重命名! 例如:

<?php /* Date de création: 2014-03-16 */ ?>
<html>
    <body>
        <?php
            require_once("lib/streams.php");
            require_once("lib/gettext.php"); 
            $locle_lang     = $_GET['lang'];
            $locale_file    = new FileReader("locale/$locle_lang/LC_MESSAGES/messages.mo");
            $locale_fetch   = new gettext_reader($locale_file);

            function __($text) {
                global $locale_fetch; 
                return $locale_fetch->translate($text);
            }
        ?> 
        <h1><?php echo __("The best place in the world to get some text") ?> </h1> <p>
        <?php echo __("the greatest son fo the bayou") ?> </p>
    </body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM