Controller validation works, Config/Validation - Syntax error |
Maybe this will be an obvious question, but I can't see what's wrong with it.
If I use this validation rule in my Controller, it works fine. Doing basically the same thing in Config/Validation, and my IDE gives me a syntax error message Controller: PHP Code: // validate form input Config/Validation: PHP Code: public $login = [ Syntax error:
That's because it's an variable. You can't execute functions in there. Not specific to CodeIgniter, it's PHP itself.
(05-19-2020, 09:57 AM)jreklund Wrote: That's because it's an variable. You can't execute functions in there. Not specific to CodeIgniter, it's PHP itself. Thanks, that's what I thought was happening, as I tried a few variations that also didn't work. Can you point me to a doc, or even a google search that would give more details? I tried, but I don't know specifically what to search for here.
Hi, the correct term are Class Properties.
https://www.php.net/manual/en/language.o...erties.php "This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated." |
Welcome Guest, Not a member yet? Register Sign In |