March 22nd, 2011
(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: email@example.com
PHP is an odd language, with odd habits. I was just looking for the file upload syntax in Symfony 1.4 and stumbled upon this bit of code.
foreach ($request->getFiles($this->form->getName()) as $uploadedFile)
$uploadDir = sfConfig::get(‘sf_upload_dir’) . ‘/assets’;
move_uploaded_file($uploadedFile["tmp_name"], $uploadDir . “/” . $uploadedFile["name"] );
I’d never seen http_build_query before, so I looked it up.
http_build_query — Generate URL-encoded query string
string http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] )
Generates a URL-encoded query string from the associative (or indexed) array provided.
PHP has a lot of convenient functions like this, which are sort of just randomly thrown into the overall pile of functions that a programmer can use. This isn’t exactly a bad thing, but it does give PHP that unique feeling of being a random pile of convenience that no one put much thought into.Source