Hi Peter,
If I recall correctly, you can use the 'use' keyword.
$factorial = function($foo) use ($factorial) {
$factorial($foo);
}
$factorial('Hello World!');
I'm still having issues compiling 5.3 on my system, so I haven't tested
this.
Thanks,
Justin Martin
Peter Danenberg wrote:
In addendum I'd like to correct the syntax that I had someone in IRC test.
Apparently it works as such:
$foo = NULL;
$foo = function($foo) use ($foo) {
...
}
Still rather hackish, but better than globals I suppose?
Thanks,
Justin Martin
Justin Martin wrote:
Hi Peter,
If I recall
Quoth Justin Martin on Pungenday, the 30th of Discord:
If I recall correctly, you can use the 'use' keyword.
Thanks, Justin; that occurred to me, too. But the following results in
Notice: Undefined variable: factorial:
$factorial = function($n) use ($factorial) {
if ($n == 1)
Quoth Justin Martin on Pungenday, the 30th of Discord:
Apparently it works as such:
$foo = NULL;
$foo = function($foo) use ($foo) {
...
}
Still rather hackish, but better than globals I suppose?
Heh; amazing. I'm not going to pretend to comprehend this hack; but
I'll use it,
Well, it's a rather simple bit of logic.
First, we define $foo and load it with NULL so that it is available for
referencing. Next, in terms of program logic, we create a closure with a
lexical ('use') variable of a reference to $foo, which is then assigned
to $foo. Thus, the reference to $foo in
First, we define $foo and load it with NULL so that it is available for
referencing.
It turns out loading $foo is superfluous; I can get away with just:
$foo = function($foo) use ($foo) {
$foo();
}
Next, in terms of program logic, we create a closure with a lexical
('use')
I suppose it's an issue of cloning. Perhaps there's some difference
between a cloned closure and a referenced closure?
Thanks,
Justin Martin
Peter Danenberg wrote:
First, we define $foo and load it with NULL so that it is available for
referencing.
It turns out loading $foo is superfluous;
PHP 5 Bug Database summary - http://bugs.php.net/
Num Status Summary (1387 total -- which includes 842 feature requests)
===[*Directory/Filesystem functions]
46990 Assigned Passing UTF8 strings to filesystem functions produce wrong
filenames
PHP 6 Bug Database summary - http://bugs.php.net/
Num Status Summary (78 total -- which includes 32 feature requests)
===[*General Issues]==
26771 Suspended register_tick_funtions crash under threaded webservers
- http://www.slideshare.net/thinkphp/php-53-and-php-6-a-look-ahead
- http://wiki.claroline.net/index.php/Coding_Rules
If it's not, then what are your thoughts on using ASP/JSP-style tags
(%), and perhaps making them the recommended option?
I've just read through an old (and rather long) thread*
Glen wrote:
It's short, and it doesn't conflict with XML.
I have to say, I don't understand all the hate on short_open_tag. So
what if it conflicts with XML? PHP is not XML. If you use an XML
construct in your PHP, escape it. PHP can generate a lot of other
languages, too -- should
Peter Danenberg pisze:
Quoth Justin Martin on Pungenday, the 30th of Discord:
If I recall correctly, you can use the 'use' keyword.
Thanks, Justin; that occurred to me, too. But the following results in
Notice: Undefined variable: factorial:
$factorial = function($n) use ($factorial) {
2009/4/13 Jeremy jer...@pinacol.com:
Glen wrote:
It's short, and it doesn't conflict with XML.
I have to say, I don't understand all the hate on short_open_tag. So what
if it conflicts with XML? PHP is not XML. If you use an XML construct in
your PHP, escape it. PHP can generate a lot
I think that's what he meant by escape it. I haven't used short_open_tags
myself much, but as I've been exploring templating options I like it for
outputting variables.
James Logsdon
On Mon, Apr 13, 2009 at 2:24 PM, Kalle Sommer Nielsen ka...@php.net wrote:
2009/4/13 Jeremy jer...@pinacol.com:
It was not my intention to initiate a massive debate regarding the use
of short_open_tag.
I posted for two reasons:
1. To ask if short_open_tag has been deprecated in PHP 6.
2. To suggest asp_tags as the recommended option for templating in PHP
(to keep both crowds* happy).
* The crowd *for*
On Mon, Apr 13, 2009 at 1:06 PM, Stanislav Malyshev s...@zend.com wrote:
It's a pretty small use case (that's a problem only if you have xml
documents which has to have php code which has to be inlined) and as you
see, can be easily handled. I think that should not make whole very useful
Hi!
The original anonymous functions patch[1] contained support for
__FUNCTION__ as a recursion mechanism in closures, such that I should
be able to do something like this:
$factorial = function($n) {
if ($n == 1)
return 1;
else
return $n *
On 13-Apr-09, at 4:06 PM, Stanislav Malyshev wrote:
Hi!
Thats because with short_open_tags on, you need to use:
?php echo('?xml ... ?'); ?
It's a pretty small use case (that's a problem only if you have xml
documents which has to have php code which has to be inlined) and as
you see,
function Y($F) {
$func = function ($f) { return $f($f); };
return $func(function ($f) use($F) {
return $F(function ($x) use($f) {
$ff = $f($f);
return $ff($x);
});
});
}
That's interesting; I
Today this topic may be the cloudiest and most heated in all of PHP.
Here's the factual history of our poor little short_open_tag directive:
php.ini values : short_open_tag
PHP 4, 5_0
*
Hey Guys,
Whenever I start an XHTML document, I do escape it this way:
?=??xml version=1.0 encoding=utf-8?
Where the ? part will be the output by PHP.
?=?? equals ? print ? ? equals ?php print ? ?
So, please do not deprecate it - because it's important for me :$
Thanks,
(c) Kenan Sulayman
21 matches
Mail list logo