Home > Backend Development > PHP Tutorial > How to display pictures in php?

How to display pictures in php?

青灯夜游
Release: 2023-04-06 15:58:02
Original
30747 people have browsed it

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;
?>
Copy after login

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?" >";
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template