Re: Variable in $_FILES?

From: Date: Tue, 02 Dec 2003 01:25:48 +0000
Subject: Re: Variable in $_FILES?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-171532@lists.php.net to get a copy of this message
On Mon, 1 Dec 2003, Dimitri Marshall wrote: > This is what I'm trying to do: > $pic = $_FILES['object$objectNumber']; > $picName = $pic['name']; > ... > $objectNumber is being defined, but for some reason this code won't work. > Can someone tell me why and also what I can do to make it work? $_FILES["object$objectnumber"] will do it... ( or $_FILES['object'.$objectnumber] ) When you enclose a string in double quotes ("") PHP will interpolate variables within the string, as you are trying to do. When you enclose a string with '' it will be treated as a literal. You may also consider "object{$objectnumber}" if you need to avoid ambiguities with the rest of your string. I personally think it's a good habit to use the curlies anyway, but I'm sure that's a matter of debate.. -- Kelly Hallman // Ultrafancy

« previous php.general (#171532) next »