php中如何显示图片?下面本篇文章就来给大家介绍使用php插入图片的两种方法,希望对你们有所帮助。

php中显示图片的两种方法:
1、使用PHP的file_get_contents()函数
file_get_contents() 函数把整个文件读入一个字符串中。
立即学习“PHP免费学习笔记(深入)”;
示例:
<?php
header('content-type:image/jpg;');
$content=file_get_contents('1.jpg');
echo $content;
?>输出:

2、使用echo+img标签
使用PHP插入图片,实际还是输出HTML代码。
示例:
<?php echo "<img src='1.jpg' />"; ?>
输出:












