A question from an obvious PHP newbie here.
I have a class that has two functions inside. I am trying to check the output of the first function using the second function (like in the code below). The problem with this is the output (1) is already being displayed in the if-statement line. Here's the result:
1Flag is: 1
So the question is, how can I do this without the output being displayed inside the if statement?
class Test{
public $flag;
private function func_one(){
$this->flag = 1;
echo $this->flag;
return $this->flag;
}
public function display_func(){
if ( !empty( $this->func_one() ) ){
echo 'Flag is: ';
$this->func_one();
}
// if ( $this->func_one() === 1 ){
// echo 'Flag is: ';
// $this->func_one();
// }
//var_dump( $this->func_one() );
}
}
$classTest = new Test();
$classTest->display_func();