RE: [PHP] echo string with question mark in it
| From: | Chris W. Parker | Date: | Wed, 01 Dec 2004 00:18:24 +0000 |
| Subject: | RE: [PHP] echo string with question mark in it | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-203193@lists.php.net to get a copy of this message | ||
Brent Clements <mailto:bclem@imaginative-enterprises.com>
on Tuesday, November 30, 2004 3:55 PM said:
> I have the following string variable
>
> $string = 'test.php?id=' . $id;
>
> but when I echo out the string it looks like this
>
> test.php?
> id=#########
> How do I make the ? part of the string instead of php evaluating that
> question mark?
>
> I've tried adding \ before the ? but it doesn't work.
PHP isn't doing anything special to the ? character. What's happening is
that you probably have a newline character at the start of your $id
variable, that's why it's printing on two lines. The ? is not what's
causing the new line.
For the sake of readability (imo) try writing it like this:
<?php
$string = "test.php?id=$id";
?>
That way you don't have to mess with concatenation.
hth,
Chris.