Re: Simple variable handling.

From: Date: Fri, 12 Aug 2016 08:54:35 +0000
Subject: Re: Simple variable handling.
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-95064@lists.php.net to get a copy of this message
On 12/08/2016 09:19, Lester Caine wrote:
I'm thinking $var->setConstraint() $var->setEscape() $var->setReadOnly() Rather than having to build 'reflections' classes to pull out data that a simple $var->is_valid or echo $var will output a correctly escaped piece of text.
Note that as discussed on the recent RFC thread, escape mechanisms are very much specific to the *destination* of the data not the *source*. So having "echo $foo" call "echo $foo->escape()" isn't going to work. I guess you could have "echo $foo->forHTML()" with some kind of fallback that converts that to "echo htmlspecialchars($foo)" if nothing further is defined. Or "echo_html( $foo )" calling "$foo->forHTML()" internally if it's been defined against the variable. I haven't thought this through fully, just throwing ideas out there. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#95064) next »