download a file by php code-PHP download files code

Basic example for download a  file by php

<?php
$file="http://testexample.com/your_test_file.jpg"; // path to your file
 header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Length: ' . filesize($file));
readfile($file); exit;
?>

download a file by php code

OR

<?php
header("Content-Transfer-Encoding: Binary");
        header("Content-length: ".filesize($dest_file_path));
        header('Content-Type: text/xml');
        header('Content-Disposition: attachment; filename="'.$dest_file_name.'"');
        readfile($dest_file_path);
?>

Exynos 5433-powered-Samsung Galaxy Note 4

The Samsung N910C is powered by a Exynos 5433 not to be
 confused with the Exynos 5430 found in the Galaxy Alpha,
while the N910S is based on Snapdragon 805. The new Exynos
 chipset moves to 64-bit processing with four Cortex-A57 cores
 and four Cortex-A53. Those are the successors to the 32-bit
A15 and A7 respectively but implement the ARMv8-A instructions
 set same as Apple's Cyclone cores. The Snapdragon 805 uses
32-bit Krait 450 cores. The chipset also brings a new generation
 of GPU, the Mali-T760, the third generation of the architecture
behind the Mali-T628 that powers Galaxy Alpha's chipset. The
Qualcomm chipset brings a next-gen GPU as well, Adreno 420.
 The Galaxy Note 4 will have 3GB of RAM in both its Exynos
and Snapdragon versions.  It helps that it has faster access to
 RAM too. The new Mali-T760 has an edge over the new
Adreno 420 at the QHD resolution of the Galaxy Note 4 screen.
 We added the score to our own charts and the new Samsung-made
 chipset certainly seems impressive. It offers a small improvement
over the 5430 but the thing to keep in mind here is that Android
 4.4 isn't optimized for the new instruction set used in the Exynos
 chipset and the QHD screen resolution.

Meizu MX4-QHD

Meizu MX4-QHD

A screenshot has leaked over in China and the source claims it
belongs to the upcoming Meizu MX4. The screenshot shows a
camera UI and was reportedly 1536 x 2502 in resolution pointing
 to QHD resolution for the Meizu MX4 screen. The issue is that
 the screenshot cannot be found in full resolution so this could
turn out to be false information. Still it's highly possible that the
Meizu MX4 will indeed sport a resolution higher than 1080p
on what's projected to be a 5.4" display.

The screenshot reveals that the camera will be able to capture
above-1080p video - we're guessing UHD. Alleged Meizu MX4
 screenshot The Meizu MX4 has already been spotted flaunting
 impressively-thin bezels. Last year's model MX3 had bezels
equal to those of the LG G2. The Meizu MX4 is going to
 become official on September 2 and should offer a 20.7MP
 Sony-made camera, 3GB of RAM, 5.4" 2560 x 1536 display,
 an octa-core Exynos 5433, Meizu's Flyme OS 4.0 and aprice
of around $406 or €303.

Google AdSense++ way to earn


Google AdSense++ way to earn

You can make a fulltime living from Google Adsense, but it takes time and
effort. You apply for Google Adsense, get approved, and get the Adsense
code on your site. The first day, you make ten bucks. You quickly add that
up, and see that if you made ten bucks each day, you would make 600 per
month from one site. You quickly add again, and see that if you had ten
sites, all making 600 a month, you could quit your traditional job.

Once your AdSense account has been approved, you’ll likely want to get
 started by adding the code that will place Google’s ads on your site.
To get started with AdSensefor Content,
 log in to Google AdSense and click the Ad Settings tab.

It is always a good idea to find out what works for others. Again, each site is
different, but this will save you a great deal of time in researching. Become a
regular visitor to Adsense related forums.

According to Google, if you elect to display image ads, you will have more
advertisers bidding to have their ads show specifically on your pages.

This usually results in more money per click, and this is definitely worth looking
into for your site. Make sure you use GoogleChannels and reports to find out if it
is working out well for you or not.

