Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PHP allow *.properties file as in Java?

Tags:

java

php

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.

like image 480
Alex Avatar asked May 05 '11 15:05

Alex


People also ask

What language is .properties file?

properties is a file extension for files mainly used in Java-related technologies to store the configurable parameters of an application. They can also be used for storing strings for Internationalization and localization; these are known as Property Resource Bundles.

How do I use .properties file?

The Properties file can be used in Java to externalize the configuration and to store the key-value pairs. The Properties. load() method of Properties class is convenient to load . properties file in the form of key-value pairs.

Can we write to properties file in Java?

In Plain Java A properties file consists of key-value pairs of string type. We can write values to a properties file in plain Java using the Properties class.


1 Answers

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.

like image 126
ceejayoz Avatar answered Sep 19 '22 22:09

ceejayoz