Hello,

I have a file (01.php)

<?php
abstract class Sender
{
    const E_NEW_APPOINTMENT       = 1;  

    /**
     * Send instant confirmation/notification emails.
     *
     * @param int $type  (E_NEW_APPOINTMENT)
     * @param CustomerAppointment $ca
     */
    public static function sendEmails( $type, CustomerAppointment $ca )
    {
        list ( $codes, $staff, $appointment, $customer ) = self::_prepareData( $ca );

        switch ( $type ) {
            case self::E_NEW_APPOINTMENT:
                $to_client = new Notification();
                $to_client->loadBy( array( 'slug' => 'client_info' ) );

                $to_staff = new Notification();
                $to_staff->loadBy( array( 'slug' => 'provider_info' ) );

                $confirmed_appointment= $codes->set( 'confirmed', $ca->get( 'confirmed' ) );

                if ( $to_staff->get( 'active' ) AND $ca->get( 'confirmed' )==1 ) {
                    // Send email notification to staff member (and admins if necessary).
                    self::_send( $to_staff, $codes, $staff->get( 'email' ) );
                }
                break;

        }
    }
}
?>

And another file (02.php)

<?php
require "http://abc.com/01.php";
sendEmails(E_NEW_APPOINTMENT, $ca);
?>

In this case, how can I call the "public static function sendEmails" in file 01.php ?

Thank you.

require '01.php'; // domain includes might not always work
Sender::sendEmails(E_NEW_APPOINTMENT, $ca);

Thank you, but my owne files don't stay in the same folder, so it perhaps works without included domain http?

Adding a relative or absolute path is not a problem.

Thank you, but I have just tried the above code but it cannot perform and call the function in file 01.php.

What's the error?

The

Sender::sendEmails(E_NEW_APPOINTMENT, $ca);

is not correct. The code is dead here and the function sendEmails doesn't work.

Sender::sendEmails(Sender::E_NEW_APPOINTMENT, $ca);

Perhaps because $ca is null, don't you need to initialize it?

Perhaps because $ca is null, don't you need to initialize it?
It is necessary because without it, the function sendEmails couldn't understand with which objet it will work.

So it is necessary, but you haven't. I suggest you add that first.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.