Home > Article > Backend Development > Use it directly. Nine super practical PHP code snippets (2)
Every programmer and developer loves to discuss their favorite code snippets, especially when PHP developers spend hours coding web pages or creating applications, they know the importance of these codes even more. In order to save coding time, the author has collected some more practical code snippets to help developers improve work efficiency. >>>
1) Whois query using PHP——Use PHP to obtain Whois request
Using this code, whois information can be obtained in a specific domain name. Take the domain name as a parameter and display information about all domain names.
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
2) Text messaging with PHP using the TextMagic API ——使用TextMagic API 获取PHP Test信息
TextMagic引入强大的核心API,可轻松将SMS发送到手机。该API是需要付费。
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
3) Get info about your memory usage——Get the memory usage
This code helps you get memory usage.
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
4) Display source code of any webpage——View the source code of any webpage
If you want to view the source code of the web page, then just change the URL on the second line and the source code will be displayed on the web page.
?
1 2 3 4 5 |
|
5) Create data uri’s——Create data uri
By using this code, you can create data Uri, which is very useful for embedding images in HTML/CSS and helps save HTTP requests.
?
1 2 3 4 5 |
|
6) Detect location by IP——Retrieve the geographical location through IP
This code helps you find a specific IP. Just enter the IP in the function parameter to detect the location.
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
7) Detect browser language——Check browser language
Detect the code script language used by the browser.
?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
;
}
echo "This is HTTPS" ; |
}
9) Generate CSV file from a PHP array——Generate .csv file in PHP array
?
|