PHP Interview Questions with Answers-part1

   What is PHP?

    PHP is a server side scripting language  used for web development applications.
    Php is the powerful tool for making dynamic website.
    Many open source, free and commercial scripts    and   Stuff made by php

 What is a data type?

A Data type is the classification of data into a category according to its attributes;
• Alphanumericcharacters are classified as strings
• Whole numbersare classified integers
• Numberswith decimal pointsare classified as floating points.
• True or falsevalues are classified as Boolean.
PHP is a loosely typed language;it does not have explicit defined data types.


What is a variable?

A variable is a name given to a memory location that stores data at runtime.
 The scope of a variable determines its visibility.
A global variable is accessible to all the scripts in an
application. A local variable is only accessible to the script
that it was defined in.

How to retrieve a secure URL?
To retrieve secure URLs, the cURL extension needs access to an SSL library, such as OpenSSL.
<?php
$c = curl_init('https://secure.example.com/accountbalance.php');
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
 $page = curl_exec($c); curl_close($c);
?>



Why you should use variables?

Variables help separate data from the program algorithms. The same algorithm can be used
for different input data values. For example, suppose that you are developing a calculator
program that adds up two numbers, you can create two variables that accept the numbers
then you use the variables names in the expression that does the addition.


  How to show all PHP runtime errors?
 
   Add error_reporting function set  1 .

  What is htaccess?

   .htaccess files are configuration files of Apache Server which provide
   a way to make configuration changes on a per-directory basis.

How to redirect a user to a page?

