Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Thank you for your advice me!



-My.php---
?php

Class My{
   private $word;
   function __construct($getword){
$this-word=$getword;
   }
   public function buff(){
mail([EMAIL PROTECTED],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

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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Thank you for your advice me!



-My.php---
?php

Class My{
   private $word;
   function __construct($getword){
$this-word=$getword;
   }
   public function buff(){
mail([EMAIL PROTECTED],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

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



Re: [PHP] Avoid object twice

2008-06-04 Thread Thijs Lensselink

Quoting Yui Hiroaki [EMAIL PROTECTED]:


Thank you for your advice me!



-My.php---
?php

Class My{
   private $word;
   function __construct($getword){
$this-word=$getword;
   }
   public function buff(){
mail([EMAIL PROTECTED],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([EMAIL PROTECTED],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



RE: [PHP] Avoid object twice

2008-06-04 Thread Boyd, Todd M.
 Thank you for your advice me!
 
 -My.php---
 ?php
 
 Class My{
private $word;
function __construct($getword){
 $this-word=$getword;
}
public function buff(){
 mail([EMAIL PROTECTED],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

You are not making any sense... if you only want the Mail() function to
run once, then ONLY CALL -BUFF() ONE TIME. It's that simple. You are
mailing twice because you call buff() in two separate places--and buff()
in turn calls Mail(). I don't understand your problem.

$objref = new My(Good);
$obj = new My(Hello);
$obj-buff();

Bam. You get Hello, Good, and it sends one e-mail. Since you are
completely abstracting your code from its real-world application, that's
the best I can do.


Todd Boyd
Web Programmer




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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
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 [EMAIL PROTECTED]:
 Quoting Yui Hiroaki [EMAIL PROTECTED]:

 Thank you for your advice me!



 -My.php---
 ?php

 Class My{
   private $word;
   function __construct($getword){
$this-word=$getword;
   }
   public function buff(){
mail([EMAIL PROTECTED],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([EMAIL PROTECTED],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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
I knew it .

But Hello and Good is different file.
I would like to get Good from b.php.

Please tell me goo advice.
Yui

2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]:
 Thank you for your advice me!

 -My.php---
 ?php

 Class My{
private $word;
function __construct($getword){
 $this-word=$getword;
}
public function buff(){
 mail([EMAIL PROTECTED],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

 You are not making any sense... if you only want the Mail() function to
 run once, then ONLY CALL -BUFF() ONE TIME. It's that simple. You are
 mailing twice because you call buff() in two separate places--and buff()
 in turn calls Mail(). I don't understand your problem.

 $objref = new My(Good);
 $obj = new My(Hello);
 $obj-buff();

 Bam. You get Hello, Good, and it sends one e-mail. Since you are
 completely abstracting your code from its real-world application, that's
 the best I can do.


 Todd Boyd
 Web Programmer





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



RE: [PHP] Avoid object twice

2008-06-04 Thread Boyd, Todd M.
 I knew it .
 
 But Hello and Good is different file.
 I would like to get Good from b.php.
 
 Please tell me goo advice.
 Yui
 
 2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]:
  Thank you for your advice me!
 
  -My.php---
  ?php
 
  Class My{
 private $word;
 function __construct($getword){
  $this-word=$getword;
 }
 public function buff(){
  mail([EMAIL PROTECTED],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
 
  You are not making any sense... if you only want the Mail() function
 to
  run once, then ONLY CALL -BUFF() ONE TIME. It's that simple. You
are
  mailing twice because you call buff() in two separate places--and
 buff()
  in turn calls Mail(). I don't understand your problem.
 
  $objref = new My(Good);
  $obj = new My(Hello);
  $obj-buff();
 
  Bam. You get Hello, Good, and it sends one e-mail. Since you are
  completely abstracting your code from its real-world application,
 that's
  the best I can do.

I still don't get it. Please explain to me WHY this is not a solution to
your problem?

===
My.php
===
?php
Class My{
   private $word;
   function __construct($getword){
$this-word=$getword;
   }
   public function buff(){
mail([EMAIL PROTECTED],test,test);
   }
}
?

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

$objref=new My(Good);
// $objref-buff(); NOTICE HOW THIS IS COMMENTED OUT!!!
?

===
c.php
===
?php
function __autoload($class_name) {
include_once $class_name . '.php';
}

$obj=new My(Hello);
$obj-buff();   // MAIL() IS EXECUTED HERE
?

If that doesn't work, then here are my questions:

1.) What on earth are you ACTUALLY trying to do?
2.) Does -buff() NEED to be called for each instance of My()?
3.) Are you wanting multiple instances of this class to share data?
4.) If (3), then are you familiar with the STATIC property?


Todd Boyd
Web Programmer

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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
My problem is that I would like to share the parameter.
For instance, goolge map key.

There are actually two files.

example,

main.php
?php
$googlemapkey=g8ejeUFEUHEU;// example
mail([EMAIL PROTECTED],test.test);
?

Above is part of code;
I will excute main.php program.
then other.php run
But when other.php run, other.php requre $googlemapkey.
Of couse, I can get $googlemapkey if I use include or require.
But if I use include or require,
mail([EMAIL PROTECTED],test.test) run again.

So this program send twice email. It is NOT GOOD.
I juse send $googlemapkey from mail.php to other.php


Please advice if you have any solution.


Regards,
Yui


2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]:
 I knew it .

 But Hello and Good is different file.
 I would like to get Good from b.php.

 Please tell me goo advice.
 Yui

 2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]:
  Thank you for your advice me!
 
  -My.php---
  ?php
 
  Class My{
 private $word;
 function __construct($getword){
  $this-word=$getword;
 }
 public function buff(){
  mail([EMAIL PROTECTED],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
 
  You are not making any sense... if you only want the Mail() function
 to
  run once, then ONLY CALL -BUFF() ONE TIME. It's that simple. You
 are
  mailing twice because you call buff() in two separate places--and
 buff()
  in turn calls Mail(). I don't understand your problem.
 
  $objref = new My(Good);
  $obj = new My(Hello);
  $obj-buff();
 
  Bam. You get Hello, Good, and it sends one e-mail. Since you are
  completely abstracting your code from its real-world application,
 that's
  the best I can do.

 I still don't get it. Please explain to me WHY this is not a solution to
 your problem?

 ===
 My.php
 ===
 ?php
 Class My{
   private $word;
   function __construct($getword){
$this-word=$getword;
   }
   public function buff(){
mail([EMAIL PROTECTED],test,test);
   }
 }
 ?

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

$objref=new My(Good);
// $objref-buff(); NOTICE HOW THIS IS COMMENTED OUT!!!
 ?

 ===
 c.php
 ===
 ?php
function __autoload($class_name) {
include_once $class_name . '.php';
}

$obj=new My(Hello);
$obj-buff();   // MAIL() IS EXECUTED HERE
 ?

 If that doesn't work, then here are my questions:

 1.) What on earth are you ACTUALLY trying to do?
 2.) Does -buff() NEED to be called for each instance of My()?
 3.) Are you wanting multiple instances of this class to share data?
 4.) If (3), then are you familiar with the STATIC property?


 Todd Boyd
 Web Programmer


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



Re: [PHP] Avoid object twice

2008-06-04 Thread Thijs Lensselink

Quoting Yui Hiroaki [EMAIL PROTECTED]:


My problem is that I would like to share the parameter.
For instance, goolge map key.

There are actually two files.

example,

main.php
?php
$googlemapkey=g8ejeUFEUHEU;// example
mail([EMAIL PROTECTED],test.test);
?

Above is part of code;
I will excute main.php program.
then other.php run
But when other.php run, other.php requre $googlemapkey.
Of couse, I can get $googlemapkey if I use include or require.
But if I use include or require,
mail([EMAIL PROTECTED],test.test) run again.

So this program send twice email. It is NOT GOOD.
I juse send $googlemapkey from mail.php to other.php


Please advice if you have any solution.


Regards,
Yui


2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]:

I knew it .

But Hello and Good is different file.
I would like to get Good from b.php.

Please tell me goo advice.
Yui

2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]:
 Thank you for your advice me!

 -My.php---
 ?php

 Class My{
private $word;
function __construct($getword){
 $this-word=$getword;
}
public function buff(){
 mail([EMAIL PROTECTED],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

 You are not making any sense... if you only want the Mail() function
to
 run once, then ONLY CALL -BUFF() ONE TIME. It's that simple. You

are

 mailing twice because you call buff() in two separate places--and
buff()
 in turn calls Mail(). I don't understand your problem.

 $objref = new My(Good);
 $obj = new My(Hello);
 $obj-buff();

 Bam. You get Hello, Good, and it sends one e-mail. Since you are
 completely abstracting your code from its real-world application,
that's
 the best I can do.


I still don't get it. Please explain to me WHY this is not a solution to
your problem?

===
My.php
===
?php
Class My{
  private $word;
  function __construct($getword){
   $this-word=$getword;
  }
  public function buff(){
   mail([EMAIL PROTECTED],test,test);
  }
}
?

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

   $objref=new My(Good);
   // $objref-buff(); NOTICE HOW THIS IS COMMENTED OUT!!!
?

===
c.php
===
?php
   function __autoload($class_name) {
   include_once $class_name . '.php';
   }

   $obj=new My(Hello);
   $obj-buff();   // MAIL() IS EXECUTED HERE
?

If that doesn't work, then here are my questions:

1.) What on earth are you ACTUALLY trying to do?
2.) Does -buff() NEED to be called for each instance of My()?
3.) Are you wanting multiple instances of this class to share data?
4.) If (3), then are you familiar with the STATIC property?


Todd Boyd
Web Programmer





I think you are making it way to complicated for yourself.

So you really just need to share settings between files.
That's exactly what include / require are for.

settings.php
?php
$googlemapkey = g8ejeUFEUHEU;// example

function sendMail() {
mail([EMAIL PROTECTED],test.test);
}
?


Here you include settings.php and are able to use the  mapkey variable.
If you want to send an email just call sendMail();

other.php
?php
include settings.php;

// use your google API key any way you want

sendMail();  // sends mail
?

If you don't need the sendMail(); function. then don't call it.
other2.php
?php
   include settings.php;

// use your google API key any way you want
?


I think that's about as clear as i can make it.

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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
NO!
That is what I do not want!
setting.php need to run mail() function.
also setting.php need $googlemapkey.

other.php just need $googlemapkey.
other .php do not need run mail() function.

If I use include, I will get twice email.

Please do advice how to share the $googlemapkey.

Regards,
Yui

2008/6/4 Thijs Lensselink [EMAIL PROTECTED]:
 Quoting Yui Hiroaki [EMAIL PROTECTED]:

 My problem is that I would like to share the parameter.
 For instance, goolge map key.

 There are actually two files.

 example,

 main.php
 ?php
 $googlemapkey=g8ejeUFEUHEU;// example
 mail([EMAIL PROTECTED],test.test);
 ?

 Above is part of code;
 I will excute main.php program.
 then other.php run
 But when other.php run, other.php requre $googlemapkey.
 Of couse, I can get $googlemapkey if I use include or require.
 But if I use include or require,
 mail([EMAIL PROTECTED],test.test) run again.

 So this program send twice email. It is NOT GOOD.
 I juse send $googlemapkey from mail.php to other.php


 Please advice if you have any solution.


 Regards,
 Yui


 2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]:

 I knew it .

 But Hello and Good is different file.
 I would like to get Good from b.php.

 Please tell me goo advice.
 Yui

 2008/6/4 Boyd, Todd M. [EMAIL PROTECTED]:
  Thank you for your advice me!
 
  -My.php---
  ?php
 
  Class My{
 private $word;
 function __construct($getword){
  $this-word=$getword;
 }
 public function buff(){
  mail([EMAIL PROTECTED],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
 
  You are not making any sense... if you only want the Mail() function
 to
  run once, then ONLY CALL -BUFF() ONE TIME. It's that simple. You

 are

  mailing twice because you call buff() in two separate places--and
 buff()
  in turn calls Mail(). I don't understand your problem.
 
  $objref = new My(Good);
  $obj = new My(Hello);
  $obj-buff();
 
  Bam. You get Hello, Good, and it sends one e-mail. Since you are
  completely abstracting your code from its real-world application,
 that's
  the best I can do.

 I still don't get it. Please explain to me WHY this is not a solution to
 your problem?

 ===
 My.php
 ===
 ?php
 Class My{
  private $word;
  function __construct($getword){
   $this-word=$getword;
  }
  public function buff(){
   mail([EMAIL PROTECTED],test,test);
  }
 }
 ?

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

   $objref=new My(Good);
   // $objref-buff(); NOTICE HOW THIS IS COMMENTED OUT!!!
 ?

 ===
 c.php
 ===
 ?php
   function __autoload($class_name) {
   include_once $class_name . '.php';
   }

   $obj=new My(Hello);
   $obj-buff();   // MAIL() IS EXECUTED HERE
 ?

 If that doesn't work, then here are my questions:

 1.) What on earth are you ACTUALLY trying to do?
 2.) Does -buff() NEED to be called for each instance of My()?
 3.) Are you wanting multiple instances of this class to share data?
 4.) If (3), then are you familiar with the STATIC property?


 Todd Boyd
 Web Programmer



 I think you are making it way to complicated for yourself.

 So you really just need to share settings between files.
 That's exactly what include / require are for.

 settings.php
 ?php
$googlemapkey = g8ejeUFEUHEU;// example

function sendMail() {
mail([EMAIL PROTECTED],test.test);
}
 ?


 Here you include settings.php and are able to use the  mapkey variable.
 If you want to send an email just call sendMail();

 other.php
 ?php
include settings.php;

// use your google API key any way you want

sendMail();  // sends mail
 ?

 If you don't need the sendMail(); function. then don't call it.
 other2.php
 ?php
   include settings.php;

// use your google API key any way you want
 ?


 I think that's about as clear as i can make it.

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



-- 
PHP 

RE: [PHP] Avoid object twice

2008-06-04 Thread Ford, Mike
On 04 June 2008 16:03, Yui Hiroaki advised:

 NO!
 That is what I do not want!
 setting.php need to run mail() function.
 also setting.php need $googlemapkey.
 
 other.php just need $googlemapkey.
 other .php do not need run mail() function.
 
 If I use include, I will get twice email.

Same answer as Thijs gave, just with the filenames moved around:

 google_info.php
 ?php
$googlemapkey = g8ejeUFEUHEU;// example

function sendMail() {
mail([EMAIL PROTECTED],test.test);
}
 ?


 setting.php
 ?php
include google_info.php;

sendMail();  // sends mail

// other stuff using your google API key
 ?

 other.php
 ?php
   include google_info.php;

// use your google API key any way you want
// ... but no call to sendMail()
 ?

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Avoid object twice

2008-06-04 Thread Boyd, Todd M.
 -Original Message-
 From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 04, 2008 10:03 AM
 To: Thijs Lensselink
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Avoid object twice
 
 NO!
 That is what I do not want!
 setting.php need to run mail() function.
 also setting.php need $googlemapkey.
 
 other.php just need $googlemapkey.
 other .php do not need run mail() function.
 
 If I use include, I will get twice email.
 
 Please do advice how to share the $googlemapkey.

  I think you are making it way to complicated for yourself.
 
  So you really just need to share settings between files.
  That's exactly what include / require are for.
 
  settings.php
  ?php
 $googlemapkey = g8ejeUFEUHEU;// example
 
 function sendMail() {
 mail([EMAIL PROTECTED],test.test);
 }
  ?
 
 
  Here you include settings.php and are able to use the  mapkey
 variable.
  If you want to send an email just call sendMail();
 
  other.php
  ?php
 include settings.php;
 
 // use your google API key any way you want
 
 sendMail();  // sends mail
  ?
 
  If you don't need the sendMail(); function. then don't call it.
  other2.php
  ?php
include settings.php;
 
 // use your google API key any way you want
  ?
 
 
  I think that's about as clear as i can make it.

For the love of everything good in this world, please take the time to
READ his reply. Most notably, you should pay attention to how he
DECLARES a function in settings.php, rather than EXECUTING a function.
Since it is just a DECLARATION, you can include that file and the
function will not be EXECUTED. You can then EXECUTE the function at a
time of your choosing.

Not everything should run when it is loaded--you built a class (My)...
this is the same idea. Rather than a class, this is a function. Think
about it--member functions of classes don't execute by themselves (save
for the constructor/destructor, etc.)... you have to invoke them. Same
with (most) functions. You build it, and then it just sits there until
you actually tell it to do something. If you don't want your script to
send mail yet, then don't tell it to use the sendMail() function.

Hope this is resolved,


Todd Boyd
Web Programmer



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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Thank you for all!

I try to use script.
But it does not run correctly.

It means that setting.php never call sendMail() from google_info.php.

Are you sure that it is possible to call function from other file?


Best Regards,
Yui

2008/6/5 Boyd, Todd M. [EMAIL PROTECTED]:
 -Original Message-
 From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 04, 2008 10:03 AM
 To: Thijs Lensselink
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Avoid object twice

 NO!
 That is what I do not want!
 setting.php need to run mail() function.
 also setting.php need $googlemapkey.

 other.php just need $googlemapkey.
 other .php do not need run mail() function.

 If I use include, I will get twice email.

 Please do advice how to share the $googlemapkey.

  I think you are making it way to complicated for yourself.
 
  So you really just need to share settings between files.
  That's exactly what include / require are for.
 
  settings.php
  ?php
 $googlemapkey = g8ejeUFEUHEU;// example
 
 function sendMail() {
 mail([EMAIL PROTECTED],test.test);
 }
  ?
 
 
  Here you include settings.php and are able to use the  mapkey
 variable.
  If you want to send an email just call sendMail();
 
  other.php
  ?php
 include settings.php;
 
 // use your google API key any way you want
 
 sendMail();  // sends mail
  ?
 
  If you don't need the sendMail(); function. then don't call it.
  other2.php
  ?php
include settings.php;
 
 // use your google API key any way you want
  ?
 
 
  I think that's about as clear as i can make it.

 For the love of everything good in this world, please take the time to
 READ his reply. Most notably, you should pay attention to how he
 DECLARES a function in settings.php, rather than EXECUTING a function.
 Since it is just a DECLARATION, you can include that file and the
 function will not be EXECUTED. You can then EXECUTE the function at a
 time of your choosing.

 Not everything should run when it is loaded--you built a class (My)...
 this is the same idea. Rather than a class, this is a function. Think
 about it--member functions of classes don't execute by themselves (save
 for the constructor/destructor, etc.)... you have to invoke them. Same
 with (most) functions. You build it, and then it just sits there until
 you actually tell it to do something. If you don't want your script to
 send mail yet, then don't tell it to use the sendMail() function.

 Hope this is resolved,


 Todd Boyd
 Web Programmer




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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Uhmm!

It is sure that function can call from other file.
But it is NOT EXECUTE mail() function.

How mail function be execute!

Please do more advice.
You may tire of this mail.


BEST REGARDS,
Yui

2008/6/5 Boyd, Todd M. [EMAIL PROTECTED]:
 -Original Message-
 From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 04, 2008 10:03 AM
 To: Thijs Lensselink
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Avoid object twice

 NO!
 That is what I do not want!
 setting.php need to run mail() function.
 also setting.php need $googlemapkey.

 other.php just need $googlemapkey.
 other .php do not need run mail() function.

 If I use include, I will get twice email.

 Please do advice how to share the $googlemapkey.

  I think you are making it way to complicated for yourself.
 
  So you really just need to share settings between files.
  That's exactly what include / require are for.
 
  settings.php
  ?php
 $googlemapkey = g8ejeUFEUHEU;// example
 
 function sendMail() {
 mail([EMAIL PROTECTED],test.test);
 }
  ?
 
 
  Here you include settings.php and are able to use the  mapkey
 variable.
  If you want to send an email just call sendMail();
 
  other.php
  ?php
 include settings.php;
 
 // use your google API key any way you want
 
 sendMail();  // sends mail
  ?
 
  If you don't need the sendMail(); function. then don't call it.
  other2.php
  ?php
include settings.php;
 
 // use your google API key any way you want
  ?
 
 
  I think that's about as clear as i can make it.

 For the love of everything good in this world, please take the time to
 READ his reply. Most notably, you should pay attention to how he
 DECLARES a function in settings.php, rather than EXECUTING a function.
 Since it is just a DECLARATION, you can include that file and the
 function will not be EXECUTED. You can then EXECUTE the function at a
 time of your choosing.

 Not everything should run when it is loaded--you built a class (My)...
 this is the same idea. Rather than a class, this is a function. Think
 about it--member functions of classes don't execute by themselves (save
 for the constructor/destructor, etc.)... you have to invoke them. Same
 with (most) functions. You build it, and then it just sits there until
 you actually tell it to do something. If you don't want your script to
 send mail yet, then don't tell it to use the sendMail() function.

 Hope this is resolved,


 Todd Boyd
 Web Programmer




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



Re: [PHP] Avoid object twice

2008-06-04 Thread David Giragosian
On 6/4/08, Yui Hiroaki [EMAIL PROTECTED] wrote:
 Uhmm!

 It is sure that function can call from other file.
 But it is NOT EXECUTE mail() function.

 How mail function be execute!

 Please do more advice.
 You may tire of this mail.

Yes.

David

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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Thanks you for php developer.

If php can not share the parameter each different
file, it is not reality of my program.

If I use include  or requre, php can share the paremeter each file.
But other files call or execute from original  file.

setting.php and google_info.php and other.php almost reach
the my goal, I thought.

But google_info.php must execute mail() function.
Or setting.php must have $googlemapkey.

Thank you for a lot.

Regards,
Yui

2008/6/5 Boyd, Todd M. [EMAIL PROTECTED]:
 -Original Message-
 From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 04, 2008 10:03 AM
 To: Thijs Lensselink
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Avoid object twice

 NO!
 That is what I do not want!
 setting.php need to run mail() function.
 also setting.php need $googlemapkey.

 other.php just need $googlemapkey.
 other .php do not need run mail() function.

 If I use include, I will get twice email.

 Please do advice how to share the $googlemapkey.

  I think you are making it way to complicated for yourself.
 
  So you really just need to share settings between files.
  That's exactly what include / require are for.
 
  settings.php
  ?php
 $googlemapkey = g8ejeUFEUHEU;// example
 
 function sendMail() {
 mail([EMAIL PROTECTED],test.test);
 }
  ?
 
 
  Here you include settings.php and are able to use the  mapkey
 variable.
  If you want to send an email just call sendMail();
 
  other.php
  ?php
 include settings.php;
 
 // use your google API key any way you want
 
 sendMail();  // sends mail
  ?
 
  If you don't need the sendMail(); function. then don't call it.
  other2.php
  ?php
include settings.php;
 
 // use your google API key any way you want
  ?
 
 
  I think that's about as clear as i can make it.

 For the love of everything good in this world, please take the time to
 READ his reply. Most notably, you should pay attention to how he
 DECLARES a function in settings.php, rather than EXECUTING a function.
 Since it is just a DECLARATION, you can include that file and the
 function will not be EXECUTED. You can then EXECUTE the function at a
 time of your choosing.

 Not everything should run when it is loaded--you built a class (My)...
 this is the same idea. Rather than a class, this is a function. Think
 about it--member functions of classes don't execute by themselves (save
 for the constructor/destructor, etc.)... you have to invoke them. Same
 with (most) functions. You build it, and then it just sits there until
 you actually tell it to do something. If you don't want your script to
 send mail yet, then don't tell it to use the sendMail() function.

 Hope this is resolved,


 Todd Boyd
 Web Programmer




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



RE: [PHP] Avoid object twice

2008-06-04 Thread Boyd, Todd M.
 -Original Message-
 From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 04, 2008 12:28 PM
 To: Boyd, Todd M.
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Avoid object twice
 
 Thanks you for php developer.
 
 If php can not share the parameter each different
 file, it is not reality of my program.
 
 If I use include  or requre, php can share the paremeter each file.
 But other files call or execute from original  file.
 
 setting.php and google_info.php and other.php almost reach
 the my goal, I thought.
 
 But google_info.php must execute mail() function.
 Or setting.php must have $googlemapkey.

I think it's a fair to assume that no programming language (i.e., PHP)
is able to magically determine the contents of another file/script
without communicating with it in some way (shared memory, pipes,
sockets, the filesystem, middleware, etc.).

How is google_info.php structured? Is it on YOUR server, so that you can
put a page-include at the top of it? If the code that contains your
class (which contains the function to execute mail()) is not included as
part of the executed script, then the executed script will have no idea
that it even exists--let alone have the knowledge of its member
functions.

I think you need to take a step back and focus on fundamental
programming concepts before trying to tackle playing with a Google API.


Todd Boyd
Web Developer

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



Re: [PHP] Avoid object twice

2008-06-03 Thread Yui Hiroaki
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



Re: [PHP] Avoid object twice

2008-06-03 Thread James Dempster
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




Re: [PHP] Avoid object twice

2008-06-03 Thread James Dempster
I suggest you don't put code other than class structures in class files.
Also don't execute My.php just execute b.php which though __autoload
includes My.php.

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

$obj=new My(Hello);
$obj-buff();

$objref=new My(Good);
$objref-buff();

---

--My.php--
?php

Class My{
   private $word;
   function __construct($getword){
   $this-word=$getword;
   }
   public function buff(){
   echo $this-word.br /;
   }
}


/James Dempster

On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED] wrote:

 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
 
 
 



Re: [PHP] Avoid object twice

2008-06-03 Thread Yui Hiroaki
Thank you for a good suggest!

Somehow, I have to execute my.php also.
This program have to run.
1)My.php
2)b.php

My.php show Hello - it is OK,
b.php shows
 Hello
Good

it is NOT good. I need to get only Good


Please give me a suggestion.

Regards,
Yui
2008/6/3 James Dempster [EMAIL PROTECTED]:
 I suggest you don't put code other than class structures in class files.
 Also don't execute My.php just execute b.php which though __autoload
 includes My.php.

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

 $obj=new My(Hello);
 $obj-buff();

 $objref=new My(Good);
 $objref-buff();

 ---

 --My.php--
 ?php

 Class My{
private $word;
function __construct($getword){
$this-word=$getword;
}
public function buff(){
echo $this-word.br /;
}
 }


 /James Dempster

 On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED] wrote:

 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



Re: [PHP] Avoid object twice

2008-06-03 Thread Yui Hiroaki
Thank you for a good suggest!

Somehow, I have to execute my.php also.
This program have to run.
1)My.php
2)b.php

