find the number of parameters passed into function in PHP?

func_num_args() function returns the number of parameters/arguments passed to a function in PHP.

difference between include and require?


Answer: It"s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the
execution of the script. If the file is not found by include(), a warning will be issued, but execution will
continue.

Use mysqldump to create a copy of the database?

mysqldump -h mysqlhost -u username -p mydatabasename > tgdbdump.sql

What is SERIAL data type in MySQL?

BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT

What’s the default port for MySQL Server?

3306

Conditional Functions mysql

The IF() Function

The IF() function provides a way to return a value based on a condition within a query.
The first argument is a condition that is evaluated for each row of the query. The value in the second is returned if the condition is trUE, and the third argument is returned if it is FALSE.
The following example is a very simple shipping rate calculator. If the product weight is less than 5 pounds, shipping costs $1.99; otherwise, it costs $2.99.
mysql> SELECT code, weight, IF(weight < 5, 1.99, 2.99)
    -> FROM products;
+------+--------+------------------------------+
| code | weight |    IF(weight <5, 1.99, 2.99) |
+------+--------+------------------------------+
| MINI |   1.50 |                         1.99 |
| MIDI |   4.50 |                         1.99 |
| MAXI |   8.00 |                         2.99 |
+------+--------+------------------------------+
3 rows in set (0.00 sec) 
 

The CASE Statement

The CASE statement is a multiple-valued conditional construct. Suppose you wanted to set three or more shipping rates based on weight. This would require a complex series of nested IF() functions.
The following example uses a CASE statement to determine the shipping rate based on three different weight bands:
mysql> SELECT code, weight,
    ->        CASE WHEN weight < 2 THEN 1.99
    ->             WHEN weight < 5 THEN 2.99
    ->             ELSE 4.99 END as shipping
    -> FROM products; 
+------+--------+----------+
| code | weight | shipping |
+------+--------+----------+
| MINI |   1.50 |     1.99 |
| MIDI |   4.50 |     2.99 |
| MAXI |   8.00 |     4.99 |
+------+--------+----------+
3 rows in set (0.00 sec)
 

Combined Queries-UNION

Mosy SQL queries contain just one SELECT statement that can return data from one table, or several tables using a join. The technique of combining two or more independent queries into a single data set is usually known as a union or a compound query.
You might want to use this technique to retrieve records from two tables that have a similar structure in a single query. For instance, suppose you have archived off some data so that you have a customers table that contains your current customers and another table called old_customers.
These tables would have the same structureor at least would share many common columns if new columns had been added to the customers table since the archive took place. Therefore, you could perform a query on this table that takes into account both current and archived customers. This would look something like the following:


SELECT name, telephone, email
FROM customers
UNION
SELECT name, telephone, email
FROM old_customers;
 
 

You can also use UNION to perform two different queries on the same table and combine the two results into a single data set.

mysql> SELECT first_name, last_name
    -> FROM customer_contacts
    -> WHERE customer_code = 'SCICORP'
    -> UNION
    -> SELECT first_name, last_name
    -> FROM customer_contacts
    -> WHERE customer_code = 'PRESINC';
+------------+-----------+
| first_name | last_name |
+------------+-----------+
| Albert     | Einstein  |
| Charles    | Darwin    |
| Marie      | Curie     |
| Benjamin   | Franklin  |
| Abraham    | Lincoln   |
| Richard    | Nixon     |
| Franklin   | Roosevelt |
| Theodore   | Roosevelt |
+------------+-----------+
8 rows in set (0.01 sec)

What is SQL Injection?

SQL Injection is the hacking technique which attempts to pass SQL commands (statements) through a web application for execution by the backend database.

it can be prevented by mysql_real_escape_string() function of PHP.

Such features as login pages, support and product request forms, feedback forms, search pages, shopping carts and the general delivery of dynamic content, shape modern websites and provide businesses with the means necessary to communicate with prospects and customers.

keep your session secure php

  1. Use SSL when authenticating users or performing sensitive operations.
  2. Regenerate the session id whenever the security level changes (such as logging in). You can even regenerate the session id every request if you wish.
  3. Have sessions time out
  4. Don't use register globals
  5. Store authentication details on the server. That is, don't send details such as username in the cookie.
  6. Check the $_SERVER['HTTP_USER_AGENT']. This adds a small barrier to session hijacking. You can also check the IP address. But this causes problems for users that have changing IP address due to load balancing on multiple internet connections etc (which is the case in our environment here).
  7. Lock down access to the sessions on the file system or use custom session handling
  8. For sensitive operations consider requiring logged in users to provide their authenication details again.

send images to mail box

<?php 
$message = "<html><head></head><body>";

$message .= "<img src='http://exp.com/images/logo.jpg' alt='' />
</body>
</html>";

$cleanedFrom="admin@abfdgd.com";
$headers = "From: $cleanedFrom";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$to="snmurty99@gmail.com"; 
$subject="sample images";

mail($to, $subject, $message, $headers);
 
?> 

Checking if a Host Is Alive

Use PEAR's Net_Ping package:
require 'Net/Ping.php';

$ping = new Net_Ping;
if ($ping->checkhost('www.oreilly.com')) {
    print 'Reachable';
} else {
    print 'Unreachable';
}

$data = $ping->ping('www.oreilly.com');
 
The ping program tries to send a message from your machine to another.
 If everything goes well, you get a series of statistics chronicling the transaction. An error means that ping can't reach the host for some reason.
On error, Net_Ping::checkhost( ) returns false
and Net_Ping::ping( ) returns the constant PING_HOST_NOT_FOUND. If there's a problem running the ping program (because Net_Ping is really just a wrapper for the program), PING_FAILED is returned.
 

Opening a Remote File

You want to open a file that's accessible to you via HTTP or FTP.

Pass the file's URL to fopen( )

$fh = fopen('http://www.example.com/robots.txt','r') or die($php_errormsg);
 
 
When fopen( ) is passed a filename that begins with http://, it retrieves the given page with an HTTP/1.0 GET request (although a Host: header is also passed along to deal with virtual hosts). Only the body of the reply can be accessed using the file handle, not the headers. Files can be read, not written, via HTTP.
When fopen( ) is passed a filename that begins with ftp://, it returns a pointer to the specified file, obtained via passive mode FTP. You can open files via FTP for either reading or writing, but not both.
To open URLs that require a username and a password with fopen( ), embed the authentication information in the URL like this: 

$fh = fopen('ftp://username:password@ftp.example.com/pub/Index','r'); 
$fh = fopen('http://username:password@www.example.com/robots.txt','r');
 
 
Opening remote files with fopen( ) is implemented via a PHP feature 
called the URL fopen wrapper. It's enabled by 
default but is disabled by setting allow_url_fopen to off in 
your php.ini or web server configuration file. If 
you can't open remote files with fopen( ), check your server 
configuration.  

Changing File Permissions by php

Use chmod( ) to change the permissions of a file: 

chmod('/home/user/secrets.txt',0400);
 
Use chown( ) to change a file's owner and chgrp( ) to change a file's group:
<?php 
chown('/tmp/myfile.txt','sklar');           // specify user by name
chgrp('/home/sklar/schedule.txt','soccer'); // specify group by name

chown('/tmp/myfile.txt',5001);              // specify user by uid
chgrp('/home/sklar/schedule.txt',102); 
 // specify group by gid
?> 

The permissions passed to chmod( ) must be specified as an octal number.
The superuser can change the permissions, owner, and group of any file. Other users are restricted. They can change only the permissions and group of files that they own, and can't change the owner at all. Nonsuperusers can also change only the group of a file to a group they belong to.
The functions chmod( ), chgrp( ), and chown( ) don't work on Windows.

XML file using the DOM API

//Use PHP's DOM XML extension. Here's how to read XML from a file:
$dom = domxml_open_file('books.xml');
//Here's how to read XML from a variable:
$dom = domxml_open_mem($books);
//You can also get just a single node. Here's how to get the root node:
$root = $dom->document_element( );
//Here's how to do a depth-first recursion to process all the nodes in a document:
 
function process_node($node) {
    if ($node->has_child_nodes( )) {
        foreach($node->child_nodes( ) as $n) {
            process_node($n);
        }
    }

    // process leaves
    if ($node->node_type( ) =  = XML_TEXT_NODE) {
        $content = rtrim($node->node_value( ));
        if (!empty($content)) {
            print "$content\n";
        }
    }

}
process_node($root);
 
The W3C's DOM provides a platform- and language-neutral method that specifies the structure and content of a document. Using the DOM, you can read an XML document into a tree of nodes and then maneuver through the tree to locate information about a particular element or elements that match your criteria. This is called tree-based parsing . In contrast, the non-DOM XML functions allow you to do event-based parsing.
 

convert time in php

<?php

     $thishour = time() + (4*60*60);

     $newTime = date("d m Y H:i:s",$thishour);

     echo $newTime;

   ?>);

what is ob_start?

ob_start turns on output buffering,

Scope Resolution Operator?

::  is the scope operator it is used to call methods of a class that has not been instantiated.

What is MVC?

MVC- Model, View, Controller - is simply
Model -  contains data access code and all of you business logic code.
View - Contains markup/design code, generally html,xml, json.
Controller -  contains very little code, just whatever is needed to call the Model code and render the View code.

What is SEO Writing?

Article Writing
press release writing
blog writing
web page writing
product description writing

eCommerce Tips

start SEO if you own an eCommerce store. eCommerce shopping is expected to rise
higher than ever before this holiday season.The series of algorithm updates from
Google staring very early this year has made everyone think if they should really focus on
SEO anymore.Social signals have huge importance because the links obtained in social media are mostly natural. Facebook and twitter are without doubt the best social networks available today and when Google says social media links are important for ranking, it is quite natural for everyone to start posting regular tweets and facebook wall updates to get social links.

How to big Your Online Marketing Technologies

For marketers looking to bust out of individual channel silos and reap the advantages of integrated marketing, this makes it even more critical to plan ahead for growth and change.
The first step is being able to understand the benefits of simplifying the chaos that is multichannel online marketing.
Integrating your online marketing tools can be difficult, but the benefits are sizeable. Done correctly, not only does it allow for a more efficient use of time and resources, but also offers the potential for deeper insights and greater returns on marketing investments.

Top Google SEO Tips Video Surpasses 5000 Views

The JM Internet Group (web: jm-seo.org), a leader in providing Google SEO tips for small business marketers, is proud to announce that their 'Quick Google SEO Tips Video' has surpassed 5000 views on YouTube. This video focuses on top SEO tricks and tips for Google; that is, the top ten easy SEO tips a small business owner or marketer can use to determine how to get to the top of Google. SEO, or Search Engine Optimization, is all about getting to the top of Google's no cost, organic listings. In this quick tutorial, Jason McDonald explains the ten most important SEO tips to begin to understand how search engine optimization works.
"Getting to the top of Google is a key marketing objective for most businesses and marketers," said Jason McDonald, Senior SEO director of the JM Internet Group. "We released this video in August, 2012, and are amazed at how many people have not only watched the SEO tips video but taken it to heart. The feedback has been impressive from small business owners and marketers across the USA, Canada, and the world."
To watch this informative small business video on Google SEO tips,
  
