Home > Article > Backend Development > A pitfall in obtaining remote images with PHP
The content of this article is about a pitfall in obtaining remote images with PHP. It has a certain reference value. Now I share it with you. Friends in need can refer to it
https://steamcdn-a .akamaihd.net/steamcommunity/public/images/avatars/3b/3b7a04c0bb38aa354bba8086871c91050a5f2170_full.jpg. This is a remote image. You can type it directly in the URL address bar. When obtaining this image, file_get_contents and curl are both used. But it doesn’t work, I just can’t get it. The specific reason is not clear, but it works better if I change https to http. Just change the above link to http://steamcdn-a.akamaihd.net/steamcommunity/public/ images/avatars/3b/3b7a04c0bb38aa354bba8086871c91050a5f2170_full.jpg, you can get this picture. There is a lot of information on the Internet about the difference between http and https, but I can’t understand it. Generally speaking, https is the safe version of HTTP. When you live or die, You can think about this when you can't get it. There is also information on the Internet, and some solutions are at:
http://blog.csdn.net/terry_water/article/details/39377255 http://blog.csdn. net/gdali/article/details/52227601 http://www.jb51.net/article/44524.htm
http://www.jb51.net/article/72552.htm
http://blog.csdn.net/terry_water/article/details/39377255
But I think the easiest thing is to change https in the path to http. How to change it? explode(‘:’,$url), then change https to http and then splice them together, that’s it.
The above is the detailed content of A pitfall in obtaining remote images with PHP. For more information, please follow other related articles on the PHP Chinese website!