Example #1
<?php
$name="Masud Alam";
$email="masud.eden@gmail.com";
$address="Dhaka,Bangladesh";
$mob_no="01722817591";
$str = <<<HEREDOC
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="200" border="1">
<tr>
<td>Name:</td>
<td>$name;</td>
</tr>
<tr>
<td>Email:</td>
<td>$email</td>
</tr>
<tr>
<td>Address:</td>
<td>$address</td>
</tr>
<tr>
<td>Mobile No:</td>
<td>$mob_no</td>
</tr>
</table>
</body>
</html>
HEREDOC;
echo $str;
?>

Example #2 with double quotes in Heredoc
<?php

<?php
echo <<<"FOOBAR"
Hello World!
FOOBAR;
?>

?>

Nowdoc

Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc.
Example #1 with single quotes in NowDoc



0 comments:

Post a Comment

 
Top
Blogger Template