SEO Courses Begin April 9, 2013, with a focus on SEO Tips for Small Business
    Top Ten: Top Ten No Charge Tools for SEO / Search Engine Optimization

    Keywords: How to Generate Great Keywords for Great Google Rank

    Page Tags - Quick Boost - Use Page Tags to Improve your Google Rank

    Link Strategies: The Who, What, Where, When and How of Getting Good Links for SEO

    News: News You Can Use - Using News as an SEO Opportunity -

    Google Rank: Monitoring Your Google Rank, and Leveraging it for SEO and PPC

    Website Structure: Creating the Best Topology for Google Rank

Data Control Language (DCL) statements ?

  • Data Control Language (DCL) statements  Allow you to change the permissions on database structures. There are two DCL statements:
    • GRANT  Allows you to give another user access to your database structures, such as tables.
    • REVOKE  Allows you to prevent another user from accessing to your database structures, such as tables.

Data Definition Language (DDL) statements?

  • Data Definition Language (DDL) statements  Allow you to define the data structures, such as tables, that make up a database. There are five basic types of DDL statements:
    • CREATE  Allows you to create a database structure. For example, CREATE TABLE is used to create a table; another example is CREATE USER, which is used to create a database user.
    • ALTER  Allows you to modify a database structure. For example, ALTER TABLE is used to modify a table.
    • DROP  Allows you to remove a database structure. For example, DROP TABLE is used to remove a table.
    • RENAME  Allows you to change the name of a table.
    • TRUNCATE  Allows you to delete the entire contents of a table.

Data Manipulation Language (DML) statements ?

  • Data Manipulation Language (DML) statements  Allow you to modify the contents of tables. There are three DML statements:
    • INSERT  Allows you to add rows to a table.
    • UPDATE  Allows you to change a row.
    • DELETE  Allows you to remove rows.

What Is a Relational Database?

The basic concepts of a relational database are fairly easy to understand. A relational database is a collection of related information that has been organized into structures known as tables. Each table contains rows that are further organized into columns. These tables are stored in the database in structures known as schemas, which are areas where database users may store their tables. Each user may also choose to grant permissions to other users to access their tables.

MySQL Subqueries?


You can use the result of a query like you use a list of values with the IN operator to filter a query based on the result of another query. The subquery appears in parentheses after the IN keyword.
The following query fetches all columns from the products table, but only for those product codes that were part of order number 1:

mysql> SELECT *
    -> FROM products
    -> WHERE product_code IN (
    ->   SELECT product_code
    ->   FROM order_lines
    ->   WHERE order_id = 1
    -> );
+--------------+---------------+--------+--------+
| product_code | name          | weight | price  |
+--------------+---------------+--------+--------+
| MINI         | Small product |   1.50 |  5.99  |
| MAXI         | Large product |   8.00 | 15.99  |
+--------------+---------------+--------+--------+
2 rows in set (0.00 sec)

MySQL Triggers

To create a new trigger, use the CREATE TRIGGER statement. You must give the trigger a unique name and then provide the timing, action, and table that will cause the trigger to fire. For example, to create a trigger that will fire every time a row is deleted from the products table, you would construct a trigger as follows:
 
CREATE TRIGGER trigger_name
BEFORE DELETE ON products
FOR EACH ROW
BEGIN
  ...
END



The timing for a trigger can be BEFORE or AFTER, indicating whether the trigger code should be executed immediately before or immediately after the SQL statement that causes the trigger to fire.
The keywords FOR EACH ROW are part of the CREATE TRIGGER syntax and are required in every trigger.

what is Triggers?

A trigger is a stored database object that contains a series of SQL commands, set to activate automatically when certain events take place.
Each trigger is associated with a table. You can create a trigger that will fire when an INSERT, UPDATE, or DELETE takes place on the named table.

What Is SQL?

The Structured Query Language (SQL) is the most common way to retrieve and manage database information. An SQL query consists of a series of keywords that define the data set you want to fetch from the database. SQL uses descriptive English keywords, so most queries are easy to understand.

Locating commands?

$ echo $PATH
/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:/home/chris/bin
especially if the command resides in a directory with a long name.
 The better way is to have commands stored in well-known directories,
and then add those directories to your shell's PATH environment variable.

LPRng?

This printing service was dropped, making CUPS the preferred (and only)
 printing service included with Red Hat Linux.

Common Linux Features?

  • Multiuser — Not only can you have many user accounts available on a Linux system, you can also have multiple users logged in and working on the system at the same time. Users can have their own environments arranged the way they want: their own home directory for storing files and their own desktop interface (with icons, menus, and applications arranged to suit them). User accounts can be password-protected, so that users can control who has access to their applications and data.
  • Multitasking — In Linux, it is possible to have many programs running at the same time, which means that not only can you have many programs going at once, but that the Linux operating system can itself have programs running in the background. Many of these system processes make it possible for Linux to work as a server, with these background processes listening to the network for requests to log in to your system, view a Web page, print a document, or copy a file. These background processes are referred to as daemons.
  • Graphical User Interface (X Window System) — The powerful framework for working with graphical applications in Linux is referred to as the X Window System (or simply X). X handles the functions of opening X-based graphical user interface (GUI) applications and displaying them on an X server process (the process that manages your screen, mouse, and keyboard).
    On top of X, you use an X-based desktop environment to provide a desktop metaphor and window manager to provide the look-and-feel of your GUI (icons, window frames, menus, and colors, or a combination of those items called themes). There are several desktop environments and several desktop managers to choose from. (Red Hat provides a few desktop managers, but focuses on GNOME and KDE desktop environments.)
  • Hardware support — You can configure support for almost every type of hardware that can be connected to a computer. There is support for floppy disk drives, CD-ROMs, removable disks (such as DVDs and Zip drives), sound cards, tape devices, video cards, and most anything else you can think of.
    • Networking connectivity — To connect your Linux system to a network, Linux offers support for a variety of local area network (LAN) boards, modems, and serial devices. In addition to LAN protocols, such as Ethernet (both wired and wireless), all the most popular upper-level networking protocols can be built-in. The most popular of these protocols is TCP/IP (used to connect to the Internet). Other protocols, such as IPX (for Novell networks) and X.25 (a packet-switching network type that is popular in Europe), are also available.
    • Network servers — Providing networking services to the client computers on the LAN or to the entire Internet is what Linux does best. A variety of software packages are available that enable you to use Linux as a print server, file server, FTP server, mail server, Web server, news server, or workgroup (DHCP or NIS) server.
    • Application support — Because of compatibility with POSIX and several different application programming interfaces (APIs), a wide range of freeware and shareware software is available for Linux. Most GNU software from the Free Software Foundation will run in Linux (although some may take a bit of tweaking).

