Hi,
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':
$view->loginHtmlInBuffer();
echo $this->getBuffer();
break;
}
}
/**
* 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 '
<html>
<head>
<!-- ... -->
</head>
<body id="LoginForm">
Hello
</body>
</html>';
}
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!
Edited by LDDbyD, 01 October 2018 - 06:36 AM.