bradym.net

Random thoughts of a Code Monkey
  • Home
  • About Me
  • JavaScript
  • Misc
  • MySQL
  • PHP
  • Windows
Home > PHP > http_build_query() and arg_separator.output

http_build_query() and arg_separator.output

September 25th, 2008 Leave a comment Go to comments

The other day I was using http_build_query to generate URLs to use with the Yahoo Geocoding API and kept getting back a “400 Bad Request” error back from Yahoo. The URLs were being echo’ed and looked fine, I could copy the URL and paste it in the browser address bar and get the results I was looking for.

When I finally viewed the source I saw that the urls were being created with & as the separator for the variables in the query string instead of &. That explained why the url looked fine when it wsa echo’ed but didn’t work when executed.

This is where arg_separator.output comes in. This setting in php.ini determines what character(s) are used when generating URLs using the built in PHP functions. So to get my code working, I just needed to change the value to just an &:

ini_set('arg_separator.output','&');

I just wish it hadn’t taken me so long to figure that out!

Categories: PHP Tags:
Comments (0) Leave a comment
  1. No comments yet.
Subscribe to comments feed

Geocoding with PHP Canonical redirect on IIS using PHP
Top
Copyright © 2008-2009 bradym.net