Home  >  Article  >  Backend Development  >  How to display pictures in php?

How to display pictures in php?

青灯夜游
青灯夜游Original
2019-05-11 15:32:2930668browse

How to display pictures in php? The following article will introduce to you two methods of inserting images using PHP. I hope it will be helpful to you.

How to display pictures in php?

Two methods to display images in PHP:

1. Use PHP’s file_get_contents() function

The file_get_contents() function reads the entire file into a string.

Example:

<?php
header(&#39;content-type:image/jpg;&#39;);
$content=file_get_contents(&#39;How to display pictures in php?&#39;);
echo $content;
?>

Output:

How to display pictures in php?

2. Use echo img tag

Using PHP to insert pictures actually outputs HTML code.

Example:

<?php
echo "<img  src=&#39;How to display pictures in php?&#39; / alt="How to display pictures in php?" >";
?>

Output:

How to display pictures in php?

The above is the detailed content of How to display pictures in php?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn