I've just started using PHP and I've been stuck on this for hours, and yet it seems like a very simple problem. I have a class full of functions and I want to call them, but nothing works. I'll just post a brief *snippet to show the issue:
<?php
class test
{
function writeMsg() {
Echo "Hello world!";
}
writeMsg();
}
writeMsg();
?>
I get the error:
Parse error: syntax error, unexpected 'writeMsg' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /Users/redacted/Sites/projects_PHP7.1/index.php on line 7.
If i delete that call on line 7 and try run again with one in line 9 the error is: Fatal error: Uncaught Error: Call to undefined function writeMsg() in /Users/redacted/Sites/projects_PHP7.1/index.php:9 Stack trace: #0 {main} thrown in /Users/redacted/Sites/projects_PHP7.1/index.php on line 9
I have no idea why any of these errors happen and any help would be greatly appreciated. I just want to be able to call the functions:-( Thank you!