doulu5109 2015-12-29 21:12
浏览 51
已采纳

字符串数组的限制? [重复]

This question already has an answer here:

I wonder wether there is a limit for the maximum lengh of strings in arrays. I ve already checked my memory reserved for PHP (which is 128MB and therefore definitelly enough for my purposes) and am quite sure that i deteteced the actual problem:

My original array was:

$tabellenA = array
    (
        "userA" => array
            (
                "`id`" => "INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY",
                "`name`" => "VARCHAR(20) NOT NULL",
                "`sirname`" => "VARCHAR(20) NOT NULL",
                "`userName`" => "VARCHAR( 50 ) NOT NULL",
                "`email`" => "VARCHAR(50) NOT NULL",            ,
                "`password`" => "VARCHAR(20) NOT NULL",
                "`country`" => "VARCHAR(150) NOT NULL",
                "`plz`" => "VARCHAR(50) NOT NULL",
                "`road`" => "VARCHAR(50) NOT NULL",
                "`city`" => "VARCHAR(50) NOT NULL",
                "`state`" => "VARCHAR(50) NOT NULL",
                "`house_number`" => "VARCHAR(50) NOT NULL",
                "`country`" => "VARCHAR(50) NOT NULL",
                "`timestamp`" => "DATETIME NOT NULL"


    )
);

and always called the Error Message: "Parse error: syntax error, unexpected ',', expecting ')' in C:\xampp\htdocs\Envifoodeq\Constants.php on line 19" until i cut the array after line 18 so that the code looked like:

    $tabellenA = array
(
    "userA" => array
        (
            "`id`" => "INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY",
            "`name`" => "VARCHAR(20) NOT NULL",
            "`sirname`" => "VARCHAR(20) NOT NULL",
            "`userName`" => "VARCHAR( 50 ) NOT NULL"/*,
            "`email`" => "VARCHAR(50) NOT NULL",            ,
            "`password`" => "VARCHAR(20) NOT NULL",
            "`country`" => "VARCHAR(150) NOT NULL",
            "`plz`" => "VARCHAR(50) NOT NULL",
            "`road`" => "VARCHAR(50) NOT NULL",
            "`city`" => "VARCHAR(50) NOT NULL",
            "`state`" => "VARCHAR(50) NOT NULL",
            "`house_number`" => "VARCHAR(50) NOT NULL",
            "`country`" => "VARCHAR(50) NOT NULL",
            "`timestamp`" => "DATETIME NOT NULL"*/
        )
);

Therefore I expected that there has to be some kind of maximum limit for strings in arrays but i did not find any but a hint that arrays (for reading big data files/xml to arrays) can get tremendously big... Additionally other arrays of mine have three times more entries and do work! Additionally I made a text Array with those keys but different, shorter contents, which do work.

Do you see my mistake or is it just that arrays do not work with larger strings?

</div>
  • 写回答

3条回答 默认 最新

  • doucong7963 2015-12-29 21:15
    关注

    The problem is not a limit, is a comma which shouldn't be in there.

    $tabellenA = array
        (
            "userA" => array
                (
                    "`id`" => "INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY",
                    "`name`" => "VARCHAR(20) NOT NULL",
                    "`sirname`" => "VARCHAR(20) NOT NULL",
                    "`userName`" => "VARCHAR( 50 ) NOT NULL",
                    "`email`" => "VARCHAR(50) NOT NULL",         // , <--This little guy
                    "`password`" => "VARCHAR(20) NOT NULL",
                    "`country`" => "VARCHAR(150) NOT NULL",
                    "`plz`" => "VARCHAR(50) NOT NULL",
                    "`road`" => "VARCHAR(50) NOT NULL",
                    "`city`" => "VARCHAR(50) NOT NULL",
                    "`state`" => "VARCHAR(50) NOT NULL",
                    "`house_number`" => "VARCHAR(50) NOT NULL",
                    "`country`" => "VARCHAR(50) NOT NULL",
                    "`timestamp`" => "DATETIME NOT NULL"
    
    
        )
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计