Re: Avoid object twice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you for your good advice.

I excute c.php I did not get "Good" from b.php.

How can I get "Good" from b.php.

Regards,
Yui

2008/6/4 Thijs Lensselink <dev@xxxxxxxx>:
> Quoting Yui Hiroaki <hiroakiyui@xxxxxxxxx>:
>
>> Thank you for your advice me!
>>
>>
>>
>> -------------My.php-------
>> <?php
>>
>> Class My{
>>       private $word;
>>       function __construct($getword){
>>            $this->word=$getword;
>>       }
>>       public function buff(){
>>            mail("aaa@xxxxxxxxxxx","test","test");
>>       }
>> }
>> ?>
>> ----------------------------------
>>
>> --------------b.php------------
>> <?php
>>  function __autoload($class_name) {
>>  include_once $class_name . '.php';
>>  }
>>
>>
>> $objref=new My("Good");
>> $objref->buff();
>> ?>
>> --------------------------------
>>
>> --------------c.php----------
>> <?php
>>  function __autoload($class_name) {
>>  include_once $class_name . '.php';
>>  }
>>
>> $obj=new My("Hello");
>> $obj->buff();
>> ------------------------------
>>
>>
>> That is what I want to try.
>>
>> When c.php run, Mail() function run // < it is OK
>> When b.php run, it also run Mail() fuction. // it is NOT OK
>>
>> I would like to run Mail() function one time only from c.php.
>> However I also get prameter which declare "Good" in b.php
>>
>> Now when c.php and b.php run, the program send twice email. That is  not
>> good!!
>> I would like to run c.php and b.php, then the program, which is Mail()
>> function, get one email and get  "Good"  from b.php
>>
>>
>> Regards,
>> Yui
>>
>
> You could add a parameter to the buff() method.
>
>  Class My{
>        private $word;
>        function __construct($getword){
>             $this->word=$getword;
>        }
>        public function buff($sendMail = false){
>             if ($sendMail) {
>                 mail("aaa@xxxxxxxxxxx","test","test");
>             }
>        }
>  }
>
> When executing b.php pass true too the buff() method to send
> an email.
>
>  --------------b.php------------
>  <?php
>   function __autoload($class_name) {
>   include_once $class_name . '.php';
>   }
>
>
>  $objref=new My("Good");
>  $objref->buff(true);
>  ?>
>  --------------------------------
>
> When executing c.php don't pass a parameter to the buff() method. So it
> defaults to false. And will not send an email.
>
>  --------------c.php----------
>  <?php
>   function __autoload($class_name) {
>   include_once $class_name . '.php';
>   }
>
>  $obj=new My("Hello");
>  $obj->buff();
>  ------------------------------
>
> --
> 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux