CSI: PHP

"Looking at your tweets I cannot even fathom what your job is. CSI:PHP?" — @grmpyprogrammer

Really? Preg_replace()?

| Comments

I found this in a database connection config file. How many problems do you see with this?  I’ll give you a head start — preg_replace() is overkill. And by overkill, I mean “absolutely unnecessary”.

1
2
3
4
5
6
7
8
9
<?php
// . . .
$MM_sql_HOSTNAME = 'hostname';
$MM_sql_DATABASE = 'mssql:dbname';
$MM_sql_DBTYPE = preg_replace('/:.*$/', '', $MM_sql_DATABASE);
$MM_sql_DATABASE = preg_replace('/^[^:]*?:/', '', $MM_sql_DATABASE);
$MM_sql_USERNAME = 'username';
$MM_sql_PASSWORD = 'secret';
// . . .

Comments