Re: [RFC] New operator for context-dependent escaping

From: Date: Tue, 26 Jul 2016 15:42:18 +0000
Subject: Re: [RFC] New operator for context-dependent escaping
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.internals 
Request: Send a blank email to internals+get-94713@lists.php.net to get a copy of this message
On 26.07.2016 at 15:15, Michael Vostrikov wrote: >> The RFC speaks of *operator*, where actually start-tags[1] are meant, to > start with. >> Using the word operator is rather confusing in this context. > > Technically yes, but there are echo operator, so it can be considered as > special construction for using echo operator. I don't think that exact work > is very important here. In my opinion, the wording is quite important in this case. An operator is supposed to be usable "anywhere" in PHP code, but most certainly you don't want to allow something like: <?php $value = read_value_from_db(); <?*$value*?> ?> >> But what happens to additional code, e.g. >> <?* $str, 'html', 42 ?> >> <?* $str, 'html'; echo 42 ?> > > This is new operator with new syntax. It will give parsing error. So you want to invent an own mini-language for this "operator"? That might require a lot of effort. Compare that with the implementation of <?=[1], i.e. it is just a shortcut for <?php echo. I suggest to *consider* doing something similar: invent a new statement (say, echoe, for the sake of giving an example), and make <?* a shortcut of <?php echoe. Then define the syntax and semantics of the echoe statement. [1] <https://github.com/php/php-src/blob/php-7.0.9/Zend/zend_language_scanner.l#L1791-L1794> -- Christoph M. Becker

« previous php.internals (#94713) next »