A must-have for developers and a practical PHP code snippet!

Source: Internet
Author: User
Tags get ip
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 );

?>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.