Home  >  Article  >  Backend Development  >  PHP中一个文件调用另一个文件类的步骤,然后输出出现乱码,求解

PHP中一个文件调用另一个文件类的步骤,然后输出出现乱码,求解

WBOY
WBOYOriginal
2016-06-13 11:45:24923browse

PHP中一个文件调用另一个文件类的方法,然后输出出现乱码,求解!
tt.php文件

<?php<br />class CTest<br />{<br />	private $m_str;<br />	public function SetData($data)<br />	{<br />		$m_str=$data;<br />	}<br />	public function GetData()<br />	{<br />		return $m_str;<br />	}<br />}<br />	<br />?>



文件test.php
<?php<br />	echo "Begin test <br>"; // 正常显示<br />	require_once './tt.php';<br />	$p=new CTest();<br />	$p->SetData("Could you get this data?");<br />	$str=$p->GetData();<br />	echo $str; // 无法正常显示<br />?>


------
在浏览器中显示test.php执行结果
Begin test 



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn