Próbuję napisać nową linię do pliku z PHP i dostaję następujący błąd:Dlaczego otrzymuję błąd składni w PHP?
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
To jest mój kod:
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+');
}
}
I wskazał na linię Błąd występuje z komentarzem php. Co jest nie tak z tą linią?
Przykład lang_contents:
<?php
$lang['1234'] = 'Restaurants';
Przykład new_contents:
<?php
$lang['1234'] = 'Restaurants';
$lang['1235'] = 'Transportation';
Prawie go masz ... ale $ Lang ma być dosłowny. – ShoeLace1291