I ran into an interesting “bug” in Twitter Tools last night that I traced back to http_build_query()
. I expected that the query strings generated by this function used &
as a separator for the key=value
pairs, but on one of our test servers, the separator being used was &
. This is a php.ini config setting, so my expectation was clearly based on false assumptions. If you want to make sure that you get a &
separator, you can pass it in as the 3rd parameter.
You’ll find this is particularly important if you’re making requests for remote data from within WordPress via wp_remote_get()
or similar technique. If you are working on something that is run within WordPress, you can look at using add_query_arg()
as an alternative to this as well.
Alex King: http_build_query() Separator Tip: I ran into an interesting “bug” in Twitter Tools last night that I … http://t.co/jpDSRsrT
Alex King: http_build_query() Separator Tip http://t.co/sPsxU7dc
Alex King: http_build_query() Separator Tip: I ran into an interesting “bug” in Twitter Too… http://t.co/3LZt547f #wordpress #wp #news