Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Can we have PROPERTIES file in PHP like JAVA?

 
Ranch Hand
Posts: 87
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 71
PHP Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Muhammad Saifuddin and Nick Charles for your valuable reply.
 
    Bookmark Topic Watch Topic
  • New Topic