SHOW VARIABLES LIKE "%version%";
This is from Maria DB
version=10.0.7-MariaDB-1~quantal-log
This is from MySQL
version_comment=MySQL Community Server (GPL)
With PDO you can use ATTR_SERVER_VERSION
attribute to get server version:
echo $conn->getAttribute(PDO::ATTR_SERVER_VERSION); // output: <major>.<minor>.<build>-MariaDB