Is there a way to use a *.properties file in PHP as you do in Java? I’d like to store some application-level constants in a properties or XML file and easily call them from throughout my code. Your guidance is much appreciated. Thanks.
Advertisement
Answer
PHP can natively load and parse .ini
files using parse_ini_file()
.
You can also set up constants in an include file using define()
.
If you’re set on XML, look into PHP’s XML functionality. The simplest solution is probably to use SimpleXML.