file_put_contents

Supported Versions: PHP 5, PHP 7, PHP 8
Write data to a file
<?php file_put_contents(    string $filename,    mixed $data,    int $flags = 0,    ?resource $context = null): int|false
<?php     public function testAdvancedRender() {

        file_put_contents($this->tpl_file, '{{str}}, {{json.value}}, {{json.arr.0.value}}, {{obj.prop}}, {{obj.this.prop}}, {{obj.arr.arr.0}}, {{arr.arr.arr.value}}, {{arr.obj.prop}}');

        $plates = [

            'str' => 'ok',

            'json' => '{"value": "ok", "arr": [{"value": "ok"}]}',
<?php     public function testContentify() {

        file_put_contents($this->tpl_file, 'value ok');

        $this->assertEquals('value ok', $this->phplater->setContent($this->tpl_file)->getContent());

        $this->assertEquals('value ok', $this->phplater->setContent('value ok')->getContent());

    }
<?php     public function testContent() {

        file_put_contents($this->tpl_file, 'value ok');

        $this->phplater->setContent($this->tpl_file);

        $this->assertEquals('value ok', $this->phplater->getContent());

    }
<?php     public function testEmptyRender() {

        file_put_contents($this->tpl_file, '');

        $this->assertEquals('', $this->phplater->render($this->tpl_file));

    }
<?php     public function testNoExtension() {

        file_put_contents($this->tpl_file, 'value ok');

        $this->assertEquals('value ok', $this->phplater->render(str_replace('.tpl', '', $this->tpl_file)));

    }
<?php     public function testRootNoExtension() {

        file_put_contents($this->tpl_file, 'value ok');

        $this->phplater->setRoot('tests');

        $this->assertEquals('value ok', $this->phplater->render('/template'));

    }
<?php     public function testQuickAccess() {

        file_put_contents($this->tpl_file, 'value {{ ok }}');

        $this->assertEquals('value ok', phplater($this->tpl_file, ['ok' => 'ok'])->render());

    }