Il 16/01/21 19:42, Arno Welzel ha scritto:
"require" just includes another file, there is result!
But it is able to return the value returned by the file
Il 16/01/21 17:38, J.O. Aho ha scritto:
There is a solution?
Use the right arguments.
????
alex:
Il 16/01/21 19:42, Arno Welzel ha scritto:
"require" just includes another file, there is result!
But it is able to return the value returned by the file
Yes, I stand corrected:
<https://www.php.net/manual/en/function.include.php>
"Handling Returns: include returns FALSE on failure and raises a
warning. Successful includes, unless overridden by the included file,
return 1. It is possible to execute a return statement inside an
included file in order to terminate processing in that file and return
to the script which called it. Also, it's possible to return values from included files. You can take the value of the include call as you would
for a normal function"
Anyway - if you want to have a new class without any parameter in the constructor, you do not write:
<?php
return new class {
function __construct($param) {}
};
But just this:
<?php
class MyClass {
function __construct() {}
};
And when you want to use that class and return an *instance* of this class:
<?php
class MyClass {
function __construct() {}
};
return new MyClass();
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 351 |
Nodes: | 16 (2 / 14) |
Uptime: | 27:38:48 |
Calls: | 7,634 |
Files: | 12,796 |
Messages: | 5,688,673 |