My.php show Hello - it is OK,
b.php shows
 Hello
Good

it is NOT good. I need to get only Good


Please give me a suggestion.

Regards,
Yui
2008/6/3 James Dempster [EMAIL PROTECTED]:
 I suggest you don't put code other than class structures in class files.
 Also don't execute My.php just execute b.php which though __autoload
 includes My.php.

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

 $obj=new My(Hello);
 $obj-buff();

 $objref=new My(Good);
 $objref-buff();

 ---

 --My.php--
 ?php

 Class My{
private $word;
function __construct($getword){
$this-word=$getword;
}
public function buff(){
echo $this-word.br /;
}
 }


 /James Dempster

 On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED] wrote:

 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



Re: [PHP] Avoid object twice

2008-06-03 Thread Yui Hiroaki
Please look at my.php

my.php load
$obj=new My(Hello);
$obj-buff();

so, if a.php load, it absolutely got hello in load b.php

Regards,
Yui

2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:
 Quoting Yui Hiroaki [EMAIL PROTECTED]:

 Thank you for a good suggest!

 Somehow, I have to execute my.php also.
 This program have to run.
 1)My.php
 2)b.php

 My.php show Hello - it is OK,
 b.php shows
  Hello
 Good

 it is NOT good. I need to get only Good


 Please give me a suggestion.

 Regards,
 Yui
 2008/6/3 James Dempster [EMAIL PROTECTED]:

 I suggest you don't put code other than class structures in class files.
 Also don't execute My.php just execute b.php which though __autoload
 includes My.php.

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

 $obj=new My(Hello);
 $obj-buff();

 $objref=new My(Good);
 $objref-buff();

 ---

 --My.php--
 ?php

 Class My{
   private $word;
   function __construct($getword){
   $this-word=$getword;
   }
   public function buff(){
   echo $this-word.br /;
   }
 }


 /James Dempster

 On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED] wrote:

 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




 If you only want to see Good Then don't run it twice.
 Take James's suggestion and try it again:

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

 $objref=new My(Good);
 $objref-buff();

 ---

 --My.php--
 ?php

 Class My{
private $word;
function __construct($getword){
$this-word=$getword;
}
public function buff(){
echo $this-word.br /;
}
 }


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



Re: [PHP] Avoid object twice

2008-06-03 Thread Thijs Lensselink

Quoting Yui Hiroaki [EMAIL PROTECTED]:


Thank you for a good suggest!

Somehow, I have to execute my.php also.
This program have to run.
1)My.php
2)b.php

My.php show Hello - it is OK,
b.php shows
 Hello
Good

it is NOT good. I need to get only Good


Please give me a suggestion.

Regards,
Yui
2008/6/3 James Dempster [EMAIL PROTECTED]:

I suggest you don't put code other than class structures in class files.
Also don't execute My.php just execute b.php which though __autoload
includes My.php.

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

$obj=new My(Hello);
$obj-buff();

$objref=new My(Good);
$objref-buff();

---

--My.php--
?php

Class My{
   private $word;
   function __construct($getword){
   $this-word=$getword;
   }
   public function buff(){
   echo $this-word.br /;
   }
}


/James Dempster

On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED] wrote:


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





If you only want to see Good Then don't run it twice.
Take James's suggestion and try it again:

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

$objref=new My(Good);
$objref-buff();

---

--My.php--
?php

Class My{
private $word;
function __construct($getword){
$this-word=$getword;
}
public function buff(){
echo $this-word.br /;
}
}


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



Re: [PHP] Avoid object twice

2008-06-03 Thread Thijs Lensselink

Quoting Yui Hiroaki [EMAIL PROTECTED]:


Please look at my.php

my.php load
$obj=new My(Hello);
$obj-buff();

so, if a.php load, it absolutely got hello in load b.php

Regards,
Yui

2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:

Quoting Yui Hiroaki [EMAIL PROTECTED]:


Thank you for a good suggest!

Somehow, I have to execute my.php also.
This program have to run.
1)My.php
2)b.php

My.php show Hello - it is OK,
b.php shows
 Hello
Good

it is NOT good. I need to get only Good


Please give me a suggestion.

Regards,
Yui
2008/6/3 James Dempster [EMAIL PROTECTED]:


I suggest you don't put code other than class structures in class files.
Also don't execute My.php just execute b.php which though __autoload
includes My.php.

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

$obj=new My(Hello);
$obj-buff();

$objref=new My(Good);
$objref-buff();

---

--My.php--
?php

Class My{
  private $word;
  function __construct($getword){
  $this-word=$getword;
  }
  public function buff(){
  echo $this-word.br /;
  }
}


/James Dempster

On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED] wrote:


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





If you only want to see Good Then don't run it twice.
Take James's suggestion and try it again:

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

$objref=new My(Good);
$objref-buff();

