2016-04-24 47 views
0

我所要做的,就是用language helper DIFF助手裏面:笨使用朗>線的輔助

$this->CI =& get_instance(); 


if (!function_exists('execute_dynamic_constants')) { 
    function execute_dynamic_constants() 
    { 
     ?> 
     <script type="text/javascript"> 
      var promptMsg = '<?php $this->CI->lang->line('success');?>'; 
     </script> 
     <?php 

    } 
} 

但似乎language helper沒有被加載。當我將它加載到$autoload['helper'] = array('url', 'file', 'language', 'form', 'Functions','DynamicJs');

我在這裏錯過了什麼?

回答

1

它看起來像缺少一個echo來將行打印到HTML。此外,CI 2文檔聲明$ CI-> lang-> line()已被棄用,以支持lang();否則,CI 2將不會使用$ {lang-> line}。 http://www.codeigniter.com/userguide2/libraries/language.html

這是我如何使你的榜樣工作:

if (!function_exists('execute_dynamic_constants')) { 
    function execute_dynamic_constants() 
    { 
     ?> 
     <script type="text/javascript"> 
      var promptMsg = '<?php echo lang('success');?>'; 
     </script> 
     <?php 

    } 
} 

我放棄了$ CI參考,因爲它不再需要,如果郎();從預加載的語言助手被使用。 希望它有幫助:)

+0

thnx很多^ _^.. – Abanoub

+0

ellislab鏈接已過時現在請使用鏈接從http://www.codeIgniter.com/docs和ellislab不處理codeIgniter了。 – user4419336