Hi All,


How do you use div class' in php such that you can attach html generated by php into that div class. Example

<html>
<head>
</head>
<body>
<div class="border">
</div>

<?php

echo "This needs to go into the class border"

?>

</body>
</html>

Recommended Answers

All 3 Replies

<html>
<head>
</head>
<body>
<div class="border">
<?php

echo "This needs to go into the class border";

?>

</div>


</body>
</html>

is this what you mean?

<html>
<head>
</head>
<body>

<div class="border">

<?php

include 'external_file.php';

?>

</div>

</body>
</html>

For an external file you can do this as well.

Member Avatar for diafol

Few ways to do this:

Place all the output into php echo:

echo "<div>blah blah blah</div>";

Just echo inside a html <div>

<div>
<?php echo blah blah blah;?>
</div>

Just include a file inside a html <div>

<div>
<?php include("blah.php");?>
</div>

Use the heredoc syntax

<?php
echo <<<HDOC
<div>
  <p>Hello $name</p>
</div>
HDOC;
?>

You can also use the newdoc syntax since php5.3

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.