For example:
$file = fopen("File.txt", "r");
$filename = $file->basename;
if there was a method like basename for file objects (file pointer resources).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there is not a method to do. You should rather store the filename in a variable, like this:
Also, a little side note: a file pointer is not an object, it is a resource, which you can see by passing it to
var_dump()(it would output something likeresource(3) of type (stream)). This means that you cannot use it directly, you would have to use functions from the PHP core or a PHP extension to handle it. In the case of file pointers, you would use functions likefread(),fwrite()andfclose()to do so.