我想写一个新行与PHP文件,我收到以下错误:为什么我在PHP中出现语法错误?
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
这是我的代码:
public function add_line($line, $value, $file){
$CI =& get_instance();
$CI->load->helper('file');
foreach($this->existing_langs as $lang){
$lang_contents = read_file($this->lang_path.'/'.$lang.'/'.$file.'_lang.php');
$new_contents = $lang_contents."\n$lang['".$line."'] = '".$value."';"; //Error happens on this line
write_file($this->lang_path.'/'.$lang.'/'.$file.'_lang.php', $new_contents, 'w+');
}
}
我已经指出了行了用php评论发生错误。这条线有什么问题? lang_contents的
实施例:new_contents的
<?php
$lang['1234'] = 'Restaurants';
实施例:
<?php
$lang['1234'] = 'Restaurants';
$lang['1235'] = 'Transportation';
你几乎已经......但是$ lang应该是文字。 – ShoeLace1291