简体   繁体   中英

pack language .ini or .php

There is a benchmark to measure the performance between parse_ini_file and include common?

I need to work with a language pack and I am in doubt whether I use .ini or .php

Could someone tell me what the positives and negatives of each way?

Thank you

It depends on how edits those files; are you considering .ini format to help translators? If so, that's an important design decision.

If who edits the files is not important, the next up is performance. In this case, parse_ini_file will always be slower; you can't beat include() , because it can be highly optimized (using opcode caches, think APC ).

Even if the performance were the same, the .ini is limited in terms of expressiveness; a .php data structure can describe more, can use objects, etc.

You should use Gettext , the common way of Internationalization

http://en.wikipedia.org/wiki/Gettext

you may take a look here: PHP ini vs array performance

i've done a test between an php file that contains an array and an ini file with 10.000 values each.

array (php) wins ;)

and array will win every time, because the server is basically optimized for reading php files (see also Jacks answer) and can load the array faster. reading an ini file means also to parse the ini into an array.

br

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM