Folks,
Look at this mystery code.
Following are 2 codes.
First one by NogDog.
Second one is an update of NogDog’s code by Zorg.
The differences between the codes are that, NogDog’s line is this:
[code]
foreach($query_parts as $q_key => $q_value) {
$query_string_parts[] = urlencode($q_key).’=’.urlencode($q_value);
}
Zorg’s line is this:
[code]
foreach($query_parts as $q_key => $q_value) {
// assemble and check if value is numeric
$query_string_parts[] = urlencode($q_key).’=’.(is_numeric($q_value) ? intval($q_value) :urlencode($q_value));
}
I had asked Zorg to add intval() and he did. But on Nogdog’s code.
And the difference between the two’s code is that, NogDog defines the $url and calls the prepare_url() function at the top. Before the prepare_url() function’s code.
[code]
$url = ‘http://nogdog.com/cat/subcat?var 1=value 1&var2=2&this other=thing&number is=12’;
echo prepare_url($url) . “n”;
While Zorg defines the $url and calls the prepare_url() function at the bottom. After the prepare_url() function’s code.
[code]
$url = ‘http://zorg.com/cat/subcat?var 1=value 1&var2=2&this other=thing&number is=13’;
echo prepare_url($url);
Apart from that, both’s code is the same.
So, if both the code is the same, then why does Nogdog’s code output like this:
**
And, why does Zorg’s code output like this:
**http%3A%2F%2Fzorg.com%2Fcat%2Fsubcat?var_1=value+1&var2=2&this_other=thing&number_is=13
What is this new mystery ?
Anyway, here is the main thread where this mystery was spotted:
I’d appreciate if you folks can engage there aswell. But after responding to this post here first, orcourse.