简体   繁体   中英

How can i use extends correctly? php

Summary.php

<?php namespace interfaces\summary;

use \interfaces\id\id;

class Summary extends \interfaces\id { // This is line 7
 // ... code
}

id.php

<?php namespace interfaces\id;

class id {
 // ... code
}


Fatal error: Class 'interfaces\Id' not found in H:\ngnx\nginx-1.9.9\html\server\interfaces\userSummary.php on line 7

I don't know what is the error there. i need to include the file? (both files are in the same folder)

Your class id is in the namespace interfaces\\id . This means that its full name is \\interfaces\\id\\id .

You will want to changes your extends line to either:

class Summary extends \interfaces\id\id

or, because you already have the use \\interfaces\\id\\id statement the line before,

class Summary extends id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM