Hongmu Notes
Home Summary of pitfalls

Summary of pitfalls

A summary of common mistakes encountered when building websites... This list isn't exhaustive; it merely records the issues I faced during my own development projects.

Use htmlspecialchars to escape articles in the database

Use htmlspecialchars to escape articles in the database Summary of pitfalls

A small note: use the htmlspecialchars_decode() function to restore escaped characters to HTML tags $str = '<p><span style=";font-family:Microsoft Yahei;font-size:16px"&…
👁 148
The solution to the confusion on the file_get_contents page

The solution to the confusion on the file_get_contents page Summary of pitfalls

My page is utf-8, the page of file_get_contents is gb2312, and the Chinese characters are garbled when output. The solution is as follows: Copy the code <?php header("Content-Type:text/html;charset=utf-8"); $keyworld="coal seam&quot…
👁 197
Optimized alternative function for file_get_contents

Optimized alternative function for file_get_contents Summary of pitfalls

curl() is several times faster than file_get_contents(). function curl_file_get_contents($durl) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $durl); curl_setopt($ch, CURL…
👁 163
Universal website pv to advertising click plug-in

Universal website pv to advertising click plug-in Summary of pitfalls

A customer asked me to write a plug-in for him to convert website PV to advertisement click. I wrote him a plug-in according to his request. I only need to put the following code into a php file, and then introduce this php file to realize this function. PHP plug-in code: <?php /************************ Parameter configuration begins *********************...
👁 229
How to refresh the verification code when clicking on it

How to refresh the verification code when clicking on it Summary of pitfalls

Generally implemented through js, just reload the value of src<img src="index.php?p=back&c=Admin&a=captcha" onclick="this.src=this.src+'&k='+Math.random();"/…
👁 198
Commonly used regular expressions

Commonly used regular expressions Summary of pitfalls

Regular expression URL (URL) [a-zA-z]+://[^\s]*IP address (IP Address)((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?) Email (Email)\w+([-+.]\w+)*@\w+([-.]\w+)*…
👁 243
Browser caching increases the speed of secondary visits to your website

Browser caching increases the speed of secondary visits to your website Summary of pitfalls

Use browser caching of official words: If users will visit your website multiple times, browser caching of static resources can save users time. Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images). Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.). Normally, HTML doesn’t…
👁 202
1 12 13 14