HTML in PHP variable

ultrakollega

Erfahrenes Mitglied
Hi,

wie kann ich Html Quelltext in eine PHP Variable speichern?

zB das in die var $msg:

Code:
<table width="300" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

hoffe die Frage ist nicht zu blöd ..

mfg
 
Code:
$msg = <<EOF
<table width="300" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>
EOF;
 
PHP:
$variale = "<table width=\"300\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">
              <tr>
                <td> </td>
                <td> </td>
                <td> </td>
              </tr>
              <tr>
                <td> </td>
                <td> </td>
                <td> </td>
              </tr>
              <tr>
                <td> </td>
                <td> </td>
                <td> </td>
              </tr>
            </table>";


ganz einfach alle " durch \" ersetzen zumindest die innerhalb der variable...
 
oder:
PHP:
<?php
echo '<table width="300" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>';
?>
falls du html-text nur via copy&past eingeben willst ;)
schöner is aber di variante mit echo "<table width=\"300\"...

greetz
 
@yson: So auf keinen Fall, das wäre ja dann nicht mehr HTML-konform ohne die Anführungszeichen...

@topic: HTML-Code in eine Datei speichern und im PHP-Code auslesen => Templates :)
 
Zurück