chriscloyd Posted December 27, 2011 Share Posted December 27, 2011 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 More sharing options...
chriscloyd Posted December 27, 2011 Author Share Posted December 27, 2011 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>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/253909-calling-a-class-function-with-var/#findComment-1301680 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.