Difference between HTTP and HTTPS

Basic Difference:

FIRST, MANY PEOPLE ARE UNAWARE OF
**The main difference between http:// and https:// is It’s all about keeping you secure** HTTP stands for Hyper Text Transport Protocol,

Which is just a fancy way of saying it’s a protocol (a language, in a manner of speaking) For information to be passed back and forth between web servers and clients. The important thing is the letter S which makes the difference between HTTP and HTTPS.

The S (big surprise) stands for “Secure”. If you visit a website or webpage, and look at the address in the web browser, it will likely begin with the following: http://.

This means that the website is talking to your browser using the regular ‘unsecure’ language. In other words, it is possible for someone to “eavesdrop” on your computer’s conversation with the website. If you fill out a form on the website, someone might see the information you send to that site. or even they can grab your content using KEYLOGGERS.

This is why you never ever enter your credit card number in an http website! But if the web address begins with https://, that basically means your computer is talking to the website in a secure code that no one can eavesdrop on.

You understand why this is so important, right?

If a website ever asks you to enter your credit card information, you should automatically look to see if the web address begins with https://.

If it doesn’t, there’s no way you’re going to enter sensitive information like a credit card number.

Its better to use virtual keyboard or keyscrambler to get hide from hackers..

How it works??

When a user connects to a website via HTTPS, the website encrypts the session with a digital certificate. A user can tell if they are connected to a secure website if the website URL begins with https:// instead of http://.

Want to know more?  earn more about How to use SSL with Comodo’s SSL Tutorials.
For a simple introduction to HTTPS, see What is HTTPS?

How Does SSL Work?

Secure Sockets Layer uses a cryptographic system that encrypts data with two keys.

PHP Interview Question and answers Part2

Will cover more set of questions clearly here..

All the question and answers listed below are the questions which i faced practically..

Array significant functions reference?

The array() function is used to create an array.

In PHP, there are three types of arrays:

    • Indexed arrays – Arrays with numeric index
    • Associative arrays – Arrays with named keys
    • Multidimensional arrays – Arrays containing one or more arrays

Sytnax

Syntax for indexed arrays:

array(value1,value2,value3,etc.);

Syntax for associative arrays:

array(key=>value,key=>value,key=>value,etc.);
Parameter Description
key Specifies the key (numeric or string)
value Specifies the value

array() -Create an indexed array named $cars, assign three elements to it, and then print a text containing the array values:

<?php
$cars=array(“Volvo”,”BMW”,”Toyota”);
echo “I like ” . $cars[0] . “, ” . $cars[1] . ” and ” . $cars[2] . “.”;
?>

Result: I like Volvo, BMW and Toyota.

array_chunk() – Split an array into chunks of two:

<?php
$cars=array(“Volvo”,”BMW”,”Toyota”,”Honda”,”Mercedes”,”Opel”);
print_r(array_chunk($cars,2));
?>

Result: Array ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] => Honda ) [2] => Array ( [0] => Mercedes [1] => Opel ) )

array_diff() – Compare arrays, and returns the differences (compare values only)

<?php
$a1=array(“a”=>”red”,”b”=>”green”,”c”=>”blue”,”d”=>”yellow”);
$a2=array(“e”=>”red”,”f”=>”green”,”g”=>”blue”);

$result=array_diff($a1,$a2);
print_r($result);
?>

Result: Array ( [d] => yellow )

array_diff_assoc() – Compare arrays, and returns the differences (compare keys and values)

<?php
$a1=array(“a”=>”red”,”b”=>”green”,”c”=>”blue”,”d”=>”yellow”);
$a2=array(“a”=>”red”,”b”=>”green”,”c”=>”blue”);

$result=array_diff_assoc($a1,$a2);
print_r($result);
?>

Result: Array ( [d] => yellow )

array_key_exists() – Checks if the specified key exists in the array

<?php
$a=array(“Volvo”=>”XC90″,”BMW”=>”X5”);
if (array_key_exists(“Volvo”,$a))
{
echo “Key exists!”;
}
else
{
echo “Key does not exist!”;
}
?>

Result: Key exists!

array_merge() – Merges one or more arrays into one array

<?php
$a1=array(“red”,”green”);
$a2=array(“blue”,”yellow”);
print_r(array_merge($a1,$a2));
?>

Result : Array ( [0] => red [1] => green [2] => blue [3] => yellow )

array_pop() – Deletes the last element of an array

<?php
$a=array(“red”,”green”,”blue”);
array_pop($a);
print_r($a);
?>

Result: Array ( [0] => red [1] => green )

array_push() – Inserts one or more elements to the end of an array

<?php
$a=array(“red”,”green”);
array_push($a,”blue”,”yellow”);
print_r($a);
?>

Result : Array ( [0] => red [1] => green [2] => blue [3] => yellow )

array_rand() -Returns one or more random keys from an array

<?php
$a=array(“red”,”green”,”blue”,”yellow”,”brown”);
$random_keys=array_rand($a,3);
echo $a[$random_keys[0]].”<br>”;
echo $a[$random_keys[1]].”<br>”;
echo $a[$random_keys[2]];
?>

Result: green
blue
brown

array_search() – Searches an array for a given value and returns the key

<?php
$a=array(“a”=>”red”,”b”=>”green”,”c”=>”blue”);
echo array_search(“red”,$a);
?>

Result: a

array_sum() – Returns the sum of the values in an array

<?php
$a=array(5,15,25);
echo array_sum($a);
?>

Result: 45

array_unique() – Removes duplicate values from an array

<?php
$a=array(“a”=>”red”,”b”=>”green”,”c”=>”red”);
print_r(array_unique($a));
?>

Result: Array ( [a] => red [b] => green )

 array_values() – Returns all the values of an array

<?php
$a=array(“Name”=>”Peter”,”Age”=>”41″,”Country”=>”USA”);
print_r(array_values($a));
?>

Result: Array ( [0] => Peter [1] => 41 [2] => USA )

 

arsort() – Sorts an associative array in descending order, according to the value

<?php
$age=array(“Peter”=>”35″,”Ben”=>”37″,”Joe”=>”43”);
arsort($age);
?>

Result:

Key=Joe, Value=43
Key=Ben, Value=37
Key=Peter, Value=35

asort() – Sorts an associative array in ascending order, according to the value

<?php
$age=array(“Peter”=>”35″,”Ben”=>”37″,”Joe”=>”43”);
asort($age);
?>

Result:

Key=Peter, Value=35
Key=Ben, Value=37
Key=Joe, Value=43

in_array() – Checks if a specified value exists in an array

<?php
$people = array(“Peter”, “Joe”, “Glenn”, “Cleveland”);

if (in_array(“Glenn”, $people))
{
echo “Match found”;
}
else
{
echo “Match not found”;
}
?>

Result: Match found

 

krsort() – Sorts an associative array in descending order, according to the key

<?php
$age=array(“Peter”=>”35″,”Ben”=>”37″,”Joe”=>”43”);
krsort($age);
?>

Result:

Key=Peter, Value=35
Key=Joe, Value=43
Key=Ben, Value=37

ksort() – Sorts an associative array in ascending order, according to the key

<?php
$age=array(“Peter”=>”35″,”Ben”=>”37″,”Joe”=>”43”);
ksort($age);

foreach($age as $x=>$x_value)
{
echo “Key=” . $x . “, Value=” . $x_value;
echo “<br>”;
}
?>

Result:

Key=Ben, Value=37
Key=Joe, Value=43
Key=Peter, Value=35

sizeof() – Alias of count()

<?php
$cars=array(“Volvo”,”BMW”,”Toyota”);
echo sizeof($cars);
?>

Result: 3

count() – Returns the number of elements in an array

<?php
$cars=array(“Volvo”,”BMW”,”Toyota”);
echo count($cars);
?>

Result: 3

String Functions yet to add…
Important String Functions…

——————————————————————————————————————————————–

what is http? diff b/n http and https? what are HTTP status codes?

HTTP

Short for HyperText Transfer ProtocolHTTP is a set of standards that allow users of the World Wide Web to exchange information found on web pages. When wanting to access any web page enter http:// in front of the web address, which tells the browser to communicate over HTTP.Today’s modern browsers no longer require HTTP in front of the URL since it is the default method of communication.

HTTPS

Short for Hypertext Transfer Protocol over SecureHTTPS is a secure method of accessing or sending information across a web page. All data sent over HTTPS isencrypted before it is sent, this prevents anyone from understanding that information if intercepted. Because data is encrypted over HTTPS, it is slower than HTTP, which is why HTTPS is only used when requiring login information or with pages that contain sensitive information such as an online bank web page.

  • HTTPS uses port 443 to transfer its information.
  • HTTPS is first used in HTTP/1.1 and is defined in RFC 2616

1xx: Information

Message: Description:
100 Continue The server has received the request headers, and the client should proceed to send the request body
101 Switching Protocols The requester has asked the server to switch protocols
103 Checkpoint Used in the resumable requests proposal to resume aborted PUT or POST requests

2xx: Successful

Message: Description:
200 OK The request is OK (this is the standard response for successful HTTP requests)
201 Created The request has been fulfilled, and a new resource is created
202 Accepted The request has been accepted for processing, but the processing has not been completed
203 Non-Authoritative Information The request has been successfully processed, but is returning information that may be from another source
204 No Content The request has been successfully processed, but is not returning any content
205 Reset Content The request has been successfully processed, but is not returning any content, and requires that the requester reset the document view
206 Partial Content The server is delivering only part of the resource due to a range header sent by the client

3xx: Redirection

Message: Description:
300 Multiple Choices A link list. The user can select a link and go to that location. Maximum five addresses
301 Moved Permanently The requested page has moved to a new URL
302 Found The requested page has moved temporarily to a new URL
303 See Other The requested page can be found under a different URL
304 Not Modified Indicates the requested page has not been modified since last requested
306 Switch Proxy No longer used
307 Temporary Redirect The requested page has moved temporarily to a new URL
308 Resume Incomplete Used in the resumable requests proposal to resume aborted PUT or POST requests

4xx: Client Error

Message: Description:
400 Bad Request The request cannot be fulfilled due to bad syntax
401 Unauthorized The request was a legal request, but the server is refusing to respond to it. For use when authentication is possible but has failed or not yet been provided
402 Payment Required Reserved for future use
403 Forbidden The request was a legal request, but the server is refusing to respond to it
404 Not Found The requested page could not be found but may be available again in the future
405 Method Not Allowed A request was made of a page using a request method not supported by that page
406 Not Acceptable The server can only generate a response that is not accepted by the client
407 Proxy Authentication Required The client must first authenticate itself with the proxy
408 Request Timeout The server timed out waiting for the request
409 Conflict The request could not be completed because of a conflict in the request
410 Gone The requested page is no longer available
411 Length Required The “Content-Length” is not defined. The server will not accept the request without it
412 Precondition Failed The precondition given in the request evaluated to false by the server
413 Request Entity Too Large The server will not accept the request, because the request entity is too large
414 Request-URI Too Long The server will not accept the request, because the URL is too long. Occurs when you convert a POST request to a GET request with a long query information
415 Unsupported Media Type The server will not accept the request, because the media type is not supported
416 Requested Range Not Satisfiable The client has asked for a portion of the file, but the server cannot supply that portion
417 Expectation Failed The server cannot meet the requirements of the Expect request-header field

5xx: Server Error

Message: Description:
500 Internal Server Error A generic error message, given when no more specific message is suitable
501 Not Implemented The server either does not recognize the request method, or it lacks the ability to fulfill the request
502 Bad Gateway The server was acting as a gateway or proxy and received an invalid response from the upstream server
503 Service Unavailable The server is currently unavailable (overloaded or down)
504 Gateway Timeout The server was acting as a gateway or proxy and did not receive a timely response from the upstream server
505 HTTP Version Not Supported The server does not support the HTTP protocol version used in the request
511 Network Authentication Required The client needs to authenticate to gain network access

what are webservices?

In simple words, webservices will establish a good mode of communication with other servers. Lets say like this, we have temperature widgets everywhere(android,ios,windows etc etc). Now you want to display temperature in your widgets..will you code everywhere to show the temperature? its a very bad idea..instead you can easily call up some webservices through api’s where your api will contact to yahoo temperature server and display temperature. Here yahoo server will have a kind of method in public where receives parameters from different clients and then process and send back responses to the websites through webservices. This is how webservices will work..the same procedure will follow for cricket score updates, currency updates etc etc. Hope this is clear to get an basic idea of webservices..

web service is a method of communication that allows two software systems to exchange this data over the internet. The software system that requests data is called a service requester, whereas the software system that would process the request and provide the data is called a service provider.

Different software might be built using different programming languages, and hence there is a need for a method of data exchange that doesn’t depend upon a particular programming language. Most types of software can, however, interpret XML tags or Json. For more..clickhere

what are websockets?

HTML5 WebSocket represents the first major upgrade in the history of web communications. Before WebSocket, all communication between web clients and servers relied only on HTTP. Now, dynamic data can flow freely over WebSocket connections that are persistent (always on), full duplex (simultaneously bi-directional) and blazingly fast.

WebSockets come after many other technologies that allow servers to send information to the client. Web applications that use Comet/Ajax, push/pull and long polling all do this over HTTP. Other than handshaking the Upgrade Header, WebSockets is independent from HTTP.

WebSockets2

 

Some advantages of WebSockets include:

• Cross origin communication (however this poses security risks)
• Cross platform compatibility (web, desktop, mobile)
• Low weight envelope when passing messages

For more: http://www.pubnub.com/blog/what-are-websockets/

http://www.html5rocks.com/en/tutorials/websockets/basics/

what is curl?

PHP has a very powerful library of calls that are specifically designed to safely fetch data from remote sites. It’s called CURL. Enabling curl is explained here

For more:

http://wiki.dreamhost.com/CURL_PHP_tutorial

http://davidwalsh.name/curl-post

http://www.startutorial.com/articles/view/php-curl

how to maintain mysql security?

Security Guidelines :

  • Except MySQL root account do not permit anyone to access the user table in the mysql database.
  • Use the GRANT and REVOKE statements to control access to MySQL. Do not grant unnecessary privileges and never grant privileges to all hosts.
  • Never store simple text passwords in your database. Store the hash value using  SHA2(), SHA1()MD5() functions or other hashing function in different way. Try to use complex password.
  • Try to use a firewall and put MySQL behind the firewall.
  • 3306 is the default user port of MySQL and this port should not be accessible from untrusted hosts. You can scan the ports from Internet using a tool such as nmap. From a remote machine you can check whether the port is open or not with this command : shell> telnet server_host 3306. If telnet hangs or the connection is refused, the port is blocked. If you get a connection and some garbage characters, the port is open, and should be closed on your firewall or router, unless you really have a good reason to keep it open.
  • Some applications access MySQL database for different purpose. Never trust these input data entered by user and must validated properly before access database.
  • Do not transmit unencrypted data over the Internet. Use an encrypted protocol such as SSL (MySQL supports internal SSL connections) or SSH.
  • Use tcpdump and strings utilities. By issuing this command shell> tcpdump -l -i eth0 -w – src or dst port 3306 | strings you can check whether MySQL data streams are unencrypted or not.

Making MySQL Secure Against Attackers :

To make a MySQL system secure, you should maintain the following suggestions :

  • Require all MySQL accounts to have a password.
  • Make sure that the only Unix user account with read or write privileges in the database directories is the account that is used for running mysqld.
  • Never run the MySQL server as the Unix root user
  • Do not grant the FILE privilege to non administrative users
  • Do not permit the use of symlinks to tables.
  • Stored programs and views should be written using the security guidelines
  • If you do not trust your DNS, you should use IP addresses rather than hostnames in the grant tables.
  • If you want to restrict the number of connections permitted to a single account, you can do so by setting the max_user_connections variable in mysqld.

For more:

http://www.w3resource.com/mysql/mysql-security.php

http://www.greensql.com/content/mysql-security-best-practices-hardening-mysql-tips

use of final method in oops?

final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

http://alexsears.com/article/using-final-php

what is sql injection?

SQL Injection is one of the many web attack mechanisms used by hackers to steal data from organizations. It is perhaps one of the most common application layer attack techniques used today. It is the type of attack that takes advantage of improper coding of your web applications that allows hacker to inject SQL commands into say a login form to allow them to gain access to the data held within your database.

In essence, SQL Injection arises because the fields available for user input allow SQL statements to pass through and query the database directly.

For more: http://www.php.net/manual/en/security.database.sql-injection.php

http://www.w3schools.com/sql/sql_injection.asp

https://www.acunetix.com/websitesecurity/sql-injection/

what is callback function?

A callback is a piece of code that is passed to a function that is later executed by that function.

For more: http://www.php.net/manual/en/language.types.callable.php

http://www.satya-weblog.com/2010/11/php-using-callback-function.html

http://www.phpriot.com/articles/php-callbacks

what are current php,mysql and apache versions?

php – 5.5.11

Mysql – 5.6.17

apache – 2.4.9

5.5.11 

what is regex and explain in detail?

Regular expressions started out as a feature of the Unix shell. They were designed to make it easier to find, replace and work with strings — and since their invention, they’ve been in wide use in many different parts of Unix based Operating Systems. They were commonly used in Perl, and since then have been implemented into PHP.

http://www.sitepoint.com/regular-expressions-php/

http://www.phpro.org/tutorials/Introduction-to-PHP-Regex.html

what is DOM?

The Document Object Model (DOM) is an API for manipulating HTML and XML documents. It provides a structural representation of the document, enabling you to modify its content and visual presentation by using a scripting language such as JavaScript.

For more: https://developer.mozilla.org/en/docs/DOM

Json and explain in detail why we will use json?

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming LanguageStandard ECMA-262 3rd Edition – December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language. In simple words, its an alternative to XML.

For more: http://www.json.org/

http://www.copterlabs.com/blog/json-what-it-is-how-it-works-how-to-use-it/

http://www.yourinspirationweb.com/en/do-you-want-to-use-json-but-dont-know-where-to-start/

what are active records?

how to maintain 2 domains in one server?

http://stackoverflow.com/questions/6970993/how-to-handle-multiple-domains-on-one-server

http://www.wikihow.com/Host-Multiple-Websites-on-a-Single-Web-Hosting-Account

difference between == & ===?

$a == $b Equal TRUE if $a is equal to $b after type juggling.
$a === $b Identical TRUE if $a is equal to $b, and they are of the same type.

Event handler in php?

what is cross side scripting?

Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into otherwise benign and trusted web sites. XSS attacks occur when an attacker uses a web application to send malicious code, generally in the form of a browser side script, to a different end user. An attacker can use XSS to send a malicious script to an unsuspecting user. The end user’s browser has no way to know that the script should not be trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by the browser and used with that site. 

More: https://www.acunetix.com/websitesecurity/cross-site-scripting/

https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)

difference b/n document.ready and window.onload?

The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (e.g. images) also has been loaded.

The onload event is a standard event in the DOM, while the ready event is specific to jQuery. The purpose of the ready event is that it should occur as early as possible after the document has loaded, so that code that adds funcionality to the elements in the page doesn’t have to wait for all content to load.

window.onload : A normal JavaScript event.

document.ready : An specific jQuery event when the entire HTML have been loaded.

Document.ready():-

document.ready() is jQuery event. Jquery document.ready function called once the DOM(Document object model) is loaded on your page.DOM means all the html tags/script I.e.(div tag, table tag,paragraph tag etc etc..). It will not wait for the images to get load. It means that it is the earliest stage in page load process.

Example : –

 $(document).ready(function(){// executes when HTML-Document is loaded and DOM is ready
 alert("document is ready to perform operation");});

Window .onload():-

window.onload() is a javascript function. The load event fires when all the content on your page loaded including the DOM (document object model) and images. Another difference between the two is we can have more than one document.ready() function in a web page but only one onload function.

Example : –

Suppose there is a large image on your page in that case window.onload wait for that image to completely load. When we use window.onload() execution will be slow but document.ready() will not wait for the image to load completely.

$(window).load(function(){// executes when complete page is fully loaded, including frames,objects and images
 alert("window is loaded to perform operations");});

what is hooks in drupal and basics/interview questions in drupal?

Clickhere for interview questions in drupal

difference between modules,extensions and plugins in joomla?

Plugins

Plugins enable you to execute code in response to certain events, either Joomla core events or custom events that are triggered from your own code. This is a powerful way of extending the basic Joomla functionality.

Components

Components are the main functional units that display in your template, like the content management system, contact forms, Web Links and the like. They are usually displayed in the center of the main content area of a template (depending on the template).

Modules

A more lightweight and flexible extension used for page rendering is a module. Modules are used for small bits of the page that are generally less complex and able to be seen across different components. Sometimes modules are linked to a component such as the core latest news module.

Extensions

Components, languages, modules, plugins and templates collectively known as Extensions.

More: http://help.joomla.org/ghop/feb2008/task048/joomla_15_quickstart.pdf

http://www.dart-creations.com/joomla/joomla-tutorials/the-difference-between-modules-and-components.html

difference between wordpress, joomla and drupal?

CMS-comparison-chart

Source:

http://websitesetup.org/cms-comparison-wordpress-vs-joomla-drupal/

http://cms.about.com/od/cms-basics/a/Pros-And-Cons-Of-Joomla-Wordpress-And-Drupal.htm

difference between primary and unique key?

Primary Key:

1. Primary key does not accept null values.
2. There is only one primary key in a table.
3. Clustered index is created in Primary key.
4. Primary key allows each row in a table to be uniquely identified and ensures that no duplicate rows exist.

Unique Key:

1. Using Unique key, Null values are accepted.
2. More than one unique key can be defined  there in a table.
3. Non-Clustered index is created in unique key.
4. Unique key constraint is used to avoid the duplication of key values within the rows of a table.

INDEX is similar to the index at the back of a book. It provides a simplified look-up for the data in that column so that searches on it are faster. MyISAM uses a hash table to store indexes, which sorts the data, but is still linearly proportional in depth to the table size. InnoDB uses a B-tree structure for its indexes. A B-tree is similar to a nested set – it breaks down the data into logical child groups, meaning search depth is significantly smaller. As such, lookups by ranges are faster in a B-tree.

UNIQUE INDEX is an index in which each row in the database must have a unique value for that column. This is useful for preventing duplication, e.g. for an email column in a users table where you want only one account per email address. Important note that in MySQL, an ON DUPLICATE KEY UPDATE clause will trigger if it finds a duplicate unique index match, even if it’s not your primary key. This is a pitfall to be aware of if you have a unique on email, for example.

PRIMARY KEY is a UNIQUE INDEX that is the identifier for any given row in the table. As such, it must not be null, and is saved as a clustered index. Clustered means that the data in your table is sorted in ascending order on the PK. This makes searches on primary key significantly faster than any other index type (as in MySQL, only the PK may be your clustered index). Note that clustering also causes concerns with INSERT statements if your data is not AUTO_INCREMENTed, as MySQL will have to shift data around if you insert a new row with a PK with a lower ordinal value. This could hamper your DB performance.

FOREIGN KEY is a reference to a column in another table. It enforces Referential Integrity, which means that you cannot create an entry in a column which has a foreign key to another table if the entered value does not exist in the referenced table. In MySQL, a FOREIGN KEY does not improve search performance. It also requires that both tables in the key definition use the InnoDB engine, and have the same data type, character set, and collation.

More: https://www.udemy.com/blog/mysql-unique-key/

declaration of variables in js?

difference between cookies and sessions?

Session Basics

Sessions are simply server-side cookies each with a corresponding client side cookie that contains only a reference to its server-side counterpart. When a user visits a page, the client sends the reference code to the server, and PHP will then match that reference code to a server-side cookie and load the data in the server’s cookie into the $_SESSION superglobal.

PROS

  1. Can store very large amounts of data easily.
  2. Save bandwidth by passing only a reference to the session each pageload. A client-side cookie has to pass all of its data.
  3. Data is stored on the web server. This makes sessions secure, because the data cannot be viewed or edited by the client.

CONS

  1. Ends when the browser is closed unless you’ve configured php.ini to extend sessions’ cookie lifetime. Cannot last forever.

Cookie Basics

Cookie data is sent to the web server every page load. PHP reads and stores the value into the $_COOKIE superglobal. When a cookie is created, you can give it a lifespan. After that lifespan runs out, it will expire.

PROS

  1. Can last as long as the website needs. They will still be there even if the browser is closed and reopened.
  2. Useful for “remember me” logins
  3. Useful for storing temporary user settings. For example, if a user is browsing a paginated list of items, sorted a certain way, the sorting setting can be stored in a cookie.

CONS

  1. Stored in the users filesystem. This means that the user can tamper with it and view it.
  2. Can only store a limited amount of data.
  3. Must pass all data to the webserver each pageload. This takes up more bandwidth.

More: http://buildinternet.com/2010/07/when-to-use-_session-vs-_cookie/

what are stored procedures(sp) and use of sp in mysql?

https://sathyalog.wordpress.com/2013/03/21/how-to-create-a-stored-procedure-in-mysql/

http://code.tutsplus.com/articles/an-introduction-to-stored-procedures-in-mysql-5–net-17843

how to improve performance loading? how we will calculate performance of a website?

difference between echo and print?

echo

  • Outputs one or more strings separated by commas
  • No return valuee.g. echo "String 1", "String 2"

print

  • Outputs only a single string
  • Returns 1, so it can be used in an expressione.g. print "Hello"or, if ($expr && print "foo")

print_r()

  • Outputs a human-readable representation of any one value
  • Accepts not just strings but other types including arrays and objects, formatting them to be readable
  • Useful when debugging
  • May return its output as a return value (instead of echoing) if the second optional argument is given

var_dump()

  • Outputs a human-readable representation of one or more values separated by commas
  • Accepts not just strings but other types including arrays and objects, formatting them to be readable
  • Uses a different output format to print_r(), for example it also prints the type of values
  • Useful when debugging
  • No return value

Notes:

  • Even though print can be used in an expression, I’d generally avoid doing so for the sake of readability (and because it’s unlikely to ever be useful). The precedence rules when it interacts with other operators can also be confusing.
  • Whereas echo and print are language constructs, print_r() and var_dump() are regular functions. You don’t need parentheses to enclose the arguments to echo or print (and if you do use them, they’ll be treated as they would in an expression).

difference between implode and explode?

  Explode() function divides a string into an array, but implode function() returns or combine a string from the   elements of an array.

explode:
<?php
$str = “Hello World”;
$str = explode(” “, $string); //here string delimeter is space
Ouput:
$str[0] = Hello;
$str[1] = World;
?>
implode:
<?php
$array = array(‘Riss’,’Energy’,’India’);
$comma_separated = implode(“,”,$array);  //here comma is separated
echo $comma_separated;
?>
Output:
RissEnergyIndia 

use of extract?

The extract() function imports variables into the local symbol table from an array.

This function uses array keys as variable names and values as variable values. For each element it will create a variable in the current symbol table.

This function returns the number of variables extracted on success.

Syntax

extract(array,extract_rules,prefix)
<?php
$a = “Original”;
$my_array = array(“a” => “Cat”,”b” => “Dog”, “c” => “Horse”);
extract($my_array);
echo “\$a = $a; \$b = $b; \$c = $c”;
?>
Output: $a = Cat; $b = Dog; $c = Horse

use of permalinks in wordpress?

An easy way to improve your site’s search engine ranking is to use “pretty permalinks.” Permalinks are the direct and, well, permanent links to your blog entries. It’s what other websites will use to link to your content. “Pretty permalinks” is the term WordPress.org uses to mean “making your links look better and be more user friendly.”

More: http://webdesign.com/why-and-how-to-use-pretty-user-friendly-permalinks/

https://managewp.com/wordpress-permalinks-guide

what is taxanomy in wordpress and why it is used? in which table it is stored?

Taxonomy = Classifying data

By default, WordPress comes with 3 taxonomies, post tag, categories, link categories.  Essentially, a taxonomy is a way of classifying data. Typically a taxonomy will have a set of characteristics that is unique to it.

  • Post Tag: acts like a label, attached to a post.
  • Category: acts like a “bucket” in which we put posts, are often hierarchical. Posts can live in multiple categories.
  • Link Category: acts like a label, attached to a link.

More: http://www.vsellis.com/a-basic-explanation-of-wordpress-taxonomies/

what are hooks in wordpress?

WordPress hooks are, essentially, triggers of sorts that allow users to, with short snippets of code, modify areas a WordPress theme or plugin, or add their own code to various parts of WordPress without modifying the original files. An example of this could be add social bookmarking links to the end of the content.

Hooks can be divided into “Action” and “Filter” hooks, the former allowing for insertion of custom code at various points.

Action Hooks

Action hooks are designated points in the WordPress core, theme and plugin code where it is possible for outside resources to insert additional code and, there by, customise the code to do additional functions they may desire. An example of this is the commonly used wp_head action hook, used by many themes and plugins to inject additional CSS stylesheets, processing code or anything else they require to sit between the <head> and </head> tags.

To hook on to an action, create a function in your theme’s functions.php file (or in your plugin’s code) and hook it on using the add_action() function, as follows:

<?php
	add_action( 'wp_head', 'wpcandy_actionhook_example' );

	function wpcandy_actionhook_example () {

		echo '<meta name="description" content="This is the meta description for this page." />' . "
";

	} // End wpcandy_actionhook_example()
