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.
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('content-type:image/jpg;'); $content=file_get_contents('How to display pictures in php?'); echo $content; ?>
Output:
2. Use echo img tag
Using PHP to insert pictures actually outputs HTML code.
Example:
<?php echo "<img src='How to display pictures in php?' / alt="How to display pictures in php?" >"; ?>
Output:
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!