note 96279 added to function.array-pop

From: Date: Thu, 18 Feb 2010 09:38:24 +0000
Subject: note 96279 added to function.array-pop
Groups: php.notes 
Request: Send a blank email to php-notes+get-166113@lists.php.net to get a copy of this message
I have used array_pop() in a function that returns the name of the current file. This can be used, for example, in conjunction with filemtime() to get the modification time of the current file. The function I coded is a one-liner: <?php function whoAmI(){ return array_pop(explode("/", $_SERVER['PHP_SELF'])); } ?> If your file URI is www.foo.com/bar/foobar.php, whoAmI() will return foobar.php. To use it with e.g. filemtime() you would simply write: <?php $modtime = filemtime(whoAmI()); ?> Greetings, Jochen ---- Server IP: 217.160.72.57 Probable Submitter: 93.192.151.240 ---- Manual Page -- http://www.php.net/manual/en/function.array-pop.php Edit -- https://master.php.net/note/edit/96279 Del: integrated -- https://master.php.net/note/delete/96279/integrated Del: useless -- https://master.php.net/note/delete/96279/useless Del: bad code -- https://master.php.net/note/delete/96279/bad+code Del: spam -- https://master.php.net/note/delete/96279/spam Del: non-english -- https://master.php.net/note/delete/96279/non-english Del: in docs -- https://master.php.net/note/delete/96279/in+docs Del: other reasons-- https://master.php.net/note/delete/96279 Reject -- https://master.php.net/note/reject/96279 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166113) next »