PHP Ampersand in String
Posted
by John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2010-06-17T23:01:59Z
Indexed on
2010/06/17
23:13 UTC
Read the original article
Hit count: 252
Hello. I'm having a bit of a problem. I am trying to create an IRC bot, which has an ampersand in its password. However, I'm having trouble putting the ampersand in a string. For example...
<?php
$var = "g&abc123";
echo $var;
?>
I believe this should print g&abc123
. However it's printing g
.
I have tried this as well:
<?php
$arr = array("key" => "g&abc123");
print_r($arr);
?>
This prints it correctly with the g&abc123
, however when I say echo $arr['key'];
it prints g
again. Any help would be appreciated. I'm running PHP5.3.1.
EDIT: Also, I just noticed that if I use g&abc123&abc123
it prints g&abc123
. Any suggestions?
© Stack Overflow or respective owner