PHP/Development/Print

Материал из Web эксперт
Перейти к: навигация, поиск

A PHP Script Including HTML

<html>
<head>
<title>A PHP script including HTML</title>
</head>
<body>
<b>
<?php
    print "hello world";
?>
</b>
</body>
</html>



Demonstrating that the syntax of print is quite flexible

<?php
     $string = "will be printed.<br />";
   
     print "This string $string";
     print "This string " . $string;
     print("This string $string");
     print("This string " . $string);
?>



Dynamically Setting and Accessing Variables

<html>
<head>
<title>Dynamically setting and accessing variables</title>
</head>
<body>
<?php
$holder = "user";
$$holder = "holder";

print "$user<br>";      
print $$holder;         
print "<br>";
print "${$holder}<br>"; 
print "${"user"}<br>";
?>
</body>
</html>



Format our strings with line breaks to make our PHP code lines short

<?
print("<HTML><HEAD></HEAD><BODY>My HTML page is too big
Line 2 <br>
line 3!</BODY></HTML>");
?>



Use Print command to output string

<?php
    print "Hello Web!";
?>



Variable interpolation

<?
$this = "this";
$that = "that";
$the_other = 2.2000000000;
print("$this,$not_set,$that+$the_other<BR>");
?>