"语法错误,意外的 '[',需要标识符 (T_STRING) 或变量 (T_VARIABLE) 或 '{' 或 '$'",

时间:2021-06-24 14:29:32

标签: syntax-error codeigniter-4

我在 CodeIgniter 4 上工作时收到此错误消息 - *语法错误、意外的“[”、需要标识符 (T_STRING) 或变量 (T_VARIABLE) 或“{”或“$”” *

class CreateProducts extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' -> [ //error line
                'type'-> 'INT',
                'constraint'-> '11',
                'unsigned' -> true,
                'auto_increment' -> true,
            ],
            'title' -> [
                'type' -> 'VARCHAR',
                'constraint' -> 255,
            ],
            'description' -> [
                'type' -> 'TEXT',
                'null' -> true,
            ],
            'price' -> [
                'type' -> 'DECIMAL',
                'constraint' -> '10,2'
            ]
        ]);

更新: 此处的解决方案https://codeigniter.com/user_guide/dbmgmt/migration.html?highlight=s

0 个答案:

没有答案
相关问题