php从字符串创建函数的方法
这篇文章主要介绍了php从字符串创建函数的方法,涉及php中字符串与create_function函数的使用技巧,需要的朋友可以参考下
本文实例讲述了php从字符串创建函数的方法。分享给大家供大家参考。具体如下:
php中可以把整个函数定义放到一个字符串内动态定义,有了create_function这个函数,你就可以根据用户输入动态创建函数了,非常方便,create_function使用方法如范例所示:
代码如下:
$lambda =create_function('$a,$b','return(strlen($a)-strlen($b));');
$array = array('really long string here,boy', 'this', 'middling length','larger');
usort($array,$lambda);
print_r($array);
?>
希望本文所述对大家的php程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools