PHP 5.5.6中的错误未定义偏移量

时间:2014-03-21 16:13:11

标签: php arrays function undefined offset

我有Web应用程序,我使用XAPP ver 1.8.3和PHP 5.5.6版 我的Web应用程序出现此错误:

http://localhost/websekolah/admin/<br /><b>Warning</b>:  Illegal string offset 'uid' in <b>C:/xampp/htdocs/websekolah/config/function.php</b> on line <b>25</b><br />main.php?module=buku_tamu&menu=update&$key=1

错误是指我的function.php文件。

function.php

<?php
    function info($message) {
        echo "
            <script>
                alert('$message');
            </script>
        ";  
    }

    function redirect($url) {
        echo("<meta http-equiv='Refresh' content='0; URL=$url'>");
    }

    function url($link, $type, $data) {
        $url = "main.php?module=" . $_GET['module'] . "&$type=$link";

        if($data != NULL) {
            foreach($data as $key => $value) {
                $valKey = $value[$key];
                $url .= '&$key=' . $valKey;
            }   
        }

        return $url;
    }
?>

我称这个函数是这样的:

<a href="<?php echo url('update','menu', array('uid' => $data['uid'])); ?>" class="table-icon edit" title="Edit"></a>

我在我的函数中传递数组,并生成了url字符串。

但是在PHP版本5.3.5的XAMPP 1.7.4中,它可以工作。

任何解决方案?

先谢谢..

0 个答案:

没有答案