Step 1: run the following code to throw to functions. phpfunctionget_qr ($ url, $ path, $ qrpic) {set_time_limit (10); set the ten-second timeout value $ destination_folder $ path? $ Path.:; $ localname $ destination_folder. $ qrpic; $ filefopen ($ url, rb); r + mode of the fopen function: Read
Step 1: run the following code to throw the function get_qr ($ url, $ path, $ qrpic) {set_time_limit (10); // set the ten-second timeout value $ destination_folder = $ path? $ Path. '/': ''; $ localname = $ destination_folder. $ qrpic; $ file = fopen ($ url, "rb"); // r + mode of the fopen function: Read
Step 1: run the following code in functions. php:
Function get_qr ($ url, $ path, $ qrpic) {set_time_limit (10); // set the 10-second timeout value $ destination_folder = $ path? $ Path. '/': ''; $ localname = $ destination_folder. $ qrpic; $ file = fopen ($ url, "rb"); // r + mode of the fopen function: open the file pointer in read/write mode to the file header if ($ file) {$ newf = fopen ($ localname, "wb"); // w +, open the file pointer in read/write mode and point to the file header. if the file does not exist, try to create if ($ newf) while (! Feof ($ file) {fwrite ($ newf, fread ($ file, 1024*2), 1024*2); // write the file, fread controls the maximum file size, here is 2 M }}if ($ file) {fclose ($ file); // close the file opened by fopen} if ($ newf) {fclose ($ newf );}}
Step 2: create a new folder named qrcode in the root directory of the website to ensure that you have the write permission,
Step 3: place the following code in the area where you need to output the QR code image, such as single. php.
/Qrcode/
. Jpg "width =" 100 "height =" 100 "alt =" QR code "/>
The tutorial is over. Below are some of my thoughts during the code writing process,
- For PHP
fopen
FunctionFopen cannot directly obtain https headers.
- For wordpress
the_permalink
Andget_permalink
FunctionThe former isDisplayDirectly output the result, which isReturnReturn value. The latter must be used to use such variables in user-defined functions.
For example, the usage of the_id and get_the_id is the same.
Fopen-qr is coded by xiaohudie. Any posts here is one hundred percent original, so please keep my link so as not to hurt this pretty girl