PHP code example of bluefrg / parsepdodsn

1. Go to this page and download the library: Download bluefrg/parsepdodsn library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bluefrg / parsepdodsn example snippets



$dsn = Bluefrg\ParsePdoDsn\Dsn::parse('mysql:host=localhost;dbname=testdb');

// Get the prefix
echo $dsn->getPrefix(); // mysql

// Fetch an element's value 
echo $dsn->element('host'); // localhost 
echo $dsn->element('dbname'); // testdb

// List all elements as key-values
print_r($dsn->getElements());