Adsence-Importance of keyword  placement
Unit name Size
Leaderboard 728 × 90
Banner 468 × 60
Large Rectangle 336 × 280
Medium Rectangle 300 × 250
Square 250 × 250
Half Banner 234 × 60

Add ads  on your main page, where more than one post appears, visitors will see
the ads at the bottom of each of those posts.

Making money from Adsense than just putting up a
site and putting Google Adsense ad code on those pages.
There are two ways to succeed with Adsense. You either
have to have a very high traffic site, or you have to have a multitude of low
to mid traffic sites.

When you build your sites, your first order of business should be to get
them listed in the major search engines. However, you should also get
listed in more specialized directories as well, and use traffic generation
techniques such as article marketing,forum marketing, social networking,
and social bookmarking.

Use Google Analytics: Google Analytics will give you a ton of
information about the traffic that comes to your site. You can use that
information to make adjustments and additions to your site, which will
increase your Adsense revenue.

Link units
Probably the second most used ad type in the AdSense program after text
ads is the link unit. Link units are very cool because when used properly
you can make them look like they belong on your page, so users are more likely
to click them.

Making a link unit look like it belongs on your page is pretty simple. You
adjust the template colors of the ad to match the template colors of your
page. Then, when the link units are displayed on your page, they look like
links that are related to the content of the page.

Themed ads
Themed units are basically text ads that have a specific theme. Google offers
these around holiday times, and they just appear in your ad structure. You
don’t have to do anything special to use themed units — they’re automatically
 enabled in your ads when you set up your AdSense account.

Creating original content
Writing your own articles and blog posts isn’t as hard as it sounds unless you
have hundreds of Web pages to populate, which could become a very
timeconsuming effort. If that’s the case, you’ll have to use somereprints, but it’s
still best if you try to keep the most important pages on your site filled with
original content.

Reading-friendly colors:Color can be your best friend or your worst
enemy online. The first thing to remember when dealing with Web site
colors is that colors display differently on-screen than they do on paper
and colors display slightly differently on different screens. So test your
colors in the real world— online rather than on paper. It wouldn’t hurt
to take a peek at your Web masterpiece from a few different computers.

Links within articles:One last element that you should include in
your articles and blog posts is links to other, related articles and blog
posts, both on your Web site and on others’ Web sites. Linking to other
resources provides additional information for your site visitors. Usually,
those visitors will click through those links and then click back to the
page from which they came. If you worry about visitors clicking away
from your site, never to return, set your links up so that they open in a
new window. Opening links in a new window keeps your Web site open
and in front of the visitors. When they’re finished examining the site
you’ve linked to, they can close the window and be right back on your
Web site.

AdSense for Domains

AdSense for Domains is a program for parked domains, meaning domains
 that are not in active use. There are many reasons someone might want
 to park a domain, including the intention of speculating in domain names
 and protecting existing related domain names from falling into the hands
 of competitors.

Video Units
What content is more compelling then video? And how better
 to monetize this compelling content on your site than by adding
 video units from Google’s YouTube, a leader in online video?
To get started, from the AdSense Setup page, click Video unit.
 You will need to login to your YouTube account.

AdSense for Search:Feel free to mention to your site visitors that you
have a search box they can use to find whatever.

Referrals: Refer away. It’s always best if you’ve actually used the
products you’re referring so that what you tell your visitors is accurate.
 Tell them your thoughts about the products and share your stories of how
the product has performed for you.

Earning with AdSense referral ads: requires some action on the part of your
Web site visitors. Earning with referrals isn’t as simple as clicking through
a link, or even searching and then clicking through search results. AdSense
referrals have conversions— which are specific actions that must take place
before you get paid for displaying the referral ad.Even after a conversion
 takes place, the payments are a little different than
what you see with other AdSense ads. All referral ads are paid on a flat fee.
However, the fee that you’re paid can be influenced by your location. Each
advertiser sets country-specific goals, so you’re paid up tothe maximum
amount shown for each of the referrals that you make from your AdSense
referral ads.

