Quantcast
Channel: Gik's notes » PHP
Browsing all 8 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Get the Current Page URL

It’s often to know current page url. Here is the snipet: function getCurrentPageUrl() { $strPageUrl = 'http'; if ($_SERVER["HTTPS"] == 'on') $strPageUrl .= 's'; $strPageUrl .= '://' ....

View Article



Image may be NSFW.
Clik here to view.

Post Request in PHP

Today we post a request! function PostRequest($url, $referer, $headersAddon, $_data) { // convert variables array to string: $data = array(); while( list($n,$v) = each($_data) ) { $data[] = "$n=$v"; }...

View Article

Image may be NSFW.
Clik here to view.

Parse cookies from Header

If you want to get cookies from a header, use the following: function ParseCookies($strHeaders) { $result = array(); if (!empty($strHeaders)) { $aHeaders = explode("\n", trim($strHeaders));...

View Article

Image may be NSFW.
Clik here to view.

Shift cookies in current context

function ShiftCookies($strHeaders) { // Parse cookies $aCookies = ParseCookies($strHeaders); // Shift cookies in current context foreach ($aCookies as $cookie) @setrawcookie($cookie['name'],...

View Article

Image may be NSFW.
Clik here to view.

Convert windows-1251 to utf8 encoding

function convertCp1251ToUtf8($str) { static $table = array( "\xA8" => "\xD0\x81", "\xB8" => "\xD1\x91", "\xA1" => "\xD0\x8E", "\xA2" => "\xD1\x9E", "\xAA" => "\xD0\x84", "\xAF" =>...

View Article


Image may be NSFW.
Clik here to view.

Singleton design pattern in PHP

When you need a single instance of some class, use pattern: class MySingleton { static private $instance = null; static public function createInstance($args = null) { if (self::$instance == null)...

View Article

Image may be NSFW.
Clik here to view.

Eclipse PHP (PDT) Syntax Formatter

Simple and well-formed php code formatter you may use: http://balakhonov-yuriy.ru/php-formatter-for-eclipse/ Just copy file:...

View Article

Image may be NSFW.
Clik here to view.

WordPress upload add another file extensions

Just add the following code to you functions.php in theme: add_filter('upload_mimes', 'custom_upload_mimes'); function custom_upload_mimes ( $existing_mimes=array() ) { // add $existing_mimes['xpi'] =...

View Article

Browsing all 8 articles
Browse latest View live




Latest Images