普通网友 2014-09-22 11:41
浏览 33
已采纳

我得到这些代码的错误,不知道原因

This is the piece of code, i think i am confused because everything is all in place but it is not working.

Dreamweaver says:It say there is a syntax error in line 50, which is the last line in beneath code?>

<?php
array_walk(array('big', 'small', 'original'), function(&$v, $k) {   
        $dir = ROOT_PATH.'user/upload/'.$row['UserName'].'/avatar/' . $v;
        if (!is_dir($dir)) {
            mkdir($dir, 0777, true);
        }
    }

?>

As i am newbie to PHP so it is difficult for me to find it out. If there is any software to detect these kind of problems then please let me know.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • douxiduan8344 2014-09-22 12:00
    关注

    You're missing the closing bracket and colon of the array_walk function:

    $array = array('big', 'small', 'original');
    array_walk($array, function(&$v, $k) {
            $dir = ROOT_PATH.'user/upload/'.$row['UserName'].'/avatar/' . $v;
            if (!is_dir($dir)) {
                mkdir($dir, 0777, true);
            }
        }
    );
    

    If your IDE or text editor doesn't provide you with hints about unclosed brackets and so on, you can turn on error reporting on a per-script basis by adding the following to the top of your php scripts:

    <?php
    ini_set('display_errors', 1);
    error_reporting(E_ALL | E_STRICT);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题