AdSense:When a user who signed up for Google AdSense through your
referral first earns $100 within 180 days of sign-up and is eligible for
payout, you’re credited with $100. Note that it’s only when the user
firstsigns up and earns $100. If a visitor has been a member of AdSense
in the past, you don’t receive this payment. Also, this applies only to
referrals located in North America, Latin America, or Japan. All others
are counted as invalid referrals because AdSense doesn’t support other
countries at this time.

Aarray And multiple array values

Aarray And multiple array values

array[key_element1] => array(1, 2,3);
array[key_element2] => array(4, 5, 6);

 associative arrays
array[key1] => array(key => value1, key => value2, key => value3);
array[key2] => array(key => value4, key => value5, key => value6);

Basically parsing the $values array and pulling the relevant value out.
 Unsetting the array as we go to leave only the values which were not
 sorted. The remaining items in the array will be merged after the loop.
 with array_merge.

PHP array

$values = array('value1', 'value2', 'value3', 'value4', 'value5', 'value6');
$keys = array(0, 2, 1, 5);

foreach ($keys AS $key) {
    $tempOutput[] = ($values[$key])?$values[$key]:'';
    unset($values[$key]);
}

$output = array_merge($tempOutput, $values);


Make new array be joining 2 arrays
shuffle($countries);
$n = count($countries); $i = 0;
$jumble = array();
foreach ($names as $name) {
    if (!isset($jumble[$name])) $jumble[$name] = array();
    $jumble[$name][] = $countries[$i++ % $n];
}

PHP Session expire-minutes inactivity

PHP Session expire-minutes inactivity

session_cache_limiter('public');
session_cache_expire(15);
//should expire after 15  minutes inactivity

asy way to handle this, is to set a variable to $_SESSION
 every time the user visits the page after a successful login.
You can check that variable every time the page loads, and then
 you will know the last time they requested a page from the site,
 and can compare it to the current time to determine what to do from there.

session.gc_maxlifetime
session.gc_maxlifetime specifies the number of seconds after which data
 will be seen as 'garbage' and cleaned up. Garbage collection occurs
 during session start.

Furthermore, when using PHP's default session.save_handler files,
 the session data is stored in files in a path specified in session.save_path.
 With that session handler, the age of the session data is calculated on the
 file's last modification date and not the last access date.

