Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #18536
| From | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: pass parameter to require/class/construct |
| Date | 2021-01-20 14:38 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ru9bof$1g6p$1@gioia.aioe.org> (permalink) |
| References | <rtu901$voh$1@gioia.aioe.org> <i6gqcfFg1noU3@mid.individual.net> <ru46dv$2kb$1@gioia.aioe.org> <i6qjviFddjrU1@mid.individual.net> |
Il 20/01/21 12:54, Arno Welzel ha scritto:
> 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();
Anyway
require 'file.php' ($ param1, $ param2, ...)
it cannot be done, because of course it goes against every paradigm
Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread
pass parameter to require/class/construct alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-01-16 09:43 +0100
Re: pass parameter to require/class/construct John-Paul Stewart <jpstewart@personalprojects.net> - 2021-01-16 11:06 -0500
Re: pass parameter to require/class/construct "J.O. Aho" <user@example.net> - 2021-01-16 17:38 +0100
Re: pass parameter to require/class/construct alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-01-18 15:24 +0100
Re: pass parameter to require/class/construct "J.O. Aho" <user@example.net> - 2021-01-18 17:18 +0100
Re: pass parameter to require/class/construct Arno Welzel <usenet@arnowelzel.de> - 2021-01-20 12:56 +0100
Re: pass parameter to require/class/construct Arno Welzel <usenet@arnowelzel.de> - 2021-01-16 19:42 +0100
Re: pass parameter to require/class/construct alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-01-18 15:36 +0100
Re: pass parameter to require/class/construct Arno Welzel <usenet@arnowelzel.de> - 2021-01-20 12:54 +0100
Re: pass parameter to require/class/construct alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-01-20 14:38 +0100
csiph-web