मैं PHP के साथ एक फ़ाइल को एक नई लाइन लिखने की कोशिश कर रहा हूँ और मैं निम्नलिखित त्रुटि हो रही है:मुझे PHP में सिंटैक्स त्रुटि क्यों मिल रही है?
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+');
}
}
मैं रेखा ने बताया है:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
यह मेरा कोड है एक PHP टिप्पणी के साथ त्रुटि होती है। इस लाइन में क्या गलत है?
lang_contents का उदाहरण:
<?php
$lang['1234'] = 'Restaurants';
new_contents का उदाहरण:
<?php
$lang['1234'] = 'Restaurants';
$lang['1235'] = 'Transportation';
आपके पास लगभग था ... लेकिन $ लैंग को शाब्दिक माना जाना चाहिए। – ShoeLace1291