If I set a varaible as
>
$EOL = "\r\n"
>
But then want to echo that to a HTML page to see the above string
i.e. \r\n
>
by doing: echo($EOL);
>
How do I do it?
>
I've tried quotemeta, addslashes and htmlspecialchar
but can't seem to work it out.
>
thanks
>
Andy
It should work with single quotes:
$EOL = '\r\n';
echo $EOL;
On Apr 2, 2:08 pm, Mike Roetgers <miker...@infor matik.uni-bremen.de>
wrote:
and...@blueyond er.com schrieb:
>
>
>
If I set a varaible as
>
$EOL = "\r\n"
>
But then want to echo that to a HTML page to see the above string
i.e. \r\n
>
by doing: echo($EOL);
>
How do I do it?
>
I've tried quotemeta, addslashes and htmlspecialchar
but can't seem to work it out.
>
thanks
>
Andy
>
It should work with single quotes:
$EOL = '\r\n';
echo $EOL;
>
That should output:
\r\n
and, of course, it should (and does) work as you've described - with
the combination of addslashes and htmlspecialchar s, although it will
work fine with just addslashes, but it isn't formally correct. So you
should do echo htmlspecialchar s(addslashes("\ r\n"));
and, of course, it should (and does) work as you've described - with
the combination of addslashes and htmlspecialchar s, although it will
work fine with just addslashes, but it isn't formally correct. So you
should do echo htmlspecialchar s(addslashes("\ r\n"));
>
>
>
But then want to echo that to a HTML page to see the above string
i.e. \r\n
by doing: echo($EOL);
>
Do you mean that you want the page to have the exact string:
>
backslash, r, backslash, n
>
??
>
If so, then use 'single quotes' when setting $EOL, not "double quotes".
>
As shown above in the example I gave - the variable is set with double
quotes.
I want to echo that variable AS IF - it had been set with single quotes.
In the general case, there's no way of doing that -- double-quoted strings
are interpolated and unescaped as soon as they are encountered, and after
that there's no way of going back to the original string.
However, in this specific case, addcslashes() should do the trick.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
If I set a varaible as
>
$EOL = "\r\n"
>
But then want to echo that to a HTML page to see the above string
i.e. \r\n
>
by doing: echo($EOL);
>
How do I do it?
>
I've tried quotemeta, addslashes and htmlspecialchar
but can't seem to work it out.
>
thanks
>
Andy
>
In the general case, there's no way of doing that -- double-quoted strings
are interpolated and unescaped as soon as they are encountered, and after
that there's no way of going back to the original string.
>
However, in this specific case, addcslashes() should do the trick.
>
>
Nice - I missed that one in the documentation - that tiny 'c' was
probably too small for my eyes to see (bad eyesight)
Its a very interesting function anyway.
Thanks Toby I'll give that a go.
In article <eur7vm$6u...@n yytiset.pp.htv. fi>, rami.elo...@gma il.com
says...
>
$EOL = "\\r\\n";
>
No.
Whaddya mean, "No." ?
Are you trying to say you can't control how the $EOL variable is set -
you want a function to take "\r\n" and turn it into somoe output that
shows as \r\n in a browser? If so, you'll have to write a function.
Comment