Reputation: 21
I have been trying to look into the error but can't seem to solve it. Can anyone help with this. Thank You.
Warning: syntax error, unexpected '(' in D:\langEn.ini on line 4 in D:\Xampp\htdocs\PhpProject1\companyinfo.php on line 12
class CompanyInfo
{
function parse_files()
{
//files created for localization
$file1 = "D:\langEn.ini";
$file2 = "D:\jap.ini";
if($file1 == TRUE)
{
print_r(parse_ini_file($file1));
}
else
{
print_r(parse_ini_file($file2));
}
}
}
$obj = new CompanyInfo;
$obj ->parse_files();
Output:
Company Name:
Unikaihatsu Software Private Limited
HO Address(Mumbai):
33-34, Udyog Bhavan, Sonawala Lane,
Goregaon (East), Mumbai, India, PIN 400-063
Phone:+91-22-26867334 Fax:+91-22-26867334
URL: http://www.usindia.com
Branch Office(Ahemdabad):
Unitech Systems
A/410, Mardia Plaza, Near G. L. S. College,
C. G. Road, Ahmedabad, India, PIN 380-006
Phone:+91-79-26461287 Fax:+91-79-40327081
URL: http://www.usindia.com
Branch Office(Indore):
1st Floor, MPSEDC-STP Building,
Electronics Complex,
Pardeshipura, Indore, India, PIN 452010
Phone : +91-731-4075738 Fax : +91-731-4075738
URL : http://www.usindia.com
Upvotes: 2
Views: 214
Reputation: 61983
I think the reason for the error is that you cannot use certain characters in your ini file.
In your case entries such as HO Address(Mumbai)
are invalid due to the brackets (
and )
.
From the PHP Manual:
Characters
?{}|&~![()^"
must not be used anywhere in the key and have a special meaning in the value.
You can read more in the parse_ini_file() documentation.
P.S. The above is the cause of the error you've asked about, but it's not the only problem you will encounter.
You should review your file structure in general, because it does not appear to match the standard ini file format at all. An ini file should generally be in the form
[simple]
val_one=SomeValue
val_two=567
[simple2]
val_three=SomeOtherValue
val_four=890
where [simple]
denotes a section, and then val_one
, val_two
etc. are keys, and SomeValue
, 567
etc. are values. Parsing the above using PHP's parse_ini_*
functions would produce either
Array
(
[val_one] => SomeValue
[val_two] => 567
[val_three] => SomeOtherValue
[val_four] => 890
)
or
Array
(
[simple] => Array
(
[val_one] => SomeValue
[val_two] => 567
)
[simple2] => Array
(
[val_three] => SomeOtherValue
[val_four] => 890
)
)
depending on whether the $process_sections
flag is set false or true. Live demo: https://3v4l.org/4q82F
Also this is slightly odd data to store in an ini file - these files are normally used to store things like application settings, whereas your office addresses are probably more suited to storing in a database (or at the very least in a JSON file), where there would be a) more structure, and b) fewer restrictions on the use of non-alphanumeric characters.
Upvotes: 1