One file in PHP calls another file class method, and then the output appears garbled, solve!
tt.php file
Class CTest
{
Private $m _str;
Public Function SetData ($data)
{
$m _str= $data;
}
Public Function GetData ()
{
return $m _str;
}
}
?>
File test.php
"; Normal display
Require_once './tt.php ';
$p =new ctest ();
$p->setdata ("Could you get this data?");
$str = $p->getdata ();
Echo $str; does not display properly
?>
------
Display test.php execution results in the browser
Begin Test
Nobelium
Share to: more
------Solution--------------------
Class CTest
{
Private $m _str;
Public Function SetData ($data)
{
$this->m_str= $data;
}
Public Function GetData ()
{
return $this->m_str;
}
}
------Solution--------------------
Please check that the encoding of the $data is consistent with the page encoding.
------Solution--------------------
Set the encoding of the page