FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » forcing double quotes
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: forcing double quotes [message #178262 is a reply to message #178257] Fri, 25 May 2012 13:22 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
[Cancel & Supersedes: Sorry, copy-and-paste error resulting in invalid code]

Olaf S. wrote:

> Am 25.05.2012 07:30, schrieb richard:
>> echo "<a href='#'>"
>>
>> how do you make it so that the output will show "#"?
>> &quot; in place of the ' does not work.
>
> echo '<a href="#">#</a>';

PHP is the *P*HP *H*ypertext *P*reprocessor. Use it:

<?php

?><a href="#">#</a><?php

?>

(Insert line-breaks where convenient, but be aware that they result in
whitespace text nodes which in turn may result in a space character being
displayed. Consult the HTML 4.01 Specification for details.)

This approach (stdin – parse – stdout) wins over a here-doc string in almost
all cases, as by contrast the ending delimiter of a here-doc string must be
at the first column (so is not easy to indent), can only be followed by at
least a semicolon (which means concatenation for more complex expressions),
and requires escaping of some characters that do not have to be escaped with
the approach above.

Incidentally, it is described and recommended by one of the first chapters
of the PHP manual:

<http://php.net/manual/en/tutorial.firstpage.php>

It should also be noted that PHP 5.4 does away with the nonsense that
`<?= … ?>' would not be working with short_open_tag=Off (which required you
to write `<?php echo …; ?>' instead), so there is no good excuse left to
`echo' *everything* (instead of just the dynamic parts) rather ineffiently:

<http://php.net/ChangeLog-5.php>


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: multiple image upload and thumbnail display
Next Topic: Overriding PHP INI Setting session.use_trans_sid=0
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 12:31:59 GMT 2024

Total time taken to generate the page: 0.03543 seconds