Declaring an interface in a php file followed by a class that implements it errors
I am getting a 255 error and can not work out why
<?php
print "1 \n";
$a = new myClass("a");
print "2 \n";
interface Interabc
{
public function test($item);
}
class myClass implements Interabc
{
public function test($item)
{
print "test";
}
}
The output I am getting is:
开发者_如何学JAVA1
Process finished with exit code 255
All the code is one file. I am calling it from the command line.
If you are running this in a single file then your class needs to be declared before you instantiate it.
<?php
interface Interabc
{
public function test($item);
}
class myClass implements Interabc
{
public function test($item)
{
print "test";
}
}
print "1 \n";
$a = new myClass();
print "2 \n";
精彩评论