php Archives | Page 2 of 18 | Codeexecute

Get current full url in php

$currentPage =  'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
If you want to check that ssl is enable or not then use below code
$currentPage =  (isset($_SERVER['HTTPS']) ? "https" : "http") . "://". $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];


Clear chache in smarty

smarty Clear cache

For Smarty version 2


For Smarty version 3


Since Smarty version 3.1.14 it is possible to delete cache files by their individual expiration time at creation by passing constant SMARTY::CLEAR_EXPIRED as expire_time parameter.


Force SSL redirection in cakephp

SSL with cakephp

Step 1. use Security component.

 public $components = array('Security');

Step 2. use the below code to post data.

//Use the below code in parent controller's beforeFilter action
$this->Security->unlockedActions = array('action_1','action_2'); // unlock actions which you want to call in ajax without ssl 
$this->Security->blackHoleCallback = 'forceSSL'; //call forceSSL action to redirect http:// uri to https:// 

// Defination of forceSSL function 
public function forceSSL() {
			return $this->redirect('https://' . env('SERVER_NAME') . $this->here);


Add existing project on Github by using commands

Simple steps to Add project on Github

//<strong>Step 1</strong> Initialize the local directory as a Git repository
$ git init

//<strong>Step 2</strong> Adds the files in the local repository and stage them for commit.
$ git add .
//to unstage a file use 'git reset HEAD YOUR-FILE'

//<strong>Step 3</strong> Commit the staged files of local repository.
$ git commit -m "First commit"

//<strong>Step 4</strong> Sets the new remote repository.
$ git remote add origin remote repository URL
//<strong>Step 4</strong> Verifies the new remote URL.
$ git remote -v

//<strong>Step 5</strong> Push the staged files of local repository in remote repository.
$ git push origin master