October 26, 2018

Srikaanth

Facebook Most Frequently Asked Latest PHP Interview Questions Answers

What Are Encryption Functions In Php?

CRYPT()
MD5()

What Types Of Images That Php Supports ?

Using imagetypes() function to find out what types of images are supported in your PHP engine.

imagetypes() - Returns the image types supported.

This function returns a bit-field corresponding to the image formats supported by the version of GD linked into PHP. The following bits are returned, IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM.

What Is The Difference Between Htmlentities() And Htmlspecialchars()?

htmlspecialchars() - Convert some special characters to HTML entities (Only the most widely used)

htmlentities() - Convert ALL special characters to HTML entities.

How To Reset/destroy A Cookie ?

Reset a cookie by specifying expire time in the past:
Example: setcookie('Test',$i,time()-3600); // already expired time
Reset a cookie by specifying its name only
Example: setcookie('Test');

What Are The Different Ways To Login To A Remote Server? Explain The Means, Advantages And Disadvantages?

There is at least 3 ways to logon to a remote server:
Use ssh or telnet if you concern with security
You can also use rlogin to logon to a remote server.

What Is Meant By Mime?

MIME is Multipurpose Internet Mail Extensions is an Internet standard for the format of e-mail. However browsers also uses MIME standard to transmit files. MIME has a header which is added to a beginning of the data. When browser sees such header it shows the data as it would be a file (for example image) Some examples of MIME types:

audio/x-ms-wmp
image/png
application/x-shockwave-flash
Facebook Most Frequently Asked Latest PHP Interview Questions Answers
Facebook Most Frequently Asked Latest PHP Interview Questions Answers

What Is The Difference Between Group By And Order By In Sql?

To sort a result, use an ORDER BY clause.
The most general way to satisfy a GROUP BY clause is to scan the whole table and create a new temporary table where all rows from each group are consecutive, and then use this temporary table to discover groups and apply aggregate functions (if any). ORDER BY [col1],[col2],...[coln]; Tells DBMS according to what columns it should sort the result. If two rows will have the same value in col1 it will try to sort them according to col2 and so on.

GROUP BY [col1],[col2],...[coln]; Tells DBMS to group (aggregate) results with same value of column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if you want to count all items in group, sum all values or view average.

Who Is The Father Of Php And Explain The Changes In Php Versions?

Rasmus Lerdorf is known as the father of PHP.PHP/F1 2.0 is an early and no longer supported version of PHP. PHP 3 is the successor to PHP/FI 2.0 and is a lot nicer. PHP 4 is the current generation of PHP, which uses the Zend engine under the hood. PHP 5 uses Zend engine 2 which, among other things, offers many additionalOOP features .

What Is The Functionality Of The Function Htmlentities?

htmlentities() - Convert all applicable characters to HTML entities
This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.

How Can We Get The Properties (size, Type, Width, Height) Of An Image Using Php Image Functions?

To know the image size use getimagesize() function
To know the image width use imagesx() function
To know the image height use imagesy() function

How To Set Cookies?

setcookie('variable','value','time')
;
variable - name of the cookie variable
value - value of the cookie variable
time - expiry time
Example:

setcookie('Test',$i,time()+3600);
Test - cookie variable name
$i - value of the variable 'Test'
time()+3600 - denotes that the cookie will expire after an one hour.

How Can We Increase The Execution Time Of A Php Script?

By the use of void set_time_limit(int seconds) Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini. If seconds is set to zero, no time limit is imposed.

When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.

In How Many Ways We Can Retrieve Data In The Result Set Of Mysql Using Php?

mysql_fetch_array - Fetch a result row as an associative array, a numeric array, or both.

mysql_fetch_assoc - Fetch a result row as an associative array.

mysql_fetch_object - Fetch a result row as an object.

mysql_fetch_row —- Get a result row as an enumerated array.

Who Is The Father Of Php And What Is The Current Version Of Php And Mysql?

Rasmus Lerdorf.
PHP 5.1. Beta
MySQL 5.0

What Is A Cookie?

A cookie is a small amount of information sent by a Web server to a web browser and then sent back unchanged by the browser each time it accesses that server. HTTP cookies are used for authenticating, tracking, and maintaining specific information about users, such as site preferences and the contents of their electronic shopping carts. The term "cookie" is derived from "magic cookie", a well-known concept in computing which inspired both the idea and the name of HTTP cookies.
A cookie consists of a cookie name and cookie value.

How To Send A Cookie To The Browser?

If you want to sent a cookie to the browser when it comes to request your PHP page, you can use the setcookie( ) function. Note that you should call setcookie() function before any output statements. The following script shows you how to set cookies:
<?php
setcookie("LoginName","XYZ");
setcookie("PreferredColor","Blue");
print("2 cookies were delivered.\n");
?>

How To Receive A Cookie From The Browser?

If you know that a cookie has been sent to the browser when it was visiting the server previously, you can check the built-in $_COOKIE array, which contains all cookies that were sent by the server previously. The script below shows you how to pickup one cookie from the $_COOKIE and loop through all cookies in $_COOKIE:
<?php
if (isset($_COOKIE["LoginName"])) {
$loginName = $_COOKIE["LoginName"];
print("Received a cookie named as LoginName: ".$loginName."\n");
} else {
print("Did not received any cookie named as LoginName.\n");
}
print("All cookies received:\n");
foreach ($_COOKIE as $name => $value) {
print " $name = $value\n";
}
?>

How Cookies Are Transported From Servers To Browsers?

Cookies are transported from a Web server to a Web browser in the header area of the HTTP response message. Each cookie will be included in a separate "Set-Cookie:" header line in the following format:
Set-Cookie: name=value; expires=time; path=pathVal; domain=domainVal.

How Cookies Are Transported From Browsers To Servers?

Cookies are transported from a Web browser to a Web server in the header area of the HTTP request message. Each cookie will be included in a separate "Cookie:" header line in the following format:
GET / HTTP/1.1
Cookie: name1=value1
Cookie: name2=value2
Cookie: name3=value3
......
Accept: */*

Where Are The Persistent Cookies Stored On Your Computer?

The location and file names where persistent cookies are stored on your computer depend on which browser you are using. If you using Microsoft Internet Explorer, persistent cookies are stored in the \Documents and Settings\$user\Cookies directory. Cookies are stored in multiple cookie files with one file per Web server. Check your cookie directory on your local system, you will be surprised to see how many Web servers are setting persistent cookies to your computer.

How To Delete Cookie Files On Your Computer?

A simple way to delete cookie files on your computer is to use the function offered by the IE browser. The following tutorial exercise shows you how to delete cookie files created by IE:

• Open IE (Internet Explorer)
• Go to Options/Internet Options
• Click the Delete Cookies button on the options dialog window.
Check the cookie directory again. All cookie files should be deleted.

How Does Firefox Manage Cookies?

FireFox browser allows you to delete old cookies, and gives you options to keep persistent cookies in cookie files until they reach their expiration time. The following tutorial shows you how to manage cookies in FireFox:

• Run FireFox
• Go to Tools/Options
• Click Privacy and then Cookies
• Click the Clear button to delete all old cookies
• Change the Keep Cookies option to "until they expire" to allow persistent cookies to be store a cookie file.

What Are The Options To Transfer Session Ids?

Once a new session is created, its session ID must be transferred to the client browser and included in the next client request, so that the PHP engine can find the same session created by the same visitor. The PHP engine has two options to transfer the session ID to the client browser:

As URL parameter - The Session ID will be embedded in all URLs in the HTML document delivered to the client browser. When the visitor clicks any of those URLs, the session ID will be returned back to the Web server as part of the requesting URL.
As a cookie - The session ID will be delivered as a cookie to the client browser. When visitor requests any other pages on the Web server, the session ID will be returned back to the Web server also as a cookie.
The PHP engine is configured to use URL parameters for transferring session IDs by default.

Is It More Secure To Use Cookies To Transfer Session Ids?

yes, because attacking your Web site using URL parameters is much easier than using cookies.
So if you are the system administrator of your Web server, you should set session.use_only_cookies=1.
If your Web server is provided by a hosting service provider, ask them to set session.use_only_cookies=1.

How can PHP and Javascript interact?

PHP and Javascript cannot directly interact since PHP is a server side language and Javascript is a client-side language. However, we can exchange variables since PHP can generate Javascript code to be executed by the browser and it is possible to pass specific variables back to PHP via the URL.

What is needed to be able to use image function?

GD library is needed to execute image functions.

What is the use of the function 'imagetypes()'?

imagetypes() gives the image format and types supported by the current version of GD-PHP.

Which function gives us the number of affected entries by a query?

mysqli_affected_rows() return the number of entries affected by an SQL query.

What is the difference between mysqli_fetch_object() and mysqli_fetch_array()?

The mysqli_fetch_object() function collects the first single matching record where mysqli_fetch_array() collects all matching records from the table in an array.

Subscribe to get more Posts :