Ever since PHP went from 5+ to 7+ and changed all of the mysql_ tags, it made me wonder if I can create my own function name that I can use in multiple and if PHP ever decides to change that function again then all I have to do it edit my own custom function instead of having to replace them all in all of by files.
Example, instead of using the old mysql_query(), I could name it my_query() and create a function like:
I know this is the old version, its not really relevant to my question
function my_query($sql)
{
$result = mysql_query($sql);
$sql_error = mysql_error();
if ( DEBUG )
{
$display_sql = $sql;
}
if( !$result )
{
print("<center><font color=red><b>SQL Error!</b></font><br><br>Query:<br>$display_sql<br>$sql_error<br><br></center>");
}
return $result;
}
I can then make the changes inside of the my_query() and change use the mysqli_query($con, $res); inside of the one my_query() function instead of having to change all of the mysql_query()’s that I used a lot in all of my files. I am wondering if that would make the site run slower or not noticable, same loading speed using my own custom function name? Thanks
PHP_Newbie45 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.