Thursday, 14 July 2016

Top 3 useful tricks of CodeIgniter



Hi all of you, today i'll share you some codeigniter top tricks.

1 there is an optional perameter in $this->uri->segment

                          when you see http://website.com/controller/method/perameter vs http://website.com/controller/method/ in action ? that time we use that type of code.....
$variable = $this->uri->segment(3)                                                                                                       
there are an optional second one peraemeter that permits set your default value
$variable = $this->uri->segment(3,'SecondPerameter')                                                                      

2 Codeigniter View can return as data with a third perameter
$variable = $this->load->view('viewpage',$data,TRUE);                                                                      
$PDF = build_pdf($page);                                                                                                                         

3 Every Library can have a configuration file
              I can try to keep my library configuration option out of my controllers where possible. suddenly codeigniter lets us seamlessly move that information into application/config widout missing any steps,you need to name your configuration file the same as the library and you are set that,this is the simple example for email library.here is the application/config/email,php file include in every bit of code which one is distibutes

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');                                              
$config['protocol'] = '****';                                                                                                                          
$config['smtp_host'] = '*****************';                                                                                           
$config['smtp_user'] = 'username';                                                                                                             
$config['smtp_pass'] = 'password';                                                                                                              
$config['smtp_port'] = '80';                                                                                                                            
?>                                                                                                                                                                       

if the third pareameter allows you to suppress errors in the event that config file done not exist
$this->config->load('blog_settings', FALSE, TRUE);                                                                                     

ENJOY : )   
By :-  RAJA MAHIYARIYA MAHER(tHuNdEr^fR0G)

Related Articles

0 comments:

Post a Comment

Prompt Web Solution. Powered by Blogger.