Displaying an image with include() or require()

I use require_once() to display pages in a div.
I wonder how I could use this to display images as well.

Here is my code :

require_once 'gauche_1.php'; 

		if ( (isset($_GET['page'])) && (isset($checkPage[$_GET['page']])) ) {
			require_once $checkPage[$_GET['page']];
        }
		    elseif ( (isset($_GET['category'])) && (isset($checkCategory[$_GET['category']])) ) {
	           readfile($checkCategory[$_GET['category']]);
	        
		} 	/* if $page has a value, include it */
		else {
			require_once 'milieu_1.php';
			echo '<script type="text/javascript" src="../js/music.js"></script>';
		}

my include.php :

$checkPage = array('Sommaire' => 'milieu_1.php',
	            'Nouveautes' => 'news/index.php' ...,
                    'Permis_D_Avoir_Du_Culot' => 'image.jpg');

Abd the html code :

<div class="licenseGallery">
                <a href="menu.php?category=Permis_D_Avoir_Du_Culot">
                    <img src="sweeties/permis/tn_permis_avoir_du_culot.jpg" alt="permis_avoir_du_culot.jpg">
                    <div class="licenseDescription">
                        permis_avoir_du_culot.jpg
                    </div>
                </a>
            </div>

:thinking: I sure do not understand why you would want to do that in the first place? That is why there are functions or methods in the first place. If you want to make a script portable in this case the ability to display an image based on a condition then consider writing a class would be better suited to do it or even a function though has a little less flexibility as a class.

Well, I’m a beginner, I don’t know how I can do that.

Sponsor our Newsletter | Privacy Policy | Terms of Service