?>

The above code adds the text “Hello WPCandy Readers!” between your theme’s <head> tags. Placing “wp_head” in the call to add_action() with “get_header” would display this text above your theme.

Filter Hooks

Filter hooks are used to manipulate output. An example of this would be to add a line or text (or a hyperlink, or a signature sign-off—whatever you’d like) to the end of the content of each of your blog posts.

Custom code is added as a filter using the add_filter() function. The following code adds a sign-off to the end of each blog post, only when viewing the full blog post screen:

<?php
	add_filter( 'the_content', 'wpcandy_filterhook_signoff' );

	function wpcandy_filterhook_signoff ( $content ) {

		if ( is_single() ) {

			$content .= '<div class="sign-off">Th-th-th-th-th That\'s all, folks!</div>' . "
";

		} // End IF Statement

		return $content;

	} // End wpcandy_filterhook_signoff()
?>

The above code adds a new div tag to the end of the content of our blog post, only when on a single blog post screen.

A filter hook is like using the str_replace() function in PHP. You give it some data, manipulate, replace or reformat the data and return the new content out at the end.

Source: http://wpcandy.com/teaches/how-to-use-wordpress-hooks/#.U1ZtWFWSzHQ

how to convert an html5 template to wordpress template?

how to add custom fields to editor in wordpress?

codeigniter: folder structure of codeigniter? how do you fetch rows? how you will do in codeigniter for mysql_fetch_array()?

interview questions and basics of codeigniter?

session maintenance in codeigniter

how do u execute query?

OOPS: what is encapsulation,inheritance,polymorphism, method overloading, method overriding, abstract class, interface, object,class,constructor, data abstraction. Use of public,static,private and protected.

PHP: How do you increase upload filesize without change in php.ini file? In form what will you specify if you have upload option?

#######################################

increase max_execution_time in php.ini file

Put this code in your file at the top.

ini_set('max_execution_time', 300); //300 seconds = 5 minutes

You can put this in the php.ini file.
max_execution_time = 30 ;

increase max_execution_time using htaccess file

php_value max_execution_time 259200

Increase post_max_size, upload_max_filesize,memory_limit,max_execution_time,max_input_time,session.gc_maxlifetime

php_value post_max_size 5M
php_value upload_max_filesize 5M
php_value memory_limit 300M
php_value max_execution_time 259200
php_value max_input_time 259200
php_value session.gc_maxlifetime 1200

 

#######################################

MySQL: Diff b/n innerjoins and joins? types of joins? what are triggers? default engine in mysql? how you will change engine?

how do you keep password for DB? primary and foreign key relationship? groupby and orderby use?

HTML5: what are latest html5 elements? types of engines in html5? how do you validate html5? how you will debug? how you will store data in localstorage in html?

CSS3: Types of transitions in css3? diff b/n css2 and css3? diff b/n LESS and CSS3? diff between inline and external stylesheet? diff b/n margin and padding? list some important interview questions on html5 and css3

Jquery: diff b/n window.onload and document.ready? how you will change html content in a tag using jquery? regex?strip splashes and add splashes? functions & events in jquery in detail? show and hide in jquery?

JS: Use of js? how you will validate? how do you get or print value of html element using jquery?

 

###############################################################

How to find checked checkbox values in an array using jquery?

<inputtype="checkbox"class="group1"value="18"checked="checked"/><inputtype="checkbox"class="group1"value="20"/><inputtype="checkbox"class="group1"value="15"/><inputtype="checkbox"class="group2"value="14"/><inputtype="checkbox"class="group1"value="55"checked="checked"/><inputtype="checkbox"class="group1"value="10"checked="checked"/><inputtype="checkbox"class="group2"value="77"checked="checked"/><inputtype="checkbox"class="group1"value="11"/>

Would return the values of the checked/selected group1 checkboxes into an array like this:

var values =[18,55,10];

You can use the :checkbox and :checked pseudo-selectors and the .class selector, with that you will make sure that you are getting the right elements, only checked checkboxes with the class you specify.

Then you can easily use the Traversing/map method to get an array of values:

var values = $('input:checkbox:checked.group1').map(function(){returnthis.value;}).get();// ["18", "55", "10"]
################################################################################