Jump to content

calling a class function with var


chriscloyd

Recommended Posts

can someone help me I am trying to call a class function using a varible.... example

say i go to index.php?page=contact i want to pull that class with out doing a switch statement can someone help me

<?php
$Site = page;
$Site->getPage($_GET['page']);
?>

<?php
class page extends site {

function getPage($page) {
	return $this->$page;	
}
function Contact() {
	echo '<h2>Contact test</h2>';
	echo '<form>

	</form>';
}

}
?>

Link to comment
https://forums.phpfreaks.com/topic/253909-calling-a-class-function-with-var/
Share on other sites

Found it out

<?php 
class page extends site {

var $newpage;

function getPage($page) {
	$this->newpage = $this->$page();
	echo $this->newpage;
}
function Contact() {
	echo '<h2>Contact</h2>';
	echo '<form>

	</form>';
}
function Who() {
	echo '<h2>Who?</h2>';
}

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.