<?php
print "print does not require parentheses.";
print PHP_EOL;
// Aucune nouvelle ligne ou espace n'est ajoutée ; ci-dessous affiche "helloworld", tout sur une ligne
print "hello";
print "world";
print PHP_EOL;
print "This string spans
multiple lines. The newlines will be
output as well";
print PHP_EOL;
print "This string spans\nmultiple lines. The newlines will be\noutput as well.";
print PHP_EOL;
// L'argument peut être n'importe quelle expression qui produit une chaîne de caractères
$foo = "example";
print "foo is $foo"; // foo is example
print PHP_EOL;
$fruits = ["lemon", "orange", "banana"];
print implode(" and ", $fruits); // lemon and orange and banana
print PHP_EOL;
// Les expressions qui ne sont pas des chaînes sont converties en chaînes, même si declare(strict_types=1) est utilisé
print 6 * 7; // 42
print PHP_EOL;
// Parce que print a une valeur de retour, il peut être utilisé dans des expressions
// Le code suivant affiche "hello world"
if ( print "hello" ) {
echo " world";
}
print PHP_EOL;
// Le code suivant affiche "true"
( 1 === 1 ) ? print 'true' : print 'false';
print PHP_EOL;
?>