note 92208 added to functions.anonymous

From: Date: Tue, 14 Jul 2009 14:43:51 +0000
Subject: note 92208 added to functions.anonymous
Groups: php.notes 
Request: Send a blank email to php-notes+get-158278@lists.php.net to get a copy of this message
Perhaps you'll find yourself wanting doing a wicked thing like: $helloworld = function(){ return "each hello world is different... ".date("His"); }; echo $helloworld; which throws: Catchable fatal error: Object of class String could not be converted to string OK... Here's the way of doing this. class Helloworld{ function __toString(){ return("each hello world is different...".date("His")); } } $helloworld = new Helloworld(); echo $helloworld; sleep(5); echo $helloworld; ---- Server IP: 187.16.23.134 Probable Submitter: 187.37.26.30 ---- Manual Page -- http://www.php.net/manual/en/functions.anonymous.php Edit -- https://master.php.net/note/edit/92208 Del: integrated -- https://master.php.net/note/delete/92208/integrated Del: useless -- https://master.php.net/note/delete/92208/useless Del: bad code -- https://master.php.net/note/delete/92208/bad+code Del: spam -- https://master.php.net/note/delete/92208/spam Del: non-english -- https://master.php.net/note/delete/92208/non-english Del: in docs -- https://master.php.net/note/delete/92208/in+docs Del: other reasons-- https://master.php.net/note/delete/92208 Reject -- https://master.php.net/note/reject/92208 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158278) next »