---

--My.php--
?php

Class My{
   private $word;
   function __construct($getword){
   $this-word=$getword;
   }
   public function buff(){
   echo $this-word.br /;
   }
}




I don't think i understand you fully. Or you're trying to make it to  
complicated.


You have a class in My.php :

Class My{
private $word;

function __construct($getword){
$this-word=$getword;
}

public function buff(){
echo $this-word.br /;
}
}

And a script that creates an instance of My b.php :

function __autoload($class_name) {
  include_once $class_name . '.php';
}

$obj=new My(Hello);
$obj-buff();

$objref=new My(Good);
$objref-buff();

The output will be Hellobr/Goodbr/. because you call it two  
times. So if you only want to see Good. Then you change b.php to  
look like this:


function __autoload($class_name) {
  include_once $class_name . '.php';
}

$objref=new My(Good);
$objref-buff();

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



Re: [PHP] Avoid object twice

2008-06-03 Thread Yui Hiroaki
The code is blelow;
-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 /;
   }
}
?
--

on website, first it execute My.php , then execute b.php

So it will show blelow;
Hello(when excute My.php)


Hello(when excute from b.php)
Good(when excute from b.php)



I do not need Hello twice


I would get

Hello(when excute My.php)
Good(when excute from b.php)



Please do help me!

