3

Is there any standard way to concatenate variables of an .ini-file?
The .ini-file is parsed by PHP, so I know that it's possible to do it in PHP, but is it possible inside an .ini-file?

Example for the file:

; definition of the server root
[root]
path=/var/path/to/server/root/
url=http://www.domain.xx/

And I'd like to define some "subpaths", I'd like something like this:

; definition of the server root
[root]
path=/var/path/to/server/root/
url=http://www.domain.xx/

; tree definition
[tree]
upload=/subpath/to/upload/directory/
upload_path=CONCATENATE(root.path,tree.upload)
upload_url=CONCATENATE(root.url,tree.upload)

Is this possible?
If not, is there a filetype used for configs where this is possible?

Varg__
  • 134
  • 9
Honza
  • 939
  • 2
  • 11
  • 28
  • INI files does not allow you to include any logic, but you can do it by being tricky. Define upload_path as `upload_path=root.path,tree.upload`. Then in PHP read a value, and do some splitting: `$parts = explode(",",$uploadPath);` Now you will have and array that will look like this: ['root.path', 'tree.upload']. Now in a loop `foreach($parts as $part) { $blocks = explode( ",", $part);}` With such array you can now build your paths without problems. – Kamil Szymański Mar 13 '15 at 11:21
  • you would need to expand the `CONCATENATE()` in PHP code. But good idea! +1 – hek2mgl Mar 13 '15 at 11:45
  • I thought it, unfortunately :-(. @eeree, please move your comment as the answer to check it as the correct one. Thanks to both of you. – Honza Mar 13 '15 at 12:23

1 Answers1

2

INI files does not allow you to include any logic, but you can do it by being tricky. Define upload_path as upload_path=root.path,tree.upload. Then in PHP read a value, and do some splitting: $parts = explode(",",$uploadPath); Now you will have and array that will look like this: ['root.path', 'tree.upload']. Now in a loop foreach($parts as $part) { $blocks = explode( ",", $part);} With such array you can now build your paths without problems. @elefantito

Kamil Szymański
  • 950
  • 12
  • 26
  • sadly it does not answer the question that is avout ini files in general... (but may be helpful for those who use it for php) – OznOg Mar 24 '21 at 08:16