php - How can I change a value on my html template from a class? -


this first attempt oop. want modify values class, can't figure out how different file. if try have class working.

so, want basic html page can modify values.

html page

<!doctype html> <html> <body>  <h1>my first heading</h1>  <p>my first paragraph.</p>  </body> </html> 

my class.php

<?php  class show {  public function settitle ($t) {     $this->title = $t;             }  public function seth1 ($h1) {     $this->h1 = $h1;             }  public function gettitle () {     return $this->title;             } public function geth1 () {     return $this->h1;             } public function render () {         $s = "<!doctype html> <html> <body>"; $s .= "<title>"; $s .= $this->title; $s .= "<title>";  $s .= "<h1>"; $s .= $this->h1; $s .= "</h1>";   $s .= "<p>and on</p>      </body>     </html>";      echo $s;  }  }  ?> 

index.php

 <?php   include dirname(__file__) . '/inc/class.php'; // above example   $s = new show;  $s->settitle('title');  $s->seth1('h1');  $s->render();  ?> 

this example of i'm trying accomplish. blank page...

is me, or missing call $s->render() ?


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -