PHP/Development/Print
Содержание
A PHP Script Including HTML
<source lang="html4strict">
<html> <head> <title>A PHP script including HTML</title> </head> <body> <?php
print "hello world";
?> </body> </html>
</source>
Demonstrating that the syntax of print is quite flexible
<source lang="html4strict">
<?php
$string = "will be printed.
"; print "This string $string"; print "This string " . $string; print("This string $string"); print("This string " . $string);
?>
</source>
Dynamically Setting and Accessing Variables
<source lang="html4strict">
<html>
<head>
<title>Dynamically setting and accessing variables</title>
</head>
<body>
<?php
$holder = "user";
$$holder = "holder";
print "$user
";
print $$holder;
print "
";
print "${$holder}
";
print "${"user"}
";
?>
</body>
</html>
</source>
Format our strings with line breaks to make our PHP code lines short
<source lang="html4strict">
<?
print("<HTML><HEAD></HEAD><BODY>My HTML page is too big
Line 2
line 3!</BODY></HTML>");
?>
</source>
Use Print command to output string
<source lang="html4strict">
<?php
print "Hello Web!";
?>
</source>
Variable interpolation
<source lang="html4strict">
<?
$this = "this";
$that = "that";
$the_other = 2.2000000000;
print("$this,$not_set,$that+$the_other
");
?>
</source>