note 104638 added to function.pathinfo

From: Date: Mon, 27 Jun 2011 16:39:38 +0000
Subject: note 104638 added to function.pathinfo
Groups: php.notes 
Request: Send a blank email to php-notes+get-181001@lists.php.net to get a copy of this message
pathinfo will return null if 0 or null is specified for the option argument. So you'll need to define it's value manually if the option field is omitted, to provide the default functionality. <?php public function getFileInfo($source = null, $option = null){ if(!$option){ //1 + 2 + 4 $option = PATHINFO_DIRNAME + PATHINFO_BASENAME + PATHINFO_EXTENSION; if(defined('PATHINFO_FILENAME')) $option += PATHINFO_FILENAME; //8 } return pathinfo($source, $option); } $obj->getFileInfo("/test/file/someFile.txt"); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 173.8.63.13 ---- Manual Page -- http://www.php.net/manual/en/function.pathinfo.php Edit -- https://master.php.net/note/edit/104638 Del: integrated -- https://master.php.net/note/delete/104638/integrated Del: useless -- https://master.php.net/note/delete/104638/useless Del: bad code -- https://master.php.net/note/delete/104638/bad+code Del: spam -- https://master.php.net/note/delete/104638/spam Del: non-english -- https://master.php.net/note/delete/104638/non-english Del: in docs -- https://master.php.net/note/delete/104638/in+docs Del: other reasons-- https://master.php.net/note/delete/104638 Reject -- https://master.php.net/note/reject/104638 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181001) next »