Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 5th, 2003, 11:57 PM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jlong Send a message via Yahoo to jlong
Default classes extending and inheriting

If I have a base class and I wish to use the extends keyword to inherit the properties of a super class, can these two classes be in different files? It would seem so according to the code provided for Professional PHP 4. However, I keep recieiving:

"Fatal error: Class book: Cannot inherit from undefined class media in C:\FoxServ\www\Test\wrox\book.php on line 3:

Could anyone tell me what I'm doing wrong?
Thanks


 
Old July 6th, 2003, 12:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo
Default

make sure you include the path to the file which contains your parent class from which the other one is inheriting using function include_once(). maybe you should try placing both of these classes in one file...

the genuine genius
 
Old July 7th, 2003, 02:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Moharo
 make sure you include the path to the file which contains your parent class from which the other one is inheriting using function include_once(). maybe you should try placing both of these classes in one file...
You shouldn't put all your eggs in one basket, nor should you necessarily put all your base and derived classes in the same file. A base class might be used by several sub-classes, neither of which need to know about the other. The best approach is to define each class in it's own file, and use require_once() in each file where a subclass of that base class is defined. There are times when you want to define your derived classes in the same file as your base class, but those cases are generally rare.


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Inheriting IE skin into C# toolbar arif134 C# 0 July 31st, 2007 11:50 AM
Inheriting SqlDataReader and new KeyWord software_developer_kk C# 2 June 28th, 2007 08:17 AM
Inheriting Web Page tanusree_ghosh General .NET 0 December 20th, 2004 02:04 PM
Copying (NOT inheriting) a form Ron Howerton VB.NET 2002/2003 Basics 2 May 18th, 2004 07:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.