🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

Display database queries, generation time, and memory usage in WordPress

This article shares a code to display the current page's database query count, page generation time, and memory usage at the bottom of any PHP website. Pure code, no need to insert code into the functions file. Add the following code to the Theme footer file (footer.php). The effect is as shown in the image below:页面数据库查询内存使用信息The specific code is as follows:
本页面在  秒里勾搭了  次数据库,消耗了   MB的内存。
Explain the meaning of /1000000: by default, memory_get_peak_usage outputs a value in Bytes. To calculate the value in MB, you need to /1024/1024, but the result will have a long tail. So, directly dividing by 1 million cuts off the tail. If you only want to display generation time and database queries, there is also the following writing method.
 –>
If you want the above code to only display in the source code, then add comment tags, as follows:
If you only want to display it to logged-in users, then write it as below
';} ?>

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step instead.

「Naibabiji WordPress Website Building Coaching」 — From selecting a domain and purchasing hosting to installing themes and publishing posts, I「ll guide you through every step, helping you avoid detours and reach your goals directly.

👉 Learn about Website Building Coaching Service
🔒

Comments are closed

The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.

×
二维码

Scan to Follow