Hello frnds input(given): filename without extension output(needed) : filename with extension thx in advance
You need to explain more, like where is the input coming from, show an example ? ...just a thought though, are you mixing up page names with file names ?
(input) $filename = thumbs_up; (output) echo " thumbs_up(.*)"; (.*) ->any extension while giving filename only as input and i wanna extension of that file as ouput (we know the filename, and its directory too)
<?php $filename = "somedir/somefile.php"; $extension = pathinfo($filename, PATHINFO_EXTENSION); echo $extension; ?> PHP:
I may have misunderstood as the question is hardly clear. I think the OP wants to pass a filename i.e. "myimage" and his PHP script works out from the file content that it's supposed to be "myimage.jpg" ? If so, I don't think there's any inbuilt support for this - there might be classes out there that support common filetypes..
There is no direct way to do this, most filetypes have their identification somewhere at the beginning. But not all do and they can be easily forged unless you use processor intensive checking.