可能重复:
PHP:self vs. $ this
我发现我可以通过$ this :: prefix调用类方法.例:
class class1 {
public function foo()
{
echo "1";
}
public function bar()
{
$this::foo();
//in this example it acts like $this->foo() and displays "2"
//using self::foo() displays "1"
}
}
class class2 {
public function foo()
{
echo "2";
}
public function bar()
{
class1::bar();
}
}
$obj = new class2();
$obj->bar(); // displays "2"
class1::bar(); // Fatal error
Run Code Online (Sandbox Code Playgroud)
我想知道使用$ this->和$ this :: prefixes调用方法的差异.
ps:在这个链接中有一个关于$ this-> foo()和self :: foo()差异的页面: 何时使用self超过$ …
我正在尝试使用 Laravel 生成 XML 文件。从控制器开始,我在控制器中生成需要在 XML 文件上使用的数据。我使用刀片模板生成 XML 文件,但无法自动保存或下载该文件
$xml_datos = [];
$total = 0;
.
.
.
$output = View::make('site.contabilidad.adeudosXML')->with(compact('xml_datos', 'total'))->render();
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> \n <Document xmlns=\"urn:iso:std:iso:20022:tech:xsd:pain.008.001.02\">" .$output;
return $xml;
Run Code Online (Sandbox Code Playgroud)
我需要下载文件,而不是显示文件。我尝试过使用存储和文件系统类,但它们似乎都不起作用