func_num_args
PHP-P1001Instead of using func_get_args()
with count()
function, consider using PHP's built-in function func_num_args()
to count number of arguments of the function.
This is a micro-optimization. Apply it in case of intensive usage.
function sql_substr($expr, $start = 1, $length = false) {
if (count(func_get_args()) < 2) {
return '';
}
if ($length === false) {
return "SUBSTR($expr, $start)";
} else {
return "SUBSTR($expr, $start, $length)";
}
}
function sql_substr($expr, $start = 1, $length = false) {
if (func_num_args() < 2) {
return '';
}
if ($length === false) {
return "SUBSTR($expr, $start)";
} else {
return "SUBSTR($expr, $start, $length)";
}
}