PHP Classes

PHP Write to File: Write array or text to a file creating its folder

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 93 All time: 9,900 This week: 71Up
Version License PHP version Categories
write 1.0.0GNU General Publi...5PHP 5, Files and Folders
Description 

Author

This class can write an array or text to a file creating its folder.

It can take a variable value as a parameter to write it to a file with a given path.

If the variable value is an array, the class can convert it to a string before writing it to the file using a given delimiter text to join the array values and form a single text string.

If the file folder does not exist, the class may create the folder with write permissions.

Picture of Ali YILMAZ
  Performance   Level  
Name: Ali YILMAZ <contact>
Classes: 16 packages by
Country: Turkey Turkey
Age: ???
All time rank: 249042 in Turkey Turkey
Week rank: 215 Up5 in Turkey Turkey Up
Innovation award
Innovation award
Nominee: 8x

Details

What is write ?

It is used to write the specified content to the specified file. It is created if the file and directory in question does not exist, returning true if the operation was successful, false otherwise. takes three parameters;

First parameter:

It represents the content and can be sent as string or array. If sent as an array, the array elements are written to the file as string by adding the : symbol between them.

Second parameter:

It represents the file path, if there is a file, the data in question is appended to the end of the file, if there is no file, a file with the specified name in the path is created and written to this file.

Third parameter:

Represents the value to be used to separate data specified as an array. It is not required to be specified, by default : is defined.

data:

$str = 'Hello world';
// $str = array('Hello', 'world');

Out-of-class use:

code:

require_once('Mind.php');
$m = new Mind();
echo $m::aliyilmaz('write')->write($str, 'new.txt');
// echo $m::aliyilmaz('write')->write($str, 'new.txt', '~');

When using it in the class:

code:

echo self::aliyilmaz('write')->write($str, 'new.txt');
// echo self::aliyilmaz('write')->write($str, 'new.txt', '~');

output:

Hello world

Dependencies

  1. info 1.0.0

License

Instructions and files in this directory are shared under the GPL3 license.


  Files folder image Files (3)  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (3)  /  src  
File Role Description
  Plain text file write.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:93
This week:0
All time:9,900
This week:71Up