PHP - Variables not replaced in PDO connection string
问题 Strange issue - I have a live copy of a database class (using PDO) that works fine. I have a copy on my machine using WAMPServer which does not. The connection string is as follows (a snippet from the class): $host = 'localhost'; $user = 'user'; $pass = 'password'; $dbname = 'my_dbname'; self::$_instance = new PDO('mysql:host=$host;dbname=$dbname', $user, $pass); The error messages I get are: Warning: PDO::__construct() [pdo.--construct]: php_network_getaddresses: getaddrinfo failed: No such