Re: Image script

From: Date: Sun, 13 Apr 2003 13:32:10 +0000
Subject: Re: Image script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143662@lists.php.net to get a copy of this message
> From: "luther" <lblanton@spacebetween.com> > > Is there a script to use with images that will determine which graphic is > needed by the name of the page? For example, say you have a site which uses > a unique header graphic for each section but you don't want to hardcode the > exact name of the image into each HTML page. So, if you have a file called > "news.php" it would automatically determine the "News" graphic is needed > for > that page. > > Any help would be appreciated as I've looked and looked and can't find a > script like this anywhere. You can write simple functions that display specific sections of a page (using different graphics or menus or whatever) based on URL: function display_header($page) { if (ereg("page_name_1", $page) { $graphic = "this.jpg"; } elseif (ereg("page_name_2", $page){ $graphic = "that.jpg"; } else { $graphic = "default.jpg"; } // HTML code using $graphic } When you call the function, pass it the value of the current page: display_header($PHP_SELF); -- Lowell Allen

« previous php.general (#143662) next »