Related Content
PHP:CSI - To Switch, Or Not To Switch?
I was writing unit tests for a API mapping function recently and came across this interesting issue. The code I was writing tests for was in a legacy codebase that I was making changes to, and it made sense to have some unit tests in there before I started work to ensure everything worked before and after.
Drupal 9: Generating Header Images For Pages Of Content Using PHP
Embedding image within pages of content helps both within the design of the page and when shared on social media. If you set up meta tags to point at a particular image then that image will appear when the page is shared on social media. This makes your page stand out more.
Using PSR-4 With Composer
The PHP Standards Recommendations (called PSR) are a set of standards that aim to make certain aspects of working with PHP easier.
Generating A PDF From A Web Page Using PHP And Chrome
Generating a PDF document from a web page through PHP can be problematic. It's often something that seems quite simple, but actually generating the document can be difficult and time consuming.
PHP:CSI - Date Is Less Than One Month Ago
Working with logic surrounding dates can sometimes be difficult and it's fairly common to come across really subtle date and time based bugs.
I was recently shown a bug in a PHP application that looks like it should be working at face value, but doesn't actually produce the correct result.
An Introduction To Object Reflection In PHP
Reflection is used to gather more information about code during the runtime of the program. This allows code to inspect itself and to make small modifications, which is useful in a variety of situations.
Comments
Submitted by Emmanuel on Mon, 06/28/2010 - 04:51
PermalinkAnyone tell me how to get extension of that file
Submitted by Anyone tell me… on Sun, 11/15/2020 - 12:55
PermalinkIn the examples above I have used the following to extract the extension of the file.
However, I have not written it this way for a number of years now. My preferred route is to use the pathinfo() function. This will return information about the file name passed to it. For example.
Will print out.
If you want to get *just* the file extension then you pass in the PATHINFO_EXTENSION flag to the pathinfo() function. Like this.
This returns a string instead of the full array of file info, so the function now prints this:
I hope that answers your question?
Submitted by philipnorton42 on Sun, 11/15/2020 - 13:46
PermalinkAdd new comment