How to track impression using image tag

Tracking the impression using image tag it’s playing important role, whenever you are sending email or include the image tag into another website to display your ads. It will send the parameters and get back the logs.

How Impression tracker works
Impression tracker display the image using server-side file and send back user details to server. It’s used to track your ads which display in different websites.

Impression tracker using image tag - codeasearch.com

Impression tracker using image tag – codeasearch.com

Let’s create simple image.html which have image tag and include image.php to display and capture logs entry.  Continue reading

Caching the Data using APC – Alternative PHP Cache

Now a days most of the website are used to cache their data to reduce the server load, Also speed up the response. We are going to discuss about the APC – Alternative PHP Cache.

APC is a Alternative PHP Cache as I already mentioned, its used to cache the data, remove and expire in the given time.  To work with APC first we need to enable php_apc.dll in windows and php_apc.so in Linux operating system.

Where to use APC ?

Consider you have a website with lots of content driven from database with data for all the users, on that time you cannot query the database each and every time. To avoid this case we will cache the data and share between the users. This will allow one time query and share the same data between the users.

Let’s see about fews function in APC.

apc_add – function used to store a data in key format and expire it in given TTL.

apc_add ( array $values [, mixed $unused = NULL [, int $ttl = 0 ]] )

Assigning value into $myData variable

<?php
    $myData = 'Welcome to APC';
    apc_add('myData',$myData);

apc_fetch – function used to fetch data from the given key. Continue reading

Persistent and Non-Persistent Cookie

Cookie used to store user data in form of text file or memory and access the values from it, Cookie are the part of HTTP header.

What is Persistent Cookie ?

Persistent Cookie which will store the data in text file with expire date and time. If you are access the website or particular page cookie will be created based on cookie name.  Next time If you are visiting the website or page it will be accessible from the cookie file which was created in the client browser.

Also Persistent Cookie is unsafe, because it will be easy viewable in the browser.

persistent_cookie.php

<?php
// creating the name:cookie_name_persistent and value:my cookie value with expire 1 hour
setcookie("cookie_name_persistent","my cookie value",time()+3600);

Above PHP file will create cookie and expire within 1 hour, you can view the cookie expire time in browser cookie part. Continue reading

Working with simple Array to CSV, XML and XLS Class in PHP

Most of the Array to CSV, XML and XLS are having different function or class, So we have though of writing all in same class. Class support different type of format like CSV, XML and XLS.

Class is design as calling the static method instead of creating he object, as the current version we have support limited methods.

How it’s work

It’s work based on the format type and date which have header and rows in array format, Once you call the getData function it will communicate the method based on the format type. Then set the header part to download the file.

Setting Up the Data

Three arguments accept in getData function. Continue reading

Debugging server-side script using ChromePHP

I have been working for server and client side scripting,  whenever I got the issue in JavaScript used to debug in console or fire-bug based on the browser and extension.

But it’s not possible in server-side script, if you want server-side script to track a log entry in browser it won’t support. Chrome Logger have the feature to track the log entry in console for server-side script.

They support few platform to display the server-side scripting in console.

  1.  Install Chrome Logger from Google Chrome web store.
  2. Click the extension icon to enable logging for the current tab’s domain (It will light up blue).
  3. Include the ChromePHP file into your script.

Simple example which will log the script-side script into console.

Chrome.php

<?php include 'ChromePhp.php';

// simple function will return content.
function chromePHPExample() {
	return 'Welcome to ChromeLogger, you can see me in Google Chrome Console.';
}

// below function will display the content from the chromePHPExample function 
// print in Google Chrome console
ChromePhp::log(chromePHPExample());

ChromePHP have lots of logging method, you can also check below list. Continue reading