CodeIgniter does not echo &timestamp

I never saw this till now example

$test="&timestamp";
echo $test;

will output xtamp if I put capital T then is correct

I try like

$url = "https://maps.googleapis.com/maps/api/timezone/json?location=".$latitude. ",".$longitude. "&".$test. "=".$date."&key=";
$url = "https://maps.googleapis.com/maps/api/timezone/json?location=".$latitude. ",".$longitude. "&timestamp=".$date."&key=";

This is output I get

https://maps.googleapis.com/maps/api/timezone/json?location=44.786568,20.4489216xtamp=1445364621&key=

Upvotes: 1

Views: 451

Answers (2)

pokemaobr
pokemaobr

Reputation: 21

&times means a multiplication sign. (Technically it should be × but lenient browsers let you omit the ;.)

Same response here: Using "&times" word in html changes to ×

If you use ('') maybe the PHP doesn't convert the &times to x

Upvotes: 2

Philip
Philip

Reputation: 4592

$test is not escaped, so it's seeing &times as s special character(x)

$query = array(
 'location'  => '',
 'timestamp' => '',
 'key' => ''
);

$url = "https://maps.googleapis.com/maps/api/timezone/json?" . http_build_query($query);

Upvotes: 2

Related Questions