PHP Parse error syntax error unexpected T IMPLEMENTS expecting in X on line Y

0 votes

I'd like to create an interface, IFoo, that's basically a combination of a custom interface, IBar, and a few native interfaces, ArrayAccess, IteratorAggregate, and Serializable. PHP doesn't seem to allow interfaces that implement other interfaces, as I get the following error when I try:

PHP Parse error: syntax error, unexpected T_IMPLEMENTS, expecting '{' in X on line Y

I know that interfaces can extend other ones, but PHP doesn't allow multiple inheritance and I can't modify native interfaces, so now I'm stuck.

Do I have to duplicate the other interfaces within IFoo, or is there a better way that allows me to reuse the native ones?

Nov 5, 2020 in PHP by kartik
• 37,520 points
2,023 views

1 answer to this question.

0 votes

Hello @kartik,

You are looking for the extends keyword:

Interface IFoo extends IBar, ArrayAccess, IteratorAggregate, Serializable
{
    ...
}

answered Nov 5, 2020 by Niroj
• 82,840 points

Related Questions In PHP

0 votes
0 answers

Parse error: Syntax error, unexpected end of file in my PHP code

I am getting this error: Parse error: syntax ...READ MORE

Jun 10, 2022 in PHP by narikkadan
• 63,600 points
2,320 views
0 votes
1 answer
0 votes
1 answer

Error:Undefined index: barangay in C:\xampp\htdocs\TextBlast\homepage\insert.php on line 22

Hello @ Regina, First checks whether a variable is ...READ MORE

answered Aug 14, 2020 in PHP by Niroj
• 82,840 points
5,768 views
–1 vote
1 answer
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,004 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
2,985 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,911 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,586 views
0 votes
1 answer

PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR

Hello @kartik, Change your syntax because it  was invalid. Updated syntax: $purchaseOrder = ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,840 points
5,256 views
0 votes
1 answer

Invalid argument supplied for foreach() on line 25. Error in my php and mysql

Hello @viven , This should be a simple fix ...READ MORE

answered Aug 4, 2020 in PHP by Niroj
• 82,840 points
4,290 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP