I wonder if I can use an alias name after call a library, let say:
$this->load->library('email','em');
How I can do this?
You can do that by providing a third parameter while loading your library.
If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Calendar, it will be assigned to a variable named $this->calendar.
If you prefer to set your own class names you can pass its value to the third parameter:
$this->load->library('calendar', NULL, 'my_calendar');
// Calendar class is now accessed using:
$this->my_calendar
Read more at the Loader Class
documentation of Codeigniter.
The only way I thing might be close to the way that your after is if you load the library as
$this->load->library('email');
And then
$em = new Email();
// All the email config stuff goes here.
$em->from('email', 'Name');
$em->to('email');
$em->subject('Test Email');
$message = 'Some Message To Send';
$em->message($message);
Or
$this->load->library('email', NULL, 'em');
// Email config stuff here.
$this->em->from();
$this->em->to();
$this->em->subject();
$this->em->message();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With