Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://old.master.cmc.msu.ru/php/function.create-function.html
Дата изменения: Sun Feb 3 22:39:43 2002 Дата индексирования: Tue Oct 2 10:09:44 2012 Кодировка: |
Creates an anonymous function from the parameters passed, and returns a unique name for it. Usually the args will be passed as a single quote delimited string, and this is also recommended for the code. The reason for using single quoted strings, is to protect the variable names from parsing, otherwise, if you use double quotes there will be a need to escape the variable names, e.g. \$avar.
You can use this function, to (for example) create a function from information gathered at run time:
Example 2. Making a general processing function with create_function()
|
Using the first array of anonymous functions parameters: 2.3445, M_PI some trig: -1.6291725057799 a hypotenuse: 3.9199852871011 b*a^2 = 4.8103313314525 min(b^2+a, a^2,b) = 8.6382729035898 ln(a/b) = 0.27122299212594 Using the second array of anonymous functions ** "Twas the night" and "Twas brilling and the slithy toves" ** Look the same to me! (looking at the first 3 chars) CRCs: -725381282 , 1908338681 similar(a,b) = 11(45.833333333333%) |
Example 3. Using anonymous functions as callback functions
|