What Is an Operating System?

An operating system is made up of software instructions that lie between the computer hardware (disks, memory, ports, and so on) and the application programs (word processors, Web browsers, spreadsheets, and so on). At the center is the kernel, which provides the most basic computing functions (managing system memory, sharing the processor, opening and closing devices, and so on). Besides the kernel, an operating system provides other basic services needed to operate the computer, including:
  • File systems — The file system provides the structure in which information is stored on the computer. Information is stored in files, primarily on hard disks inside the computer. Files are organized within a hierarchy of directories. The Linux file system holds the data files that you save, the programs you run, and the configuration files that set up the system.
  • Device drivers — These provide the interfaces to each of the hardware devices connected to your computer. A device driver enables a program to write to a device without needing to know details about how each piece of hardware is implemented. The program opens a device, sends and receives data, and closes a device.
  • User interfaces — An operating system needs to provide a way for users to run programs and access the file system. Linux has both graphical and text-based user interfaces. GNOME and KDE provide graphical user interfaces, whereas shell command interpreters (such as bash) run programs by typing commands and options.
  • System services — An operating system provides system services, many of which can be started automatically when the computer boots. In Linux, system services can include processes that mount file systems, start your network, and run scheduled tasks. In Linux, many services run continuously, enabling users to access printers, Web pages, files, databases, and other computing assets over a network.

What is the difference between internal and external commands?

Internal commands are commands that are already loaded in the system.
 They can be executed any time and are independent

What is GUI?

Graphical User Interface, makes use of images and icons that users click and manipulate as a way of communicating with the computer.

What is BASH?

BASH is short for Bourne Again SHell. It was written by Steve Bourne as a replacement to the original Bourne Shell (represented by /bin/sh).

What is LILO?

This boot loader has been replaced by GRUB by and removed from the distribution.
LILO is a boot loader for Linux. It is used mainly to load the Linux operating
system into main memory so that it can begin its operations.


most important in organically ranking a site?

domain trust, inbound links/anchor
text, and properly formatted title tags are a good start.

What do you think of using XML sitemaps?

They are an additional tool to help the search engines
when they crawl a site. There is no requirement for any sitemap and your
pages will get indexed without them if you pay close attention to
navigation within your site.

What SEO tools do you use?

Keyword analysis tools, keyword density tools, index checking,
backlink checking, wordprocessor to check spelling and grammar, HTML
validation

What do you mean by keyword stemming?

Keyword stemming is a useful tool for web pages and search engine optimization.
The process of keyword stemming involves taking a basic but popular keyword pertaining
to a particular website and adding a prefix, suffix, or pluralization to make the
keyword into a new word.

keyword proximity?

The proximity of the keywords or keywords included in a phrase in
relation to each other and one another is of great importance and is the
basis of using the appropriate combination of the words in the page
titles,headers,paragraphs and page content.

What Is a Sitemap?

A Sitemap is especially useful for sites that feature images that may be hard to find by Googlebot or contain pages that aren’t linked or have few included links. Sites that contain compelling information or content can also benefit by the creation of a Sitemap.

Who is Matt Cutts?

Matt Cutts works for the Search Quality group in Google, specializing in search engine optimization issues. He is well known in the SEO community for enforcing the Google Webmaster Guidelines and cracking down on link spam. Cutts also advises the public on how to get better website visibility in Google.

what are meta tags?

meta tags are labeled as meta keyword tags and meta descriptions tags. These tags are invisible to the user and are used to supply data or directions to the search engines in order to access information.

What is Anchor Text?

It is the visible text that is hyper linked to another page ?

What does the 301 server response code signify?

Moved Permanently

how get a list of all pages indexed by google?

You can do site:example.com searches with  results per page, but if you
 try to do so with a script, then you will be stopped after just a few requests.

Security issue for sitemap SEO?

They typically name their sitemap something like sitemapRXTNAP.xml and submit it to Google using webmaster tools, rather than listing it in robots.txt

how access a method in the parent class that's been overridden in the child?

Prefix parent:: to the method name:
class shape {
    function draw( ) {
        // write to screen
    }
}

class circle extends shape {
   function draw($origin, $radius) {
      // validate data
      if ($radius > 0) {
          parent::draw( );
          return true;
      }

      return false;
   }
}

how execute different code depending on the number and type of arguments passed to a method?

