{"id":7181,"date":"2014-05-27T08:58:48","date_gmt":"2014-05-27T08:58:48","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/27\/using-this-var-to-call-an-existing-method-collection-of-common-programming-errors\/"},"modified":"2014-05-27T08:58:48","modified_gmt":"2014-05-27T08:58:48","slug":"using-this-var-to-call-an-existing-method-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/27\/using-this-var-to-call-an-existing-method-collection-of-common-programming-errors\/","title":{"rendered":"using $this-&gt;$Var to call an existing method-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m in the process of creating a controller to display pages. I currently have this;<\/p>\n<pre><code> $request  = str_replace(\"\/Smarty\/\", \"\", $_SERVER['REQUEST_URI']); \n   $params = explode(\"\/\", $request);  \n\n  function FormatArr ($Arr){\n        $Array_Keys = array (\"PageName\",\"Username\");\n        if (count($Arr) &gt; 2){\n            trigger_error(\"Unexpected Params\",E_USER_ERROR);\n        }\n        return array_combine($Array_Keys,$Arr);\n    }\n    $New_Params = FormatArr($params);\n<\/code><\/pre>\n<p>On the setup.php page, then on my libs:<\/p>\n<pre><code>class testing {\n        protected $Smarty;\n        protected $fixpath;\n        public function __construct($Template_Name){\n            $this-&gt;Smarty = new Smarty;\n            $this-&gt;fixpath = dirname(__FILE__).\".\/Templates\/\".$Template_Name;           \n            $this-&gt;Smarty-&gt;compile_dir=$this-&gt;fixpath.\"\/compile\";\n            $this-&gt;Smarty-&gt;template_dir=$this-&gt;fixpath.\"\/html\";\n        }\n        public function index(){\n            $this-&gt;Smarty-&gt;assign(\"name\",\"test\");\n            $this-&gt;Smarty-&gt;assign(\"test\",\"..\/test\/\");   \n        }\n        public function Display_Page($PageName){\n            $this-&gt;$PageName();\n            $this-&gt;Smarty-&gt;display($PageName.\".html\");\n\n        }\n    }\n    $Test = new testing('Testing\/');\n<\/code><\/pre>\n<p>I have it sucessfully working, but I want to dynamically call pages which will render the correct variables on the smarty template. The problem is caused by:<\/p>\n<pre><code>$this-&gt;$PageName;\n<\/code><\/pre>\n<p>I&#8217;m struggling on finding the way of making this sucessfully call the necessary method<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m in the process of creating a controller to display pages. I currently have this; $request = str_replace(&#8220;\/Smarty\/&#8221;, &#8220;&#8221;, $_SERVER[&#8216;REQUEST_URI&#8217;]); $params = explode(&#8220;\/&#8221;, $request); function FormatArr ($Arr){ $Array_Keys = array (&#8220;PageName&#8221;,&#8221;Username&#8221;); if (count($Arr) &gt; 2){ trigger_error(&#8220;Unexpected Params&#8221;,E_USER_ERROR); } return array_combine($Array_Keys,$Arr); } $New_Params = FormatArr($params); On the setup.php page, then on my libs: class testing { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7181","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7181"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7181\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}