Return to Snippet

Revision: 1418
at October 5, 2006 03:00 by rmaltete


Initial Code
<?php
$str = <<<EOD
  Exemple de chaîne
  s'étalant sur
  plusieurs lignes
  avec la syntaxe heredoc
EOD;

/* Exemple plus complexe, avec des variables. */
class foo {
   var $foo;
   var $bar;
   function foo() {
       $this->foo = 'Foo';
       $this->bar = array('Bar1', 'Bar2', 'Bar3');
   }
}

$foo = new foo();
$name = 'MonNom';

echo <<<EOT
  Mon nom est "$name". J'affiche des $foo->foo.
  Maintenant, j'affiche un {$foo->bar[1]}.
  Ceci se traduit par un 'A' majuscule : \x41
EOT;
?>

Initial URL
http://fr2.php.net/manual/fr/language.types.string.php#language.types.string.syntax.heredoc

Initial Description
for heredoc syntax (like perl)

Initial Title
syntaxe heredoc

Initial Tags


Initial Language
PHP