How to change the timezone in CodeIgniter 3.1.6

date_default_timezone_set() function is used to sets the default timezone used by all date or time functions in core PHP, CodeIgniter etc. date_default_timezone_set(); date_default_timezone_set('Asia/Kolkata'); # Option-1: In case of CodeIgniter, we can set the default timezone in the application/config.php file In case of CodeIgniter, we can set the default timezone in the application/config.php file <?php defined('BASEPATH') … Continue reading How to change the timezone in CodeIgniter 3.1.6

PHP Sessions across sub domains

User will  login or set sessions at auth.domain.com and can use that session all the sub domains of that domain. the session will use across all sub domains. auth.domain.com sub1.domain.com sub2.domain.com where if the user visits sub1.domain.com or sub2.domain.com and they are not logged in, they get pushed over to auth.domain.com and can log in. … Continue reading PHP Sessions across sub domains

How to send a cross domain ajax request

  I want to send a cross domain ajax request but I am getting below error. I need to allow others send ajax requests to my script . So external requests may come from other websites and domains. Code which I have tried for request. $(document).ready(function () { $.ajax({ type: 'POST', url: "http://otherdomain.com/mypage.php", data: 'ss=' … Continue reading How to send a cross domain ajax request

Download File in php or codeigniter

Want to download file using php. Here is the sample code. By using it you can download the file in php. you can use it in Codeigniter Also. the function are tested in Codeigniter. So it will works file in Codeigniter.  Just Call the function, download_sample(); It will start Downloading the file. public function download_sample(){ … Continue reading Download File in php or codeigniter

Php Code Encoding Benefits or which Encoder do I Need?

Php Code Encoding Benefits or which Encoder do I Need? Encoding Benefits PHP scripts can be easily read, changed and run on any PHP enabled system. Encoding PHP offers important benefits. Product Developers: protect and license your code before distribution. Time restricting is ideal for protecting evaluation copies, and server/domain based locking helps secure revenue from … Continue reading Php Code Encoding Benefits or which Encoder do I Need?

How to protect and hide PHP source code?

How to protect and hide PHP source code? In the time of open-source there are multiple benefits of making your code available to all. However when deploying or selling your PHP code to a client you might want to protect and hide it because of different business reasons or security. There are multiple approaches to … Continue reading How to protect and hide PHP source code?

Download File in php

Download File in php function. Force Download. Here, $filepath = File Full path, where the file exists. $filename = File name of the file , which have to download ,LIKE: file1.txt header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\";"); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($filename)); ob_clean(); … Continue reading Download File in php

on every third block ul tag will close and new tag open in php

<!DOCTYPE html> <html lang="en"> <head>   <title>Bootstrap Example</title>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width, initial-scale=1">   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container">   <h2>Basic List Group</h2> <?php  $products = array(1,2,3,4,5,6,7,8,9,10); ?> <?php foreach ($products as $key => $prod) { ?> <?php if( ($key+1)==1 || (($key+1)%3)==1 ) { … Continue reading on every third block ul tag will close and new tag open in php

Change Server url dynamically for xampp or LIVE server in php

Here, whitelist array contains all the ip address that we uses for xampp or Local server. All all local ip address in the whitelist array and filter easily which is for local and which is for LIVE server url. <?php  $whitelist = array( '127.0.0.1', '::1', '192.168.2.10' ); if(in_array( $_SERVER['REMOTE_ADDR'], $whitelist)){     $serverHost = 'http://'.$_SERVER['HTTP_HOST'].'/mentor/'; … Continue reading Change Server url dynamically for xampp or LIVE server in php