adrian Posted April 19, 2013 Share Posted April 19, 2013 Hey Ryan, I am sure you have good reason for the approach you have taken - you usually do, and usually teach me something I don't know, but I was thinking it would be nice if we had the exact same options as PHP ie: dirname basename extension filename I know there is some overlap, but there seems to be some difference in behavior as well. In particular what I am missing is an emulation of PHP's filename which returns the basename without the extension. This of course would be a problematic backwards compatibility change. Anyway, just wanted to throw it out there Link to comment Share on other sites More sharing options...
ryan Posted April 22, 2013 Share Posted April 22, 2013 The only two of those that are PHP functions are dirname() and basename(). As far as I know, filename() and extension() are not PHP functions? So I'm not sure what you mean when you say "emulation of PHP's filename which returns the basename without the extension"? But I think I can tell you how to get the result you asked for of "basename without extension": echo basename($file->filename, '.jpg'); // substitute .jpg with extension you want to remove. Link to comment Share on other sites More sharing options...
adrian Posted April 22, 2013 Author Share Posted April 22, 2013 Sorry Ryan, I wasn't very clear on this - I was referring to the pathinfo options in php for: dirname basename extension filename Because I don't know what the extension is, I actually used which works great. pathinfo($file->filename,PATHINFO_FILENAME) I am fine with using this, rather than needing PW option. I think what prompted this email was the description in the API cheatsheet for $file->name which says: "Returns the filename without the path (basename)". I thought it would be nice if $file->name became $file->basename to make this clearer for those people used to PHP. Then it just seemed logical to have the other pathinfo options also availble. Anyway, really no big deal at all - just thinking out loud really Link to comment Share on other sites More sharing options...
ryan Posted April 24, 2013 Share Posted April 24, 2013 Actually $file->basename is there too. It's the same thing as $file->name. The $file->name is mainly there for consistency with other PW objects, in that we want everything in ProcessWire to reliably have a 'name' property. But I usually use $file->basename myself. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now