Professional Web Applications Themes

[PHP] Problem with HTML Text box and PHP variable. - PHP Development

Question: will the substitution for the variable $dins occur if surrounded by single quotes? I could be mixing languages here, but I seem to recall a rule in one language about substituting variable contents only occurring between double quotes. Warren Vail -----Original Message----- From: John W. Holmes [mailto:holmes072000charter.net] Sent: Thursday, September 11, 2003 5:03 PM To: Jim Lucas Cc: murugesan; Golawala, Moiz M (IndSys, GE Interlogix); [email]php-generallists.php.net[/email] Subject: Re: [PHP] Problem with HTML Text box and PHP variable. Jim Lucas wrote: >>><?php >>> $dins="Dinesh"; >>> echo "<input type=text name=dins class='textbox' value='$dins' >"; >>>?> >> >>Use double quotes for HTML attributes. ...

  1. #1

    Default RE: [PHP] Problem with HTML Text box and PHP variable.

    Question: will the substitution for the variable $dins occur if surrounded by single quotes?

    I could be mixing languages here, but I seem to recall a rule in one language about substituting variable contents only occurring between double quotes.

    Warren Vail

    -----Original Message-----
    From: John W. Holmes [mailto:holmes072000charter.net]
    Sent: Thursday, September 11, 2003 5:03 PM
    To: Jim Lucas
    Cc: murugesan; Golawala, Moiz M (IndSys, GE Interlogix);
    [email]php-generallists.php.net[/email]
    Subject: Re: [PHP] Problem with HTML Text box and PHP variable.


    Jim Lucas wrote:
    >>><?php
    >>> $dins="Dinesh";
    >>> echo "<input type=text name=dins class='textbox' value='$dins' >";
    >>>?>
    >>
    >>Use double quotes for HTML attributes.
    >
    > Why do you say that?
    Yeah, I figured someone would ask that. :) I couldn't find anything
    definitive on w3c.org; can someone back me up?

    AFAIK, they are required in XML and XHTML. It's a good habit to get into
    with regular HTML, also (although, yes, both will work in HTML).

    --
    ---John Holmes...

    Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

    php|architect: The Magazine for PHP Professionals www.phparch.com

    --
    PHP General Mailing List (http://www.php.net/)
    To unsubscribe, visit: http://www.php.net/unsub.php
    Warren Vail Guest

  2. #2

    Default Re: [PHP] Problem with HTML Text box and PHP variable.

    Vail, Warren wrote:
    > Question: will the substitution for the variable $dins occur if surrounded by single quotes?
    >
    > I could be mixing languages here, but I seem to recall a rule in one language about substituting variable contents only occurring between double quotes.

    In PHP, no, variables will not be evaluated within single quotes. The
    original question was about HTML attributes, though.

    --
    ---John Holmes...

    Amazon Wishlist: [url]www.amazon.com/o/registry/3BEXC84AB3A5E/[/url]

    php|architect: The Magazine for PHP Professionals [url]www.phparch.com[/url]
    John W. Holmes Guest

  3. #3

    Default RE: [PHP] Problem with HTML Text box and PHP variable.

    On 11 September 2003 19:56, CPT John W. Holmes wrote:
    > From: "murugesan" <mukeshgcthotpop.com>
    >
    >
    > > This will help you
    > >
    > > <?php
    > > $dins="Dinesh";
    > > echo "<input type=text name=dins class='textbox' value='$dins' >";
    > > >
    >
    > Use double quotes for HTML attributes.
    Why? Both the HTML 4.01 and XHTML 1.0 (via XML 1.0) specifications explicitly allow both single and double quotes for attribute values.

    Cheers!

    Mike

    ---------------------------------------------------------------------
    Mike Ford, Electronic Information Services Adviser,
    Learning Support Services, Learning & Information Services,
    JG125, James Graham Building, Leeds Metropolitan University,
    Beckett Park, LEEDS, LS6 3QS, United Kingdom
    Email: [email]m.fordlmu.ac.uk[/email]
    Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
    Mike Ford Guest

  4. #4

    Default RE: [PHP] Problem with HTML Text box and PHP variable.

    On 12 September 2003 11:50, Ford, Mike [LSS] wrote:
    > On 11 September 2003 19:56, CPT John W. Holmes wrote:
    >
    > > From: "murugesan" <mukeshgcthotpop.com>
    > >
    > >
    > > > This will help you
    > > >
    > > > <?php
    > > > $dins="Dinesh";
    > > > echo "<input type=text name=dins class='textbox' value='$dins'
    > > > >";
    > > > >
    > >
    > > Use double quotes for HTML attributes.
    >
    > Why? Both the HTML 4.01 and XHTML 1.0 (via XML 1.0)
    > specifications explicitly allow both single and double quotes for
    > attribute values.
    OK, I've now seen the other followups requesting backup for this, so:

    HTML 4.01: At [url]http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2[/url], the
    spec says:

    "By default, SGML requires that all attribute values be
    delimited using either double quotation marks (ASCII
    decimal 34) or single quotation marks (ASCII decimal 39)."

    XHTML 1.0 relies on the XML 1.0 spec for this, and the XML 1.0 spec, at
    [url]http://www.w3.org/TR/2000/REC-xml-20001006#NT-AttValue[/url], defines an attribute
    value thusly:

    AttValue ::= '"' ([^<&"] | Reference)* '"'
    | "'" ([^<&'] | Reference)* "'"

    Hope this helps!

    Cheers!

    Mike

    ---------------------------------------------------------------------
    Mike Ford, Electronic Information Services Adviser,
    Learning Support Services, Learning & Information Services,
    JG125, James Graham Building, Leeds Metropolitan University,
    Beckett Park, LEEDS, LS6 3QS, United Kingdom
    Email: [email]m.fordlmu.ac.uk[/email]
    Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
    Mike Ford Guest

Similar Threads

  1. Problem with body text extraction with HTML::Pr
    By Perl_user in forum PERL Modules
    Replies: 3
    Last Post: November 9th, 12:49 AM
  2. HTML <Href Link inside a form (HTML text box)
    By Lingodude in forum Coldfusion Database Access
    Replies: 1
    Last Post: February 15th, 08:31 AM
  3. Dynamic text - html list problem
    By tvspec in forum Macromedia Flash Data Integration
    Replies: 2
    Last Post: May 20th, 07:54 PM
  4. Converting PDF to HTML...text problem
    By Heather_O_Taylor@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 1
    Last Post: May 11th, 06:05 PM
  5. Problem with HTML Text box and PHP variable.
    By Moiz M Golawala in forum PHP Development
    Replies: 5
    Last Post: September 12th, 02:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139