Php method for creating a function from a string, php string function _ PHP Tutorial

Source: Internet
Author: User
Php method for creating a function from a string, php string function. Php: how to create a function from a string. This document describes how to create a function from a string in php. Share it with you for your reference. The details are as follows: php can create a function from a string using the php string function.

This example describes how to create a function from a string in php. Share it with you for your reference. The details are as follows:

In php, you can place the entire function definition in a string for dynamic definition. with the create_function function, you can dynamically create a function based on user input, which is very convenient, the usage of create_function is shown in the following example:

The code is as follows: <? Php
$ Lambda = create_function ('$ a, $ B', 'Return (strlen ($ a)-strlen ($ B ));');
$ Array = array ('really long string here, boys', 'C', 'middling length', 'larger ');
Usort ($ array, $ lambda );
Print_r ($ array );
?>

I hope this article will help you with php programming.

Examples in this article describes how to create a function from a string in php. Share it with you for your reference. The details are as follows...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.