相关疑难解决方法(0)

什么是PHP嵌套函数?

在JavaScript中,嵌套函数非常有用:闭包,私有方法以及你有什么...

什么是嵌套的PHP函数?有没有人使用它们,为什么?

这是我做的一个小调查

<?php
function outer( $msg ) {
    function inner( $msg ) {
        echo 'inner: '.$msg.' ';
    }
    echo 'outer: '.$msg.' ';
    inner( $msg );
}

inner( 'test1' );  // Fatal error:  Call to undefined function inner()
outer( 'test2' );  // outer: test2 inner: test2
inner( 'test3' );  // inner: test3
outer( 'test4' );  // Fatal error:  Cannot redeclare inner()
Run Code Online (Sandbox Code Playgroud)

php nested-function

76
推荐指数
5
解决办法
5万
查看次数

在php中的函数中声明一个函数

代码:

public function couts_complets($chantier,$ponderation=100){

    function ponderation($n)
    {
        return($n*$ponderation/100); //this is line 86
    }

            ...

    }
Run Code Online (Sandbox Code Playgroud)

我要做的是:在函数A中声明一个函数B,以便将它用作
array_map()中的参数.

我的问题: 我收到一个错误:

未定义的变量:思考[APP\Model\Application.php,第86行]

php

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

php ×2

nested-function ×1