can you use html as value for php variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KidBrax

    can you use html as value for php variable

    Is there a way to use html as a value for a php variable while going
    in and out of the php tag?

    For example, can you do something like this?

    <?php $strHtml = ?>
    <p>somehtml here</p>
    <?php ; ?>

    so that the value of $strHtml equals "<p>somehtm l here</p>"

  • Vince Morgan

    #2
    Re: can you use html as value for php variable


    "KidBrax" <braxton.beyer@ gmail.comwrote in message
    news:1177605988 .744898.320720@ u32g2000prd.goo glegroups.com.. .
    Is there a way to use html as a value for a php variable while going
    in and out of the php tag?
    >
    For example, can you do something like this?
    >
    <?php $strHtml = ?>
    <p>somehtml here</p>
    <?php ; ?>
    >
    so that the value of $strHtml equals "<p>somehtm l here</p>"
    >
    <?php
    $strHtml = "<p>somehtm l here<p>";
    ?>
    Don't forget to end the line with a semicolon.
    HTH
    Vince


    Comment

    • Rik

      #3
      Re: can you use html as value for php variable

      KidBrax wrote:
      Is there a way to use html as a value for a php variable while going
      in and out of the php tag?
      >
      For example, can you do something like this?
      >
      <?php $strHtml = ?>
      <p>somehtml here</p>
      <?php ; ?>
      >
      so that the value of $strHtml equals "<p>somehtm l here</p>"
      >
      AFAIK, no. Which a simple test would show.
      Heredoc saves a lot of escaping quotes though, if that's your problem:


      $strHTML = <<<HTML
      <p>someHtml here, where we dont have to worry about escaping ' and ", so
      that'll just go fine. Hell, we can even use variables:
      {$_SERVER['HTTP_HOST']}. The only thing that should be escaped here is
      are valid variable names, so $names should be \$names.
      HTML;


      --
      Rik Wasmus

      Estimated date being able to walk again: 01-05-2007.
      Less then a week, hurray!

      Comment

      • Vince Morgan

        #4
        Re: can you use html as value for php variable

        "Vince Morgan" <vinhar@REMOVEo ptusnet.com.auw rote in message
        news:4630e7b2$0 $16556$afc38c87 @news.optusnet. com.au...
        >
        "KidBrax" <braxton.beyer@ gmail.comwrote in message
        news:1177605988 .744898.320720@ u32g2000prd.goo glegroups.com.. .
        Is there a way to use html as a value for a php variable while going
        in and out of the php tag?

        For example, can you do something like this?

        <?php $strHtml = ?>
        <p>somehtml here</p>
        <?php ; ?>

        so that the value of $strHtml equals "<p>somehtm l here</p>"
        >
        <?php
        $strHtml = "<p>somehtm l here<p>";
        ?>
        Don't forget to end the line with a semicolon.
        Or close your tags </plike I just did ;)
        HTH
        Vince
        >
        >

        Comment

        • Rami Elomaa

          #5
          Re: can you use html as value for php variable

          KidBrax kirjoitti:
          Is there a way to use html as a value for a php variable while going
          in and out of the php tag?
          >
          For example, can you do something like this?
          >
          <?php $strHtml = ?>
          <p>somehtml here</p>
          <?php ; ?>
          >
          so that the value of $strHtml equals "<p>somehtm l here</p>"
          >
          <?php ob_start(); ?>
          <p>some html here</p>
          <?php $strHtml = ob_get_clean(); ?>

          --
          Rami.Elomaa@gma il.com

          "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
          usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

          Comment

          Working...