I'm beginner in PHP, and for long have been doing my site in XHTML. Now I want to make a News box and have made PHP code for that function as shown below:

<?php
function pop_boxes($words, $class)
	{
		$string = "<div $class> $words </div>";
		print($string);
	}
	?>

And here is how I call it as inc.container.php :

<div id="mainarea" style="padding:10;">
				<?php
				include("$paths/include/inc.main.php");					
				$words = "Try again";
				$class = "pop_window";
                                //the code are in the below file
				include("$paths/include/inc.container.php");	
				pop_boxes($words, $class);			
				?>
			</div>

and the class in CSS is only configure to have red background as test enviroment, that is:

.pop_window{
		border:1px;
		background-color:red;
}

It strangely prints "Try again" with no formatting and no <div> box. What is wrong?

Thanks for your help!

Did you check the source ? $string = "<div id=\"$class\"> $words </div>"; I just had everything in one script and it works fine. (Oh, I also replaced . with # of your css.

<?php
function pop_boxes($words, $class) {
		$string = "<div id=\"$class\"> $words </div>";
		print($string);
}
?>
<style>
#pop_window{
		border:1px;
		background-color:red;
}
</style>
<div id="mainarea" style="padding:10;">
<?php
$words = "Try again";
$class = "pop_window";
pop_boxes($words, $class);
?>
</div>
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.