Answer the question
In order to leave comments, you need to log in
Why is it not recommended to set resource type constants in PHP?
php.net/manual/en/function.define.php
Warning
It is also possible to set resource type constants, but it is not recommended to do so as it can lead to unpredictable results.
Answer the question
In order to leave comments, you need to log in
<?php
$file_handler = fopen('test_123456.php', 'a+');
define('FILE_HANDLER', $file_handler);
echo fgets(FILE_HANDLER, 50);
Well. The behavior is quite working on PHP 7.1. But the question is "why?" (I immediately recall a picture with a trolleybus made from a loaf of bread).
Therefore, they warn - yes, this can be done. Yes, sometimes it will work. But we cannot foresee all cases, so stay out of harm's way.
The resource type in PHP is legacy from PHP3 times. This type is not valid.
Now you can only meet him with the old way of working with files (the result of running fopen).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question