Jump to content

Check out our Community Blogs


Member Since 09 May 2012
Offline Last Active Oct 03 2018 06:00 AM

Topics I've Started

set property with HTML content as string in from include not possible

01 October 2018 - 06:33 AM


it has been a long time I didn't came here, it's good to code again!


What I wanna do:

- include the content of a file at a specific moment in a method's class and set it in a property's class


What it means in real:

- 1 I call function giveMeView in SessionController class -> this one ask the child SessionView class to get HTML and set it in property buffer

class SessionController{

    public $buffer;

    public function giveMeView($what){
        $view = new SessionView();
        switch (strtolower($what)){
            case 'login_form':
                echo $this->getBuffer();

     * GET&SET
    public function getBuffer(){
        return $this->buffer;
    public function setBuffer($buffer){
        $this->buffer = $buffer;

- 2 in SessionView child extended to SessionController parent, it require login form and call returnBuffer function from it and set content in buffer property

class SessionView extends SessionController{

    public function loginHtmlInBuffer(){
        require_once './login_form.phtml';
        $this->setBuffer(strval(returnBuffer())); //I tried to call it without strval() = same result


- 3 in the login_form.phtml it return HTML content

function returnBuffer()
    return '
            <!-- ... -->
        <body id="LoginForm">

What is the problem:

- if I set returned value in property buffer (what I would like to do), nothing is displayed!

- But when I use echo function without set content in property, display of HTML is perfect


What I tried:

- echo function at every step (works)

- return function without any function in login_form.phtml (works)

- use of global variable (re-declaring it in the method's class) (works)

- use of local variable (works)

- use of property's class (sucks)

- take a break  :) (no change)


How it is now:

- return direct HTML string

- use it as a local variable


Anyone see or know where is the bug? I'm searching the web from many hours now and I feel lost...


Thanks for the time and answers!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download