Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions i-o/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
```php
<?php
require_once './TraitTest.php';
class MainClass {
use TraitTest;
# Input / Output

private function __construct($data)
{
$this->setData($data);
}
This section covers Array functionality on IO

public static function getInstance($data)
{
if (!empty($data)) return new static($data);
}
}
```
# Code Examples
[Here](code)

# PHP Official Documentation

* https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
* http://php.net/manual/pt_BR/function.fopen.php
* http://php.net/manual/pt_BR/function.fclose.php
* http://php.net/manual/en/book.sockets.php
* http://php.net/manual/pt_BR/ref.filesystem.php
* http://php.net/manual/pt_BR/class.splfileinfo.php
43 changes: 18 additions & 25 deletions i-o/index.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<?php
declare(strict_types=1);
//https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
//http://php.net/manual/pt_BR/function.fopen.php
//http://php.net/manual/pt_BR/function.fclose.php
//http://php.net/manual/en/book.sockets.php
//http://php.net/manual/pt_BR/ref.filesystem.php
//http://php.net/manual/pt_BR/class.splfileinfo.php
// $file = fopen('./zce.txt', 'w+');
// print_r($file);
// fclose($file);
Expand All @@ -27,25 +21,24 @@
// print_r(file_get_contents($file_path));
// }
//stream contexts
// $options = [
// 'ftp' => [
// 'proxy' => 'ftp://proxy:3128'
// ],
// ];
// $params = [];
// $context = stream_context_create($options, $params);
// print(file_get_contents('ftp://speedtest.tele2.net/', false, $context));
// exit;
// print_r(file_get_contents('./zce.txt'));
// $contexto = stream_context_create([
// 'http' => [
// 'method' => 'POST',
// 'header' => 'Content-Type: application/x-www-form-urlencoded',
// 'content' => 'livro=php',
// ],
// ]
// );
// print file_get_contents('http://marabesi.com', false, $contexto);
$options = [
'ftp' => [
'proxy' => 'ftp://proxy:3128'
],
];
$params = [];
$context = stream_context_create($options, $params);
print(file_get_contents('ftp://speedtest.tele2.net/', false, $context));
exit;
print_r(file_get_contents('./zce.txt'));
$context = stream_context_create([
'http' => [
'method' => 'GET',
'header' => 'Content-Type: text/html',
],
]
);
print file_get_contents('http://www.google.com', false, $context);

// $put = fopen('php://input', 'r');
// print fgets($put);
Expand Down
3 changes: 3 additions & 0 deletions i-o/src/fclose.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$file = fopen('./zce.txt', 'w+');
fclose($file);
3 changes: 3 additions & 0 deletions i-o/src/file_get_contents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$file_path = './zce2.txt';
file_get_contents($file_path);
3 changes: 3 additions & 0 deletions i-o/src/file_put_contents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$file_path = './zce2.txt';
file_put_contents($file_path, 'Easy way to create a file!');
3 changes: 3 additions & 0 deletions i-o/src/fopen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$file = fopen('./zce.txt', 'w+');
print_r($file);
10 changes: 10 additions & 0 deletions i-o/src/fwrite-fgets-fread-feof-example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
$studing_zce = 'Studing for ZCE';
$file = fopen('./zce.txt', 'w+');
fwrite($file, $studing_zce, strlen($studing_zce));
rewind($file);
while (feof($file) !== true) {
print fread($file, filesize('./zce.txt'));
print fgets($file);
}
fclose($file);