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
Switch to threaded view of this topic Create a new topic Submit Reply
forcing double quotes [message #178256] Fri, 25 May 2012 05:30 Go to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
echo "<a href='#'>"

how do you make it so that the output will show "#"?
&quot; in place of the ' does not work.
Re: forcing double quotes [message #178257 is a reply to message #178256] Fri, 25 May 2012 06:26 Go to previous messageGo to next message
Olaf S. is currently offline  Olaf S.
Messages: 10
Registered: December 2011
Karma: 0
Junior Member
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>';
Re: forcing double quotes [message #178258 is a reply to message #178256] Fri, 25 May 2012 07:54 Go to previous messageGo to next message
Shake is currently offline  Shake
Messages: 40
Registered: May 2012
Karma: 0
Member
El 25/05/2012 7:30, richard escribió:
>
> 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="#">';

Or

echo "<a href=\"#\">";

Greetings
Re: forcing double quotes [message #178259 is a reply to message #178256] Fri, 25 May 2012 08:46 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
richard wrote:
> 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=\"#\">";

or

echo '<a href="#">';

--
To people who know nothing, anything is possible.
To people who know too much, it is a sad fact
that they know how little is really possible -
and how hard it is to achieve it.
Re: forcing double quotes [message #178260 is a reply to message #178256] Fri, 25 May 2012 11:54 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 5/24/2012 10:30 PM, richard wrote:
>
> echo "<a href='#'>"
>
> how do you make it so that the output will show "#"?
> &quot; in place of the ' does not work.

If you are working with many tags that you have to have in double quotes
and don't want to have many escapes I find this works very well for me.

Heredocs

http://www.php.net/manual/en/language.types.string.php#language.types.strin g.syntax.heredoc

<?php
// off the cuff
define("SITE_NAME", "SiteName");
$id = 1;
$alt_color = "yellow";
$content = "http://" . SITE_NAME;

$link = <<<EOD // Must be on its own line but not needed to be first.
<table border="0" cellpadding="0" cellsapcing="0">
<tr class="tr_class">
<td style="border-bottom:1px solid gray; color:{$alt_color};">
<a href="http://{$content}?id={$id}">{$content}</a>
</td>
</tr>
</table>
EOD; // Must be first and only on its own line.

echo $link;

?>
Re: forcing double quotes [message #178262 is a reply to message #178257] Fri, 25 May 2012 13:22 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
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.)
Re: forcing double quotes [message #178263 is a reply to message #178256] Fri, 25 May 2012 13:57 Go to previous messageGo to next message
Markus Sonnenberg is currently offline  Markus Sonnenberg
Messages: 2
Registered: May 2012
Karma: 0
Junior Member
On 5/25/2012 7:30 AM, richard wrote:
>
> 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=\"#\">"; does that work?

ct,
--
Das Abspringen einer Begrenzungsmauer dient nicht dem direkten
Zurücklegen des Arbeitsweges.
http://www.rz-amper.de
Re: forcing double quotes [message #178267 is a reply to message #178256] Fri, 25 May 2012 19:19 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(richard)

> echo "<a href='#'>"
>
> how do you make it so that the output will show "#"?
> &quot; in place of the ' does not work.

What's wrong with the single quotes? HTML doesn't care.

Micha

--
http://mfesser.de/blickwinkel
Re: forcing double quotes [message #178268 is a reply to message #178262] Fri, 25 May 2012 19:57 Go to previous messageGo to next message
Olaf S. is currently offline  Olaf S.
Messages: 10
Registered: December 2011
Karma: 0
Junior Member
Am 25.05.2012 15:22, schrieb Thomas 'PointedEars' Lahn:
> [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:
YES SIR!

>
> <?php
> …
> ?><a href="#">#</a><?php
> …
> ?>
>
He asked with ECHO. And that is PHP.

Olaf
Re: forcing double quotes [message #178269 is a reply to message #178268] Fri, 25 May 2012 20:35 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
Olaf S. wrote:

> He asked with ECHO. And that is PHP.

richard doesn't know what he wants, because he has no clue about writing
server-side PHP code...

--
-bts
-This space for rent, but the price is high
Re: forcing double quotes [message #178280 is a reply to message #178269] Sat, 26 May 2012 14:09 Go to previous message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 5/25/2012 1:35 PM, Beauregard T. Shagnasty wrote:
> Olaf S. wrote:
>
>> He asked with ECHO. And that is PHP.
>
> richard doesn't know what he wants, because he has no clue about writing
> server-side PHP code...
>

I kind of just realized that myself and think my example might of been
over-kill.
  Switch to threaded view of this topic Create a new topic Submit Reply
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 Jul 03 08:45:30 GMT 2024

Total time taken to generate the page: 0.03075 seconds