Re: function basename()

From: Date: Mon, 30 Jul 2001 11:02:26 +0000
Subject: Re: function basename()
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-61537@lists.php.net to get a copy of this message
<teo@gecadsoftware.com> wrote in message news:20010726181145.B1100@gecadsoftware.com... > Hi Marcus! > On Thu, 26 Jul 2001, Marcus wrote: > > > shouldn't the function basename() return only the > > script part and not the query part? > I guess basename() is a filesistem function, and hence it doesn't make sense > to care about `query string' cause in the file systems there are no such > things. > > I guess you are trying to determine the name of the script from the query > string or what exactly? If so, it's quite simple to use basename(__FILE__); > No, i have a view selection - meaning on every page the user can select how to view the data. So there is a selection from those views. Each current view can be identified by basename( $PHP_SELF) which does not contain the query. The list of available views is generated dynamically into an array from an included script. Also the navigation is done in an included page becase every view includes this. Therefore: 1) if another view needs a query the navigation list must have that query. 2) __FILE__ cannot be userd as it is always the include file.... include1: ... $nav = array( $view1=>$url1, $view2=>$url2...) ... include2: ... <selct .... <?php $current_view = basename( $PHP_SELF); // PHP_SELF HAS NO QUERY foreach( $nav as $view=>$url) { $base = basename( $url); // HERE BASENAME HAS TO EXCLUDE QUERY if ( $basename==$current_view) { echo "<option value='$url' selected>$view</option>\n"; } else { echo "<option value='$url'>$view</option>\n"; } } ?></select> ...

« previous php.dev (#61537) next »