This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we have PROPERTIES file in PHP like JAVA?

 
Aniket S. Kulkarni
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?
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
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.
 
Nick Charles
Ranch Hand
Posts: 71
Linux PHP 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic