Hi,

Code below generates this error Warning: Missing argument 1, 2, 3for MyWebpage::pageElements(): Class_for_HTML.class on line 18 ) but i cannot solve the problem.

Thanks

<?php
class MyWebpage {
	var $header = "<html>\n<head>\n";
	var $title;
	var $keywords;
	var $content;
	var $footer = "</body></html>";

	function generatePage() {
		echo $this->header;
		$this->pageElements();
		echo "<meta name=\"keywords\" content=\"". $this->keywords. "\">\n";
		echo "<title>". $this->title. "</title>\n";
		echo "<body>\n". $this->content ."\n";
		echo $this->footer;
	}

	function pageElements($pageTitle, $pageKeywords, $pageContent) {
		$this->title = $pageTitle;
		$this->keywords = $pageKeywords;
		$this->content = $pageContent;
	}
}
?>
<?php
require_once("class_for_HTML.class");

$createSample = new MyWebpage();

$pageTitle = "Test page";
$pageKeywords = "php, class, object";
$pageContent = "<h1>This page has been generated by a class</h1>\n";

$createSample->pageElements($pageTitle, $pageKeywords, $pageContent);
$createSample->generatePage();
?>

Recommended Answers

All 2 Replies

In the bottom example:

$createSample->pageElements($pageTitle, $pageKeywords, $pageContent);

In the upper example:

$this->pageElements();

Here, the 3 parameters are missing. But I think you can remove the line.

$this->pageElements(); removed from class and solved. Thanks

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.