For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > March 2004 > echo "<?php"









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author echo "<?php"
Jonny T

2004-03-31, 10:32 am

hi,
i want to echo the string '<?php' in a php script like :

echo "<?php";

but when i try nothing gets displayed ...

if I use

echo "<\?php";

then the string is displayed as : <\?php

Is there anything I can do ??
Jon Kraft

2004-03-31, 10:32 am

Jonny T <jonnyt@someisp3.com> wrote:

> i want to echo the string '<?php' in a php script like :
>
> echo "<?php";
>
> but when i try nothing gets displayed ...
>
> if I use
>
> echo "<\?php";
>
> then the string is displayed as : <\?php
>
> Is there anything I can do ??


Yes, have a look at the HTML source.

JOn
Dennis Biletsky

2004-03-31, 10:32 am

use htmlspecialchars like this
$phpstrsp="<?php";
$phpstrsp=htmlspecialchars($phpstrsp);
echo $phpstrsp;


"Jonny T" <jonnyt@someisp3.com> ???????/???????? ? ???????? ?????????:
news:c4ek8o$ic3$1@sparta.btinternet.com...
> hi,
> i want to echo the string '<?php' in a php script like :
>
> echo "<?php";
>
> but when i try nothing gets displayed ...
>
> if I use
>
> echo "<\?php";
>
> then the string is displayed as : <\?php
>
> Is there anything I can do ??



Ike

2004-03-31, 10:32 am

Just looking at how I have done it succesfully in the past as....
$fp = fopen($savename, "w+");
fputs($fp, "<?php" . "\n");

//-Ike


"Jonny T" <jonnyt@someisp3.com> wrote in message
news:c4ek8o$ic3$1@sparta.btinternet.com...
> hi,
> i want to echo the string '<?php' in a php script like :
>
> echo "<?php";
>
> but when i try nothing gets displayed ...
>
> if I use
>
> echo "<\?php";
>
> then the string is displayed as : <\?php
>
> Is there anything I can do ??



2004-03-31, 11:36 am

"Jonny T" <jonnyt@someisp3.com> wrote in message
news:c4ek8o$ic3$1@sparta.btinternet.com...
> i want to echo the string '<?php' in a php script like :
>
> echo "<?php";
>
> but when i try nothing gets displayed ...


Try:
echo "&lt;?php";

-or-

echo '<?php';


Ian.H

2004-03-31, 11:36 am

On Wed, 31 Mar 2004 14:23:21 +0000, Jonny T wrote:

> hi,
> i want to echo the string '<?php' in a php script like :
>
> echo "<?php";
>
> but when i try nothing gets displayed ...
>
> if I use
>
> echo "<\?php";
>
> then the string is displayed as : <\?php
>
> Is there anything I can do ??



echo '&lt;php'


You need to use the HTML entities character for '<' which is '&lt;'
(LessThan). This will also be valid (X)HTML too where '<?php' would not
even if it was displayed as you expected =)



Regards,

Ian


[XP honoured.. FU: comp.lang.php]

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com