Re[2]: [PHP] $_FILES help!

From: Date: Tue, 27 May 2003 12:58:45 +0000
Subject: Re[2]: [PHP] $_FILES help!
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-149106@lists.php.net to get a copy of this message
Hi, Tuesday, May 27, 2003, 10:48:48 PM, you wrote: AJR> Tom - thanks a lot. You have no idea how long I was pulling my hair out over AJR> that one. AJR> Obviously, I'm new to PHP programming. What is the rule for when you need AJR> quotes in an echo statement? And why can it not print out the above variable AJR> in a echo statement that includes other string characters (i.e. echo "Error AJR> number $_FILES["myfile"]["error"])? I thought it just did replacement of AJR> the AJR> variable values. For the above statement, I have to do: AJR> $err = $_FILES["myfile"]["error"]; AJR> echo "Error number $err"; AJR> I'm just confused as to why it will substitute in one situation and not in AJR> another. AJR> Adam >> >> You don't need the quotes >> >> <? echo $_FILES["myfile"]["error"]?> >> >> -- >> regards, >> Tom >> echo does not handle arrays and objects very well so it is probably a good idea to get used to using the dot operator with echo. So I would do this: $err = $_FILES['myfile']['error']; echo 'Error number '.$err; or echo 'Error number '.$_FILES['myfile']['error']; The other thing is to use single quotes so you can put double quotes in without needing to escape them like this echo '<table border="1" width="'.$width.'">'; Only use double quotes when you need php to do substitution and php will run a tiny bit faster. -- regards, Tom

« previous php.general (#149106) next »