Multiple Arguments

In real life, I’m not a fan of arguments.
But sometimes in code, arguments can be a good thing.

function addFailure($id) {
	$query = "insert into billing_history (id, auth_success) values($id, 0)";
	mysql_query($query) or die(mysql_error());
}
function addSuccess($id) {
	$query = "insert into billing_history (id, auth_success) values($id, 1)";
	mysql_query($query) or die(mysql_error());
}

Sometimes 1 function with 2 arguments is better than 2 functions with 1 argument.

function billing_history_create($id, $success) {
	$query = "insert into billing_history (id, auth_success) values($id, $success)";
	mysql_query($query) or die(mysql_error());
}

No Comment

No comments yet

Leave a reply