Tuesday, 27 August 2013

how to understand "Classes must be defined before they are used " in php manual of keyword "extends"

how to understand "Classes must be defined before they are used " in php
manual of keyword "extends"

I get to php file a.php
<?php
class A extends B {}
class B{}
php a.php
>>>no error
b.php
<?php
class A extends B {}
class B extends C {}
class C{}
php b.php
>>>>Fatal error: Class 'B' not found in t1.php on line 2
according to php.net manual

>>>>Classes must be defined before they are used! If you want the class
Named_Cart to extend the class Cart, you will have to define the class
Cart first. If you want to create another class called
Yellow_named_cart based on the class Named_Cart you have to define
Named_Cart first. To make it short: the order in which the classes are
defined is important.<<<<
so anyboy pls explain why a.php get no "Fatal Error".

No comments:

Post a Comment