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

<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.

Jump to Post

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

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 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.