$dsn = 'mysql://user:password@localhost/mydatabase'; $parsed = parseDSN($dsn); print_r($parsed);
Array ( [phptype] => mysql [hostspec] => localhost [database] => mydatabase [username] => user [password] => password )
$dsn = 'pgsql://user:password@localhost/mydatabase?sslmode=require'; $parsed = parseDSN($dsn); echo $parsed['sslmode'];
requireIn this example, we are parsing a PostgreSQL database DSN with an SSL mode parameter and printing its value. The output is "require", which is the value of the SSL mode parameter specified in the DSN. The parseDSN function is part of the PEAR package library, which is a collection of reusable PHP components that can be installed and used as standalone libraries in PHP applications.