$requestParams = [ 'aame_uuid' => 'aba627', 'currency' => 'TEST'];
ksort($requestParams);
$hashString = http_build_query($requestParams);
var_dump( $hashString);
gives
string(30) "aame_uuid=aba627¤cy=TEST"
so why does currency transformed to ¤cy , how can correct it ?
I think the problem is the ¤ html code.
http://character-code.com/currency-html-codes.php ¤ gets replaced to this char.
Maybe you should add an specific seperator like &
to the http_build_query to make sure it will replaced to foo.php?aaaa_uid=aba627¤cy=Test
I just tested your code and I get the following string back:
C:\wamp64\www\test\test.php:8:string 'aame_uuid=aba627¤cy=TEST' (length=30)
It seems to be working fine for me. Have you tried using some other key? If it gives somewhat the same result your file or server could be corrupt.
If not the word curren might be presaved as a function to do something (which is highly unlikely). Did you mistype it as currentcy maybe (current is a php function)?
Related
I have been banging my head in the wall for couple of hours, I still couldn't figure out the issue. I have an associative array and when I try to build a query with it, It shows weird characters in the browser.
$reportVars = [
"__report" => "alpha",
"start_date" => "2001",
"end_date" => "2002",
"dsp_id" => "SPP",
"current_sp_id" => "SPP_1",
"sp_name" => "fawzan"
];
print_r(http_build_query($reportVars));
This is the output I get in the browser
__report=alpha&start_date=2001&end_date=2002&dsp_id=SPP¤t_sp_id=SPP_1&sp_name=fawzan
Note the strange character (¤) in the output after SPP, Before you ask No, I did not copy it from anywhere. I just typed it with my bare hand.
Can anyone please help me here?
¤ is being converted to ¤
you may have few options now:
move the current_sp_id to top, making it the first variable so that there is no & before it
use & as separator instead of & only by using:
print_r(http_build_query($reportVars, '', '& amp;'));
(remove the space between & and amp, added it because it's being converted to & only here too).
P.S. php isn't causing this issue as per my understanding, it's how your browser treats ¤ by probably converting it to ¤ itself
I'm building a website with yii2 and xampp and there I have a NavBar with
$menuItems = [...
['label' => 'Mitlesen', 'url' => ['/site/uebersicht&seite=1']],
...]
This leads to the site: index.php?r=site%2Fuebersicht%26seite%3D1
And here I'm getting the error-message:
Not Found (#404)
Unable to resolve the request: site/uebersicht&seite=1
When I delete the &seite=1 the error disappears.
And when I call ... site/uebersicht&seite=1 directly in the browser, it works fine, too.
You should simply use 'url' => ['/site/uebersicht', 'seite' => 1]
You are url encoding the url so the & gets converted to %26.
You need to make sure no url encoding occurs on this url.
See here for a reference to url encoded characters.
However, I'm not sure why you would want to put an "&" in the query string if there is no "?" first. Perhaps you want to swap it over?
A proper query string may look like this:
htttp://site.com/some/route/?name=sam&country=spain
It is an incorrect query string. You should put ? instead of &. So your url should be /site/uebersicht?seite=1
I have a simple function that uses cURL to grab a page and pull out the first and surname:
$base_url = 'http://www.behindthename.com/random/random.php';
$query = http_build_query($params);
$url = $base_url . '?' . $query;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
A sample $params array could look like this:
Array (
[number] => 1
[gender] => f
[surname] =>
[randomsurname] => yes
[all] => no
[usage_lth] => 1
)
Some of the names that come back have accents in them (which is fine, and I would like that to happen). However, I need to remove the accents when I am doing certain things with the names.
I have tried using Wordpress's remove_accents function, but it never seems to get passed the first !preg_match conditional. The conditional always evaluates to true and the original string just gets returned.
However, if I copy paste a name with accents in it, hard code it, and then run remove_accents on it, everything works. For example:
$name = 'Þýri';
echo remove_accents($name);
Returns 'THyri'.
I don't really understand, since as far as I can tell, the result from curl_exec is utf8, which should work fine.
I have tried calling remove_accents directly on the result returned by cURL (to make sure that my method of pulling out the names wasn't messing anything up), and that doesn't work either - the accents remain.
I have also tried removing the !preg_match conditional, in this case, seems_utf8 comes back true, but still the accents don't get removed.
What am I doing wrong?
I think you could give a try to htmlentities, the function will convert name with accents to their respective html code you can read documentation here: http://php.net/manual/en/function.htmlentities.php
Using this function will covert for example:
$string = 'noè';
echo htmlentities($string);
This will output:
noè
Wich will be read by html as
noè
Otherwise if you just need to replace accent with normal letter you can use str_replace function wich will look for a given value and change it with a target value, here an example:
echo str_replace('è', 'e', $string);
Will output
noe
In this case you will have to manually insert all accents you want to replace.
UPDATED
in your case you already have html code for your accent so you can either decode them and then exchange with normal letters or store them with accents (wich is possible, depends on your db codification (UTF-8) should allow you to store them
I am trying to pass an argument containing apostrophe character to function call but apparently it is being stripped out. Here's what I am doing:
$input = array(
'kod_modelu' => "187'",
'nr_nadwozia' => '00552889'
);
$result = $client->call('certyfikat_gwarancji_dane_pobierz', $input);
var_dump($result);
And in output I'm getting:
'kod_modelu' => string '187' (length=3)
'nr_nadwozia' => string '00552889' (length=8)
(I am repeating input in output and apostrophe is being stripped out).
How can I solve this?
EDIT: Here's a code to reproduce the issue:
Pastebin
Ok, case closed.
PHP 5.2.6 is the issue (referring to bugs.php.net). Upgrading to the latest version of 5.2.x branch solves the problem.
This might be a long shot, but since SOAP is XML based your quotes must be converted to XML entities somewhere.
I have no experience with nuSOAP, but a single quote's XML entity value is: '.
Refer to the PHP function: htmlspecialchars()
Sorry I can’t log in claim ID is having server issues (im normally Arthur Gibbs)
Data from my database currently outputs this when there are strange charecters...
This is just a example
What I get: De√ilscrat™
What I want: De√ilscrat™
It seems that some characters are being translated into character code by the other guys system..
So what I want to know is:
Is there a function that will expand charecter codes within a string?
Turning FUNCTION(De√ilscrat™) >>> De√ilscrat™.
This √ stuff looks like an HTML entity ; so, let's try de-entitying it...
This can be done using the html_entity_decode function, that's provided by PHP.
For instance, with the string you provided, here's a sample of code :
// So the browser interprets the correct charsert
header('Content-type: text/html; charset=UTF-8');
$input = 'De√ilscrat™';
$output = html_entity_decode($input, ENT_NOQUOTES, 'UTF-8');
var_dump($input, $output);
And the output I'm getting is this one :
string 'De√ilscrat™' (length=19)
string 'De√ilscrat™' (length=15)
(First one is the original version, and second one is the "decoded" version)
So, it seems to do the trick ;-)