Previously, the R & D channel published "use directly, 10 PHP code snippets", which was well received by netizens. In this article, I will continue to share nine extremely useful PHP code snippets. When developing websites, applications, or blogs, you can use the code to save a lot of time. Previously, the R & D channel published "use directly, 10 PHP code snippets". it was well received by netizens. In this article, I will continue to share nine extremely useful PHP code snippets. When developing websites, applications, or blogs, you can use the code to save a lot of time.
1. check whether the email has been read
When you send an email, you may want to know whether the email has been read by the recipient. Here is a very interesting code snippet that shows the actual date and time when the recipient's IP address records are read.
Error_reporting (0 );
Header ("Content-Type: image/jpeg ");
// Get IP
If (! Empty ($ _ SERVER ['http _ CLIENT_IP '])
{
$ Ip = $ _ SERVER ['http _ CLIENT_IP '];
}
Elseif (! Empty ($ _ SERVER ['http _ X_FORWARDED_FOR '])
{
$ Ip = $ _ SERVER ['http _ X_FORWARDED_FOR '];
}
Else
{
$ Ip = $ _ SERVER ['remote _ ADDR '];
}
// Time
$ Actual_time = time ();
$ Actual_day = date ('Y. m. D', $ actual_time );
$ Actual_day_chart = date ('d/m/Y', $ actual_time );
$ Actual_hour = date ('H: I: S', $ actual_time );
// GET Browser
$ Browser = $ _ SERVER ['http _ USER_AGENT '];
// LOG
$ MyFile = "log.txt ";
$ Fh = fopen ($ myFile, 'A + ');
$ StringData = $ actual_day. ''. $ actual_hour.''. $ ip. ''. $ browser.''. "\ r \ n ";
Fwrite ($ fh, $ stringData );
Fclose ($ fh );
// Generate Image (Es. dimesion is 1x1)
$ Newimage = ImageCreate (1, 1 );
$ Grigio = ImageColorAllocate ($ newimage, 255,255,255 );
ImageJPEG ($ newimage );
ImageDestroy ($ newimage );
?>