php - My code with str_replace don't work -


why code isn't working? trying rename, switch location , other, seems str_replace bug. nice, if told me, what's wrong... index.php

<?php header('content-type:text/html;charset=utf-8'); session_start();  require_once ('inc/core.php'); $core = new core($_get['viev']); 

this core.php

<?php class core{      var $template;     var $view;      public function __construct($view) {         $this->template = $this->loadtemplate();         $this->view = $view;         $this->loadview();         echo $this->template;     }      private function loadtemplate(){         if(file_exists('template/template.html')){             $template = file_get_contents('template/template.html');         }         else{             $template = 'coś poszło nie tak z szablonem ;/';         }         return $template;     }      private function loadview(){         global $core;                     $core = $this;          if($this->view == ""){             $this->view = "home";         }         if(file_exists('inc/view/'.$this->view.'.php')){             require_once ('inc/view/'.$this->view.'.php');         }         else{             str_replace('{{page.content}}', 'wybacz, wygląda na to, że podałeś zły adres ;(', $this->template);         }     }      public function viewreplace($replace){         if(strpos($this->template, '{{page.content}}') !== false){             str_replace('{{page.content}}', $replace, $this->template);         }     } } 

and example home.php

<?php $core->viewreplace(homeview());  function homeview(){     global $core;     return '<article>   <h2>witaj na stronie serwera snowcraft!</h2>   <a href="https://www.facebook.com/snowcraftpl" class="button">odwiedz nasz "fanpejdz" na facebook-u</a>   <p>serwer snowcraft.pl nowy pomysł na serwer minecraft. wywodzi się z połączenie kilku pomysłów zrealizowania ich w gronie wieloosobowej administracji.</p>   <h4>cos wiecej</h4>   <p>nasz serwer jest fuzją serwerów typu "minez" "paintball". grać na nim może jednocześnie wiele graczy, cała rozgrywka została zrobiona tak, sprawiać wam jak największą przyjemność.<br>      oto, byście mogli na nim grać bez przeszkód dba grupa w której skład wchodzą:<br>      załorzyciel-kiwiszon;<br>      headadmin-thekrzywda;<br>      admini-;<br>      moderatorzy-;</p> </article>'; } 

i don't have bugs on site, {{page.content}} isn't working , don't know why ;(

and also, sorry bad english ;/

for 1 thing str_replace() returns replaced string, doesn't modify original string, written new replaced value created , thrown away because haven't assigned return value anything. need set template value replaced value:

$this->template = str_replace('{{page.content}}', $replace, $this->template); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -