Re: Avoid object twice

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

 



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. <tmboyd1@xxxxxxxx>:
>> -----Original Message-----
>> From: Yui Hiroaki [mailto:hiroakiyui@xxxxxxxxx]
>> Sent: Wednesday, June 04, 2008 10:03 AM
>> To: Thijs Lensselink
>> Cc: php-general@xxxxxxxxxxxxx
>> Subject: Re:  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("test@xxxxxxxxxxx","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


[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