aspose file tools*
The moose likes PHP and the fly likes Can we have PROPERTIES file in PHP like JAVA? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » PHP
Bookmark "Can we have PROPERTIES file in PHP like JAVA?" Watch "Can we have PROPERTIES file in PHP like JAVA?" New topic
Author

Can we have PROPERTIES file in PHP like JAVA?

Aniket S. Kulkarni
Ranch Hand

Joined: Jun 15, 2011
Posts: 87

I want to know can we have .PROPERTIES file as like JAVA in PHP to access resources?
if yes then tell me how is it?


Aniket Kulkarni
Oracle Certified Professional, Java SE 6 Programmer.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

yes you can use properties file but it doesn't behave like in java, let say you have file like this.

sample.properties

value1 =text one
value2 =text two
value3 =text three


so when you load this file like this.



this returns you the array like this



while php has another way of loading key value file using parse_ini_file check this out.

hope its helps.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Nick Charles
Ranch Hand

Joined: Oct 09, 2011
Posts: 71

Java uses properties files because Java code gets compiled into binary format and therefore making any code changes becomes difficult. By removing configuration values ot a text file, Java enables people to change the confioguration without recompiling.

PHP, on the other hand, is not compiled into binary. Therefore, the PHP files are always editable by a a plain text editor. Most PHP apps handle confguration options by placing them into a separate PHP file with lots of comments describing each setting. And the settings are directly made to variables. Then any PHP code that needs those settings includes that file and then uses the variables. For an example of this, look at the settings.php file that comes with Drupal.
Aniket S. Kulkarni
Ranch Hand

Joined: Jun 15, 2011
Posts: 87

Thank you Muhammad Saifuddin and Nick Charles for your valuable reply.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we have PROPERTIES file in PHP like JAVA?