php – Moodle error: SyntaxError Unexpected token m in JSON at position 0
I’ve encountered this error in Moodle (v3.11), and was wondering if anyone knows of a fix.
I have a block plugin that I am building with my team. All four of us are getting the same error.
After installing, when I click on the “Add a Block” button in the Moodle Dashboard, it is throwing this error:
I have narrowed down the code that is causing the error to a simple echo call:
Note: I’ve been using echo to temporarily display information from the functions I’m developing in the block.
example (throwing the unexpected “m” at position 0).
echo 'mod id: ' . $moduleid . "<br>";
While exploring the error, the m in “Unexpected token m in JSON at position 0” always shows the first character in the first echo block in my code, regardless of which or how many echo calls I have in the block.
As this is my first coding job, and I’ve only been using Moodle and PHP for only about 3 weeks now, I am concerned that I may have done something wrong with my echo call? The error throws when using both ‘single’ and “double” quotes.
Why would adding an echo to a block plugin cause a syntax error when clicking “Add a Block” in Moodle 3.11?
Read more here: Source link