How to load a html page on mail in codeignaiter
In CodeIgniter, you can load a HTML page using the load
function provided by the CI_Controller
class. Here are a few ways to do it:
Method 1: Using the load
function
class MyController extends CI_Controller {
public function index() {
$this->load->view('path/to/your/html/page.html');
}
}
In this example, path/to/your/html/page.html
should be the relative path to your HTML file from the application/views
directory.
Method 2: Using the view
function with a custom template
class MyController extends CI_Controller {
public function index() {
$this->load->view('template', array('content' => 'path/to/your/html/page.html'));
}
}
In this example, template
is a custom template that you need to create in the application/views
directory. The content
variable will be replaced with the contents of path/to/your/html/page.html
.
Method 3: Using the file_get_contents
function
class MyController extends CI_Controller {
public function index() {
$html = file_get_contents('path/to/your/html/page.html');
$this->output->set_output($html);
}
}
In this example, file_get_contents
reads the contents of the HTML file and sets it as the output of the controller.
Method 4: Using the CI_Output
class
class MyController extends CI_Controller {
public function index() {
$this->output->set_header('Content-Type: text/html');
$this->output->set_output(file_get_contents('path/to/your/html/page.html'));
}
}
In this example, CI_Output
is used to set the content type of the output to text/html
and then sets the output to the contents of the HTML file.
Note that in all cases, you need to make sure that the HTML file is located in a directory that is accessible by the web server.