Regards,
Yui

















2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:
 Quoting Yui Hiroaki [EMAIL PROTECTED]:

 Please look at my.php

 my.php load
 $obj=new My(Hello);
 $obj-buff();

 so, if a.php load, it absolutely got hello in load b.php

 Regards,
 Yui

 2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:

 Quoting Yui Hiroaki [EMAIL PROTECTED]:

 Thank you for a good suggest!

 Somehow, I have to execute my.php also.
 This program have to run.
 1)My.php
 2)b.php

 My.php show Hello - it is OK,
 b.php shows
  Hello
 Good

 it is NOT good. I need to get only Good


 Please give me a suggestion.

 Regards,
 Yui
 2008/6/3 James Dempster [EMAIL PROTECTED]:

 I suggest you don't put code other than class structures in class
 files.
 Also don't execute My.php just execute b.php which though __autoload
 includes My.php.

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

 $obj=new My(Hello);
 $obj-buff();

 $objref=new My(Good);
 $objref-buff();

 ---

 --My.php--
 ?php

 Class My{
  private $word;
  function __construct($getword){
  $this-word=$getword;
  }
  public function buff(){
  echo $this-word.br /;
  }
 }


 /James Dempster

 On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED]
 wrote:

 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




 If you only want to see Good Then don't run it twice.
 Take James's suggestion and try it again:

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

 $objref=new My(Good);
 $objref-buff();

 ---

 --My.php--
 ?php

 Class My{
   private $word;
   function __construct($getword){
   $this-word=$getword;
   }
   public function buff(){
   echo $this-word.br /;
   }
 }



 I don't think i understand you fully. Or you're trying to make it to
 complicated.

 You have a class in My.php :

 Class My{
private $word;

function __construct($getword){
$this-word=$getword;
}

public function buff(){
echo $this-word.br /;
}
 }

 And a script that creates an instance of My b.php :

 

