PHPのfile()関数に関して

実現したいこと

$todoArrayの部分のエラーを無くしたい

前提

ここに質問の内容を詳しく書いてください。
PHPにて、file()を使用した際に一番下の$todoArrayに出てしまうエラーを解決したいです。

発生している問題・エラーメッセージ

Syntax error: unexpected token '$todoArray'PHP(PHP2014) Unexpected 'VariableName'.intelephense(1001)

該当のソースコード

<?php class Registration { public $register; public function __construct($register) { $this->register = $register; if (!empty($_POST['message'])) { file_put_contents('./todo.txt', $_POST['message'] . "\n", FILE_APPEND); } } } class Deletion { public $delete; public function __construct($delete) { $this->delete = $delete; if (isset($_POST['todoIndex'])) { $todoArray = file('./todo.txt'); unset(file('./todo.txt')[$_POST['todoIndex']]); file_put_contents('./todo.txt', file('./todo.txt')); }} $todoArray = file('./todo.txt'); }

試したこと

ここに問題に対して試したことを記載してください。

補足情報(FW/ツールのバージョンなど)

ここにより詳細な情報を記載してください。

コメントを投稿

0 コメント