Connection strings, or data source names (abbreviated DSN) as they are called in the PDO documentation, are PHP strings that carry such information as the name of the database management system and of the database itself, as well as other connection parameters.
Their advantage over using traditional methods of creating database connection is that you don't have to modify your code if you change the database management system. A connection string can be defined in a configuration file and that file gets processed by your application. Should your database (data source) change, you just edit that configuration file and the rest of your code is kept intact.
The connection strings used in PDO differ due to the existence of different database management systems. However, they always have a common prefix, which denotes the underlying database driver. Remember the MySQL, SQLite, and PostgreSQL examples in the Chapter 1. The three connection strings looked like the following:
mysql...