Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6176 > unrolled thread

forcing double quotes

Started byrichard <member@newsguy.com>
First post2012-05-25 01:30 -0400
Last post2012-05-25 21:19 +0200
Articles 11 — 9 participants

Back to article view | Back to comp.lang.php


Contents

  forcing double quotes richard <member@newsguy.com> - 2012-05-25 01:30 -0400
    Re: forcing double quotes "Olaf S." <thesys@gmx.de> - 2012-05-25 08:26 +0200
      Re: forcing double quotes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-25 15:22 +0200
        Re: forcing double quotes "Olaf S." <thesys@gmx.de> - 2012-05-25 21:57 +0200
          Re: forcing double quotes "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> - 2012-05-25 20:35 +0000
            Re: forcing double quotes Scott Johnson <noonehome@chalupasworld.com> - 2012-05-26 07:09 -0700
    Re: forcing double quotes Shake <QUITAESTO@QUITAESTO.NOES> - 2012-05-25 09:54 +0200
    Re: forcing double quotes The Natural Philosopher <tnp@invalid.invalid> - 2012-05-25 09:46 +0100
    Re: forcing double quotes Scott Johnson <noonehome@chalupasworld.com> - 2012-05-25 04:54 -0700
    Re: forcing double quotes Markus Sonnenberg <lassmichinruhe@rz-amper.de> - 2012-05-25 15:57 +0200
    Re: forcing double quotes Michael Fesser <netizen@gmx.de> - 2012-05-25 21:19 +0200

#6176 — forcing double quotes

Fromrichard <member@newsguy.com>
Date2012-05-25 01:30 -0400
Subjectforcing double quotes
Message-ID<16h7yuzz2ij5y.1kuobop2m04gl.dlg@40tude.net>
echo "<a href='#'>"

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

[toc] | [next] | [standalone]


#6177

From"Olaf S." <thesys@gmx.de>
Date2012-05-25 08:26 +0200
Message-ID<4fbf262f$0$9515$9b4e6d93@newsspool1.arcor-online.net>
In reply to#6176
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>';

[toc] | [prev] | [next] | [standalone]


#6183

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-05-25 15:22 +0200
Message-ID<4334594.ikGlJlNZSe@PointedEars.de>
In reply to#6177
[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.)

[toc] | [prev] | [next] | [standalone]


#6189

From"Olaf S." <thesys@gmx.de>
Date2012-05-25 21:57 +0200
Message-ID<4fbfe424$0$6565$9b4e6d93@newsspool4.arcor-online.net>
In reply to#6183
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

[toc] | [prev] | [next] | [standalone]


#6190

From"Beauregard T. Shagnasty" <a.nony.mous@example.invalid>
Date2012-05-25 20:35 +0000
Message-ID<jpoqev$5f2$1@dont-email.me>
In reply to#6189
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

[toc] | [prev] | [next] | [standalone]


#6201

FromScott Johnson <noonehome@chalupasworld.com>
Date2012-05-26 07:09 -0700
Message-ID<jpqo76$njf$1@dont-email.me>
In reply to#6190
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.

[toc] | [prev] | [next] | [standalone]


#6178

FromShake <QUITAESTO@QUITAESTO.NOES>
Date2012-05-25 09:54 +0200
Message-ID<jpndr3$nsr$1@dont-email.me>
In reply to#6176
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

[toc] | [prev] | [next] | [standalone]


#6179

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2012-05-25 09:46 +0100
Message-ID<jpngti$1qt$1@news.albasani.net>
In reply to#6176
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.

[toc] | [prev] | [next] | [standalone]


#6180

FromScott Johnson <noonehome@chalupasworld.com>
Date2012-05-25 04:54 -0700
Message-ID<jpnrup$45k$1@dont-email.me>
In reply to#6176
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.string.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;

?>

[toc] | [prev] | [next] | [standalone]


#6184

FromMarkus Sonnenberg <lassmichinruhe@rz-amper.de>
Date2012-05-25 15:57 +0200
Message-ID<jpo3d0$gmb$1@dont-email.me>
In reply to#6176
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

[toc] | [prev] | [next] | [standalone]


#6188

FromMichael Fesser <netizen@gmx.de>
Date2012-05-25 21:19 +0200
Message-ID<bomvr71s9ghipkqp21gnvak92umrtt1o87@mfesser.de>
In reply to#6176
.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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web