PHP Using XML for configuration file (s) are elements that are better than attributes or vice versa?

I am using XML for a configuration file in PHP (using SimpleXML), creating a configuration file that is more standard.

Having all the values ​​in the elements or using attributes?

Elements Example:

<database>
   <user>test-user</user>
   <pass>test-pass</pass>
</database>

Attribute Example:

<database user="test-user" pass="test-pass"></database>

Are there any advantages anyway?

Other languages ​​may also need to read the same configuration file, such as Java and Perl.

+3
source share
2 answers

, XML - XML-. , .

. XML: IBM. .

:

XML, , , . :

  • , , , .
  • , , .
  • DTD, ID, IDREF ENTITY, .
  • , . (XML- , .)
+3

XML , , .

, PHP.

<?
    $config['db']['user']="user";
    $config['db']['pass']="pass";
?>  

.

-2

Source: https://habr.com/ru/post/1735316/


All Articles