HI!

I had mistake in code in php.

When I excute My.php, it say "Hello"
When I excute b.php, it say
Hello
Good

I would like to execute b.php and show
only "Good"

If you know it ,please teach me!

Here is code below;

-----------------b.php----------------
<?php
function __autoload($class_name) {
   include_once $class_name . '.php';
}


$objref=new My("Good");
$objref->buff();
?>
-----------------------------------

----------My.php--------------
<?php
$obj=new My("Hello");
$obj->buff();


Class My{
        private $word;
        function __construct($getword){
        $this->word=$getword;
        }
        public function buff(){
        echo $this->word."<br />";
        }
}
?>
--------------------------------------
Regards,
Yui


2008/6/3 James Dempster <[EMAIL PROTECTED]>:
> I don't see how it's possible for you to get "Hello" after "Good", when the
> file that cause's "Hello" is required to do "Good"
>
> /James
>
> On Mon, Jun 2, 2008 at 2:00 PM, Yui Hiroaki <[EMAIL PROTECTED]> wrote:
>>
>> Please take a look at code.
>>
>> --------a.php--------
>>
>> $obj=new my("Hello");
>> $obj->buff();
>>
>>
>> Class my{
>>
>> private $word;
>> function __construct($getword){
>>       $this->word=$getword;
>> }
>> public function buff(){
>>     echo $this->word."<br />";
>> }
>> --------------------------------------
>>
>>
>> -----b.php-----------------------
>>
>> function __autoload($class_name) {
>>    include_once $class_name . '.php';
>> }
>>
>>
>> $objref=new my("Good");
>> $objref->buff();
>> --------------------------------------------
>>
>>
>>
>> I get an Echo;
>>
>> Good
>> Hello
>> Hello
>>
>> I do not need to get Hello twice.
>>
>> When I b.php , $obj=new my("Hello") is loaded.
>>
>>
>> Do you have any adia to avoid load $obj in a.php twice?
>>
>> Regards,
>> Yui
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to