Controller validation works, Config/Validation - Syntax error - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Controller validation works, Config/Validation - Syntax error (/showthread.php?tid=76512) |
Controller validation works, Config/Validation - Syntax error - BilltheCat - 05-19-2020 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: RE: Controller validation works, Config/Validation - Syntax error - jreklund - 05-19-2020 That's because it's an variable. You can't execute functions in there. Not specific to CodeIgniter, it's PHP itself. RE: Controller validation works, Config/Validation - Syntax error - BilltheCat - 05-19-2020 (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. RE: Controller validation works, Config/Validation - Syntax error - jreklund - 05-19-2020 Hi, the correct term are Class Properties. https://www.php.net/manual/en/language.oop5.properties.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." |