Re: [PHP] Avoid object twice

2008-06-03 Thread Stut

On 3 Jun 2008, at 17:12, Yui Hiroaki wrote:

The code is blelow;
-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 /;
  }
}
?
--

on website, first it execute My.php , then execute b.php

So it will show blelow;
Hello(when excute My.php)


Hello(when excute from b.php)
Good(when excute from b.php)



I do not need Hello twice


I would get

Hello(when excute My.php)
Good(when excute from b.php)


As you've already been told you should not really mix classes and  
procedural code in files. Put the My class into My.php, then have  
b.php and c.php where c.php contains the procedural code from My.php  
along with the __autoload from b.php.


I don't see why you insist on being able to run My.php. If it  
contains a class it should not be run as the main script. Ever!!


-Stut

--
http://stut.net/

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



Re: [PHP] Avoid object twice

2008-06-03 Thread Jim Lucas

Yui Hiroaki wrote:

The code is blelow;
-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 /;
   }
}
?
--

on website, first it execute My.php , then execute b.php

So it will show blelow;
Hello(when excute My.php)


Hello(when excute from b.php)
Good(when excute from b.php)



I do not need Hello twice


I would get

Hello(when excute My.php)
Good(when excute from b.php)



Please do help me!

Regards,
Yui

















2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:

Quoting Yui Hiroaki [EMAIL PROTECTED]:


Please look at my.php

my.php load
$obj=new My(Hello);
$obj-buff();

so, if a.php load, it absolutely got hello in load b.php

Regards,
Yui

2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:

Quoting Yui Hiroaki [EMAIL PROTECTED]:


Thank you for a good suggest!

Somehow, I have to execute my.php also.
This program have to run.
1)My.php
2)b.php

My.php show Hello - it is OK,
b.php shows
 Hello
Good

it is NOT good. I need to get only Good


Please give me a suggestion.

Regards,
Yui
2008/6/3 James Dempster [EMAIL PROTECTED]:

I suggest you don't put code other than class structures in class
files.
Also don't execute My.php just execute b.php which though __autoload
includes My.php.

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

$obj=new My(Hello);
$obj-buff();

$objref=new My(Good);
$objref-buff();

---

--My.php--
?php

Class My{
 private $word;
 function __construct($getword){
 $this-word=$getword;
 }
 public function buff(){
 echo $this-word.br /;
 }
}


/James Dempster

On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED]
wrote:

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




If you only want to see Good Then don't run it twice.
Take James's suggestion and try it again:

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

$objref=new My(Good);
$objref-buff();

---

--My.php--
?php

Class My{
  private $word;
  function __construct($getword){
  $this-word=$getword;
  }
  public function buff(){
  echo $this-word.br /;
  }
}



I don't think i understand you fully. Or you're trying to make it to
complicated.

You have a class in My.php :

Class My{
   private $word;

   function __construct($getword){
   $this-word=$getword;
   }

   public function buff(){
   echo $this-word.br /;
   }
}

And a script that creates an instance of My b.php :

function __autoload($class_name) {
 include_once $class_name . '.php';
}

$obj=new My(Hello);
$obj-buff();

$objref=new My(Good);
$objref-buff();

The output will be Hellobr/Goodbr/. because you call it two 

Re: [PHP] Avoid object twice

2008-06-03 Thread Shawn McKenzie

Stut wrote:

On 3 Jun 2008, at 18:35, Yui Hiroaki wrote:

Sorry I still have a problem.


Let's take a step back. What are you *actually* trying to do. I'm 
assuming it's not just printing out Hello and Good. What is the real 
problem you're trying to solve and what are the constraints that are 
causing you to be weird in the implementation?


-Stut



As Stut says, depending upon what you're trying to do there is most 
likely a much better way.  Why If you want to execute a method or 
retrieve a property from both objects, why do you have them in two 
separate files?


-Shawn


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



Re: [PHP] Avoid object twice

2008-06-03 Thread Yui Hiroaki
Thank you for everyone who helps me!


I got a message what I want.


Thank you!
Yui

