Suppose we have two files:
- main.php for further work he needs to get the text from the file
- string.php allows you to get text from a file
As I see (receiving text in the abstract, the main logic):
1 option
<?php /* * main.php */ require_once 'string.php'; $text_1 = get_string_1(); $text_2 = get_string_2(); <?php /* * string.php */ function get_string_1() { $data = file_get_contents('text_first.txt' ); return $data; } function get_string_2() { $data = file_get_contents('text_second.txt' ); return $data; } Option 2
<?php /* * main.php */ require_once 'string.php'; $str = new string(); $text_1 = str->get_1(); $text_2 = str->get_2(); <?php /* * string.php */ class string { function get_1 () { $data = file_get_contents('text_first.txt' ); return $data; } function get_2 () { $data = file_get_contents('text_second.txt' ); return $data; } } My question is to find out how to perform this task for example, and where can I read about it?
[ 'str1' => 'path_to_file1', ...]- teran