PHP Classes

File: src/helpers/printToFile.php

Recommend this page to a friend!
  Classes of Adão Pedro   PHP OpenSSL Proxy   src/helpers/printToFile.php   Download  
File: src/helpers/printToFile.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP OpenSSL Proxy
Manage certificates and encrypt data using OpenSSL
Author: By
Last change:
Date: 2 years ago
Size: 604 bytes
 

Contents

Class file image Download
<?php

   
/*
    * This file is part of the php-openssl-proxy.
    *
    * (c) Adão Pedro <adao.pedro16@gmail.com>
    *
    * For the full copyright and license information, please view the LICENSE
    * file that was distributed with this source code.
    */

    /**
     * Write a string to a file
     */
   
function printToFile(mixed $data, string $filename, string $dir = __DIR__ . "/.."): void {
       
$dir = trim($dir, " /");

        if(
file_exists("/{$dir}/{$filename}")) unlink("/{$dir}/{$filename}");

       
file_put_contents(
           
"/{$dir}/{$filename}", $data
       
);
    }