header('Location: http://www.example.com/');
The redirect URL must include the protocol and hostname.




   What is  echo in php?

    It is a keyword.
    It is used to print  data on the webpage, like that <?php echo 'test'; ?> ,
  
    How to include a file to a php page?

    Add include a file using include() or require() function with the path.


    What's the difference between include and require?

    PHP provides two constructs to load code and HTML from another module: require and include.
    They both load a file as the PHP script runs, work in conditionals and loops, and complain if
    the file being loaded can't be found. The main difference is that attempting to require a
   nonexistent file is a fatal error, while attempting to include such a file produces a warning
    but does not stop script execution.

    If the file is not found by require(), it will gives a fatal error and stop the execution of the script.
    If the file is not found by include(), it  will gives a warning , but execution will continue.

    will not get the "function re-declared" error.
   
    Differences between GET and POST methods ?
    A GET request encodes the form parameters in the URL, in what is called a query string:

    /path/to/chunkify.php?word=despicable&length=3
    A POST request passes the form parameters in the body of the HTTP request, leaving the URL untouched.
    POST requests are not idempotent. This means that they cannot be cached,
    and the server is recontacted every time the page is displayed.

    How to declare an array php?

    Example : var $arr = array('ie', 'firefox', 'safari');

    What is the use of 'print' in php?

    This is not actually a real function, It is a language construct.
    So you can use with out parentheses with its argument list.
   


    What is  in_array() function?

    The in_array( ) function returns true or false, depending on whether the first
     argument is an element in the array given as the second argument.
    in_array used to checks if a value exists in an array that Searching for Values of array.
   
    What is count() function in php ?

    The count( ) and sizeof( ) functions are identical in use and effect.
    They return the number of elements in the array.


    What’s the difference between include and require?

    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.


    What is the difference between Session and Cookie?

    sessions are stored on the server, and cookies are stored on the client’s computers in the text file format.
    A cookie is a bit of information that the server can give to a client.
    Every session has a data store associated with it. You can register variables to be loaded
    from the data store when each page starts and saved back to the data store when the page ends.
   

   How to set cookies in PHP?

    Setcookie("test", "sem", time()+3600);
   

    How to Retrieve a Cookie Value?
     echo $_COOKIE["test"];
   

    How to create a session? 

    Create session by  session_start();

   How to set a value in session ?

    Set value into session by  $_SESSION['test_ID']=1987654;

   How to Remove data from a session?

   Remove data from  session -> session_unset($_SESSION['test_ID'];



    How to create a mysql connection?
    call mysql_connect(servername,username,password);


    How to select a database?

    call mysql_select_db($db_name);

    How to execute an sql query? How to fetch its result ?
    $my_qry = mysql_query("SELECT * FROM `test` WHERE `test_id`='16'; ");
    $result = mysql_fetch_array($my_qry);
    echo $result['First_test_name'];


    How to get the resultset of MySQL using PHP?
        1. mysql_fetch_row
        2. mysql_fetch_array
        3. mysql_fetch_object
        4. mysql_fetch_assoc
   
       
   
    How to strip whitespace or other characters from the beginning and end of a string ?

    The trim() function removes whitespaces or other predefined characters from both sides of a string.
   
    What is the use of header() function in php ?

    The header() function sends a raw HTTP header to a client browser.
    Remember that this function must be called before sending the actual out put.
    For example, You do not print any HTML element before using this function.
   
    How to redirect a page in php?

    The following code can be add for it, header("Location:test.php");
   
    How stop the execution of a php scrip ?

    exit() function  stop the execution of a page.
   
   
    How to get the length of a string?

    strlen() function  gives  the length of a string


    How to generate random numbers in php?

    Add rand function  to generate random numbers.

    How  to varify a variable in php?

    This is_set  function is used to determine if a variable is set and is not .   

      
    What is mean by an associative array?

    Associative arrays are arrays that indexed by string keys is called associative arrays.


   
   
    How do you define a constant?

    Using define() directive, like  that define ("MYCONSTANT",765754);
   
   
    How send email using php?

    To send email using PHP, you use the mail() function.This mail() function accepts 5 parameters

    How to find current date and time?

    The date() function gives  the current date and time .
  
       
    What is the use of ksort in php?

    Its  sort an array by key in reverse order.
  
  Who is the father of PHP ?

  Rasmus Lerdorf is known as the father of PHP.     
       
    How to delete a file from the system?

    Unlink() deletes the  file from the file system.
   
    How to get the value of current session id?

    session_id() function gives the session id for the current session.


What is the difference between $name and $$name?

$name is variable where as $$name is reference variable
like $name=sonia and $$name=singh so $sonia value is singh.

  mysql_fetch_object vs  mysql_fetch_array?

mysql_fetch_object() is similar tomysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets numbers are illegal property names

In PHP for pdf which library used?. 

The PDF functions in PHP can create PDF files using the PDFlib library With version 6, PDFlib offers an object-oriented API for PHP 5 in addition to the function-oriented API for PHP 4. There is also the » Panda module. FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs. FPDF requires no extension (except zlib to activate compression and GD for GIF support) and works with PHP4 and PHP5.
 
How  to Connecting two Strings? 
a useful concept—concatenation. It refers to the process of linking
items together. Specifically in programming, you concatenate strings.
The period . is the operator for performing this action, and it's used like so:

$tString = $String1 . $bString2;

echo $tString;





Why we use strstr?
strstr returns all of string after the first occurrence of substring .
If substring doesn't exist in string , the function returns FALSE.

How to  capitalize only the first character of a string?
you use ucfirst:
$txt = "welcome to the this site";
echo $ucfirst($txt);
 
What three components need to create a dynamic web page? 
A web server, a server-side programming language, and a database.

What does Apache use to load extensions?

Modules.

What does the PHP Interpreter do?
 It processes the HTML and PHP files.

What's a more secure function than md5() for encoding passwords? 
The sh1() function creates a 160-bit key instead of md5()'s 128-bit string. 
It also uses a superior algorithm for making it difficult to determine the 
values that generate a particular encoding.

What are the advantages of using PEAR?
 The PEAR functions are more compact, and they automate some of the manual
 work of connecting to and selecting from the database. Because PEAR code
 is used by many developers, it is less likely to have an error than to have code
 that's written from scratch.

Learn Php Code
 
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

Configuring IPv6 Networks

At the beginning, IANA gave requestors an entire class A network space thereby granting requestors 16.7 million addressesmany more than necessary. Realizing their error, they began to assign class B networksagain, providing far too many addresses for the average requestor. As the Internet grew, it quickly became clear that allocating class A and class B networks to every requestor did not make sense. Even their later action of assigning class C banks of addresses still squandered address space, as most companies didn't require 254 IP addresses. Since IANA could not revoke currently allocated address space, it became necessary to deal with the remaining space in a way that made sense. One of these ways was through the use of Classless Inter-Domain Routing CIDR

IPv4 space is becoming scarcer by the day. By 2005, some estimates place the number of worldwide Internet users at over one billion. Given the fact that many of those users will have a cellular phone, a home computer, and possibly a computer at work, the available IP address space becomes critically tight. China has recently requested IP addresses for each of their students, for a total of nearly 300 million addresses. Requests such as these, which cannot be filled, demonstrate this shortage. When IANA initially began allotting address space, the Internet was a small and little- known research network. There was very little demand for addresses and class A address space was freely allocated. However, as the size and importance of the Internet started to grow, the number of available addresses diminished, making obtaining a new IP difficult and much more expensive. NAT and CIDR are two separate responses to this scarcity. NAT is an individual solution allowing one site to funnel its users through a single IP address. CIDR allows for a more efficient division of network address block. Both solutions, however, have limitations.

CIDR allows network blocks to be allocated outside of the well-defined class A/B/C ranges. In an effort to get more mileage from existing class C network blocks, CIDR allows administrators to divide their address space into smaller units, which can then be allocated as individual networks. This made it easier to give IPs to more people because space could be allocated by need, rather than by predefined size-of-space. For example, a provider with a class C subnet could choose to divide this network into 32 individual networks, and would use the network addresses and subnet masks to delineate the boundaries. A sample CIDR notation looks like this:
10.10.0.64/29

In this example, the /29 denotes the subnet mask, which means that the first 29 bits of the address are the subnet. It could also be noted as 255.255.255.248, which gives this network a total of six usable addresses.
While CIDR does deal with the problem in a quick and easy way, it doesn't actually create more IP addresses, and it does have some additional disadvantages. First, its efficiency is compromised since each allocated network requires a broadcast IP and a network address IP. So if a provider breaks a class C block into 32 separate networks, a total of 64 individual IPs are wasted on network and broadcast IPs. Second, complicated CIDR networks are more prone to configuration errors. A router with an improper subnet mask can cause an outage for small networks it serves.
.

what is IMAP

IMAP, fully documented in RFC 3501, was designed to provide a robust, mobile mail delivery and access mechanism. For more detail on the protocol and how it functions on the network layer, or for additional information on the numerous specification options, please consult the RFC documentation.


POP and IMAP tend to be grouped together or compared, which is a bit unfair since they are dissimilar in many ways. POP was created as a simple mail delivery vehicle, which it does very well. Users connect to the server and obtain their messages, which are then, ideally, deleted from the server. IMAP takes an entirely different approach. It acts as the keeper of the messages and provides a framework in which the users can efficiently manipulate the stored messages. While administrators and users can configure POP to store the messages on the server, it can quickly become inefficient since a POP client will download all old messages each time the mail is queried. This can get messy quickly, if the user is receiving any quantity of email. For users who do not need any kind of portability, or receive little email, POP is probably an acceptable choice, but those seeking greater functionality will want to use IMAP.


Once you've decided that IMAP is for you, there are two primary options. The two main flavors are Cyrus IMAP and the University of Washington IMAP server. Both follow the RFC specification for IMAP and have their advantages and disadvantages. They also use different mailbox formats and therefore cannot be mixed. One key difference between the two is found in Cyrus IMAP. It does not use /etc/passwd for its mail account database, so the administrator does not have to specially add mail users to the system password file. This is more secure option for system administrators, because creating accounts on systems can be construed as a security risk. However, the ease of configuration and installation of UW IMAP often makes it more appealing. In this chapter, we'll primarily focus on the two most common IMAP servers: UW IMAP, because of its popularity and ease of installation, and Cyrus IMAP, because of its additional security features.

 
Once the server software has been downloaded and decompressed, it can be installed. However, because of UW-IMAP's large portability database, it does not support GNU automake, meaning that there isn't a configure script. Instead, a Makefile that relies on user-specified parameters is used. There are many supported operating systems, including a number of Linux distributions. Here's a list of a few of the supported Linuxes distributions:

# ldb   Debian Linux
# lnx   Linux with traditional passwords and crypt( ) in the C library
#        (see lnp, sl4, sl5, and slx)
# lnp   Linux with Pluggable Authentication Modules (PAM)
# lrh   RedHat Linux 7.2
# lsu   SuSE Linux
# sl4   Linux using -lshadow to get the crypt( ) function
# sl5   Linux with shadow passwords, no extra libraries
# slx   Linux using -lcrypt to get the crypt( ) function

The lrh version will probably work on newer Red Hat versions as well. If your distribution isn't listed, try one of the matching generic options. lnp is a good guess for most modern versions of Linux.


To begin the installation of the Cyrus server, download and decompress the latest version. You will need to download both the IMAP and SASL packages.
SASL is the authentication mechanism used by Cyrus IMAP, and will need to be configured and installed first. It is easily built using the standard "configure-make" order.
vlager# cd cyrus-sasl-2.1.15 
vlager# ./configure 
loading cache ./config.cache
checking host system type... i686-pc-linux-gnu
.
creating saslauthd.h
Configuration Complete. Type 'make' to build.
vlager# make 
make  all-recursive
make[1]: Entering directory `/tmp/cyrus-sasl-2.1.15'

Assuming the compile is completed without failure and you've successfully executed the make install, you can now proceed to configuring and installing the Cyrus IMAP server itself.

Translate Any Page with Yahoo

Because the Web is a global space, we've all come across pages in different languages,
 especially among search results. If you're searching for information about a phrase like
 hamburger recipe, it's strange to come across a page about it in German. It's stranger
 still to find a mention of your name on a page in a foreign language.

Yahoo!'s Language Tools page http://tools.search.yahoo.com/language has some ways to help
 you work with other languages. Among them is a translation service that will translate any
 block of text to a different language.


If you find yourself translating pages frequently, there are some ways to speed up
 the process. You can translate an entire web page by copying and pasting the URL
into the field labeled "Translate this web page" on the Yahoo! Language Tools page,
 choosing the language from the drop-down menu, and clicking Translate. Yahoo! will
 display the page with all of the text translated.


From any web page, you can click the Translate button and Yahoo! will display a version
 in English. Yahoo! will also automatically detect the source language, so you don't need
 to choose a language from a menu. This is also handy if you can't tell what language the
 page is in. If you just want to translate a block of text instead of the entire page,
you can click the arrow next to the fish and choose Language and Translation Tools from
 the menu; you'll go to the Yahoo! Language Tools page, where you can paste the text you
 want to translate into the translation form.


    http://tools.search.yahoo.com/language/translation/translatedPage.


In addition to the simple search form you'll find at http://search.yahoo.com, Yahoo!
 offers an Advanced Web Search form at http://search.yahoo.com/web/advanced.

This form lets you refine your search in a number of ways, so you can narrow
the results to a more useful list.

Chitrangada Singh - the eye






How to gets sms backup

 your Android device there are  SMS Backup option.
 set SMS Backup With Your Gmail
Log into your Gmail account. The first thing make   SMS Backup folder uploads them and
labels them, then shoves them in that label folder.


 SMS Pro is the feature-filled alternative messaging Android app,
make  a store for Cloud Messageing.

Advanced PHP

PHP's strength lies in its huge library of built-in functions, which allows even a novice user
 to perform very complicated tasks without having to install new libraries or worry about
low-level details, as is often the case with other popular server-side languages like Perl.
 Because of the focus of this book, we've constrained ourselves to exploring only those functions
 that were directly related to MySQL databases (in fact, we didn't even see all of those).
In this final instalment, we'll broaden our horizons a little and explore some of the other
 useful features PHP has to offer someone building a database driven Website.

We'll begin by learning about PHP's include function, which allows us to use a single
piece of PHP code in multiple pages, and makes the use of common code fragments much more
 practical. We'll also see how to add an extra level of security to our site with this feature.

PHP, while generally quick and efficient, nevertheless adds to the load time and the
 workload of the machine on which the server is run. On high-traffic sites , this load can
grow to unacceptable levels. But this challenge doesn't mean we have to abandon the
database-driven nature of our site. We'll see how to use PHP behind the scenes to
create semi-dynamic pages that don't stress the server as much.

In essence, SSIs allow you to insert the content of one file stored on your Web
 server into the middle of another. The most common use for this technology is
 to encapsulate common design elements of a Website in small HTML files that
can then be incorporated into Web pages on the fly. Any changes to these small
files immediately affect all files that include them. And, just like a PHP script,
 the Web browser doesn't need to know about any of it, since the Web server
 does all the work before it sends the requested page to the browser.

PHP has a function that provides similar capabilities. But in addition to
being able to incorporate regular HTML and other static elements into your
 included files, you can also include common script elements.
 example:

<!-- include.php -->
<?php
  echo( '<p>"Make me one with everything!"</p>\n' );
?>
The above file, include.php, contains some simple PHP code- also need the following file:

<!-- testinclude.php -->
<html>
<head>
<title> Test of PHP Includes </title>
</head>
<body>
<p>What did the Buddhist monk say to the hot dog vendor?</p>
<?php
  include('include-me.php');
?>
</body>
</html>


Notice the call to the include function. We specify the name of the file we want to include include.php,
and PHP will attempt to grab the named file and stick it into the file to replace the call to include.



Finally, an extremely powerful feature of PHP is the ability to send email messages
 with dynamically generated content. Whether you want to use PHP to let visitors
send email versions of your site's content to their friends, or just provide a
way for users to retrieve their forgotten passwords, PHP's email function will
serve nicely.

PHP Interview questions-with-answers


To guard against this kind of security breach, you should put any security-sensitive
 code into an include file, and place that file into a directory that's not part of
your Web server's directory structure. If you add that directory to your PHP
include_path setting in php.ini, you can refer to the files directly with the PHP
include function, but have them tucked away safely somewhere where your Web server
 can't display them as Web pages.

Samsung galaxy s4

Samsung galaxy s4 gt-i9500 user manual global unlocked one stop shop for cell phone parts, ideal parts for repairing and refurbished phone making, wholesale and retail available worldwide. Samsung i9505 galaxy s4 vs samsung i9500 galaxy s4 - phone compare samsung galaxy s4 full specifications side by side see the common features and the differences that make them better or worse. How to root your samsung galaxy s4 gt-i9500 samsung gs4 ready to start rooting your samsung galaxy s4 for those of you with the gt-i9500 model gs4, this quick video will walk you through the entire rooting process using.

samsung galaxy note-3

Samsung galaxy note 3 vs samsung galaxy s4 specs battle samsung has released the successor to its giant note 2 the note 3 is yet another phablet with massive dimensions and great functionality on paper - but is. Spigen samsung galaxy note 3 case protective neo hybrid samsung announced the galaxy note 3 on september 4 and since the south korean company already has a high-end smartphone on the market, we though we should. Samsung galaxy note 3 a specifications review hey my name is marques brownlee and i m a pretty heavy galaxy note 3 user some of you may already know me from the mkbhd youtube channel to others, i m a new face. 

Spigen samsung galaxy note 3 case protective neo hybrid shop for samsung galaxy note 3 protector cases samsung galaxy note 3 protector cases are snap-on covers for your cell phone free shipping on samsung galaxy note 3. Review: samsung galaxy note 3 - neowin - where unprofessional shop for samsung galaxy note 3 protector cases samsung galaxy note 3 protector cases are snap-on covers for your cell phone free shipping on samsung galaxy note 3. Samsung updates compare samsung galaxy note 3 price with other models check out the latest original, rrp or ap price for samsung galaxy note 3. Samsung galaxy note 3 and galaxy gear launch today in over 140 remember if the flashing process is interrupted your phone might be very difficult to revive firmwares provided by samsung-updates.com are not. 

Samsung galaxy note 3 review, price in india, specifications compare samsung galaxy note 3 price with other models check out the latest original, rrp or ap price for samsung galaxy note 3. Samsung galaxy note 3 accessories . Samsung galaxy note 3 vs samsung galaxy s4 specs battle shop for samsung galaxy note 3 protector cases samsung galaxy note 3 protector cases are snap-on covers for your cell phone free shipping on samsung galaxy note 3. Top 10 samsung galaxy note 3 features video compare samsung galaxy note 3 price with other models check out the latest original, rrp or ap price for samsung galaxy note 3. Galaxy note 3 neo today is the big day the samsung galaxy note 3 and galaxy gear should be available in most corners of the globe however, this is just the initial rollout.

Php global variables





Php global variables

variables are automagically available in all contexts in function and global scopes. They are named respectively: $ POST, $ GET, $ COOKIE, $ ENV and $ SERVER.

 Additionally, a new array called $ REQUEST was added, which contains all $ GET, $ POST and $ COOKIE variables. Variables defined outside of a function are called global variables.

They exist in one scope. Variables defined inside of a function are called local variables. The tips to access a global variable inside a function is to use the global keyword. This tells the PHP interpreter that further use of the named variable inside a function should refer to the global variable with the given name, not a local variable. Print the entire $GLOBALS array using PHP's functions for processing associative
arrays:


 <?php
reset($GLOBALS);
while (list($key, $var) = each($GLOBALS)) {
    print "$key => $var\ n<br>\ n";
}
?>




 PHP's list() and each() functions to iteratively process the $GLOBALS array. It then prints the keys names of the variables stored in the $GLOBALS array and their corresponding values. To access a variable that is not declared within the current function, you must do one of two things: either access it through the $GLOBALS array or declare the variable as the global variable.
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

Table Types-MySQL

MyISAM is the default table type in MySQL Version 3.23. It's based on the ISAM code and
has a lot of useful extensions.

The index is stored in a le with the .MYI (MYIndex) extension, and the data is stored
in a le with the .MYD (MYData) extension. You can check/repair MyISAM tables with the
myisamchk utility.

The following is new in MyISAM:
 If mysqld is started with --myisam-recover, MyISAM tables will automaticly be repaired on open if the table wasn't closed properly.

 You can INSERT new rows in a table without deleted rows, while other threads are
reading from the table.

 Support for big les 63-bit on lesystems/operating systems that support big les.
 All data is stored with the low byte rst. This makes the data machine and OS
independent. The only requirement is that the machine uses two's-complement signed
integers (as every machine for the last 20 years has) and IEEE

oating-point format
also totally dominant among mainstream machines. The only area of machines that
may not support binary compatibility are embedded systems because they sometimes
have peculiar processors.
There is no big speed penalty in storing data low byte rst; The bytes in a table row
is normally unaligned and it doesn't take that much more power to read an unaligned
byte in order than in reverse order. The actual fetch-column-value code is also not
time critical compared to other code.

 All number keys are stored with high byte rst to give better index compression.
 Internal handling of one AUTO_INCREMENT column. MyISAM will automatically update
this on INSERT/UPDATE. The AUTO_INCREMENT value can be reset with myisamchk.
This will make AUTO_INCREMENT columns faster (at least 10 %) and old numbers will
not be reused as with the old ISAM. Note that when an AUTO_INCREMENT is de ned on
the end of a multi-part-key the old behavior is still present.
 When inserted in sorted order (as when you are using an AUTO_INCREMENT column) the
key tree will be split so that the high node only contains one key. This will improve
the space utilization in the key tree.
 BLOB and TEXT columns can be indexed.
 NULL values are allowed in indexed columns. This takes 0-1 bytes/key.
 Maximum key length is now 500 bytes by default. In cases of keys longer than 250
bytes, a bigger key block size than the default of 1024 bytes is used for this key.
 Maximum number of keys/table enlarged to 32 as default. This can be enlarged to 64
without having to recompile myisamchk.

 There is a ag in the MyISAM le that indicates whether or not the table was closed
correctly. This will soon be used for automatic repair in the MySQL server.
 myisamchk will mark tables as checked if one runs it with --update-state. myisamchk
--fast will only check those tables that don't have this mark.

 myisamchk -a stores statistics for key parts (and not only for whole keys as in ISAM).
 Dynamic size rows will now be much less fragmented when mixing deletes with updates
and inserts. This is done by automatically combining adjacent deleted blocks and by
extending blocks if the next block is deleted.

 myisampack can pack BLOB and VARCHAR columns.

Running MySQL on Windows

MySQL supports TCP/IP on all Windows platforms and named pipes on NT. The default
is to use named pipes for local connections on NT and TCP/IP for all other cases if the
client has TCP/IP installed. The host name speci es which protocol is used:
Host name Protocol
NULL (none) On NT, try named pipes rst; if that doesn't work, use
TCP/IP. On Win95/Win98, TCP/IP is used.
. Named pipes
localhost TCP/IP to current host
hostname TCP/IP
You can force a MySQL client to use named pipes by specifying the --pipe option or by
specifying . as the host name. Use the --socket option to specify the name of the pipe.

You can test whether or not MySQL is working by executing the following commands:

C:\mysql\bin\mysqlshow
C:\mysql\bin\mysqlshow -u root mysql
C:\mysql\bin\mysqladmin version status proc
C:\mysql\bin\mysql test
If mysqld is slow to answer to connections on Win95/Win98, there is probably a problem with your DNS. In this case, start mysqld with --skip-name-resolve and use only
localhost and IP numbers in the MySQL grant tables. You can also avoid DNS when
connecting to a mysqld-nt MySQL server running on NT by using the --pipe argument
to specify use of named pipes. This works for most MySQL clients.
There are two versions of the MySQL command-line tool:
mysql Compiled on native Windows, which o ers very limited text editing capabilities.
mysqlc Compiled with the Cygnus GNU compiler and libraries, which
o ers readline editing.
If you want to use mysqlc.exe, you must copy `C:\mysql\lib\cygwinb19.dll' to
`\windows\system' (or similar place).
The default privileges on Windows give all local users full privileges to all databases. To
make MySQL more secure, you should set a password for all users and remove the row in
the mysql.user table that has Host='localhost' and User=''.
You should also add a password for the root user. (The following example starts by
removing the anonymous user, that allows anyone to access the 'test' database.):
C:\mysql\bin\mysql mysql

mysql> DELETE FROM user WHERE Host='localhost' AND User='';
mysql> QUIT
C:\mysql\bin\mysqladmin reload
C:\mysql\bin\mysqladmin -u root password your_password

Javascript cookie string

We can set a cookie by setting document.cookie to a cookie string.
 The following code will set a cookie with the UserName set as Paul,
 and an expiration date of 28 December 2010.

<html>
<head>
<script language=JavaScript>
   document.cookie = "UserName=Paul;expires=Tue, 28 Dec 2010 00:00:00;";
</script>
</head>
<body>
<p>This page just created a cookie</p>
</body>
</html>

Save the page as FreshBakedCookie.htm. We'll see how the code works as we
 discuss the parts of a cookie string, but first let's see what happens
 when a cookie is created.

In this section we'll see how to look at the cookies that are already stored by IE on our computer. We'll then load the cookie-creating page we just created with the preceding code to see what effect this has.

First we need to open IE. I'm using IE 6, so if you're using IE 4 or 5 you will find the screenshots and menus in slightly different places.

Before we view the cookies, we'll first clear the temporary Internet file folder for the browser because this will make it easier to view the cookies that our browser has stored. In IE, select Internet Options from the Tools menu,




javascript Date, Time





Javascript Date

The methods getDate(), getDay(), getMonth(), and getFullYear() allow us to retrieve date values from inside a Date object. The setDate(), setMonth(), and setFullYear() methods allow us to set the date values of an existing Date object.

The getHours(), getMinutes(), getSeconds(), and getMilliseconds() methods retrieve the time values in a Date object. The setHours(), setMinutes(), setSeconds(), and setMilliseconds() methods allow us to set time values of an existing Date object.

 One thing that we didn't cover in that chapter was the idea that the time depends on your location around the world. For example, imagine you have a chat room on your website and want to organize a chat for a certain date and time. Simply stating 15:30 is not good enough if your website attracts international visitors.

The time 15:30 could be Eastern Standard Time, Pacific Standard Time, the time in the United Kingdom, or even the time in Kuala Lumpur. You could of course say 15:30 EST and let your visitors work out what that means, but even that isn't foolproof. There is an EST in Australia as well as in the U.S.


So how does this work? In the script block at the top of the page, we have just this one line:
var localTime = new Date();
This creates a new Date object and initializes it to the current date and time based on the client computer's clock. (Note that in fact the Date object simply stores the number of milliseconds between the date and time on your computer's clock and midnight UTC time on the 1st of January 1970.)
Within the body of the page we have seven more script blocks that use the three world time methods we looked at earlier. Note that some of them are enclosed in an if statement, for example
if (localTime.toLocaleTimeString)
{
  document.write(localTime.toLocaleTimeString())
}
This checks to see if the browser supports that method and only makes use of it if it does. Older browsers don't support all of the date/time methods so doing this prevents ugly errors.

In the following line
document.write(localTime.toUTCString());
we write the string returned by the toUTCString() method to the page. This converts the date and time stored inside the localTime Date object to the equivalent UTC date and time.

What is TCP/IP





What is TCP/IP

The Transmission Control Protocol and the Internet Protocol manage the sending and receiving of messages as packets over the Internet. The two protocols together provide a service to applications that use the Internet: communication through a network.

The World Wide Web is a network application that uses the services of TCP and IP to communicate over the Internet. When a web browser requests a page from a web server, the TCP/IP services provide a virtual connection -- a virtual circuit—between the two communicating systems. Remember that packet-switched networks don't operate like telephone networks that create an actual circuit dedicated to a particular call.

Once a connection is established and acknowledged, the two systems can communicate by sending messages. These messages can be large, such as the binary representation of an image, and TCP may fragment the data into a series of IP datagrams. An IP datagram is equivalent to the couriers' envelope in that it holds the fragment of the message along with the destination address and several other fields that manage its transmission through the network. Each node in the network runs IP software, and IP moves the datagrams through the network, one node at a time. When an IP node receives a datagram, it inspects the address and other header fields, looks up a table of routing information, and sends it on to the next node. Often these nodes are dedicated routers—systems that form interconnections between networks—but the nodes can also include the computer systems on which the applications are running. IP datagrams are totally independent of each other as far as IP is concerned: the IP software just moves them from node to node through a network. The size of a datagram is primarily determined by the largest size message that can be sent by any part of the network. TCP software performs the function of gluing the fragments together at the destination using the fragment identifier field in the IP datagram header. Because IP datagrams are transmitted through the network independently, there is no guarantee they will arrive at the destination in order, and TCP stores the fragments in a buffer until all preceding fragments are received. IP doesn't guarantee that datagrams are delivered. If an IP node receives a corrupt datagram, it throws it away. Datagrams may be missing from the stream the TCP software receives because a datagram was corrupt and not passed on from the IP software or was delayed in the network. TCP buffers the fragments to allow the out-of-order datagrams to arrive. If a missing datagram fails to arrive, TCP eventually requests that it be resent. This can cause datagrams to be received twice; however TCP recognizes and discards the duplicate datagram when it arrives.

How to traffic to your website





How to traffic to your website

1. Article marketing. If you'd like to acquire numerous inbound links, establish your expertise on your field, and generate enormous traffic to your site all at the same time, you should definitely engage to article marketing. It is the most efficient and cost-effective way to build traffic to your site. All you have to do is write quality articles that are highly relevant to your website or products that you promoting and submit these articles to submission sites.

2. Multiple Pages - If possible, divide the websiteinto several pages and access them through separate items links on a menu or navigation bar.

3. Be consistent - Have same menu or some extensionof it on all pages so that viewers know where they are at all times. Home page is a must on every page. Visitors should be able to easily look around your website. If visitors are frustrated andcan't find what they are looking for, they are likely to leave quickly and never come back or recommend yourwebsite to others.The menu can be located at the top, left or right side of the page.

4. Keep Content Fresh - Static content is dead content; Write new articles, update old ones. New or updated content is a great way to keep visitors coming back. Search engines also rank websites with fresh content higher. Keeping an active blog is a great way to keep your website new and fresh.

5. Use Descriptive File Names - Use descriptive keywords as names for the files like pictures, videos on your site. This will help your site appear more with search engines - especially through Google Image Search.

6. Create Links - Getting links to your website from other websites will help generate more traffic and improve your placement in search engines. Find other websites on your same topic and put a link to them on your site -- maybe in a new Favorite Links page. Then ask those websites to link back to you by signing their guestbook.

7. Tag your Site - Adding tags can increase the number of times your website shows up in search results. To pick the right keywords, try putting yourself in the shoes of your visitors and think whatthey would search for if they wanted to find your site.

8.Visitors Contact You - Make it simple for visitors to reach you if they want. Include a guestbook or blog where they can post questions. Add a contact us form where they can submit questions to you via email.

Kangana Ranaut-the gold


Php file uploading code





Php file uploading code

To uploading a file, two changes must be made to the standard HTML form. First, the initial FORM line must include the code ENCTYPE = "multipart/form-data", which lets the HTML know to expect a file as well other data.
Second, <input name="NAME" type="FILE" />
the element is used to create the necessary field.
Another trap is the size of uploaded files.

 Although you can tell the browser the maximum size of file to upload, this is only a recommendation and it cannot ensure that your script won't be handed a file of a larger size. The danger is that an attacker will try a denial of service attack by sending you several large files in one request and filling up the filesystem in which PHP stores the decoded files.

 The  php file uploading code:

<form action="" method="post">
Select  Filename: <input type="file" name="adFile">
<input type="submit" value="Upload">
</form>

<?php

move_uploaded_file ($_FILES['adFile'] ['tmp_name'],
       "../uploads/{$_FILES['adFile'] ['name']}")

?>



Set the post_max_size configuration option in php.ini to the maximum size in bytes that you want:

post_max_size = 1024768 ; one megabyte The

default 10 MB is probably larger than most sites require.

Php Code for a Valid Number





Php Code for a Valid Number

Besides working on numbers, is_numeric( ) can also be applied to numeric strings. Use is_numeric( ):

if (is_numeric('five')) { /* false */ }
if (is_numeric(5)) { /* true */ }
if (is_numeric('5')) { /* true */ }
if (is_numeric(-5)) { /* true */ }
if (is_numeric('-5')) { /* true */ }
It is often useful to determine where in the code output originates.

Helpfully, is_numeric( ) properly parses decimal numbers, however, numbers with thousands separators, such as 5,100, cause is_numeric( ) to return false.

To strip the thousands separators from your number before calling is_numeric( ) use str_replace( ): is_numeric(str_replace($number, ',', '')); To check if your number is a specific type, there are a variety of self-explanatorily named related functions: is_bool( ) , is_float( ) (or is_double( ) or is_real( ); they're all the same), and is_int( ) (or is_integer( ) or is_long( )).