Re: Avoid object twice

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

 



if I delete
$obj=new my("Hello");
$obj->buff();

I can not show "Hello."

I would like to see "hello" one time only.

Regards,
Yui
2008/6/2 Scott McNaught [Synergy 8] <scott.mcnaught@xxxxxxxxxxxx>:
> Try removing from a.php the lines:
>
> $obj=new my("Hello");
> $obj->buff();
>
> I think this will achieve what you want.
>
> -----Original Message-----
> From: Yui Hiroaki [mailto:hiroakiyui@xxxxxxxxx]
> Sent: Monday, June 02, 2008 11:01 PM
> To: php-general@xxxxxxxxxxxxx
> Subject:  Avoid object twice
>
> 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
>
>

-- 
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