PHP doesn't support method polymorphism as a built-in feature. However, you can emulate it using various type-checking functions. The following combine( ) function uses is_numeric(), is_string(), is_array(), and is_bool():
// combine() adds numbers, concatenates strings, merges arrays,
// and ANDs bitwise and boolean arguments
function combine($a, $b) {
    if (is_numeric($a) && is_numeric($b)) {
        return $a + $b;
    }

    if (is_string($a)  && is_string($b))  {
        return "$a$b";
    }

    if (is_array($a)   && is_array($b))   {
        return array_merge($a, $b);
    }

    if (is_bool($a)    && is_bool($b))    {
        return $a & $b;
    }

    return false;
}

want to link two objects, so when you update one, you also update the other?

Use =& to assign one object to another by reference:
$adam = new user;
$dave =& $adam;

how eliminate an object?

Objects are automatically destroyed when a script terminates. To force the destruction of an object, use unset( ):
$car = new car; // buy new car
...
unset($car);    // car wreck

how create a new instance of an object?

Define the class, then use new to create an instance of the class:
class user {
    function load_info($username) {
       // load profile from database
    }
}

$user = new user;
$user->load_info($_REQUEST['username']);

exchange the values in two variables without using additional variables for storage?

To swap $a and $b:
list($a,$b) = array($b,$a);

access the values passed to a function?how

Use the names from the function prototype:
function commercial_sponsorship($letter, $number) { 
    print "This episode of Sesame Street is brought to you by ";
    print "the letter $letter and number $number.\n";
}

commercial_sponsorship('G', 3);
commercial_sponsorship($another_letter, $another_number);

how associate multiple elements with a single key?

Store the multiple elements in an array:
$fruits = array('red' => array('strawberry','apple'),
                'yellow' => array('banana'));
Or, use an object:
while ($obj = mysql_fetch_object($r)) {
    $fruits[ ] = $obj;
}

How to check whether two floating-point numbers are equal?

Use a small delta value, and check if the numbers are equal within that delta:
$delta = 0.00001;

$a = 1.00000001;
$b = 1.00000000;

if (abs($a - $b) < $delta) { /* $a and $b are equal */ }

You want to extract part of a string, starting at a particular place in the string

Use substr( ) to select your substrings:
$substring = substr($string,$start,$length);
$username = substr($_REQUEST['username'],0,8);

Php get_meta_tags-Extracts all meta tag content attributes

get_meta_tagsExtracts all meta tag content attributes from a file and returns an array

<?php// Assuming the above tags are at www.example.com$tags get_meta_tags('http://www.example.com/');
// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo $tags['author'];       // nameecho $tags['keywords'];     // php documentationecho $tags['description'];  // a php manualecho $tags['geo_position']; // 49.33;-86.59?>

PHP Redirect - Redirect Script?

PHP Redirect Function

header('Location:  destination.php');
exit();
 
ou need the Location: part so the browser knows what header it's 
receiving. Also, don't forget to 
do an exit() or die() right after the redirect. 

 

Finding the Position of a Value in an Array

Use array_search( ) . It returns the key of the found value. If the value is not in the array, it returns false:
 
$position = array_search($value, $array);
if ($position !== false) {
    // the element in position 
//$position has $value as its 
//value in array $array
}
 
Use in_array( ) to find if an array contains a value; use array_search( ) to discover where that value is located. However, because array_search( ) gracefully handles searches in which the value isn't found, it's better to use array_search( ) instead of in_array( ). The speed difference is minute, and the extra information is potentially useful:

$favorite_foods = array(1 => 'artichokes', 'bread', 'cauliflower', 'deviled eggs');
 $food = 'cauliflower'; $position = array_search($food, $favorite_foods);
 if ($position !== false)
{
echo "My #$position favorite food is $food";
}
 else {
 echo "Blech! I hate $food!";
 }


Use the !== check against false because if your string is found in the array at position 0, the if evaluates to a logical false, which isn't what is meant or wanted.
If a value is in the array multiple times, array_search( ) is only guaranteed to return one of the instances, not the first instance.
 

Turning an Array into a String

convert it into a  formatted string.
Use join( ):
// make a comma delimited list
$string = join(',', $array);

Or loop yourself:
$string = '';

foreach ($array as $key => $value) {
    $string .= ",$value";
}