if (isset($_SESSION['LAST_ACTIVITY']) &&
 (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
    // last request was more than 30 minutes ago
    session_unset();     // unset $_SESSION variable for the run-time
    session_destroy();   // destroy session data in storage
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp

          OR

if (!isset($_SESSION['CREATED'])) {
    $_SESSION['CREATED'] = time();
} else if (time() - $_SESSION['CREATED'] > 1800) {
    // session started more than 30 minutes ago
    session_regenerate_id(true);  
// change session ID for the current session and invalidate old session ID
    $_SESSION['CREATED'] = time();  // update creation time
}

Note that session.gc_maxlifetime should be at least equal to the
 lifetime of this custom expiration handler 1800 in this example.

PHP INTERFACES


Class inheritanceenables you to describe a parent-child relationship
between classes. For example, you might have a base class
 Shapefrom which both Squareand Circlederive. However,
 you might often want to add additional “interfaces” to classes,
 basically meaning additional
 contracts to which
the class must adhere. This is achieved in C++ by using multiple
 inheritance and deriving from two classes. PHP chose interfaces
 as an alternative to multiple inheritance, which allows you to specify
 additional contracts a class must follow. An interface is declared
similar to a class but only includes function prototypes without
implementation and constants. Any class that “implements”
 this interface automatically has the interface’s constants defined and,
as the implementing class, needs to supply the function definitions for the
interface’s function prototypes that are all abstractmethods unless you
declare the implementing class as abstract.

abstract class Shape {
function setCenter($x, $y) {
$this->x = $x;
$this->y = $y;
}
abstract function draw();

protected $x, $y;
}
class Square extends Shape {
function draw()
{
// Here goes the code which draws the Square
...
}
}
class Circle extends Shape {
function draw()
{
// Here goes the code which draws the Circle
...
}
}
You can see that the draw()abstract method does not
 contain any code.

To implement an interface, use the following syntax:
class A implements B, C, ... {
...
}

Classes that implement an interface have an instance of a relationship
 with the interface; for example, if class Aimplements interface
 myInterface, the following results in '$obj is-A myInterface'printing:

$obj = new A();
if ($obj instanceof myInterface) {
print '$obj is-A myInterface';
}

parent AND self PHP oops

 parent  AND self PHP oops

self::refers to the current class and it is usually used to access
static members, methods, and constants. parent::refers to the
 parent class and it is most often used when wanting to call the
 parent constructor or methods. It may also be used to access
members and constants. You should use parent::as
opposed to the parent’s class name because it makes it easier
 to change your class hierarchy because you are not hard-coding
 the parent’s class name.

The following example makes use of both parent::and self::for
 accessing the Childand Ancestorclasses:

class Ancestor {
const NAME = "Ancestor";
function __construct()
{
print "In " . self::NAME . " constructor\n";
}
}
class Child extends Ancestor {
const NAME = "Child";
function __construct()
{
parent::__construct();
print "In " . self::NAME . " constructor\n";
}
}
$obj = new Child();

The previous example outputs
In Ancestor constructor
In Child constructor
Make sure you use these two class names whenever possible.

Static Methods-PHP

 PHP supports declaring methods as static.
Whatthis means is that your static methods are part of the
 class and are not bound to any specific object instance and
 its properties. Therefore, $this isn’t accessible in these methods,
 but the class itself is by using selfto access it. Because
static methods aren’t bound to any specific object, you can
 call them without creating an object instance by using the
class_name::method()syntax. You may also call them from an
 object instance using $this->method(), but $thiswon’t
be defined in the called method. For clarity, you should use self::method()
instead of $this->method().

class PrettyPrinter {
static function printHelloWorld()
{
print "Hello, World";
self::printNewline();
}
static function printNewline()
{
print "\n";
}
}
PrettyPrinter::printHelloWorld();

The example prints the string "Hello, World"followed by a newline.
Although it is a useless example, you can see that printHelloWorld()can be
called on the class without creating an object instance using the class name,
and the static method itself can call another static method of the
class printNewline()using the self::notation. You may call a parent’s
 static method by using the parent::notation.

Static Properties

As you know by now, classes can declare properties. Each instance of the
class,object has its own copy of these properties. However, a class can
also contain static properties. Unlike regular properties, these belong to
the class itself and not to any instance of it.

class propertiesas opposed to object or instance properties. You can also
think of static properties as global variables that sit inside a class but are
accessible from anywhere via the class.
Static properties are defined by using the static keyword:
class MyClass {
static $myStaticVariable;
static $myInitializedStaticVariable = 0;
}
To access static properties, you have to qualify the property name with
the class it sits in

MyClass::$myInitializedStaticVariable++;
print MyClass::$myInitializedStaticVariable;

What is array

Arrays
An arrayin PHP is a collection of key/value pairs.
 This means that it maps keys or indexes to values.
Array indexescan be either integers or strings
whereas values can be of any type.
Arrays in PHP are implemented using hash tables, which
 means that accessing a value has an average complexity.

array()construct Arrays can be declared using the array()language
 construct, which generally takes the following form elements inside
square brackets, [], are optional:

array([key =>] value, [key =>] value, ...)

The key is optional, and when it’s not specified, the key is
 automatically assigned one more than the largest previous
 integer key starting with 0. You can intermix the use with
 and without the key even within the same declaration.
The value itself can be of any PHP type, including an array.
 Arrays containing arrays give a similar result as multi-dimensional
 arrays in other languages.

Accessing Array Elements Array elements can be accessed by using
the $arr[key]notation, where keyis either an integer or string expression.
When using a constant string for key,make sure you don’t forget the single or
double quotes, such as $arr["key"]. This notation can be used for both reading
array elements and modifying or creating new elements.

$arr1 = array(1, 2, 3);
$arr2[0] = 1;
$arr2[1] = 2;
$arr2[2] = 3;
print_r($arr1);
print_r($arr2);

The print_r()function has not been covered yet in this book, but when it
is passed an array, it prints out the array’s contents in a readable way. You can
use this function when debugging your scripts.

Array
(
[0] => 1
[1] => 2
[2] => 3
)
Array
(
[0] => 1
[1] => 2
[2] => 3
)
So, you can see that you can use both the array()construct
 and the $arr[key] notation to create arrays.
Usually, array()is used to declare arrays
whose elements are known at compile-time, and
 the $arr[key]notation is used when the elements
 are only computed at runtime.
PHP also supports a special notation, $arr[], where the key is
 not specified. When creating new array offsets using
 this notation , the key is automatically assigned as one
 more than the largest previous integer key.

Therefore, the previous example can be rewritten as follows:
$arr1 = array(1, 2, 3);
$arr2[] = 1;
$arr2[] = 2;
$arr2[] = 3;

$arr1 = array("name" => "John", "age" => 28);
$arr2["name"] = "John";
$arr2["age"] = 28;
if ($arr1 == $arr2) {
print '$arr1 and $arr2 are the same' . "\n";
}

Reading array values You can use the
 $arr[key]notation to read array values.
The next few examples build on top of the previous example:
print $arr2["name"];
if ($arr2["age"] < 35) {
print " is quite young\n";
}
Php Interview-questions-with-answers
Php code for valid number
Php file uploading code
Php by code
Advanced php
Php global variables
Top 550 php interview-questions

PHP Functions
Php tutorial - imagemagick
php.ini Basics
PHP Sessions
Cookies Versus Sessions
PHP Web-Related Variables
PHP ERRORS
maximum size of a file uploaded
Php Image upload
php file_get_contents
MySQL Data on the Web
What are GET and POST
php and pdf
$_ENV and $_SERVER
PEAR with php
SELECTING DATA PHP
prevent hijacking with PHP
LAMP
PHP MySQL Functions
PHP Zip File Functions
Substrings PHP
PHP Variable names
PHP magic methods
How to get current session id
Add variables into a session
$_GET , $_POST,$_COOKIE
different tables present in mysql
PHP CURL
php Sessions page
PHP-sorting an array
PHP-count the elements of array
Operators for If/Else Statements
PHP file uploading code
PHP global variables
Testing working using phpinfo
PHP Code for a Valid Number
PHP-Associative Arrays
PHP mvc tutorial
PHP get_meta_tags-Extracts
difference between print and echo
PHP best tutorial-PHP variables
Reading DOC file in PHP
PHP interview questions
convert time PHP
PHP implode array elements
header function-PHP
PHP-Renaming Files Directories
PHP Classes
in_array function in PHP
keep your session secure PHP
Web Application with PHP
What is SQL Injection
PHP-extract part of a string
PHP urlencode
PHP- know browser properties
PHP- Extracting Substrings
Checking Variable Values /Types
PHP-best 20 Open Source cms
IP AddressPHP
PHP-Scope Resolution Operator
how create new instance of object
how eliminate an object
PHP- ob_start
XML file using the DOM API
PHP- MVC
PHP- CAPTCHA
PHP- Position of a Value in an Array
PHP-Mail Functions
PHP-difference include vs require
calculate the sum of values in an array
PHP-total number of rows
Show unique records mysql
MySQL Triggers
MySQL data directory
MySQL Subqueries
PHP- Networking Functions
PHP- Operators
Restore database
Conditional Functions mysql
PHP-function overloading
Friend function
mysql_connect /mysql_pconnect
PHP-Error Control Operators
what is IMAP
Apache-Specific Functions
Send Email from a PHP Script
SQL inherently
WAMP, MAMP, LAMP
Php tutorial-SYMBOLS
Table Types-MySQL
PHP-Encryption data management
PHP Array
Running MySQL on Windows
Maximum Performance MySQL
XML-RPC
PHP-static variables
Advanced Database Techniques
FTP
Codeigniter
Apache Pool Size
Why NoSQL
MySQL Server Performance
Database software
SQL Interview Answers
PHP Redirect
PHP Interview Questions with Answers
Advanced PHP