Hi all,
I have recently been through someone else's script for file upload.
There were two scripts. One of them had:
<form action=page2.php enctype="multipart/form-data" method=post>
<input type=file name=blah>
</form>
Page2.php had lots of things, but there was a variable $blah_name, which was a complete mistery ! Of course, it is clear it was the name of the file, but he never set the variable, nor did he use it as global elsewhere ! It seems that the single fact that the file was input with name "blah" in one page would create a variable in next one.
The code worked, but it bugged me for long. I finally changed it to something like:
$leonelFileName = $_FILES[blah][name]
doSomeThingWith( $leonelFileName );
where doSomeThingWith is what I did with $blah_name, and now I do with $leonelFileName. (I chose to call the variable leonelFileName, because my name is Leonel and I wanted to make sure it would not collide with some built-in variable)
Both codes work, and the least is more easy to understand, especially for programmers that will take this script after me. Some questions arise: what makes PHP create variables this way ? Is it some configuration, if so, where can I set it ? It there some other case in which a variable is created this way ?
Has something similar happened to any of you ?
Thanks
Leonel