Home >Backend Development >PHP Tutorial >Can php only use code to display an image?
Is there a way to use PHP functions to read an image and display it without using any front-end code? ? ?
Is there a way to use PHP functions to read an image and display it without using any front-end code? ? ?
file_get_contents(你的图片路径,可以是URL地址)
<code><?php $imagedata=file_get_contents('logoquan14483280771.PNG'); $data=getimagesizefromstring($imagedata); if(!$data){ exit('图片无效'); } header("content-type:".$data['mime']); ob_clean(); echo $imagedata;</code>
Yes, the verification code is a separate php file.
First of all, you need to set the file header. If the content-type is an image format, then you can directly output the image you read in. You can check the PHP image api
http://php.net/manual/en/book.image.php
Just read the base64 of the image and output it
The verification code is output directly using PHP. Generally, PHP is used to output the content. Just set the request header and add the relevant API. Usually, the text/html type is used to output text. Any apk, doc, exls can be output.