$string = substr($string, 1); // remove leading ","
 
 
If you can use join( ), do; it's faster than any PHP-based loop. However, join( ) isn't very flexible. First, it places a delimiter only between elements, not around them. To wrap elements inside HTML bold tags and separate them with commas, do this:
$left = '<b>'; $right = '</b>'; $html = $left . join("$right,$left", $html) . $right;
Second, join( ) doesn't allow you to discriminate against values. If you want to include a subset of entries, you need to loop yourself:
$string = ''; foreach ($fields as $key => $value) { // don't include password if ('password' != $key) { $string .= ",<b>$value</b>"; } } $string = substr($string, 1); // remove leading ","
 

Setting Environment Variables

Setting environment variables in your server configuration
on a host-by-host basis allows you to configure virtual hosts differently.

<?php
putenv('ORACLE_SID=ORACLE'); // configure oci extension
?>
 

Adjusting behavior based on an environment variable

 <?php
$version = $_SERVER['SITE_VERSION'];

// redirect to http://guest.example.com, 
//if user fails to sign in correctly
if ('members' == $version) {
    if (!authenticate_user($_POST['username'], $_POST['password'])) {
        header('Location: http://guest.example.com/');
        exit;
    }
}
include_once "${version}_header"; // load custom header

http://www.php.net/putenv; information on setting environment 
variables in Apache at 

Extracting Substrings

You want to extract part of a string, starting at a particular place in the string. For example, you want the first eight characters of a username entered into a form.

 Extracting a substring with substr( )

<?php
$substring = substr($string,$start,$length);
$username = substr($_GET['username'],0,8);
?>
 
If $start and $length are positive, substr( ) returns 
$length characters in the string, starting at $start.
 
If $start is bigger than the length of the string, substr( ) returns false..
 


Setting Default Values for Function Parameters

Assign the default value to the parameters inside the function prototype:

function wrap_html_tag($string, $tag = 'b') {
    return "<$tag>$string</$tag>";
}
 
 
The example in the Solution sets the default tag value to b, for bold. For example:
$string = 'I am some HTML'; wrap_html_tag($string);
returns:
<b>I am some HTML</b>
This example:
wrap_html_tag($string, 'i');
returns:
<i>I am some HTML</i>


There are two important things to remember when assigning default values. First, all parameters with default values must appear after parameters without defaults. Otherwise, PHP can't tell which parameters are omitted and should take the default value and which arguments are overriding the default. So wrap_html_tag( ) can't be defined as:
function wrap_html_tag($tag = 'i', $string)

If you do this and pass wrap_html_tag( ) only a single argument, PHP assigns the value to $tag and issues a warning complaining of a missing second argument.
Second, the assigned value must be a constant, such as a string or a number. It can't be a variable. Again, 
using wrap_html_tag( ), such as our example, you can't do this:
$my_favorite_html_tag = 'i'; function wrap_html_tag($string, $tag = $my_favorite_html_tag) { ... }
If you want to assign a default of nothing, one solution is to assign the empty string to your parameter:
function wrap_html_tag($string, $tag = '') { if (empty($tag)) return $string; return "<$tag>$string</$tag>"; }
This function returns the original string, if no value is passed in for the $tag. Or if a (nonempty) tag is passed in, it returns the string wrapped inside of tags.

Depending on circumstances, another option for the $tag default value is either 0 or NULL. In wrap_html_tag( ), you don't want to allow an empty-valued tag. However, in some cases, the empty string can be an acceptable option. For instance, join( ) is often called on the empty string, after calling file( ), to place a file into a string. Also, as the following code shows, you can use a default message if no argument is provided but an empty message if the empty string is passed:
function pc_log_db_error($message = NULL) { if (is_null($message)) { $message = 'Couldn't connect to DB'; } error_log("[DB] [$message]"); }
 

CuteNews right

Additional X-Field, ability to see the first posts while adding and editing,
 PHP-code error protection while news output, error logging at backend.

A notable feature of the CuteNews engine is that it doesn't use MySQL to store news,
comments, user profiles, or any other data.
The CuteNews engine can be installed on practically any web server.

CuteNews allows for different types of users with different permission levels: Administrator, Editor, Journalist, Commenter. Each of these types of users has access to different features on a
CuteNews-driven website.

You don't have to worry about creating news items: CuteNews does everything automatically. It is also capable of archiving old news items and activating postponed ones on its own.

Download Cute News 1.5.2 zip (570 Kb)

Staying Private on the Facebook

Facebook is a personal vault that can contain photos of your firstborn, plans to bring down your government and, occasionally, a record of your indiscretions.

Facebook insists it is up to you to decide how much you want others to see. And that is true, to some extent. But you cannot entirely opt out of Facebook searches. Facebook, however, does let you fine-tune who can see your “likes” and pictures, and, to a lesser extent, how much of yourself to expose to marketers.
The latest of its frequent changes to the site’s privacy settings was made in December. Facebook is nudging each of its billion subscribers to review them.

Apple took home 72% of all handset profits last quarter

  • Apple took home 72% of the profits with only 21.7% of unit sales (up from 15.4% in Q3).
  • Samsung's 29% of the profits came from 28.9% of unit sales (down from 32.3% in Q3).
  • 43 cents of every dollar spent in the world on a cellphone in Q4 ended up in Apple's coffers.
  • Samsung got 36 cents. Nokia got 7 cents. All the rest got less than 5.
  • For 2013, Walkley predicts that Apple and Samsung will split 103% of the profits, 69/34.

4G may lead to bigger smartphone bills

Thinking about upgrading to a 4G phone? Prepare to pay more. Before you know it, those 2-gigabyte data caps your carrier put in place just aren't going to cut it.

The average American will use 6.2 GB of data on their mobile devices each month in 2017, according to the latest annual Visual Networking Index released by Cisco (CSCO, Fortune 500). To put that into context, Americans used just 752 MB Americans on average last year.

If data plans stay the same five years down the road, the average user's smartphone bill could grow by $40 a month.
The wide-spread roll-out of 4G, the lightning-fast wireless networks that all four of the major carriers are in the process of deploying across the country, is expected to be the main culprit. 4G is capable of speeds comparable to your home broadband service, and it's roughly 10 times faster than 3G. By 2017, Cisco predicts that the average smartphone connection speed will grow more than three-fold.

JavaScript Interview Questions

JavaScript Interview Questions




What is the difference between == and === ?
The == checks for value equality, but === checks for both type and value.

difference between innerHTML and append() in JavaScript?
InnerHTML is not standard, and its a String. The DOM is not, and although innerHTML is faster and less verbose, its better to use the DOM methods like appendChild(), firstChild.nodeValue, etc to alter innerHTML content.

break and continue statements?
Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop. 



Javascript closures?
A closure takes place when a function creates an environment that binds local variables to it in such a way that they are kept alive after the function has returned. A closure is a special kind of object that combines two things: a function, and any local variables that were in-scope at the time that the closure was created.

What is Strict Mode in JavaScript?
Strict Mode has been introduced as part of ECMAScript 5 and introduces new, restricted variant of JavaScript which has following aims:
  • Throws errors for actions that are rather silly but previously didn’t throw an error
  • Throws errors for potentially unsafe actions
  • Disables functions that are poorly thought out
  • Potentially code in strict mode could run faster by eliminating mistakes that would make it difficult for JavaScript engines to perform optimizations
Is javascript case sensitive?
Yes javascript is case sensitive.
Examples are isNaN , Number, new Array().

How to set the cursor to wait ?
document.body.style.cursor = 'wait';
//do something interesting and time consuming
document.body.style.cursor = 'auto';  



What's Prototypes for JavaScript?  
Objects have "prototypes" from which they may inherit fields and functions. 

 a checkbox using Javascript?  
var checked = window.document.getElementById("thmyCheckBox").checked;
What does "5"+2+4 evaluate to?  
Since 5 is a string, everything is a string, so the result is 524.  
How to create arrays in JavaScript? 
 declare an array like this
var scripts = new Array();
We can add elements to this array like this

scripts[0] = "A";
scripts[1] = "B";
scripts[2] = "C";
scripts[3] = "D"; 
 


isNaN function?
Return true if the argument is not a number.  


GET and POST in HTML forms?
GETmethod: Parameters are passed in the querystring. Maximum amount of data that can be sent via the GET method is limited to about 2kb.
POST
method: Parameters are passed in the request body. There is no limit to the amount of data that can be transferred using POST. However, there are limits on the maximum amount of data that can be transferred in one name/value pair.
 


Differentiate between “var a=5” and “a =5” ?
difference is between the two is that one variable is local and the other is global.


How to get value from a textbox?

document.getElementById('txtbox1').value;

What are global variables?

Global variables are available throughout your code: That is, the variables have no scope. Local variables scope, on the other hand, is restricted to where it is declared (like within a function). The var keyword is used to declare a local variable or object, while omitting the var keyword creates a global variable.

// Declare a local variable
var localVariable = "testtest";
// Declare a global
globalVariable = "Cghdg";

What are JavaScript types?

• Number
• String
• Boolean
• Function
• Object
• Null
• Undefined

What is this keyword?

It refers to the current object.


how html Elements using javascript? 
the getElementById method is preferred.
document.getElementById("test").style.color = "green";

 


 

 


Prototypes

Every Java-
Script object has a second JavaScript object (or null, but this
is rare) associated with it. This second object is known as a
prototype, and the first object inherits properties from the
prototype.
All objects created by object literals have the same prototype
object, and we can refer to this prototype object in JavaScript
code as Object.prototype. Objects created using the new keyword
and a constructor invocation use the value of the proto
type property of the constructor function as their prototype.
So the object created by new Object() inherits from Object.pro
totype just as the object created by {} does. Similarly, the object
created by new Array() uses Array.prototype as its prototype,
and the object created by new Date() uses Date.prototype as its
prototype.
Object.prototype is one of the rare objects that has no prototype:
it does not inherit any properties. Other prototype objects
are normal objects that do have a prototype. All of the built-in
constructors (and most user-defined constructors) have a prototype
that inherits from Object.prototype.

Object.create() is a static function, not a method invoked on
individual objects. To use it, simply pass the desired prototype
object:
// o1 inherits properties x and y.
var o1 = Object.create({x:1, y:2});

JavaScript Timers

setTimeout() and setInterval() allow you to register a function
to be invoked once or repeatedly after a specified amount
of time has elapsed. These are important global functions of
client-side JavaScript, and are therefore defined as methods of
Window, but they are general-purpose functions and don’t
really have anything to do with the window.
The setTimeout() method of the Window object schedules a
function to run after a specified number of milliseconds elapses.
setTimeout() returns a value that can be passed to clear
Timeout() to cancel the execution of the scheduled function.


Retrieving the Response

A complete HTTP response consists of a status code, a set of
response headers, and a response body. These are available
through properties and methods of the XMLHttpRequest
object:
• The status and statusText properties return the HTTP
status in numeric and textual forms. These properties hold
standard HTTP values like 200 and “OK” for successful
requests, and 404 and “Not Found” for URLs that don’t
match any resource on the server.
• The response headers can be queried with getResponse
Header() and getAllResponseHeaders().
• The response body is available in textual form from the
responseText property.
The XMLHttpRequest object is used asynchronously: the
send() method returns immediately after sending the request,
and the response methods and properties listed above aren’t
valid until the response is received.

WebSocket() constructor

socket with the WebSocket() constructor:
var s = new WebSocket("ws://ws.example.com/resource");
The argument to the WebSocket() constructor is a URL that uses
the ws:// protocol (or wss:// for a secure connection like that
used by https://). The URL specifies the host to connect to,
and may also specify a port (WebSockets use the same default
ports as HTTP and HTTPS) and a path or resource.
Once you have created a socket, you generally register event
handlers on it:
s.onopen = function(e) { /* The socket is open. */ };
s.onclose = function(e) { /* The socket closed. */ };
s.onerror = function(e) { /* Something went wrong! */ };
s.onmessage = function(e) {
var m = e.data; /* The server sent a message. */
};
In order to send data to the server over the socket, you call the
send() method of the socket:
s.send("Hello, server!");
When your code is done communicating with the server, you
can close a WebSocket by calling its close() method.
WebSocket communication is completely bidirectional. Once
a WebSocket connection has been established, the client and
server can send messages to each other at any time, and that
communication does not have to take the form of requests and
responses.

3 Top Internet Marketing Tips

One Traffic Source
Submit your Blog to Content Aggregators like AllTop.com and 9Rules.
If you have a top-notch blog that regularly publishes valuable content (which you should), then you can submit your blog to sites like Alltop.com and 9Rules.com. These are content aggregators that aggregates the best content from around the web.


Write Tutorials! Tutorials are a HUGE untapped traffic source online. If you have a
website related to graphic design, wordpress, web development, SEO,
marketing, or programming, then you can use tutorials to send thousands of visitors to your website.  There are hundreds of websites online that you can submit your tutorials to.

SEO your Site 
  • Format — text or image? image map? javascript? drop-downs? Text is best.
  • Page URLs — look at URL structure, path names, file names. How long are URLs? How far away from the root are they? Are they separated by dashes or underscores?
  • Are keywords used appropriately in text links or image alt tags?

Reading DOC file in php

  read PDF and DOC files using PHP

Reading PDF Files

 
$content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -');
 
 

Reading DOC Files

 $content = shell_exec('/usr/local/bin/antiword '.$filename);


concat() Method

The concat() method returns the array resulting from appending its arguments to
 the array on which it was invoked. Given the script:

Blog Flipping?

Practicing selling blog to other after attaining traffic and popularity 
is known as Blog Flipping.

List some SEO techniques you follow when a new site is given?

Check with on page factors such as Meta tags, Title, Keywords and Meta description in content.
• Site is submitted to major search engines
• Bookmarking site pages
• Directory submission
• Press release which announces your site launch
• Blog commenting
• Submitting articles to concentrate article readers
• Web 2.0 page creation
Classifieds to target local users

Black Hat SEO?

several websites to get high ranking is brought numerous
methods and techniques to achieve goal.

Interview Questions-Networking



·         What is an IP address?
·         What is a subnet mask?
·         What is ARP?
·         What is ARP Cache Poisoning?
·         What is the ANDing process?
·         What is a default gateway? What happens if I don't have one?
·         Can a workstation computer be configured to browse the Internet and yet NOT have a default gateway?
·         What is a subnet?
·         What is APIPA?
·         What is an RFC? Name a few if possible (not necessarily the numbers, just the ideas behind them)
·         What is RFC 1918?
·         What is CIDR?
·         You have the following Network ID: 192.115.103.64/27. What is the IP range for your network?
·         You have the following Network ID: 131.112.0.0. You need at least 500 hosts per network. How many networks can you create? What subnet mask will you use?
·         You need to view at network traffic. What will you use? Name a few tools
·         How do I know the path that a packet takes to the destination?
·         What does the ping 192.168.0.1 -l 1000 -n 100 command do?
·         What is DHCP? What are the benefits and drawbacks of using it?
·         Describe the steps taken by the client and DHCP server in order to obtain an IP address.
·         What is the DHCPNACK and when do I get one? Name 2 scenarios.
·         What ports are used by DHCP and the DHCP clients?
·         Describe the process of installing a DHCP server in an AD infrastructure.
·         What is DHCPINFORM?
·         Describe the integration between DHCP and DNS.
·         What options in DHCP do you regularly use for an MS network?
·         What are User Classes and Vendor Classes in DHCP?
·         How do I configure a client machine to use a specific User Class?
·         What is the BOOTP protocol used for, where might you find it in Windows network infrastructure?
·         DNS zones – describe the differences between the 4 types.
·         DNS record types – describe the most important ones.
·         Describe the process of working with an external domain name
·         Describe the importance of DNS to AD.
·         Describe a few methods of finding an MX record for a remote domain on the Internet.
·         What does "Disable Recursion" in DNS mean?
·         What could cause the Forwarders and Root Hints to be grayed out?
·         What is a "Single Label domain name" and what sort of issues can it cause?
·         What is the "in-addr.arpa" zone used for?
·         What are the requirements from DNS to support AD?
·         How do you manually create SRV records in DNS?
·         Name 3 benefits of using AD-integrated zones.
·         What are the benefits of using Windows 2003 DNS when using AD-integrated         
        zones?
·         You installed a new AD domain and the new (and first) DC has not registered its
SRV records in DNS. Name a few possible causes.
·         What are the benefits and scenarios of using Stub zones?
·         What are the benefits and scenarios of using Conditional Forwarding?
What are the differences between Windows Clustering, Network Load Balancing  and Round Robin, and scenarios for each use?
·         How do I work with the Host name cache on a client computer?
·         How do I clear the DNS cache on the DNS server?
·         What is the 224.0.1.24 address used for?
·         What is WINS and when do we use it?
Can you have a Microsoft-based network without any WINS server on it? What are the "considerations" regarding not using WINS?
·         Describe the differences between WINS push and pull replications.
What is the difference between tombstoning a WINS record and simply deleting  it?
Name the NetBIOS names you might expect from a Windows 2003 DC that is   registered in WINS.
·         Describe the role of the routing table on a host and on a router.
·         What are routing protocols? Why do we need them? Name a few.
·         What are router interfaces? What types can they be?
·         In Windows 2003 routing, what are the interface filters?
·         What is NAT?
·         What is the real difference between NAT and PAT?
·         How do you configure NAT on Windows 2003?
·         How do you allow inbound traffic for specific hosts on Windows 2003 NAT?
·         What is VPN? What types of VPN does Windows 2000 and beyond work with natively?
·         What is IAS? In what scenarios do we use it?
·         What's the difference between Mixed mode and Native mode in AD when dealing with RRAS?
·         What is the "RAS and IAS" group in AD?
·         What are Conditions and Profile in RRAS Policies?
·         What types or authentication can a Windows 2003 based RRAS work with?
·         How does SSL work?
·         How does IPSec work?
·         How do I deploy IPSec for a large number of computers?
·         What types of authentication can IPSec use?
·         What is PFS (Perfect Forward Secrecy) in IPSec?
·         How do I monitor IPSec?
·         Looking at IPSec-encrypted traffic with a sniffer. What packet types do I see?
·         What can you do with NETSH?
·         How do I look at the open ports on my machine?