2008/6/4 Jim Lucas [EMAIL PROTECTED]:
 Yui Hiroaki wrote:

 The code is blelow;
 -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 /;
   }
 }
 ?
 --

 on website, first it execute My.php , then execute b.php

 So it will show blelow;
 Hello(when excute My.php)


 Hello(when excute from b.php)
 Good(when excute from b.php)



 I do not need Hello twice


 I would get

 Hello(when excute My.php)
 Good(when excute from b.php)



 Please do help me!

 Regards,
 Yui

















 2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:

 Quoting Yui Hiroaki [EMAIL PROTECTED]:

 Please look at my.php

 my.php load
 $obj=new My(Hello);
 $obj-buff();

 so, if a.php load, it absolutely got hello in load b.php

 Regards,
 Yui

 2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:

 Quoting Yui Hiroaki [EMAIL PROTECTED]:

 Thank you for a good suggest!

 Somehow, I have to execute my.php also.
 This program have to run.
 1)My.php
 2)b.php

 My.php show Hello - it is OK,
 b.php shows
  Hello
 Good

 it is NOT good. I need to get only Good


 Please give me a suggestion.

 Regards,
 Yui
 2008/6/3 James Dempster [EMAIL PROTECTED]:

 I suggest you don't put code other than class structures in class
 files.
 Also don't execute My.php just execute b.php which though __autoload
 includes My.php.

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

 $obj=new My(Hello);
 $obj-buff();

 $objref=new My(Good);
 $objref-buff();

 ---

 --My.php--
 ?php

 Class My{
 private $word;
 function __construct($getword){
 $this-word=$getword;
 }
 public function buff(){
 echo $this-word.br /;
 }
 }


 /James Dempster

 On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED]
 wrote:

 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



 If you only want to see Good Then don't run it twice.
 Take James's suggestion and try it again:

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

 $objref=new My(Good);
 $objref-buff();

 ---

 --My.php--
 ?php

 Class My{
  private $word;
  function __construct($getword){
  $this-word=$getword;
  }
  public function buff(){
  echo $this-word.br /;
  }
 }


 I don't think i understand you fully. Or you're trying to make it to
 complicated.

 You have a class in My.php :

 Class My{
   private $word;

   function __construct($getword){
   $this-word=$getword;
   }

   public function buff(){
   echo 

Re: [PHP] Avoid object twice

2008-06-03 Thread Stut

On 3 Jun 2008, at 18:35, Yui Hiroaki wrote:

Sorry I still have a problem.


Let's take a step back. What are you *actually* trying to do. I'm  
assuming it's not just printing out Hello and Good. What is the real  
problem you're trying to solve and what are the constraints that are  
causing you to be weird in the implementation?


-Stut

--
http://stut.net/

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



Re: [PHP] Avoid object twice

2008-06-03 Thread Yui Hiroaki
Sorry I still have a problem.

I separete files belows;
-My.php---
?php

Class My{
private $word;
function __construct($getword){
$this-word=$getword;
}
public function buff(){
echo $this-word.br /;
}
}
?
--

--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();
--


First I execute c.php
Then I got Hello

Next I execute b.php
Then I got Good

I would like to get to execute b.php
Then I got Hello and Good -I need


The problem is how to get parameter from c.php to b.php.

Please do help me!


Regards,
Yui

2008/6/4 Jim Lucas [EMAIL PROTECTED]:
 Yui Hiroaki wrote:

 The code is blelow;
 -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 /;
   }
 }
 ?
 --

 on website, first it execute My.php , then execute b.php

 So it will show blelow;
 Hello(when excute My.php)


 Hello(when excute from b.php)
 Good(when excute from b.php)



 I do not need Hello twice


 I would get

 Hello(when excute My.php)
 Good(when excute from b.php)



 Please do help me!

 Regards,
 Yui

















 2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:

 Quoting Yui Hiroaki [EMAIL PROTECTED]:

 Please look at my.php

 my.php load
 $obj=new My(Hello);
 $obj-buff();

 so, if a.php load, it absolutely got hello in load b.php

 Regards,
 Yui

 2008/6/3 Thijs Lensselink [EMAIL PROTECTED]:

 Quoting Yui Hiroaki [EMAIL PROTECTED]:

 Thank you for a good suggest!

 Somehow, I have to execute my.php also.
 This program have to run.
 1)My.php
 2)b.php

 My.php show Hello - it is OK,
 b.php shows
  Hello
 Good

 it is NOT good. I need to get only Good


 Please give me a suggestion.

 Regards,
 Yui
 2008/6/3 James Dempster [EMAIL PROTECTED]:

 I suggest you don't put code other than class structures in class
 files.
 Also don't execute My.php just execute b.php which though __autoload
 includes My.php.

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

 $obj=new My(Hello);
 $obj-buff();

 $objref=new My(Good);
 $objref-buff();

 ---

 --My.php--
 ?php

 Class My{
 private $word;
 function __construct($getword){
 $this-word=$getword;
 }
 public function buff(){
 echo $this-word.br /;
 }
 }


 /James Dempster

 On Tue, Jun 3, 2008 at 9:17 AM, Yui Hiroaki [EMAIL PROTECTED]
 wrote:

 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 

RE: [PHP] Avoid object twice

2008-06-02 Thread Scott McNaught [Synergy 8]
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:[EMAIL PROTECTED] 
Sent: Monday, June 02, 2008 11:01 PM
To: php-general@lists.php.net
Subject: [PHP] 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



Re: [PHP] Avoid object twice

2008-06-02 Thread Jim Lucas

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



Just to make sure, you are calling your a.php script my.php in real life right?

If not, this might be part of your problem.  When I run the above script, and 
change the a.php to my.php, it loads just fine and it only displays one instance 
of hello.  I am thinking that you calling the class more then once and you don't 
realize it.



--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Avoid object twice

2008-06-02 Thread Yui Hiroaki
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] [EMAIL PROTECTED]:
 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:[EMAIL PROTECTED]
 Sent: Monday, June 02, 2008 11:01 PM
 To: php-general@lists.php.net
 Subject: [PHP] 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